001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018:
019: package org.apache.roller.business;
020:
021: import java.sql.Connection;
022: import org.apache.commons.logging.Log;
023: import org.apache.commons.logging.LogFactory;
024: import org.apache.roller.RollerException;
025: import org.apache.roller.business.referrers.ReferrerQueueManager;
026: import org.apache.roller.business.referrers.ReferrerQueueManagerImpl;
027: import org.apache.roller.business.runnable.ThreadManagerImpl;
028: import org.apache.roller.business.search.IndexManagerImpl;
029: import org.apache.roller.business.utils.UpgradeDatabase;
030: import org.apache.roller.business.FileManager;
031: import org.apache.roller.business.search.IndexManager;
032: import org.apache.roller.business.PluginManager;
033: import org.apache.roller.business.Roller;
034: import org.apache.roller.business.ThemeManager;
035: import org.apache.roller.business.runnable.ThreadManager;
036:
037: /**
038: * The abstract version of the Roller implementation.
039: *
040: * Here we put code that pertains to *all* implementations of the Roller
041: * interface, regardless of their persistence strategy.
042: */
043: public abstract class RollerImpl implements Roller {
044:
045: private static Log mLogger = LogFactory.getLog(RollerImpl.class);
046:
047: private FileManager fileManager = null;
048: private IndexManager indexManager = null;
049: private ThreadManager threadManager = null;
050: private ThemeManager themeManager = null;
051: private PluginManager pluginManager = null;
052:
053: public RollerImpl() {
054: // nothing to do here yet
055: }
056:
057: /**
058: * @see org.apache.roller.model.Roller#getFileManager()
059: */
060: public FileManager getFileManager() throws RollerException {
061: if (fileManager == null) {
062: fileManager = new FileManagerImpl();
063: }
064: return fileManager;
065: }
066:
067: /**
068: * @see org.apache.roller.model.Roller#getThreadManager()
069: */
070: public ThreadManager getThreadManager() throws RollerException {
071: if (threadManager == null) {
072: threadManager = new ThreadManagerImpl();
073: }
074: return threadManager;
075: }
076:
077: /**
078: * @see org.apache.roller.model.Roller#getIndexManager()
079: */
080: public IndexManager getIndexManager() throws RollerException {
081: if (indexManager == null) {
082: indexManager = new IndexManagerImpl();
083: }
084: return indexManager;
085: }
086:
087: /**
088: * @see org.apache.roller.model.Roller#getThemeManager()
089: */
090: public ThemeManager getThemeManager() throws RollerException {
091: if (themeManager == null) {
092: themeManager = new ThemeManagerImpl();
093: }
094: return themeManager;
095: }
096:
097: /**
098: * @see org.apache.roller.business.referrers.ReferrerQueueManager
099: */
100: public ReferrerQueueManager getReferrerQueueManager() {
101: return ReferrerQueueManagerImpl.getInstance();
102: }
103:
104: /**
105: * @see org.apache.roller.model.Roller#getPluginManager()
106: */
107: public PluginManager getPagePluginManager() throws RollerException {
108: if (pluginManager == null) {
109: pluginManager = new PluginManagerImpl();
110: }
111: return pluginManager;
112: }
113:
114: public void release() {
115: try {
116: if (fileManager != null)
117: fileManager.release();
118: if (threadManager != null)
119: threadManager.release();
120: if (pluginManager != null)
121: pluginManager.release();
122: } catch (Throwable e) {
123: mLogger.error("Error calling Roller.release()", e);
124: }
125: }
126:
127: public void shutdown() {
128: try {
129: HitCountQueue.getInstance().shutdown();
130: if (getReferrerQueueManager() != null)
131: getReferrerQueueManager().shutdown();
132: if (indexManager != null)
133: indexManager.shutdown();
134: if (threadManager != null)
135: threadManager.shutdown();
136: } catch (Throwable e) {
137: mLogger.error("Error calling Roller.shutdown()", e);
138: }
139: }
140:
141: }
|