KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > business > RollerImpl


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * 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. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 /*
19  * RollerImpl.java
20  *
21  * Created on April 29, 2005, 5:33 PM
22  */

23 package org.apache.roller.business;
24
25 import java.sql.Connection JavaDoc;
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28 import org.apache.roller.RollerException;
29 import org.apache.roller.business.referrers.ReferrerQueueManager;
30 import org.apache.roller.business.referrers.ReferrerQueueManagerImpl;
31 import org.apache.roller.business.utils.UpgradeDatabase;
32 import org.apache.roller.model.FileManager;
33 import org.apache.roller.model.IndexManager;
34 import org.apache.roller.model.PluginManager;
35 import org.apache.roller.model.Roller;
36 import org.apache.roller.model.ThemeManager;
37 import org.apache.roller.model.ThreadManager;
38
39
40 /**
41  * The abstract version of the Roller implementation.
42  * Here we put code that pertains to *all* implementations of the Roller
43  * interface, regardless of their persistence strategy.
44  *
45  * @author Allen Gilliland
46  */

47 public abstract class RollerImpl implements Roller {
48     
49     private static Log mLogger = LogFactory.getLog(RollerImpl.class);
50     
51     private FileManager fileManager = null;
52     private IndexManager indexManager = null;
53     private ThreadManager threadManager = null;
54     private ThemeManager themeManager = null;
55     private PluginManager pluginManager = null;
56     
57     
58     public RollerImpl() {
59         // nothing to do here yet
60
}
61     
62     
63     /**
64      * @see org.apache.roller.model.Roller#getFileManager()
65      */

66     public FileManager getFileManager() throws RollerException {
67         if (fileManager == null) {
68             fileManager = new FileManagerImpl();
69         }
70         return fileManager;
71     }
72     
73     
74     /**
75      * @see org.apache.roller.model.Roller#getThreadManager()
76      */

77     public ThreadManager getThreadManager() throws RollerException {
78         if (threadManager == null) {
79             threadManager = new ThreadManagerImpl();
80         }
81         return threadManager;
82     }
83     
84     
85     /**
86      * @see org.apache.roller.model.Roller#getIndexManager()
87      */

88     public IndexManager getIndexManager() throws RollerException {
89         if (indexManager == null) {
90             indexManager = new IndexManagerImpl();
91         }
92         return indexManager;
93     }
94     
95     
96     /**
97      * @see org.apache.roller.model.Roller#getThemeManager()
98      */

99     public ThemeManager getThemeManager() throws RollerException {
100         if (themeManager == null) {
101             themeManager = new ThemeManagerImpl();
102         }
103         return themeManager;
104     }
105     
106     
107     /**
108      * @see org.apache.roller.business.referrers.ReferrerQueueManager
109      */

110     public ReferrerQueueManager getReferrerQueueManager() {
111         return ReferrerQueueManagerImpl.getInstance();
112     }
113     
114     
115     /**
116      * @see org.apache.roller.model.Roller#getPluginManager()
117      */

118     public PluginManager getPagePluginManager() throws RollerException {
119         if (pluginManager == null) {
120             pluginManager = new PluginManagerImpl();
121         }
122         return pluginManager;
123     }
124     
125     
126     public void release() {
127         try {
128             if (fileManager != null) fileManager.release();
129             if (threadManager != null) threadManager.release();
130             if (pluginManager != null) pluginManager.release();
131         } catch(Throwable JavaDoc e) {
132             mLogger.error("Error calling Roller.release()", e);
133         }
134     }
135     
136     
137     public void shutdown() {
138         try {
139             if (getReferrerQueueManager() != null) getReferrerQueueManager().shutdown();
140             if (indexManager != null) indexManager.shutdown();
141             if (threadManager != null) threadManager.shutdown();
142         } catch(Throwable JavaDoc e) {
143             mLogger.error("Error calling Roller.shutdown()", e);
144         }
145     }
146     
147 }
148
Popular Tags