01: /*
02: * CoadunationLib: The coaduntion implementation library.
03: * Copyright (C) 2006 Rift IT Contracting
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18: *
19: * RMICacheEntry.java
20: */
21:
22: // package path
23: package com.rift.coad.lib.deployment.rmi;
24:
25: // java imports
26: import java.util.Date;
27:
28: // coad imports
29: import com.rift.coad.lib.cache.Cache;
30: import com.rift.coad.lib.cache.CacheEntry;
31:
32: /**
33: * This object is responsible for implementing the cache entry.
34: *
35: * @author Brett Chaldecott
36: */
37: public class RMICacheEntry implements CacheEntry {
38: // private member variables
39: private long timeout = -1;
40: private CacheEntry cacheEntry = null;
41:
42: /**
43: * The constructor of the proxy cache object.
44: *
45: * @param timeout The timeout for this proxy object.
46: * @param cacheEntry The cache entry object.
47: */
48: public RMICacheEntry(long timeout, CacheEntry cacheEntry) {
49: this .timeout = timeout;
50: this .cacheEntry = cacheEntry;
51: }
52:
53: /**
54: * The touch method
55: */
56: public void touch() {
57: // do nothing
58: }
59:
60: /**
61: * This method will return true if the date is older than the given expiry
62: * date.
63: *
64: * @return TRUE if expired FALSE if not.
65: * @param expiryDate The expiry date to perform the check with.
66: */
67: public boolean isExpired(Date expiryDate) {
68: // check if this object should never be expired
69: if (timeout <= 0) {
70: return false;
71: }
72: Date calculatedExpiry = new Date(expiryDate.getTime() - timeout);
73: return cacheEntry.isExpired(calculatedExpiry);
74: }
75:
76: /**
77: * This method is called by the cache when an object is removed.
78: */
79: public void cacheRelease() {
80: cacheEntry.cacheRelease();
81: }
82:
83: /**
84: * This method returns the cache entry
85: */
86: public CacheEntry getCacheEntry() {
87: return cacheEntry;
88: }
89:
90: /**
91: * This method returns the remove interface reference.
92: *
93: * @return The reference to the remove interface.
94: */
95: public java.rmi.Remote getRemoteInterface() {
96: return (java.rmi.Remote) cacheEntry;
97: }
98: }
|