01: package com.knowgate.cache.server;
02:
03: import java.lang.System;
04: import java.util.TreeMap;
05:
06: import javax.ejb.CreateException;
07: import javax.ejb.SessionBean;
08: import javax.ejb.SessionContext;
09:
10: public class DistributedCacheCoordinatorBean implements SessionBean {
11: private SessionContext sessionContext;
12: private TreeMap oBTree;
13:
14: // -----------------------------------------------------------------
15:
16: public void setSessionContext(SessionContext sessionContext) {
17: this .sessionContext = sessionContext;
18: }
19:
20: // -----------------------------------------------------------------
21:
22: public void ejbCreate() throws CreateException {
23: oBTree = new TreeMap();
24: }
25:
26: // -----------------------------------------------------------------
27:
28: public void ejbRemove() {
29: oBTree.clear();
30: oBTree = null;
31: }
32:
33: // -----------------------------------------------------------------
34:
35: public void ejbActivate() {
36: }
37:
38: // -----------------------------------------------------------------
39:
40: public void ejbPassivate() {
41: }
42:
43: // -----------------------------------------------------------------
44:
45: public long now() {
46: return System.currentTimeMillis();
47: }
48:
49: // -----------------------------------------------------------------
50:
51: public long lastModified(String sKey) {
52: Long oDt = (Long) oBTree.get(sKey);
53:
54: if (oDt == null)
55: oDt = new Long((long) 0);
56:
57: return oDt.longValue();
58: }
59:
60: // -----------------------------------------------------------------
61:
62: public long modify(String sKey) {
63: Long oDt = new Long(System.currentTimeMillis());
64:
65: oBTree.remove(sKey);
66: oBTree.put(sKey, oDt);
67:
68: return oDt.longValue();
69: }
70:
71: // -----------------------------------------------------------------
72:
73: public void expire(String sKey) {
74: oBTree.remove(sKey);
75: }
76:
77: // -----------------------------------------------------------------
78:
79: public void flush() {
80: oBTree.clear();
81: }
82: }
|