Package org.xmlBlaster.util.protocol.socket

Examples of org.xmlBlaster.util.protocol.socket.SocketUrl


               // getInetAddress().toString() does no reverse DNS lookup (no blocking danger) ...
               log.info(ME+": Client connected, coming from host=" + socket.getInetAddress().toString() + " port=" + socket.getPort());

               CallbackAddress[] cbArr = conQos.getSessionCbQueueProperty().getCallbackAddresses();
               for (int ii=0; cbArr!=null && ii<cbArr.length; ii++) {
                  SocketUrl cbUrl = new SocketUrl(glob, cbArr[ii].getRawAddress());
                  SocketUrl remoteUrl = new SocketUrl(glob, socket.getInetAddress().getHostAddress(), socket.getPort());
                  if (this.addressServer != null) {
                     this.addressServer.setRemoteAddress(remoteUrl);
                  }
                  if (log.isLoggable(Level.FINE)) log.fine(ME+": remoteUrl='" + remoteUrl.getUrl() + "' cbUrl='" + cbUrl.getUrl() + "'");
                  if (true) { // !!!!! TODO remoteUrl.equals(cbUrl)) {
                     if (log.isLoggable(Level.FINE)) log.fine(ME+": Tunneling callback messages through same SOCKET to '" + remoteUrl.getUrl() + "'");
                    
                     // Set client ConnectQos wishes like
                     // <attribute name='updateResponseTimeout' type='long'>20000</attribute>
                     initializeCb(cbArr[ii]);

                     this.callback = new CallbackSocketDriver(this.loginName, this);
                     //this.callback.init(this.glob, cbArr[ii]); is done in connectLowLeve()
                     cbArr[ii].setCallbackDriver(this.callback);
                     if (this.addressServer != null) { // pass for "useRemoteLoginAsTunnel"
                      this.addressServer.setCallbackDriver(this.callback);
                     }
                  }
                  else {
                     log.severe(ME+": Creating SEPARATE callback " + this.driver.getType() + " connection to '" + remoteUrl.getUrl() + "'");
                     this.callback = new CallbackSocketDriver(this.loginName);
                     // DispatchConnection.initialize() -> CbDispatchConnection.connectLowlevel()
                     // will later call callback.initialize(loginName, callbackAddress)
                  }
               }
