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

📄 mapplugin.java

📁 java开源的企业总线.xmlBlaster
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
               it = this.storage.values().iterator();               if (it.hasNext()) {                  I_MapEntry entry = (I_MapEntry)it.next();                  remove(entry);                  return entry;               }            }            return null;         }      }      finally {         this.storageSizeListenerHelper.invokeStorageSizeListener();      }   }   public long clear() {      if (log.isLoggable(Level.FINER)) log.finer("clear()");      synchronized(this.storage) {         long ret = this.storage.size();         Iterator iter = this.storage.values().iterator();         while (iter.hasNext()) {            ((I_MapEntry)iter.next()).setStored(false);         }         this.lruSet.clear();         this.storage.clear();         this.sizeInBytes = 0L;         this.persistentSizeInBytes = 0L;         this.numOfPersistentEntries = 0L;         this.storageSizeListenerHelper.invokeStorageSizeListener();         return ret;      }   }   /**    * @see I_Map#getNumOfEntries()    */   public long getNumOfEntries() {      synchronized(this.storage) {         return this.storage.size();      }   }   public long getMaxNumOfEntries() {      return property.getMaxEntries();   }   /**i    * @see I_Map#getNumOfPersistentEntries()    */   public long getNumOfPersistentEntries() {      synchronized(this.storage) {         return this.numOfPersistentEntries;      }   }   /**    * @see I_Map#getNumOfBytes()    */   public long getNumOfBytes() {      synchronized(this.storage) {         return this.sizeInBytes;      }   }   /**    * @see I_Map#getNumOfPersistentBytes()    */   public long getNumOfPersistentBytes() {      synchronized(this.storage) {         return this.persistentSizeInBytes;      }   }   /**    * @see I_Map#getMaxNumOfBytes()    */   public final long getMaxNumOfBytes() {      return this.property.getMaxBytes();   }   public final void shutdown() {      if (log.isLoggable(Level.FINER)) log.finer("Entering shutdown(" + this.storage.size() + ")");      //Thread.currentThread().dumpStack();      synchronized (this.storage) {         if (this.storage.size() > 0) {            if (log.isLoggable(Level.FINE)) log.fine("Shutting down RAM map which contains " + this.storage.size() + " messages");         }         this.lruSet.clear();         isShutdown = true;      }      if (log.isLoggable(Level.FINER)) log.finer("shutdown() of RAM map " + this.getStorageId());      this.storageSizeListenerHelper.invokeStorageSizeListener();      removeStorageSizeListener(null);      // glob.getQueuePluginManager().cleanup(this);      if (glob instanceof ServerScope) {         ((ServerScope)glob).getStoragePluginManager().cleanup(this);      }      else         log.warning("The global is not a ServerScope: we can not clean up this entry from the storage plugin manager");         }   public final boolean isShutdown() {      return this.isShutdown;   }   public void destroy() throws XmlBlasterException {      this.property = null;   }   public String usage() {      return "no usage";   }   public final String toXml() {      return toXml((String)null);   }   public final String toXml(String extraOffset) {      StringBuffer sb = new StringBuffer(256);      if (extraOffset == null) extraOffset = "";      String offset = Constants.OFFSET + extraOffset;      sb.append(offset).append("<MapPlugin id='").append(getStorageId().getId());      sb.append("' type='").append(getType());      sb.append("' version='").append(getVersion());      sb.append("' numOfEntries='").append(getNumOfEntries());      sb.append("' numOfBytes='").append(getNumOfBytes());      sb.append("'>");      sb.append(property.toXml(extraOffset+Constants.INDENT));      sb.append(offset).append("</MapPlugin>");      return sb.toString();   }   /**    * Enforced by I_Plugin    * @see org.xmlBlaster.util.plugin.I_Plugin#init(org.xmlBlaster.util.Global, PluginInfo)    */   public void init(org.xmlBlaster.util.Global glob, PluginInfo pluginInfo) {//      java.util.Properties props = pluginInfo.getParameters();      this.glob = glob;      this.pluginInfo = pluginInfo;   }   /**    * Enforced by I_Plugin    * @return "RAM"    */   public String getType() { return "RAM"; }   /**    * Enforced by I_Plugin    * @return "1.0"    */   public String getVersion() { return "1.0"; }   /**    * Enforced by I_StoragePlugin    * @return the pluginInfo object.    */   public PluginInfo getInfo() { return this.pluginInfo; }   /**    * @see org.xmlBlaster.util.queue.I_StorageProblemNotifier#registerStorageProblemListener(I_StorageProblemListener)    */   public boolean registerStorageProblemListener(I_StorageProblemListener listener) {      return false;   }   /**    * @see org.xmlBlaster.util.queue.I_StorageProblemNotifier#unRegisterStorageProblemListener(I_StorageProblemListener)    */   public boolean unRegisterStorageProblemListener(I_StorageProblemListener listener) {      return false;   }   /**    * @see I_Map#change(I_MapEntry, I_ChangeCallback)    */   public I_MapEntry change(I_MapEntry entry, I_ChangeCallback callback) throws XmlBlasterException {      synchronized(this.storage) {         long oldSizeInBytes = entry.getSizeInBytes(); // must be here since newEntry could reference same obj.         I_MapEntry newEntry = entry;          if (callback != null) newEntry = callback.changeEntry(entry);         if (oldSizeInBytes != newEntry.getSizeInBytes()) {            throw new XmlBlasterException(this.glob, ErrorCode.INTERNAL_UNKNOWN, ME + ".change", "the size of the entry '" + entry.getUniqueId() + "' has changed from '" + oldSizeInBytes + "' to '" + newEntry.getSizeInBytes() +"'. This is not allowed");         }          if (entry != newEntry) { // then they are not the same reference ...            int tmp = remove(entry);            if (tmp < 1) throw new XmlBlasterException(this.glob,  ErrorCode.INTERNAL_UNKNOWN, ME + ".change", "the size of the entry '" + entry.getUniqueId() + "' has not been found on this map");            put(newEntry);         }         return newEntry;      }   }   /**    * @see I_Map#change(long, I_ChangeCallback)    */   public I_MapEntry change(long uniqueId, I_ChangeCallback callback) throws XmlBlasterException {      synchronized(this.storage) {         I_MapEntry oldEntry = get(uniqueId);         return change(oldEntry, callback);      }   }   /**    * @see I_Map#embeddedObjectsToXml(OutputStream, Properties)    */   public long embeddedObjectsToXml(OutputStream out, Properties props) {      log.warning("Sorry, dumping transient entries is not implemented");      return 0;   }   /**    * @see I_Queue#addStorageSizeListener(I_StorageSizeListener)    */   public void addStorageSizeListener(I_StorageSizeListener listener) {      this.storageSizeListenerHelper.addStorageSizeListener(listener);   }      /**    * @see I_Queue#removeStorageSizeListener(I_StorageSizeListener)    */   public void removeStorageSizeListener(I_StorageSizeListener listener) {      this.storageSizeListenerHelper.removeStorageSizeListener(listener);   }      /**    * @see I_Queue#hasStorageSizeListener(I_StorageSizeListener)    */   public boolean hasStorageSizeListener(I_StorageSizeListener listener) {      return this.storageSizeListenerHelper.hasStorageSizeListener(listener);   }   /**    * @see I_Storage#getStorageSizeListeners()    */   public I_StorageSizeListener[] getStorageSizeListeners() {      return storageSizeListenerHelper.getStorageSizeListeners();   }   /**    * Sorts the entries in the the last recent added order (no real LRU).     */   class LruComparator implements Comparator, java.io.Serializable   {      private static final long serialVersionUID = -8286998211709086682L;      // We compare the MsgUnitWrapper by its cache entry timestamp      public final int compare(Object o1, Object o2) {         I_MapEntry id1 = (I_MapEntry)o1;         I_MapEntry id2 = (I_MapEntry)o2;         if (id1.getSortTimestamp() == null) id1.setSortTimestamp(new Timestamp()); // assert != null         if (id2.getSortTimestamp() == null) id2.setSortTimestamp(new Timestamp()); // assert != null                  if (id1.getSortTimestamp().getTimestamp() > id2.getSortTimestamp().getTimestamp()) {            return 1;         }         else if (id1.getSortTimestamp().getTimestamp() < id2.getSortTimestamp().getTimestamp()) {            return -1;         }         return 0;      }   }   /**    * java org.xmlBlaster.engine.msgstore.ram.MapPlugin    */   public static void main(String[] args) {      try {         Global glob = new Global(args);         MapPlugin pl = new MapPlugin();         StorageId mapId = new StorageId("msgUnitStore", "/node/unknown");         pl.initialize(mapId, new org.xmlBlaster.util.qos.storage.MsgUnitStoreProperty(glob, glob.getId()));      }      catch (XmlBlasterException e) {         System.out.println("ERROR: " + e.getMessage());      }   }}

⌨️ 快捷键说明

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