KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > portal > expire > ExpireFactory


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 //jetspeed stuff
20
import org.apache.jetspeed.portal.Portlet;
21 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
22 import org.apache.jetspeed.services.logging.JetspeedLogger;
23 import org.apache.jetspeed.util.JetspeedException;
24
25 /**
26 Handles content expiration
27
28 @author <a HREF="mailto:burton@apache.org">Kevin A. Burton</a>
29 @version $Id: ExpireFactory.java,v 1.6 2004/02/23 03:24:40 jford Exp $
30 */

31 public class ExpireFactory
32 {
33
34     /**
35      * Static initialization of the logger for this class
36      */

37     private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(ExpireFactory.class.getName());
38     
39     public static final String JavaDoc FILE_WATCH_EXPIRE
40         = "org.apache.jetspeed.portal.expire.FileWatchExpire";
41
42     public static final String JavaDoc NO_EXPIRE
43         = "org.apache.jetspeed.portal.expire.NoExpire";
44
45     
46     /**
47     Since this object essentially does nothing. Only use one instance for
48     performance
49     */

50     public static Expire noExpire = new NoExpire();
51         
52     
53     /**
54     Create a new Expire object with the specified Portlet and classname.
55
56     @author <a HREF="mailto:burton@apache.org">Kevin A. Burton</a>
57     @version $Id: ExpireFactory.java,v 1.6 2004/02/23 03:24:40 jford Exp $
58     */

59     public static Expire getExpire( Portlet portlet,
60                                     String JavaDoc classname ) throws JetspeedException {
61         
62         if ( classname.equals( NO_EXPIRE ) ) {
63             return noExpire;
64         }
65         
66         try {
67             Expire expire = (Expire)Class.forName( classname ).newInstance();
68             expire.init();
69             expire.setPortlet( portlet );
70             expire.setExpired( false );
71
72             return expire;
73         } catch ( Throwable JavaDoc t ) {
74             logger.error("Throwable", t );
75             throw new JetspeedException( t.getMessage() );
76         }
77     }
78     
79 }
80
81
Popular Tags