KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > deployment > rmi > RMICacheEntry


1 /*
2  * CoadunationLib: The coaduntion implementation library.
3  * Copyright (C) 2006 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
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 JavaDoc;
27
28 // coad imports
29
import com.rift.coad.lib.cache.Cache;
30 import com.rift.coad.lib.cache.CacheEntry;
31
32
33 /**
34  * This object is responsible for implementing the cache entry.
35  *
36  * @author Brett Chaldecott
37  */

38 public class RMICacheEntry implements CacheEntry {
39     // private member variables
40
private long timeout = -1;
41     private CacheEntry cacheEntry = null;
42     
43     
44     /**
45      * The constructor of the proxy cache object.
46      *
47      * @param timeout The timeout for this proxy object.
48      * @param cacheEntry The cache entry object.
49      */

50     public RMICacheEntry(long timeout, CacheEntry cacheEntry) {
51         this.timeout = timeout;
52         this.cacheEntry = cacheEntry;
53     }
54     
55     
56     /**
57      * The touch method
58      */

59     public void touch() {
60         // do nothing
61
}
62     
63     
64     /**
65      * This method will return true if the date is older than the given expiry
66      * date.
67      *
68      * @return TRUE if expired FALSE if not.
69      * @param expiryDate The expiry date to perform the check with.
70      */

71     public boolean isExpired(Date JavaDoc expiryDate) {
72         // check if this object should never be expired
73
if (timeout <= 0) {
74             return false;
75         }
76         Date JavaDoc calculatedExpiry = new Date JavaDoc(expiryDate.getTime() - timeout);
77         return cacheEntry.isExpired(calculatedExpiry);
78     }
79     
80     
81     /**
82      * This method is called by the cache when an object is removed.
83      */

84     public void cacheRelease() {
85         cacheEntry.cacheRelease();
86     }
87     
88     
89     /**
90      * This method returns the cache entry
91      */

92     public CacheEntry getCacheEntry() {
93         return cacheEntry;
94     }
95     
96     
97     /**
98      * This method returns the remove interface reference.
99      *
100      * @return The reference to the remove interface.
101      */

102     public java.rmi.Remote JavaDoc getRemoteInterface() {
103         return (java.rmi.Remote JavaDoc)cacheEntry;
104     }
105 }
Popular Tags