View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
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, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.cms.core;
17  
18  import org.apache.commons.logging.Log;
19  import org.apache.commons.logging.LogFactory;
20  import org.seasar.tuigwaa.cms.core.wiki.base.WikiConfiguration;
21  import org.seasar.tuigwaa.cms.core.wiki.base.WikiConfigurationFactory;
22  import org.seasar.tuigwaa.cms.core.wiki.base.WikiException;
23  import org.seasar.tuigwaa.plugin.Plugin;
24  
25  
26  public class CmsContainer {
27  
28  	private static WikiConfiguration wikiconfig_;
29  
30  	private static Log log_ = LogFactory.getLog(CmsContainer.class);
31  
32  	static {
33  		try {
34  			WikiConfigurationFactory factory = WikiConfigurationFactory
35  					.getInstance();
36  			wikiconfig_ = factory.createConfiguration();
37  		} catch (WikiException we) {
38  			log_.error("wiki configuration is invalid.");
39  			log_.error("all wiki related data cannot be processed.");
40  			throw new RuntimeException(we);
41  		}
42  	}
43  
44  	public static CmsContainer INSTANCE = new CmsContainer();
45  
46  	private CmsContainer() {
47  	}
48  
49  	public WikiConfiguration getConfiguration() {
50  		return wikiconfig_;
51  	}
52  
53  	public Plugin getPlugin(String pluginName){
54  		return wikiconfig_.getPlugin(pluginName);
55  	}
56  	
57  	public void service(CmsRequest request, CmsResponse resonse){
58  		String contentType = request.getPage().getResource().getContentType();
59  		CmsEngine engine = wikiconfig_.getEngine(contentType);
60  		engine.service(request, resonse);
61  	}
62  }