1 package com.knowgate.cache.server; 2 3 import java.lang.System ; 4 import java.util.TreeMap ; 5 6 import javax.ejb.CreateException ; 7 import javax.ejb.SessionBean ; 8 import javax.ejb.SessionContext ; 9 10 public class DistributedCacheCoordinatorBean implements SessionBean { 11 private SessionContext sessionContext; 12 private TreeMap oBTree; 13 14 16 public void setSessionContext(SessionContext sessionContext) { 17 this.sessionContext = sessionContext; 18 } 19 20 22 public void ejbCreate() throws CreateException { 23 oBTree = new TreeMap (); 24 } 25 26 28 public void ejbRemove() { 29 oBTree.clear(); 30 oBTree = null; 31 } 32 33 35 public void ejbActivate() { } 36 37 39 public void ejbPassivate() { } 40 41 43 public long now() { 44 return System.currentTimeMillis(); 45 } 46 47 49 public long lastModified(String sKey) { 50 Long oDt = (Long ) oBTree.get(sKey); 51 52 if (oDt==null) oDt = new Long ((long) 0); 53 54 return oDt.longValue(); 55 } 56 57 59 public long modify(String sKey) { 60 Long oDt = new Long (System.currentTimeMillis()); 61 62 oBTree.remove(sKey); 63 oBTree.put(sKey, oDt); 64 65 return oDt.longValue(); 66 } 67 68 70 public void expire(String sKey) { 71 oBTree.remove(sKey); 72 } 73 74 76 public void flush() { 77 oBTree.clear(); 78 } 79 } | Popular Tags |