1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 }