Package org.xmlBlaster.protocol.socket

Examples of org.xmlBlaster.protocol.socket.CallbackSocketDriver


                      SessionInfo myRemotePartnerLogin = fatherGlob.getRequestBroker().getAuthenticate(secretSessionId).getSessionInfo(sessionName);
                      if (myRemotePartnerLogin != null && myRemotePartnerLogin.getAddressServer() != null) {
                         Object obj = myRemotePartnerLogin.getAddressServer().getCallbackDriver();
                         if (obj != null && obj instanceof CallbackSocketDriver) {
                            // cbDriver.callbackAddress: socket://192.168.1.20:8920
                            CallbackSocketDriver cbDriver = (CallbackSocketDriver)myRemotePartnerLogin.getAddressServer().getCallbackDriver();
                            log.info("toAlive(" + sessionName.getAbsoluteName() + ")... found existing session to back-tunnel '" + getId() + "' on address '" + myRemotePartnerLogin.getAddressServer().getRawAddress() + "' protocol=" + myRemotePartnerLogin.getAddressServer().getType() + " cbDriver-Handler " + ((cbDriver.getHandler()==null)?"null":cbDriver.getHandler().getAddressServer().getRawAddress()));
                            //log.severe("Register toAlive: CallbackSocketDriver.handler=" + cbDriver.getHandler());
                            remoteGlob.addObjectEntry(globalKey, cbDriver.getHandler());
                            log.info(sessionName.toString() + " Adding toAlive '" + cbDriver.getHandler() + "' entryKey=" + globalKey + " global.instanceId=" + remoteGlob.getInstanceId() + "-" + remoteGlob.hashCode());
                         }
                         else {
                            log.info("toAlive(" + sessionName.getAbsoluteName() + ")... no  CallbackSocketDriver to back-tunnel '" + getId() + "' found");
                            remoteGlob.addObjectEntry(globalKey, "dummyPlaceHolder");
                            log.info(sessionName.toString() + " Adding toAlive 'dummyPlaceHolder' entryKey=" + globalKey + " global.instanceId=" + remoteGlob.getInstanceId() + "-" + remoteGlob.hashCode());
View Full Code Here


                  ConnectQosServer conQos = new ConnectQosServer(glob, receiver.getQos());
                  if (conQos.getSecurityQos() == null)
                     throw new XmlBlasterException(glob, ErrorCode.USER_SECURITY_AUTHENTICATION_ILLEGALARGUMENT, ME, "connect() without securityQos");
                  conQos.getSecurityQos().setClientIp (socket.getInetAddress().getHostAddress());
                  conQos.setAddressServer(getAddressServer());
                  Object callbackSocketDriver = new CallbackSocketDriver(conQos.getSessionName().getLoginName(), this);
                  conQos.getAddressServer().setCallbackDriver(callbackSocketDriver);
                  conQos.getData().getCurrentCallbackAddress().setCallbackDriver(callbackSocketDriver);
                  ConnectReturnQosServer retQos = getAuthenticateCore().connect(conQos);
                  this.secretSessionId = retQos.getSecretSessionId();
                  receiver.setSecretSessionId(retQos.getSecretSessionId()); // executeResponse needs it
                  executeResponse(receiver, retQos.toXml(), SocketUrl.SOCKET_TCP);
               }
               else if (MethodName.DISCONNECT == receiver.getMethodName()) {
                  executeResponse(receiver, Constants.RET_OK, SocketUrl.SOCKET_TCP);   // ACK the disconnect to the client and then proceed to the server core
                  // Note: the disconnect will call over the CbInfo our shutdown as well
                  // setting sessionId = null prevents that our shutdown calls disconnect() again.
                  getAuthenticateCore().disconnect(getAddressServer(), receiver.getSecretSessionId(), receiver.getQos());
                  shutdown();
               }
               else {
                  if (log.isLoggable(Level.FINE)) log.fine("Received tunneled message, forwarding now to xmlBlaster core: " + receiver.getMethodNameStr());
                  boolean processed = receiveReply(receiver, SocketUrl.SOCKET_TCP);    // Parse the message and invoke actions in same thread
                  if (!processed)
                     log.warning("Received message is not processed: " + receiver.toLiteral());
               }
            }
            else if (this.acceptRemoteLoginAsTunnel
                  && receiver.isResponse()
                  && MethodName.UPDATE.equals(receiver.getMethodName())
                  && MethodName.UPDATE_ONEWAY.equals(receiver.getMethodName()) // ONEWAY have no response, just do be complete
            ) {
               log.severe("UPDATE RESPONSE IS NOT YET IMPLEMENTED");              
               boolean processed = receiveReply(receiver, SocketUrl.SOCKET_TCP);    // Parse the message and invoke actions in same thread
               if (!processed)
                  log.warning("Received message is not processed: " + receiver.toLiteral());
            }
            else {
               // Normal client operation
               if (receiver.isInvoke() && multiThreaded) {
                  // Parse the message and invoke callback to client code in a separate thread
                  // to avoid dead lock when client does a e.g. publish() during this update()
                  WorkerThread t = new WorkerThread(glob, this, receiver);
                  // -dispatch/callback/plugin/socket/invokerThreadPrio 5
                  t.setPriority(this.callbackAddress.getEnv("invokerThreadPrio", Thread.NORM_PRIORITY).getValue());
                  t.start();
               }
               else {
                  boolean processed = receiveReply(receiver, SocketUrl.SOCKET_TCP);    // Parse the message and invoke actions in same thread
                  if (!processed)
                     log.warning("Received message is not processed: " + receiver.toLiteral());
               }
               if (MethodName.DISCONNECT == receiver.getMethodName() && receiver.isResponse()) {
                  if (log.isLoggable(Level.FINE)) log.fine("Terminating socket callback thread because of disconnect response");
                  threadRunning = false;
               }
            }
         }
         catch(XmlBlasterException e) {
            log.warning(e.toString());
         }
         catch(Throwable e) {
            if (e instanceof NullPointerException)
               e.printStackTrace();
            if (threadRunning == true) {
               if (e.toString().indexOf("javax.net.ssl") != -1) {
                  log.warning("Closing connection to server, please try debugging SSL with 'java -Djavax.net.debug=all ...': " + e.toString());
               }
               else if (e instanceof IOException) {
                  log.warning("Closing connection to server: " + e.toString());
               }
               else {
                  log.severe("Closing connection to server: " + e.toString());
               }
               try {
                  // calls our shutdownSocket() which does this.threadRunning = false
                  sockCon.shutdown();
               }
               catch (XmlBlasterException ex) {
                  log.severe("run() could not shutdown correctly. " + ex.getMessage());
               }
               // Exceptions ends nowhere but terminates the thread
              
               // Notify client library  XmlBlasterAccess.java to go to polling
               try {
                  I_CallbackExtended cb = this.cbClient;
                  if (cb != null) {
                     cb.lostConnection(XmlBlasterException.convert(this.glob, ME, "Lost socket connection", e));
                  }
               }
               catch(Throwable xx) {
                  xx.printStackTrace();
               }
              
               if (this.acceptRemoteLoginAsTunnel) {
                  try {
                     AddressServer addr = this.addressServer;
                     if (addr != null) {
                        CallbackSocketDriver cbd = (CallbackSocketDriver)addr.getCallbackDriver();
                        if (cbd != null) {
                           cbd.shutdown(); // notify about lost connection
                        }
                     }
                  }
                  catch(Throwable xx) {
                     xx.printStackTrace();
View Full Code Here

TOP

Related Classes of org.xmlBlaster.protocol.socket.CallbackSocketDriver

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.