View Javadoc

1   /*
2    * Copyright 2000-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.portlets;
18  
19  //jetspeed
20  import org.apache.jetspeed.portal.expire.Expire;
21  import org.apache.jetspeed.portal.expire.ExpireFactory;
22  import org.apache.jetspeed.portal.expire.FileWatchExpire;
23  import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
24  import org.apache.jetspeed.services.logging.JetspeedLogger;
25  import org.apache.jetspeed.util.JetspeedException;
26  
27  
28  /***
29  Just like AbstractPortlet except that when its URL is modified on disk it 
30  automatically expires itself.
31  
32  @author <A HREF="mailto:burton@apache.org">Kevin A. Burton</A>
33  @version $Id: FileWatchPortlet.java,v 1.9 2004/02/23 04:03:34 jford Exp $
34  */
35  public abstract class FileWatchPortlet extends AbstractInstancePortlet 
36  {
37  
38      /***
39       * Static initialization of the logger for this class
40       */    
41      private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(FileWatchPortlet.class.getName());    
42      
43      FileWatchExpire expire = null;
44      
45      /***
46      Expire this Portlet if it's URL Changes on disk.
47      */
48      public Expire getExpire() {
49          
50          try {
51  
52              if ( this.expire == null ) {
53              
54                  this.expire = (FileWatchExpire)ExpireFactory
55                      .getExpire( this, ExpireFactory.FILE_WATCH_EXPIRE );
56                  
57                  this.expire.setURL( this.getPortletConfig().getURL() );
58              }
59  
60              return this.expire;
61  
62          } catch ( JetspeedException e ) {
63              logger.error("Exception",  e);
64              return null;
65          }
66  
67          
68      }
69      
70  }
71