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.expire;
18  
19  //java stuff
20  import java.io.IOException;
21  
22  // Jetspeed classes
23  import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
24  import org.apache.jetspeed.services.logging.JetspeedLogger;
25  
26  /***
27  Handles expiration mechanisms that expire when the file changes.
28  
29  @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
30  @version $Id: FileWatchExpire.java,v 1.10 2004/02/23 03:24:40 jford Exp $
31  */
32  public class FileWatchExpire extends BaseExpire 
33  {
34  
35      /***
36       * Static initialization of the logger for this class
37       */    
38      private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(FileWatchExpire.class.getName());    
39      
40      FileWatcher fw = null;
41      
42      /***
43      @see Expire#isExpired
44      
45      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
46      @version $Id: FileWatchExpire.java,v 1.10 2004/02/23 03:24:40 jford Exp $
47      */
48      public boolean isExpired() {
49          
50          if ( this.fw != null ) {
51              return this.fw.hasChanged();
52          } else {
53              return false;
54          }
55          
56          
57      }
58      
59      /***
60      Set the url on which this depends.  It is required that you call this 
61      method before you use it.
62      */
63      public void setURL( String url ) {
64          try {
65              this.fw = new FileWatcher( url, this.getPortlet().getName() );
66          } catch ( IOException e ) {
67              logger.error("Exception",  e);
68          }
69      }
70      
71      
72  }