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

📄 globalinfo.java

📁 java开源的企业总线.xmlBlaster
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      initJmx();      this.helper.replaceAllEntries(this, this.propsOfOwnInterest);   }   private void initJmx() {      Map jmxMap = InfoHelper.getObjectsWithKeyStartingWith(JMX_PREFIX, this, null);      if (jmxMap.size() < 1)         return;      String[] keys = (String[])jmxMap.keySet().toArray(new String[jmxMap.size()]);      for (int i=0; i < keys.length; i++) {         Object obj = jmxMap.get(keys[i]);         String name = keys[i];         ContextNode child = new ContextNode(ContextNode.CONTRIB_MARKER_TAG, name, this.contextNode);         log.info("MBean '" + name + "' found. Will attach it as '" + child.getRelativeName() + "' to '" + this.contextNode.getAbsoluteName() + "'");         try {            JmxMBeanHandle mBeanHandle = this.global.registerMBean(child, obj);            this.jmxHandleSet.add(mBeanHandle);         }         catch(XmlBlasterException e) {            log.severe(e.getMessage());         }      }   }      /**    * The plugin name as configured im <tt>xmlBlasterPlugins.xml</tt>    * @see org.xmlBlaster.util.plugin.I_Plugin#getType()    */   public String getType() {      if (this.pluginInfo != null)         return this.pluginInfo.getType();      return null;   }   /**    * The plugin version as configured in <tt>xmlBlasterPlugins.xml</tt>    * @see org.xmlBlaster.util.plugin.I_Plugin#getVersion()    */   public String getVersion() {      if (this.pluginInfo != null)         return this.pluginInfo.getVersion();      return null;   }   /**    * @see org.xmlBlaster.util.plugin.I_Plugin#shutdown()    */   public void shutdown() throws XmlBlasterException {      if (this.jmxHandleSet.size() < 1)         return;      JmxMBeanHandle[] handles = (JmxMBeanHandle[])this.jmxHandleSet.toArray(new JmxMBeanHandle[this.jmxHandleSet.size()]);      for (int i=0; i < handles.length; i++) {         log.info("Unregistering MBean '" + handles[i].getContextNode().getAbsoluteName() + "'");         this.global.unregisterMBean(handles[i]);      }   }      /**    */   public String getRaw(String key) {      if (key == null) return null;      try {         if (this.propsOfOwnInterest.contains(key)) {            String ret = (this.pluginInfo == null) ? null : this.pluginInfo.getParameters().getProperty(key, null);            String prefix = (this.pluginInfo == null) ? "" : this.pluginInfo.getPrefix();             return this.global.getProperty().get(prefix + key, ret);         }                  String value = this.global.get(key, null, null, this.pluginInfo);         if ("jdbc.drivers".equals(key) && (value == null || value.length() < 1))            return this.global.getProperty().get("JdbcDriver.drivers", ""); // ask xmlBlaster.properties         log.fine("Resolving " + key + " to '" + value + "'");         return value;      }      catch (XmlBlasterException e) {         log.warning(e.toString());         return null;      }   }   /**    * @see org.xmlBlaster.contrib.I_Info#get(java.lang.String, java.lang.String)    */   public String get(String key, String def) {      if (key == null)         return def;      key = this.helper.replace(key);            // hack: if in topic name is a ${..} our global tries to replace it and      // throws an exception, but we need it without replacement:      // $_{...} resolves this issue, but nicer would be:      //       <attribute id='db.queryMeatStatement' replace='false'>...</attribute>      try {         if (this.propsOfOwnInterest.contains(key)) {            String ret = (this.pluginInfo == null) ? def : this.pluginInfo.getParameters().getProperty(key, def);            ret = this.helper.replace(ret);            String prefix = (this.pluginInfo == null) ? "" : this.pluginInfo.getPrefix();             return this.global.getProperty().get(prefix + key, ret);         }                  String value = this.global.get(key, def, null, this.pluginInfo);         value = this.helper.replace(value);         if ("jdbc.drivers".equals(key) && (value == null || value.length() < 1))            return this.global.getProperty().get("JdbcDriver.drivers", ""); // ask xmlBlaster.properties         log.fine("Resolving " + key + " to '" + value + "'");         return value;      }      catch (XmlBlasterException e) {         log.warning(e.toString());         return def;      }   }   /**    * @see org.xmlBlaster.contrib.I_Info#put(java.lang.String, java.lang.String)    */    public void put(String key, String value) {       if (key != null)          key = this.helper.replace(key);       if (value != null)          value = this.helper.replace(value);       if (value == null)          this.global.getProperty().removeProperty(key);       else {          try {             String prefix = (this.pluginInfo == null) ? "" : pluginInfo.getPrefix();  // "plugin/" + getType() + "/"             this.global.getProperty().set(prefix + key, value);          }          catch (Exception e) {             log.warning(e.toString() + ": Ignoring setting " + key + "=" + value);          }       }    }    /**     * @see org.xmlBlaster.contrib.I_Info#put(java.lang.String, java.lang.String)     */     public void putRaw(String key, String value) {        if (value == null)           this.global.getProperty().removeProperty(key);        else {           try {              String prefix = (this.pluginInfo == null) ? "" : pluginInfo.getPrefix();  // "plugin/" + getType() + "/"              this.global.getProperty().set(prefix + key, value);           }           catch (Exception e) {              log.warning(e.toString());           }        }     }   /**    * @see org.xmlBlaster.contrib.I_Info#getLong(java.lang.String, long)    */   public long getLong(String key, long def) {      if (key == null)         return def;      key = this.helper.replace(key);      try {        return this.global.get(key, def, null, this.pluginInfo);      }      catch (XmlBlasterException e) {         log.warning(e.toString());         return def;      }   }    /**    * @see org.xmlBlaster.contrib.I_Info#getInt(java.lang.String, int)    */   public int getInt(String key, int def) {      if (key == null)         return def;      key = this.helper.replace(key);      try {        return this.global.get(key, def, null, this.pluginInfo);      }      catch (XmlBlasterException e) {         log.warning(e.toString());         return def;      }   }   /**    * @see org.xmlBlaster.contrib.I_Info#getBoolean(java.lang.String, boolean)    */   public boolean getBoolean(String key, boolean def) {      if (key == null)         return def;      key = this.helper.replace(key);      try {        return this.global.get(key, def, null, this.pluginInfo);      }      catch (XmlBlasterException e) {         log.warning(e.toString());         return def;      }   }   /**    * @see org.xmlBlaster.contrib.I_Info#getObject(java.lang.String)    */   public Object getObject(String key) {      return this.objects.get(key);   }   /**    * @see org.xmlBlaster.contrib.I_Info#putObject(java.lang.String, Object)    */   public Object putObject(String key, Object o) {      if (o == null)         return this.objects.remove(key);      return this.objects.put(key, o);   }   /**    * @see org.xmlBlaster.contrib.I_Info#getKeys()    */   public Set getKeys() {      Iterator iter = this.global.getProperty().getProperties().keySet().iterator();      HashSet out = new HashSet();      String prefix = "";      if (this.pluginInfo != null)         prefix = this.pluginInfo.getPrefix();      while (iter.hasNext()) {         String key = (String)iter.next();         if (key.startsWith(prefix))            key = key.substring(prefix.length());            out.add(key);      }      if (this.pluginInfo != null)         PropertiesInfo.addSet(out, this.pluginInfo.getParameters().keySet());      return out;   }   /**    * @see org.xmlBlaster.contrib.I_Info#getObjectKeys()    */   public Set getObjectKeys() {      return this.objects.keySet();   }      public static String dump(I_Info info) {      StringBuffer buf = new StringBuffer();      Iterator iter = info.getKeys().iterator();      while (iter.hasNext()) {         String key = (String)iter.next();         String val = info.get(key, "");         buf.append(key).append("=").append(val).append("\n");      }      return buf.toString();   }      public Global getGlobal() {      return this.global;   }   }

⌨️ 快捷键说明

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