View Javadoc

1   /*
2    * Copyright 2000-2001,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.jetspeed.services.portletcache;
18  
19  import org.apache.jetspeed.portal.expire.Expire;
20  import org.apache.turbine.services.cache.CachedObject;
21  
22  /***
23   * <p>This is an interface for defining Jetspeed objects that may be 
24   * cached in the object cache.</p>
25   * <p>Each such object must be able to prodive a caching handle
26   * that will uniquely identify it within the cache system</p>
27   *
28   * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
29   * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
30   * @version $Id: Cacheable.java,v 1.7 2004/02/23 03:34:54 jford Exp $
31   */
32  public interface Cacheable
33  {
34      /***
35       * Return true if this Cacheable is allowed to be cached.
36       *
37       * @return <CODE>TRUE</CODE> if object is cachable<br>
38       * <CODE>FALSE</CODE> if object is not cacheable
39       */
40      public boolean isCacheable();
41      
42      /***
43       * Set this cacheable status.
44       *
45       * @param cacheable Set the cacheability of the object
46       */
47      public void setCacheable(boolean cacheable);
48      
49      /***
50       * Used by a Cacheable object to determine when it should expire itself from
51       * the cache.
52       *
53       * @return Expire handle
54       */
55      public Expire getExpire();
56  
57      /***
58       * <p>Used by the cache to get a unique reference on what you want to add
59       * and then retrieve in the future from the cache</p>
60       *
61       * <p>Most implementations should just call the CacheHandleManager with
62       * the given params within the implementation and just return this.</p>
63       *
64       * @deprecated cacheable classes should now implement a static getHandle(config) method
65       */
66      public String getHandle();
67  
68      /****
69       * <p>Set the handle for this Cacheable.</p>
70       *
71       * <p>Note that factories should call setHandle() so that getHandle() always
72       * returns a value correctly.</p>
73       *
74       * @deprecated cacheable classes should now implement a static getHandle(config) method
75       */
76      public void setHandle( String handle );
77    
78      /***
79       * Return the expiration time in milliseconds.
80       *
81       * @return Expiration time in milliseconds since epoch, or null if the 
82       *         expiration was not set
83       */
84      public Long getExpirationMillis();
85  
86      /***
87       * Set the expiration time in milliseconds.
88       *
89       * @param expirationMillis Set expiration in millis
90       */
91      public void setExpirationMillis( long expirationMillis);
92  
93      /***
94       * This allows the associated CachedObject to be
95       * known.  One use of the <code>co</code> is to set the expiration time
96       *
97       * @param co Handle to the CachedObject
98       */    
99       public void setCachedObject(CachedObject co);
100 }