Java Code Examples for com.google.protobuf.GeneratedMessage#getClass()
The following examples show how to use
com.google.protobuf.GeneratedMessage#getClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlResultMessageListener.java From lams with GNU General Public License v2.0 | 6 votes |
public Boolean createFromMessage(XMessage message) { GeneratedMessage msg = (GeneratedMessage) message.getMessage(); Class<? extends GeneratedMessage> msgClass = msg.getClass(); if (this.resultType == null) { if (ColumnMetaData.class.equals(msgClass)) { this.resultType = ResultType.DATA; } else if (!Error.class.equals(msgClass)) { this.resultType = ResultType.UPDATE; } } if (this.resultType == ResultType.DATA) { // delegate to the result creation return this.resultListener.createFromMessage(message); } // done return this.okListener.createFromMessage(message); }
Example 2
Source File: AsyncMessageReader.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Dispatch a message to a listener or "peek-er" once it has been read and parsed. * * @param messageClass * class extending {@link GeneratedMessage} * @param message * {@link GeneratedMessage} */ private void dispatchMessage(XMessageHeader hdr, GeneratedMessage message) { if (message.getClass() == Frame.class && ((Frame) message).getScope() == Frame.Scope.GLOBAL) { // we don't yet have any global notifications defined. throw new RuntimeException("TODO: implement me"); } // if there's no message listener waiting, expose the message class as pending for the next read if (getMessageListener(false) == null) { synchronized (this.pendingMsgMonitor) { this.pendingMsgHeader = CompletableFuture.completedFuture(hdr); this.pendingMsgMonitor.notify(); } } getMessageListener(true); // we must ensure that the message has been delivered and the pending message is cleared atomically under the pending message lock. otherwise the // pending message may still be seen after the message has been delivered but before the pending message is cleared // // t1-nio-thread | t2-user-thread // ------------------------------------------------------+------------------------------------------------------ // pendingMsgClass exposed - no current listener | // | listener added // getMessageListener(true) returns | // dispatchMessage(), in currentMessageListener.apply() | // | getNextMessageClass(), pendingMsgClass != null // | pendingMsgClass returned, but already being delivered // | in other thread // pendingMsgClass = null | // synchronized (this.pendingMsgMonitor) { // we repeatedly deliver messages to the current listener until he yields control and we move on to the next boolean currentListenerDone = this.currentMessageListener.createFromMessage(new XMessage(message)); if (currentListenerDone) { this.currentMessageListener = null; } // clear this after the message is delivered this.pendingMsgHeader = null; } }