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

📄 xmlblasteraccess.java

📁 java开源的企业总线.xmlBlaster
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    * <p>Enforced by interface I_ConnectionHandler</p>    * @return The queue used to store tailback messages.    */   public I_Queue getQueue() {      return this.clientQueue;   }   /**    * <p>Enforced by interface I_ConnectionHandler</p>    * @return The current state of the connection    */   public ConnectionStateEnum getState() {      if (!isConnected()) return ConnectionStateEnum.UNDEF;      return this.dispatchManager.getDispatchConnectionsHandler().getState();   }   /**    * Get the connection state.    * String version for JMX access.    * @return "UNDEF", "ALIVE", "POLLING", "DEAD"    */   public String getConnectionState() {      return getState().toString();   }   /**    * <p>Enforced by interface I_ConnectionHandler</p>    * @return true if the connection to xmlBlaster is operational    */   public boolean isAlive() {      if (!isConnected()) return false;      return this.dispatchManager.getDispatchConnectionsHandler().isAlive();   }   /**    * <p>Enforced by interface I_ConnectionHandler</p>    * @return true if we are polling for the server    */   public boolean isPolling() {      if (!isConnected()) return false;      return this.dispatchManager.getDispatchConnectionsHandler().isPolling();   }   /**    * <p>Enforced by interface I_ConnectionHandler</p>    * @return true if we have definitely lost the connection to xmlBlaster and gave up    */   public boolean isDead() {      if (!isConnected()) return false;      return this.dispatchManager.getDispatchConnectionsHandler().isDead();   }   /**    * Access the returned QoS of a connect() call.    * <p>Enforced by interface I_XmlBlasterAccess</p>    * @return Can be null if not connected    */   public ConnectReturnQos getConnectReturnQos() {      return this.connectReturnQos;   }   /**    * Access the current ConnectQos    * <p>Enforced by interface I_XmlBlasterAccess</p>    * @return Can be null if not connected    */   public ConnectQos getConnectQos() {      return this.connectQos;   }   /**    * @see org.xmlBlaster.client.I_XmlBlasterAccess#leaveServer(Map)    */   public void leaveServer(Map map) {      if (!this.isValid) return;      synchronized(this) {         this.isValid = false;         if (this.cbServer != null) {            try {               this.cbServer.shutdown();            }            catch (XmlBlasterException ex) {               ex.printStackTrace();               log.severe(getLogId()+"could not leave the server properly: " + ex.getMessage());            }            this.cbServer = null;         }         if (this.dispatchManager != null) {            //this.dispatchManager.shutdown();            //this.dispatchManager = null;         }      }   }   /**    * @return null if no callback is configured    */   public final DispatchStatistic getDispatchStatistic() {      if (this.statistic == null) {         synchronized (this) {            if (this.statistic == null) {               if (this.dispatchManager != null)                  this.statistic = this.dispatchManager.getDispatchStatistic();               else                  this.statistic = new DispatchStatistic();            }         }      }      return this.statistic;   }   /**    * Access the login name.    * @return your login name or null if you are not logged in    */   public synchronized final String getLoginName() {      SessionName sn = getSessionName();      if (sn == null) return "xmlBlasterClient";      return sn.getLoginName();      /*      //if (this.connectReturnQos != null)      //   return this.connectReturnQos.getLoginName();      //try {         if (connectQos != null && connectQos.getSecurityQos() != null) {            String nm = connectQos.getSecurityQos().getUserId();            if (nm != null && nm.length() > 0)               return nm;         }      //}      //catch (XmlBlasterException e) {}      return glob.getId(); // "client?";      */   }   public final boolean isCallbackConfigured() {      return (this.cbServer != null);   }   public final long getUptime() {      return (System.currentTimeMillis() - this.startupTime)/1000L;   }   public final String getLoginDate() {      long ll = this.startupTime;      java.sql.Timestamp tt = new java.sql.Timestamp(ll);      return tt.toString();   }   public synchronized final long getPublicSessionId() {      SessionName sn = getSessionName();      if (sn == null) return 0;      return sn.getPublicSessionId();   }   public final long getNumPublish() {      return getDispatchStatistic().getNumPublish();   }   public final long getNumSubscribe() {      return getDispatchStatistic().getNumSubscribe();   }   public final long getNumUnSubscribe() {      return getDispatchStatistic().getNumUnSubscribe();   }   public final long getNumGet() {      return getDispatchStatistic().getNumGet();   }   public final long getNumErase() {      return getDispatchStatistic().getNumErase();   }   public final long getNumUpdateOneway() {      return getDispatchStatistic().getNumUpdateOneway();   }   public final long getNumUpdate() {      return getDispatchStatistic().getNumUpdate();   }   public synchronized final long getConnectionQueueNumMsgs() {      if (this.clientQueue == null) return 0L;      return this.clientQueue.getNumOfEntries();   }   public synchronized final long getConnectionQueueMaxMsgs() {      if (this.clientQueue == null) return 0L;      return this.clientQueue.getMaxNumOfEntries();   }   public final long getPingRoundTripDelay() {      return getDispatchStatistic().getPingRoundTripDelay();   }   public final long getRoundTripDelay() {      return getDispatchStatistic().getRoundTripDelay();   }   /** JMX **/   public String invokePublish(String key, String content, String qos) throws Exception {      if (key == null || key.length()==0 || key.equalsIgnoreCase("String"))         throw new IllegalArgumentException("Please pass a valid XML key like '<key oid='Hello'/> or the simple oid like 'Hello'");      if (key.indexOf("<") == -1) {         key = "<key oid='" + key + "'/>";      }      qos = checkQueryKeyQos(key, qos);      if (content == null) content = "";      try {         MsgUnit msgUnit = new MsgUnit(key, content, qos);         PublishReturnQos prq = publish(msgUnit);         return prq.toString();      }      catch (XmlBlasterException e) {         throw new Exception(e.toString());      }   }   private String checkQueryKeyQos(String url, String qos) {      if (log.isLoggable(Level.FINE)) log.fine(getLogId()+"url=" + url + " qos=" + qos);      if (url == null || url.length()==0 || url.equalsIgnoreCase("String"))         throw new IllegalArgumentException("Please pass a valid URL like 'xpath://key' or a simple oid like 'Hello'");      if (qos == null || qos.length()==0 || qos.equalsIgnoreCase("String")) qos = "<qos/>";      return qos;   }   /** JMX **/   public String[] invokeUnSubscribe(String url, String qos) throws Exception {      qos = checkQueryKeyQos(url, qos);      try {         UnSubscribeKey usk = new UnSubscribeKey(glob, url);         UnSubscribeReturnQos[] usrq = unSubscribe(usk, new UnSubscribeQos(glob, glob.getQueryQosFactory().readObject(qos)));         if (usrq == null) return new String[0];         String[] ret = new String[usrq.length];         if (ret.length < 1) {            return new String[] { "unSubscribe '"+url+"' did not match any subscription" };         }         for (int i=0; i<usrq.length; i++) {            ret[i] = usrq[i].toXml();         }         return ret;      }      catch (XmlBlasterException e) {         throw new Exception(e.toString());      }   }   /** JMX **/   public String invokeSubscribe(String url, String qos) throws Exception {      qos = checkQueryKeyQos(url, qos);      try {         SubscribeKey usk = new SubscribeKey(glob, url);         SubscribeReturnQos srq = subscribe(usk, new SubscribeQos(glob, glob.getQueryQosFactory().readObject(qos)));         if (srq == null) return "";         return srq.toXml();      }      catch (XmlBlasterException e) {         throw new Exception(e.toString());      }   }   /** JMX **/   public String[] invokeGet(String url, String qos) throws Exception {      qos = checkQueryKeyQos(url, qos);      try {         GetKey gk = new GetKey(glob, url);         MsgUnit[] msgs = get(gk, new GetQos(glob, glob.getQueryQosFactory().readObject(qos)));         if (msgs == null) return new String[0];         if (msgs == null || msgs.length < 1) {            return new String[] { "get('"+url+"') did not match any topic" };         }         ArrayList tmpList = new ArrayList();         for (int i=0; i<msgs.length; i++) {            tmpList.add("  "+msgs[i].getKeyData().toXml());            tmpList.add("  "+msgs[i].getContentStr());            tmpList.add("  "+msgs[i].getQosData().toXml());         }         return (String[])tmpList.toArray(new String[tmpList.size()]);      }      catch (XmlBlasterException e) {         throw new Exception(e.toString());      }   }   /** JMX **/   public String[] invokeErase(String url, String qos) throws Exception {      qos = checkQueryKeyQos(url, qos);      try {         EraseKey ek = new EraseKey(glob, url);         EraseReturnQos[] erq = erase(ek, new EraseQos(glob, glob.getQueryQosFactory().readObject(qos)));         if (erq == null) return new String[0];         String[] ret = new String[erq.length];         if (ret.length < 1) {            return new String[] { "erase('"+url+"') did not match any topic, nothing is erased." };         }         for (int i=0; i<erq.length; i++) {            ret[i] = erq[i].toXml();         }         return ret;      }      catch (XmlBlasterException e) {         throw new Exception(e.toString());      }   }   /**    * Sets the DispachManager belonging to this session to active or inactive.    * It is initially active. Setting it to false temporarly inhibits dispatch of    * messages which are in t

⌨️ 快捷键说明

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