⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.java

📁 java开源的企业总线.xmlBlaster
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
         }      }      return this.queryQosFactory;   }   /**    * Return a factory parsing QoS XML strings from subcribe(), unSubscribe() and erase() returns.    */   public final I_StatusQosFactory getStatusQosFactory() {      if (this.statusQosFactory == null) {         synchronized (this) {            if (this.statusQosFactory == null) {               //this.statusQosFactory = new StatusQosSaxFactory(this);               this.statusQosFactory = new StatusQosQuickParseFactory(this);            }         }      }      return this.statusQosFactory;   }   /**    * The key is the protocol and the address to access the callback instance.    *    * @param key  e.g. "SOCKET192.168.2.2:7604" from 'cbAddr.getType() + cbAddr.getRawAddress()'    * @return The instance of the protocol callback driver or null if not known    */   public final I_CallbackDriver getNativeCallbackDriver(String key)   {      if (log.isLoggable(Level.FINER)) log.finer("getNativeCallbackDriver(" + key + ")");      return (I_CallbackDriver)nativeCallbackDriverMap.get(key);   }   /**    * The key is the protocol and the address to access the callback instance.    *    * @param key  e.g. "SOCKET192.168.2.2:7604" from 'cbAddr.getType() + cbAddr.getRawAddress()'    * @param The instance of the protocol callback driver    */   public final void addNativeCallbackDriver(String key, I_CallbackDriver driver)   {      if (log.isLoggable(Level.FINER)) log.finer("addNativeCallbackDriver(" + key + "," + driver.getName() + ")");      nativeCallbackDriverMap.put(key, driver);   }   /**    * The key is the protocol and the address to access the callback instance.    *    * @param key  e.g. "SOCKET192.168.2.2:7604" from 'cbAddr.getType() + cbAddr.getRawAddress()'    * @param The instance of the protocol callback driver    */   public final void removeNativeCallbackDriver(String key)   {      if (log.isLoggable(Level.FINER)) log.finer("removeNativeCallbackDriver(" + key + ")");      nativeCallbackDriverMap.remove(key);   }   /**    * Get an object in the scope of an xmlBlaster client connection or of one cluster node.    * <p />    * This is helpful if you have more than one I_XmlBlasterAccess or cluster nodes    * running in the same JVM    *    * @param key  e.g. <i>"SOCKET192.168.2.2:7604"</i> from 'cbAddr.getType() + cbAddr.getRawAddress()'<br />    *             or <i>"/xmlBlaster/I_Authenticate"</i>    * @return The instance of this object    */   public final Object getObjectEntry(String key)   {      synchronized (this.objectMapMonitor) {         return objectMap.get(key);      }   }   /**    * Add an object in the scope of an I_XmlBlasterAccess or of one cluster node.    * <p />    * This is helpful if you have more than one I_XmlBlasterAccess or cluster nodes    * running in the same JVM    *    * @param key  e.g. "SOCKET192.168.2.2:7604" from 'cbAddr.getType() + cbAddr.getRawAddress()'    * @param The instance of the protocol callback driver    */   public final void addObjectEntry(String key, Object driver)   {      synchronized (this.objectMapMonitor) {         objectMap.put(key, driver);      }   }   /**    * Remove an object from the scope of an I_XmlBlasterAccess or of one cluster node.    * <p />    * This is helpful if you have more than one I_XmlBlasterAccess or cluster nodes    * running in the same JVM    *    * @param key  e.g. "SOCKET192.168.2.2:7604" from 'cbAddr.getType() + cbAddr.getRawAddress()'    */   public final void removeObjectEntry(String key)   {     synchronized (this.objectMapMonitor) {        objectMap.remove(key);     }   }   /**    * Force to use the given bootstrap address, used for cluster connections    */   public final void setBootstrapAddress(Address address) {      this.bootstrapAddress = address;   }   /**    * Returns the address of the xmlBlaster internal http server.    * <p />    * Is configurable with    * <pre>    *   -bootstrapHostname myhost.mycompany.com   (or the raw IP)    *   -bootstrapPort 3412    * </pre>    * Defaults to the local machine and the IANA xmlBlaster port.<br />    * You can set "-bootstrapPort 0" to avoid starting the internal HTTP server    */   public final Address getBootstrapAddress() {      if (this.bootstrapAddress == null) {         synchronized (this) {            if (this.bootstrapAddress == null) {               if (log.isLoggable(Level.FINER)) log.finer("Entering getBootstrapAddress(), trying to resolve one ...");               this.bootstrapAddress = new Address(this);               if (log.isLoggable(Level.FINE)) log.fine("Initialized bootstrapAddress to host=" + this.bootstrapAddress.getBootstrapHostname() +                              " port=" + this.bootstrapAddress.getBootstrapPort() + ", rawAddress='" + this.bootstrapAddress.getRawAddress()+"'");               this.bootstrapAddress.setRawAddress(this.bootstrapAddress.getBootstrapUrl());            }         }      }      return this.bootstrapAddress;   }   /**    * Returns a local IP or bootstrapHostname as a default setting to use for callback servers.    * <p />    * It is determined by doing a short connect to the xmlBlaster HTTP server    * an reading the used local hostname.    * The precedence of finding the callback hostname is:    * <ol>    *  <li>Evaluate the -bootstrapHostnameCB property</li>    *  <li>Try to determine it by a temporary connection to the xmlBlaster bootstrap server and reading the used local IP</li>    *  <li>Use default IP of this host</li>    * </ol>    * @return The default IP, is never null    */   public String getCbHostname() {      if (this.cbHostname == null) {         Address addr = getBootstrapAddress();         this.cbHostname = getProperty().get("bootstrapHostnameCB",                           getCbHostname(addr.getBootstrapHostname(), addr.getBootstrapPort()));      }      return this.cbHostname;   }   /**    * Returns a local IP as a default setting to use for callback servers.    * <p />    * It is determined by doing a short connect to the given hostname/socket    * an reading the used local hostname.    * The precedence of finding the callback hostname is:    * <ol>    *  <li>Try to determine it by a temporary connection to the given hostname/socket and reading the used local IP</li>    *  <li>Use default IP of this host</li>    * </ol>    * @return The default IP, is never null    */   public String getCbHostname(String hostname, int port) {      String cbHostname = null;      if (port > 0) {         try {            Socket sock = new Socket(hostname, port);            cbHostname = sock.getLocalAddress().getHostAddress();            sock.close();            sock = null;            if (log.isLoggable(Level.FINE)) log.fine("Default cb host is " + this.cbHostname);         }         catch (java.io.IOException e) {            log.fine("Can't find default cb hostname: " + e.toString());         }      }      if (cbHostname == null)         cbHostname = getLocalIP();      return cbHostname;   }   /**    * Access the xmlBlaster internal HTTP server and download the requested path.    * <p />    * Currently we only use it for CORBA IOR download. To avoid the name service,    * one can access the AuthServer IOR directly    * using a http connection.    *    * @param address The address we want to connect to or null    * @param urlPath The part after the host:port, from an URL "http://myhost.com:3412/AuthenticationService.ior"    *                urlPath is "AuthenticationService.ior"    * @param false Suppress error logging when server not found    */   public String accessFromInternalHttpServer(Address address, String urlPath, boolean verbose) throws XmlBlasterException   {      if (log.isLoggable(Level.FINER))         log.finer("Entering accessFromInternalHttpServer(" + ((address==null)?"null":address.getRawAddress()) + ") ...");      //log.info(ME, "accessFromInternalHttpServer address=" + address.toXml());      Address addr = address;      if (addr != null && addr.getBootstrapPort() > 0) {         if (addr.getBootstrapHostname() == null || addr.getBootstrapHostname().length() < 1) {            addr.setBootstrapHostname(getLocalIP());         }      }      else {         addr = getBootstrapAddress();      }      try {         if (urlPath != null && urlPath.startsWith("/") == false)            urlPath = "/" + urlPath;         if (log.isLoggable(Level.FINE))            log.fine("Trying internal http server on " +                               addr.getBootstrapHostname() + ":" + addr.getBootstrapPort() + "" + urlPath);         java.net.URL nsURL = new java.net.URL("http", addr.getBootstrapHostname(), addr.getBootstrapPort(), urlPath);         java.io.InputStream nsis = nsURL.openStream();         byte[] bytes = new byte[4096];         java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();         int numbytes;         for (int ii=0; ii<20 && (nsis.available() <= 0); ii++) {            if (log.isLoggable(Level.FINE)) log.fine("XmlBlaster on host " + addr.getBootstrapHostname() + " and bootstrapPort " + addr.getBootstrapPort() + " returns empty data, trying again after sleeping 10 milli ...");            Timestamp.sleep(10); // On heavy logins, sometimes available() returns 0, but after sleeping it is OK         }         while (nsis.available() > 0 && (numbytes = nsis.read(bytes)) > 0) {            bos.write(bytes, 0, numbytes);         }         nsis.close();         String data = bos.toString();         if (log.isLoggable(Level.FINE)) log.fine("Retrieved http data='" + data + "'");         return data;      }      catch(MalformedURLException e) {         String text = "XmlBlaster not found on host " + addr.getBootstrapHostname() + " and bootstrap port " + addr.getBootstrapPort() + ".";         log.severe(text + e.toString());         e.printStackTrace();         throw new XmlBlasterException(this, ErrorCode.USER_CONFIGURATION, ME+"NoHttpServer", text, e);      }      catch(IOException e) {         if (verbose) log.warning("XmlBlaster not found on host " + addr.getBootstrapHostname() + " and bootstrapPort " + addr.getBootstrapPort() + ": " + e.toString());         throw new XmlBlasterException(this, ErrorCode.COMMUNICATION_NOCONNECTION, ME+"NoHttpServer",                   "XmlBlaster not found on host " + addr.getBootstrapHostname() + " and bootstrap port " + addr.getBootstrapPort() + ".", e);      }   }   /**    * The IP address where we are running.    * <p />    * You can specify the local IP address with e.g. -bootstrapHostname 192.168.10.1    * on command line, useful for multi-homed hosts.    *    * @return The local IP address, defaults to '127.0.0.1' if not known.    */   public final String getLocalIP()   {      if (this.ip_addr == null) {         if (getBootstrapAddress().hasBootstrapHostname()) { // check if bootstrapHostname is available to avoid infinit looping            this.ip_addr = getBootstrapAddress().getBootstrapHostname();         }         else {            try {               this.ip_addr = java.net.InetAddress.getLocalHost().getHostAddress(); // e.g. "204.120.1.12"            } catch (java.net.UnknownHostException e) {               log.warning("Can't determine local IP address, try e.g. '-bootstrapHostname 192.168.10.1' on command line: " + e.toString());            }            if (this.ip_addr == null) this.ip_addr = "127.0.0.1";         }      }      return this.ip_addr;   }   /**    * Needed by java client helper classes to load    * the security plugin    */   public final PluginLoader getClientSecurityPluginLoader() {      synchronized (PluginLoader.class) {         if (clientSecurityLoader == null)            clientSecurityLoader = new PluginLoader(this);      }      return clientSecurityLoader;   }   public final QueuePluginManager getQueuePluginManager() {      if (queuePluginManager == null) {         synchronized (QueuePluginManager.class) {            if (queuePluginManager == null)               queuePluginManager = new QueuePluginManager(this);         }      }      return queuePluginManager;   }   public final DispatchPluginManager getDispatchPluginManager() {      if (dispatchPluginManager == null) {         synchronized (DispatchPluginManager.class) {            if (dispatchPluginManager == null)               dispatchPluginManager = new DispatchPluginManager(this);         }      }      return dispatchPluginManager;   }   /**    * Access the xmlBlaster Classloader.    * Every Global instance may have an own factory instance.    * Set classLoaderFactory property to not use default StandaloneClassLoaderFactory.    * @return null if switched off with "useXmlBlasterClassloader=false"    */   public ClassLoaderFactory getClassLoaderFactory() {      boolean useXmlBlasterClassloader = getProperty().get("useXmlBlasterClassloader", true);      if (useXmlBlasterClassloader == false) return null;      synchronized (ClassLoaderFactory.class) {         if (classLoaderFactory == null) {            String clf = getProperty().get("classLoaderFactory",(String)null);            if ( clf != null) {               try {                  Class clfc = Thread.currentThread().getContextClassLoader().loadClass(clf);                  classLoaderFactory = (ClassLoaderFactory)clfc.newInstance();                  classLoaderFactory.init(this);                  return classLoaderFactory;               } catch (Exception e) {                  log.warning("Could not load custom classLoaderFactory " + clf + " using StandaloneClassLoaderFactory");               } // end of try-catch            } // end of if ()            classLoaderFactory = new StandaloneClassLoaderFactory(this);         }      }      return classLoaderFactory;   }   /**    * Access the http server which allows bootstrapping the CORBA IOR    */   public final HttpIORServer getHttpServer() throws XmlBlasterException {      if (this.httpServer == null) {         synchronized(this) {            if (this.httpServer == null)               this.httpServer = new HttpIORServer(this, getBootstrapAddress().getBootstrapHostname(), getBootstrapAddress().getBootstrapPort());         }      }      return this.httpServer;   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -