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.system;
17  
18  import java.util.Hashtable;
19  
20  import org.seasar.tuigwaa.cms.ContentsStoreService;
21  import org.seasar.tuigwaa.cms.ContentsStoreServiceSlideImpl;
22  import org.seasar.tuigwaa.database.DatabaseUtils;
23  import org.seasar.tuigwaa.plugin.PluginService;
24  import org.seasar.tuigwaa.security.DirectoryUtils;
25  import org.seasar.tuigwaa.util.TgwContext;
26  import org.seasar.tuigwaa.util.TgwUtils;
27  
28  import com.isenshi.util.ResourceUtils;
29  
30  public class TgwSystemServiceImpl implements TgwSystemService {
31  
32  	private ContentsStoreService contentsStore;
33  
34  	private SiteService siteService;
35  
36  	private PluginService pluginService;
37  	
38  	private Hashtable ldapenv;
39  
40  	public TgwSystemServiceImpl(ContentsStoreService contentsStore,
41  			SiteService siteService, PluginService pluginService) {
42  		this.contentsStore = contentsStore;
43  		this.siteService = siteService;
44  		this.pluginService  = pluginService;
45  	}
46  
47  	public void setLdapEnv(Hashtable ldapenv) {
48  		this.ldapenv = ldapenv;
49  	}
50  
51  	public void init() {
52  		TgwContext.setAdmin();
53  		
54  		siteService.initSkins();
55  		siteService.loadAllSites();
56  						
57  		String defaultSite = ResourceUtils.readContent(Constants.FILE_DEFAULTSITE);
58  		if(defaultSite==null){
59  			defaultSite = "tgw-manager";
60  		}else{
61  			defaultSite = defaultSite.trim();
62  		}
63  		TgwUtils.getTuigwaaActionServlet().getServletContext().setAttribute(Constants.CATTR_DEFAULTSITENAME, defaultSite);
64  	}
65  
66  	public void destroy() {
67  		try {
68  			((ContentsStoreServiceSlideImpl) contentsStore).getNamespace()
69  					.disconnect();
70  			DatabaseUtils.shutdown();
71  			DirectoryUtils.shutdown(ldapenv);
72  		} catch (Exception e) {
73  			e.printStackTrace();
74  		}
75  	}
76  }