View Full Code Here


   public void connectLowlevel(CallbackAddress callbackAddress) throws XmlBlasterException {
      if (isConnected())
         return;
      this.clientAddress = callbackAddress;
      this.socketUrl = new SocketUrl(glob, this.clientAddress);

      if (log.isLoggable(Level.FINER)) log.finer("Entering connectLowlevel(), connection with seperate raw socket to client " +
                                    this.socketUrl.getUrl() + " ...");
      try {
         // SSL support
View Full Code Here

      if (log.isLoggable(Level.FINER)) log.finer("Entering init()");
      this.addressServer = addressServer;
      this.authenticate = authenticate;
      this.xmlBlasterImpl = xmlBlasterImpl;

      this.socketUrl = new SocketUrl(glob, this.addressServer);

      if (Constants.COMPRESS_ZLIB_STREAM.equals(this.addressServer.getCompressType())) {
         log.info("Full stream compression enabled with '" + Constants.COMPRESS_ZLIB_STREAM + "' for " + getType());
      }
      else if (Constants.COMPRESS_ZLIB.equals(this.addressServer.getCompressType())) {
View Full Code Here

   public synchronized void activate() throws XmlBlasterException {
      if (log.isLoggable(Level.FINER)) log.finer("Entering activate");
      try {
         final boolean isLocal = false;
         // SocketUrl socketUrl = new SocketUrl(glob, addressServer, isLocal, DEFAULT_HTTP_PORT);
         SocketUrl socketUrl = new SocketUrl(glob, xmlRpcUrl.getHostname(), xmlRpcUrl.getPort());

         webServer = new XblWebServer(xmlRpcUrl, socketUrl, addressServer);
         // publish the public methods to the XmlRpc web server:
         // webServer.addHandler("authenticate", new AuthenticateImpl(glob, this, authenticate));
         // webServer.addHandler("xmlBlaster", new XmlBlasterImpl(glob, this, xmlBlasterImpl));
View Full Code Here

      if (this.pluginInfo != null)
         this.clientAddress.setPluginInfoParameters(this.pluginInfo.getParameters());

      if (log.isLoggable(Level.FINER)) log.finer("Entering connectLowlevel(), connection with raw socket to server, plugin setting is: " + this.pluginInfo.dumpPluginParameters());

      this.socketUrl = new SocketUrl(glob, this.clientAddress);

      if (this.socketUrl.getPort() < 1) {
         String str = "Option dispatch/connection/plugin/socket/port set to " + this.socketUrl.getPort() +
                      ", socket client not started";
         log.info(str);
         throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION_ADDRESS, ME, str);
      }

      this.localSocketUrl = new SocketUrl(glob, this.clientAddress, true, -1);

      // SSL support
      boolean ssl = this.clientAddress.getEnv("SSL", false).getValue();
      if (log.isLoggable(Level.FINE)) log.fine(clientAddress.getEnvLookupKey("SSL") + "=" + ssl);
     
      try {
         if (this.useRemoteLoginAsTunnel) {
          String entryKey = SocketExecutor.getGlobalKey(this.clientAddress.getSessionName());
            Object obj = glob.getObjectEntry(entryKey);
            if (obj != null && obj instanceof org.xmlBlaster.protocol.socket.HandleClient) {
               org.xmlBlaster.protocol.socket.HandleClient h = (org.xmlBlaster.protocol.socket.HandleClient)obj;
               this.sock = h.getSocket();
               // TODO: HandleClient.closeSocket() can set sock = null!
               if (this.sock != null) {
                  log.info(getLoginName() + " " + getType() + " entryKey=" + entryKey + " global.instanceId=" +glob.getInstanceId() + "-" + glob.hashCode() + (ssl ? " SSL" : "") +
                     " client is reusing existing SOCKET '"+this.sock.getInetAddress().getHostAddress() + ":" + this.sock.getPort()+ "' configured was '" +
                     this.socketUrl.getUrl() +
                     "', your configured local parameters are localHostname=" + this.localSocketUrl.getHostname() +
                     " on localPort=" + this.localSocketUrl.getPort() + " useUdpForOneway=" + this.useUdpForOneway +
                     "', callback address is '" + this.sock.getLocalAddress().getHostAddress() + ":" + this.sock.getLocalPort() + "'");
               }
               else {
                  log.severe(getLoginName() + " " + getType() + " " + getLocalSocketUrlStr()
                        + " Didn't expect null socket for sessionName="
                        + this.clientAddress.getSessionName() + ": Removing entryKey=" + entryKey + " global.instanceId=" +glob.getInstanceId() + "-" + glob.hashCode() + ": " + Global.getStackTraceAsString(null));
                  glob.removeObjectEntry(entryKey);
               }
            }
            else {
               // instance of dummy string: no HandleClient available, remote node has not yet connected
               String str = "Connection to xmlBlaster server failed, no established socket to reuse found entryKey=" + entryKey;
               if (log.isLoggable(Level.FINE)) log.fine(str);
               throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, str);
            }
         }
         else {
            if (ssl) {
               this.sock = this.socketUrl.createSocketSSL(this.localSocketUrl, this.clientAddress);
            }
            else {
               if (this.localSocketUrl.isEnforced()) {
                  this.sock = new Socket(this.socketUrl.getInetAddress(), this.socketUrl.getPort(),
                                      this.localSocketUrl.getInetAddress(), this.localSocketUrl.getPort());
               }
               else {
                  if (log.isLoggable(Level.FINE)) log.fine("Trying socket connection to " + socketUrl.getUrl() + " ...");
                  this.sock = new Socket(this.socketUrl.getInetAddress(), this.socketUrl.getPort());
               }
            }
  
            if (this.localSocketUrl.isEnforced()) {
               log.info(getType() + (ssl ? " SSL" : "") +
                     " client connected to '" + this.socketUrl.getUrl() +
                     "', your configured local parameters are localHostname=" + this.localSocketUrl.getHostname() +
                     " on localPort=" + this.localSocketUrl.getPort() + " useUdpForOneway=" + this.useUdpForOneway +
                     "', callback address is '" + this.sock.getLocalAddress().getHostAddress() + ":" + this.sock.getLocalPort() + "'");
            }
            else {
               // SocketUrl constructor updates client address
               this.localSocketUrl = new SocketUrl(glob, this.sock.getLocalAddress().getHostAddress(), this.sock.getLocalPort());
               this.clientAddress.setRawAddress(this.socketUrl.getUrl());
               log.info(getType() + (ssl ? " SSL" : "") +
                     " client connected to '" + socketUrl.getUrl() +
                     "', callback address is '" + this.localSocketUrl.getUrl() +
                     "' useUdpForOneway=" + this.useUdpForOneway + " clientAddress='" + this.clientAddress.getRawAddress() + "'");
View Full Code Here

    * A string with the local address and port (the client side).
    *
    * @return For example "socket://myServer.com:7607", never null
    */
   public String getLocalSocketUrlStr() {
      SocketUrl url = this.localSocketUrl;
      if (url != null) {
         return url.getUrl();
      }
      return "";
   }
View Full Code Here

            if (proxyPort == null)
               proxyPort = "3128";
            trFact.setProxy(proxyHost, Integer.parseInt(proxyPort));
         }
         if (isSSL) {
            SocketUrl socketUrl = new SocketUrl(glob, xmlRpcUrl.getHostname(), xmlRpcUrl.getPort());
            SSLSocketFactory ssf = socketUrl.createSocketFactorySSL(address);
            if (ssf != null)
               trFact.setSSLSocketFactory(ssf);
            else
               log.warning("The SSL Socket Factory was null but SSL is required");
         }
View Full Code Here

   public void testBasic() {
      try {
         {
            String hostname = null;
            int port = -1;
            SocketUrl s = new SocketUrl(glob, hostname, port);
            assertEquals("", glob.getLocalIP(), s.getHostname());
            assertEquals("", port, s.getPort());
            assertEquals("", "socket://"+glob.getLocalIP()+":"+port, s.getUrl());
            log.info("SUCCESS testBasic(): hostname=" + hostname + " port=" + port + " resultUrl=" + s.getUrl());
         }

         {
            String hostname = "127.1.5.4";
            int port = 9999;
            SocketUrl s = new SocketUrl(glob, hostname, port);
            assertEquals("", hostname, s.getHostname());
            assertEquals("", port, s.getPort());
            assertEquals("", "socket://"+hostname+":"+port, s.getUrl());
            log.info("SUCCESS testBasic(): hostname=" + hostname + " port=" + port + " resultUrl=" + s.getUrl());
         }

         {
            SocketUrl s = new SocketUrl(glob, "192.1.1.5:911");
            SocketUrl other = new SocketUrl(glob, "192.1.1.5", 911);
            assertTrue("", s.equals(other));
            log.info("SUCCESS testBasic(): equals=true");
         }

         {
            SocketUrl s = new SocketUrl(glob, "192.1.1.5");
            SocketUrl other = new SocketUrl(glob, "192.1.1.5", SocketUrl.DEFAULT_SERVER_PORT);
            assertTrue("", s.equals(other));
            log.info("SUCCESS testBasic(): equals=true");
         }

         {
            SocketUrl s = new SocketUrl(glob, "192.1.1.5:900");
            SocketUrl other = new SocketUrl(glob, "192.1.1.5", 911);
            assertTrue("", !s.equals(other));
            log.info("SUCCESS testBasic(): equals=false");
         }

         {
            SocketUrl s = new SocketUrl(glob, "192.1.1.5:911");
            SocketUrl other = new SocketUrl(glob, "192.1.77.5", 911);
            assertTrue("", !s.equals(other));
            log.info("SUCCESS testBasic(): equals=false");
         }
      }
      catch (XmlBlasterException e) {
View Full Code Here

               "-plugin/"+type+"/port",
               ""+port
            };
            glob.init(args);
            Address address = new Address(glob, type);
            SocketUrl s = new SocketUrl(glob, address);
            assertEquals("", hostname, s.getHostname());
            assertEquals("", port, s.getPort());
            assertEquals("", "socket://"+hostname+":"+port, s.getUrl());
            log.info("SUCCESS testAddress(): resultUrl=" + s.getUrl());
         }

         {
            String hostname = "168.99.55.2";
            int port = 6666;
            Address address = new Address(glob);
            address.setPluginProperty("hostname", hostname);
            address.setPluginProperty("port", ""+port);
            SocketUrl s = new SocketUrl(glob, address);
            assertEquals("", hostname, s.getHostname());
            assertEquals("", port, s.getPort());
            assertEquals("", "socket://"+hostname+":"+port, s.getUrl());
            log.info("SUCCESS testAddress(): resultUrl=" + s.getUrl());
         }
      }
      catch (XmlBlasterException e) {
         log.severe("ERROR: " + e.toString());
         fail(e.toString());
View Full Code Here

   public void testParseUrl() {
      try {
         try {
            String url = null;
            new SocketUrl(glob, url);
            fail("Null url is not allowed");
         } catch (XmlBlasterException e) {
            log.info("SUCCESS testParseUrl(): expected exception: " + e.toString());
         }

         {
            String url = "";
            SocketUrl s = new SocketUrl(glob, url);
            assertEquals("", glob.getLocalIP(), s.getHostname());
            assertEquals("", SocketUrl.DEFAULT_SERVER_PORT, s.getPort());
            assertEquals("", "socket://"+glob.getLocalIP()+":"+SocketUrl.DEFAULT_SERVER_PORT, s.getUrl());
            log.info("SUCCESS testParseUrl(): url=" + url + " resultUrl=" + s.getUrl());
         }

         {
            String url = "127.1.1.1";
            SocketUrl s = new SocketUrl(glob, url);
            assertEquals("", url, s.getHostname());
            assertEquals("", SocketUrl.DEFAULT_SERVER_PORT, s.getPort());
            assertEquals("", "socket://"+url+":"+SocketUrl.DEFAULT_SERVER_PORT, s.getUrl());
            log.info("SUCCESS testParseUrl(): url=" + url + " resultUrl=" + s.getUrl());
         }

         {
            String url = "127.1.1.1:8080";
            SocketUrl s = new SocketUrl(glob, url);
            assertEquals("", "127.1.1.1", s.getHostname());
            assertEquals("", 8080, s.getPort());
            assertEquals("", "socket://"+url, s.getUrl());
            log.info("SUCCESS testParseUrl(): url=" + url + " resultUrl=" + s.getUrl());
         }

         {
            String url = "socket:127.1.1.1:8080";
            SocketUrl s = new SocketUrl(glob, url);
            assertEquals("", "127.1.1.1", s.getHostname());
            assertEquals("", 8080, s.getPort());
            assertEquals("", "socket://127.1.1.1:8080", s.getUrl());
            log.info("SUCCESS testParseUrl(): url=" + url + " resultUrl=" + s.getUrl());
         }

         {
            String url = "socket://127.1.1.1:8080";
            SocketUrl s = new SocketUrl(glob, url);
            assertEquals("", "127.1.1.1", s.getHostname());
            assertEquals("", 8080, s.getPort());
            assertEquals("", url, s.getUrl());
            log.info("SUCCESS testParseUrl(): url=" + url + " resultUrl=" + s.getUrl());
         }
      }
      catch (XmlBlasterException e) {
         log.severe("ERROR: " + e.toString());
         fail(e.toString());
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.protocol.socket.SocketUrl

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.