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