/** Get the raw TimedEntry for key without performing any expiration check. @return the TimedEntry value associated with key if one exists, null otherwise. */ public TimedEntry peekEntry(Object key) { Serializable skey = (Serializable) key; TimedEntry entry = (TimedEntry) this.entryMap.get(this.category, skey); return entry; }
/** Remove all entries from the cache. */ public void flush() { Collection keys = this.entryMap.getAllKeys(this.category); // Notify the entries of their removal Iterator iter = keys.iterator(); while (iter.hasNext()) { Serializable key = (Serializable) iter.next(); TimedEntry entry = (TimedEntry) this.entryMap.get(this.category, key); entry.destroy(); } }
/** Get the cache value for key. This method does not check to see if the entry has expired. @return the TimedEntry value or the original value if it was not an instancee of TimedEntry if key is in the cache, null otherwise. */ public Object peek(Object key) { Serializable skey = (Serializable) key; TimedEntry entry = (TimedEntry) this.entryMap.get(this.category, skey); Object value = null; if (entry != null) { value = entry.getValue(); } return value; }
/** * This method is called when single entities are to be found. The * persistence manager must find out whether the wanted instance is * available in the persistence store, if so it returns the primary key of * the object. * * @param finderMethod the find method in the home interface that was * called * @param args any finder parameters * @param instance the instance to use for the finder call * @return a primary key representing the found entity * * @throws java.rmi.RemoteException thrown if some system exception occurs * @throws javax.ejb.FinderException thrown if some heuristic problem occurs */ public Object findEntity (Method finderMethod, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if (finderMethod.getName ().equals ("findByPrimaryKey")) { if (this.ds.get (DS_CATEGORY, args[0].toString ()) == null) throw new javax.ejb.FinderException (args[0]+" does not exist"); return factory.getEntityEJBObject(args[0]); } else return null; }
/** * * Convenience method for sharing state across a cluster partition. * Delegates to the DistributedStateService * * @param key key for the distributed object * @return Serializable the distributed object * */ public Serializable getDistributedState(String key) { DistributedState ds = this.getHAPartition().getDistributedStateService(); return ds.get(this.getHAServiceKey(), key); }
byte[] content = (byte[])this.ds.get (this.DS_CATEGORY, ctx.getId ().toString ());
TimedEntry entry = (TimedEntry) this.entryMap.get(this.category, skey); if (entry != null)
if (this.ds.get (DS_CATEGORY, id.toString ()) != null) throw new javax.ejb.DuplicateKeyException ("Already exists:"+id);
/** Get the cache value for key if it has not expired. If the TimedEntry is expired its destroy method is called and then removed from the cache. @return the TimedEntry value or the original value if it was not an instance of TimedEntry if key is in the cache, null otherwise. */ public Object get(Object key) { Serializable skey = (Serializable) key; TimedEntry entry = (TimedEntry) this.entryMap.get(this.category, skey); if (entry == null) return null; if (entry.isCurrent(this.now) == false) { // Try to refresh the entry if (entry.refresh() == false) { // Failed, remove the entry and return null entry.destroy(); try { this.entryMap.remove(this.category, skey); } catch (Exception e) { log.debug("Failed to remove expired entry", e); } return null; } } Object value = entry.getValue(); return value; }