Package org.xmlBlaster.util

Examples of org.xmlBlaster.util.I_ResponseListener


         return true;
      }

      // Handling response or exception ...
      I_ResponseListener listener = getResponseListener(receiver.getRequestId());
      if (listener == null) {
         log.warning("Ignoring received '" + receiver.getMethodName() + "' response message, requestId=" + receiver.getRequestId() + ", nobody is interested in it");
         if (log.isLoggable(Level.FINEST)) log.finest("Ignoring received message, nobody is interested in it: >" + receiver.toLiteral() + "<");
         return true;
      }
      removeResponseListener(receiver.getRequestId());

      if (receiver.isResponse()) {
         if (receiver.getMethodName().returnsMsgArr()) { // GET returns MsgUnitRaw[]
            listener.incomingMessage(receiver.getRequestId(), receiver.getMessageArr());
         }
         else if (receiver.getMethodName().returnsStringArr()) {  // PUBLISH etc. return String[]
            listener.incomingMessage(receiver.getRequestId(), receiver.getQosArr());
         }
         else if (receiver.getMethodName().returnsString()) { // SUBSCRIBE, CONNECT etc. return a String
            listener.incomingMessage(receiver.getRequestId(), receiver.getQos());
         }
         else // SUBSCRIBE, CONNECT etc. return a String
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "The method " + receiver.getMethodName() + " is not expected in this context");
         }
      }
      else if (receiver.isException()) { // XmlBlasterException
         listener.incomingMessage(receiver.getRequestId(), receiver.getException());
      }
      else {
         log.severe("PANIC: Invalid response message for " + receiver.getMethodName());
         listener.incomingMessage(receiver.getRequestId(), new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Invalid response message '" + receiver.getMethodName()));
      }

      return true;
   }
View Full Code Here


      // Register the return value / Exception listener ...
      if (expectingResponse) {
         //startSignal = new Latch(); // defaults to false
         startSignal = addLatch(new Latch()); //synchronized (this.latchSet) { this.latchSet.add(startSignal); } // remember all blocking threads for release on shutdown
         if (!hasConnection()) return null;
         addResponseListener(requestId, new I_ResponseListener() {
            public void incomingMessage(String reqId, Object responseObj) {
               if (log.isLoggable(Level.FINE)) log.fine("RequestId=" + reqId + ": return value arrived ...");
               response[0] = responseObj;
               startSignal.latch.release(); // wake up
            }
View Full Code Here

      // so we deliver them to the registrar and they should decide
      //if (emailData.isExpired())
      //   return DISCARD;
     
      String key = emailData.getSessionId(msgIdFileName) + emailData.getRequestId(msgIdFileName);
      I_ResponseListener listenerSession = null;
      I_ResponseListener listenerRequest = null;
      I_ResponseListener listenerClusterNodeId = null;
      synchronized (this.listeners) {
         listenerRequest = (I_ResponseListener) this.listeners.get(key);
         if (listenerRequest == null) {
            listenerSession = (I_ResponseListener) this.listeners
                  .get(emailData.getSessionId(msgIdFileName));
            if (listenerSession == null) {
               listenerClusterNodeId = (I_ResponseListener) this.listeners
                     .get(this.glob.getId());
            }
         }
      }

      // A request/reply handler is interested in specific messages only
      if (listenerRequest != null) {
         if (log.isLoggable(Level.FINER))
            log.finer("Request specific listener found for key=" + key
                  + ", email is " + emailData.toString());
         listenerRequest.incomingMessage(emailData.getRequestId(msgIdFileName),
               emailData);
         return key;
      }

      // A session is interested in all messages
      if (listenerSession != null) {
         if (log.isLoggable(Level.FINER))
            log.finer("SessRequest specific listener found for key="
                  + emailData.getSessionId(msgIdFileName) + ", email is "
                  + emailData.toString());
         listenerSession.incomingMessage(emailData.getRequestId(msgIdFileName),
               emailData);
         return emailData.getSessionId(msgIdFileName);
      }

      // A cluster node is interested in all messages (EmailDriver.java)
      if (listenerClusterNodeId != null) {
         if (log.isLoggable(Level.FINER))
            log.finer("Node specific listener found for key="
                  + this.glob.getId() + ", email is " + emailData.toString());
         listenerClusterNodeId.incomingMessage(emailData.getRequestId(msgIdFileName),
               emailData);
         return emailData.getSessionId(msgIdFileName);
      }
     
      if (calledFromHoldbackMap) {
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.I_ResponseListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.