/** Remove the entry associated with key and call destroy on the entry if found. */ public void remove(Object key) { Serializable skey = (Serializable) key; try { TimedEntry entry = (TimedEntry) this.entryMap.remove(this.category, skey); if (entry != null) { entry.destroy(); } } catch (Exception e) { log.error("Failed to remove entry", e); } }
@SuppressWarnings("unchecked") protected synchronized void publishLocalInvalidationGroups() throws Exception { this.localGroups = this.invalMgr.getInvalidationGroups(); this.log.debug("Publishing locally available invalidation groups: " + this.localGroups); ArrayList<InvalidationGroup> content = new ArrayList<InvalidationGroup>(this.localGroups); ArrayList<String> result = new ArrayList<String>(content.size()); for (int i = 0; i < content.size(); i++) { String aGroup = content.get(i).getGroupName(); result.add(aGroup); } String nodeName = this.partition.getNodeName(); DistributedState ds = this.partition.getDistributedStateService(); if (result.size() > 0) { NodeInfo info = new NodeInfo(result, nodeName); ds.set(this.RPC_HANDLER_NAME, nodeName, info, true); } else { ds.remove(this.RPC_HANDLER_NAME, nodeName, true); } }
ds.remove(this.RPC_HANDLER_NAME, nodeEntry, true);
/** * This method is called when an entity shall be removed from the * underlying storage. The persistence manager must call ejbRemove on the * instance and then remove its state from the underlying storage. * * @param ctx the instance to remove * * @throws java.rmi.RemoteException thrown if some system exception occurs * @throws javax.ejb.RemoveException thrown if the instance could not be removed */ public void removeEntity (EntityEnterpriseContext ctx) throws javax.ejb.RemoveException { try { if (this.ds.remove (this.DS_CATEGORY, ctx.getId ().toString (), false) == null) throw new javax.ejb.RemoveException ("Could not remove bean:" + ctx.getId ()); } catch (Exception e) { throw new javax.ejb.RemoveException (e.toString ()); } }
/** 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; }
@Override public void stopService() { DistributedReplicantManager drm = this.partition.getDistributedReplicantManager(); DistributedState ds = this.partition.getDistributedStateService(); try { this.partition.unregisterRPCHandler(this.RPC_HANDLER_NAME, this); ds.unregisterDSListenerEx(this.RPC_HANDLER_NAME, this); drm.unregisterListener(this.RPC_HANDLER_NAME, this); drm.remove(this.RPC_HANDLER_NAME); this.invalidationSubscription.unregister(); ds.remove(this.RPC_HANDLER_NAME, this.partition.getNodeName(), true); // this.invalMgr = null; // partition = null; this.invalidationSubscription = null; this.RPC_HANDLER_NAME = null; this.localGroups = null; this.bridgedGroups = new Vector<String>(); } catch (Exception e) { this.log.info("Problem while shuting down invalidation cache bridge", e); } }