001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/service/impl/MvnForumServiceImplDefault.java,v 1.9 2008/01/07 10:28:24 tbtrung Exp $
003: * $Author: tbtrung $
004: * $Revision: 1.9 $
005: * $Date: 2008/01/07 10:28:24 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author: Phong Ta Quoc
039: */
040: package com.mvnforum.service.impl;
041:
042: import net.myvietnam.mvncore.util.AssertionUtil;
043:
044: import org.apache.commons.logging.Log;
045: import org.apache.commons.logging.LogFactory;
046:
047: import com.mvnforum.service.*;
048:
049: public class MvnForumServiceImplDefault implements MvnForumService {
050:
051: private static Log log = LogFactory
052: .getLog(MvnForumServiceImplDefault.class);
053:
054: protected SearchService searchService;
055: protected CategoryService categoryService;
056: protected WatchMailService watchMailService;
057: protected MvnForumInfoService mvnForumInfoService;
058: protected MvnForumAdService mvnForumAdService;
059: protected ModuleProcessorService moduleProcessorService;
060: protected MvnForumLifeCycleService mvnForumLifeCycleService;
061:
062: private static int count;
063:
064: public MvnForumServiceImplDefault() {
065: count++;
066: AssertionUtil.doAssert(count == 1,
067: "Assertion: Must have only one instance.");
068: }
069:
070: public SearchService getSearchService() {
071: if (searchService == null) {
072: searchService = new SearchServiceImplDisk();
073: }
074: return searchService;
075: }
076:
077: public CategoryService getCategoryService() {
078: if (categoryService == null) {
079: categoryService = new CategoryServiceImplDefault();
080: }
081: return categoryService;
082: }
083:
084: public WatchMailService getWatchMailService() {
085: if (watchMailService == null) {
086: watchMailService = new WatchMailServiceImplDefault();
087: }
088: return watchMailService;
089: }
090:
091: public MvnForumInfoService getMvnForumInfoService() {
092: if (mvnForumInfoService == null) {
093: mvnForumInfoService = new MvnForumInfoServiceImplDefault();
094: }
095: return mvnForumInfoService;
096: }
097:
098: public MvnForumAdService getMvnForumAdService() {
099: if (mvnForumAdService == null) {
100: String className = "com.mvnsoft.ad.service.impl.MvnForumAdServiceImplDefault";
101: try {
102: mvnForumAdService = (MvnForumAdService) Class.forName(
103: className).newInstance();
104: mvnForumAdService.reload();
105: } catch (ClassNotFoundException e) {
106: mvnForumAdService = new MvnForumAdServiceImplStub();
107: log.info("Could not find class " + className
108: + ". Ads is disabled.");
109: } catch (InstantiationException e) {
110: mvnForumAdService = new MvnForumAdServiceImplStub();
111: log.error("Could not initiate class " + className
112: + ". Ads is disabled.", e);
113: } catch (IllegalAccessException e) {
114: mvnForumAdService = new MvnForumAdServiceImplStub();
115: log.error("Could not access class " + className
116: + ". Ads is disabled.", e);
117: }
118: }
119: return mvnForumAdService;
120: }
121:
122: public ModuleProcessorService getModuleProcessorService() {
123: if (moduleProcessorService == null) {
124: moduleProcessorService = new ModuleProcessorServiceImplDefault();
125: }
126: return moduleProcessorService;
127: }
128:
129: public MvnForumLifeCycleService getMvnForumLifeCycleService() {
130: if (mvnForumLifeCycleService == null) {
131: mvnForumLifeCycleService = new MvnForumLifeCycleServiceImplDefault();
132: }
133: return mvnForumLifeCycleService;
134: }
135: }
|