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.portal.security.portlets;
18  
19  //jetspeed
20  import org.apache.jetspeed.portal.Portlet;
21  import org.apache.jetspeed.portal.expire.Expire;
22  import org.apache.jetspeed.services.portletcache.Cacheable;
23  
24  import org.apache.turbine.services.cache.CachedObject;
25  
26  
27  /***
28  <p>
29  This object is used to wrap a Portlet, ensuring that access control rules are enforced.
30  </p>
31  
32  @author <A HREF="mailto:sgala@apache.org">Santiago Gala</A>
33  @version $Id: CacheableStatefulPortletWrapper.java,v 1.4 2004/02/23 03:27:46 jford Exp $
34  */
35  public class CacheableStatefulPortletWrapper extends StatefulPortletWrapper implements /*FIXME*/Cacheable
36  {
37  
38      /*
39       * The cacheable associated with us
40       */
41      private Cacheable wrappedCacheable = null;
42  
43      
44      public CacheableStatefulPortletWrapper( Portlet inner )
45      {
46          super( inner );
47          if( inner instanceof Cacheable )
48          {
49              wrappedCacheable = (Cacheable) inner;
50          }
51          else
52          {
53              //Log error or throw exception
54          }
55              
56      }
57  
58      //Cacheable interface
59  
60      /***
61      */
62      public boolean isCacheable()
63      {
64          return wrappedCacheable.isCacheable();
65      }
66  
67      /***
68      */
69      public void setCacheable(boolean cacheable)
70      {
71          wrappedCacheable.setCacheable( cacheable );
72      }
73  
74  
75      /***
76      */
77      public Expire getExpire()
78      {
79          return wrappedCacheable.getExpire();
80      }
81  
82      /***
83      */
84      public final String getHandle()
85      {
86          return wrappedCacheable.getHandle();
87      }
88  
89      /***
90      */
91      public final void setHandle( String handle )
92      {
93          wrappedCacheable.setHandle( handle );
94      }
95  
96      /***
97      @see Cacheable#getExpirationMillis
98      */
99      public Long getExpirationMillis()
100     {
101       return wrappedCacheable.getExpirationMillis();
102     }
103     
104 
105     /***
106     @see Cacheable#setExpirationMillis
107     */
108     public void setExpirationMillis( long expirationMillis)
109     {
110       wrappedCacheable.setExpirationMillis( expirationMillis );
111     }
112 
113     /***
114      * This allows the associated CachedObject to be
115      * known.  One use of the <CODE>cachedObject</CODE> is to
116      * set the expiration time
117      *
118      * @param cachedObject Handle to the CachedObject
119      */
120     public void setCachedObject(CachedObject cachedObject)
121     {
122       wrappedCacheable.setCachedObject( cachedObject );
123     }
124     
125 }