KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > bean > ProxyCacheEntry


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  * ProxyCacheEntry.java
20  */

21
22 // package path
23
package com.rift.coad.lib.bean;
24
25 // java imports
26
import java.util.Date JavaDoc;
27
28 // coadunation 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 ProxyCacheEntry implements CacheEntry {
39     // private member variables
40
private long timeout = -1;
41     private Object JavaDoc proxy = null;
42     private CacheEntry cacheEntry = null;
43     
44     
45     /**
46      * The constructor of the proxy cache object.
47      *
48      * @param timeout The timeout for this proxy object.
49      * @param proxy The proxy interface for the object.
50      * @param cacheEntry The cache entry being handled.
51      */

52     public ProxyCacheEntry(long timeout, Object JavaDoc proxy, CacheEntry cacheEntry) {
53         this.timeout = timeout;
54         this.proxy = proxy;
55         this.cacheEntry = cacheEntry;
56     }
57     
58     
59     /**
60      * The touch method
61      */

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

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

87     public void cacheRelease() {
88         cacheEntry.cacheRelease();
89     }
90     
91     
92     /**
93      * This method returns the handler stored with
94      */

95     public CacheEntry getCacheEntry() {
96         return cacheEntry;
97     }
98 }
99
100
101
Popular Tags