KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > config > schema > setup > StandardL1TVSConfigurationSetupManager


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

5 package com.tc.config.schema.setup;
6
7 import org.apache.xmlbeans.XmlObject;
8
9 import com.tc.config.schema.IllegalConfigurationChangeHandler;
10 import com.tc.config.schema.L2ConfigForL1;
11 import com.tc.config.schema.L2ConfigForL1Object;
12 import com.tc.config.schema.NewCommonL1Config;
13 import com.tc.config.schema.NewCommonL1ConfigObject;
14 import com.tc.config.schema.defaults.DefaultValueProvider;
15 import com.tc.config.schema.dynamic.FileConfigItem;
16 import com.tc.config.schema.repository.ChildBeanFetcher;
17 import com.tc.config.schema.repository.ChildBeanRepository;
18 import com.tc.config.schema.utils.XmlObjectComparator;
19 import com.tc.logging.TCLogging;
20 import com.tc.object.config.schema.NewL1DSOConfig;
21 import com.tc.object.config.schema.NewL1DSOConfigObject;
22 import com.tc.util.Assert;
23 import com.terracottatech.config.Client;
24 import com.terracottatech.config.DsoClientData;
25
26 /**
27  * The standard implementation of {@link com.tc.config.schema.setup.L1TVSConfigurationSetupManager}.
28  */

29 public class StandardL1TVSConfigurationSetupManager extends BaseTVSConfigurationSetupManager implements
30     L1TVSConfigurationSetupManager {
31   private final ConfigurationCreator configurationCreator;
32   private final NewCommonL1Config commonL1Config;
33   private final L2ConfigForL1 l2ConfigForL1;
34   private final NewL1DSOConfig dsoL1Config;
35   private boolean loadedFromTrustedSource;
36
37   public StandardL1TVSConfigurationSetupManager(ConfigurationCreator configurationCreator,
38                                                 DefaultValueProvider defaultValueProvider,
39                                                 XmlObjectComparator xmlObjectComparator,
40                                                 IllegalConfigurationChangeHandler illegalConfigChangeHandler)
41       throws ConfigurationSetupException {
42     super(defaultValueProvider, xmlObjectComparator, illegalConfigChangeHandler);
43
44     Assert.assertNotNull(configurationCreator);
45
46     this.configurationCreator = configurationCreator;
47     runConfigurationCreator(this.configurationCreator);
48     loadedFromTrustedSource = this.configurationCreator.loadedFromTrustedSource();
49
50     commonL1Config = new NewCommonL1ConfigObject(createContext(clientBeanRepository(), null));
51     l2ConfigForL1 = new L2ConfigForL1Object(createContext(serversBeanRepository(), null),
52                                             createContext(systemBeanRepository(), null));
53     dsoL1Config = new NewL1DSOConfigObject(createContext(new ChildBeanRepository(clientBeanRepository(),
54                                                                                  DsoClientData.class,
55                                                                                  new ChildBeanFetcher() {
56                                                                                    public XmlObject getChild(
57                                                                                                              XmlObject parent) {
58                                                                                      return ((Client) parent).getDso();
59                                                                                    }
60                                                                                  }), null));
61
62   }
63
64   public void setupLogging() {
65     FileConfigItem logsPath = commonL1Config().logsPath();
66     TCLogging.setLogDirectory(logsPath.getFile(), TCLogging.PROCESS_TYPE_L1);
67     logsPath.addListener(new LogSettingConfigItemListener(TCLogging.PROCESS_TYPE_L1));
68   }
69
70   public boolean loadedFromTrustedSource() {
71     return this.loadedFromTrustedSource;
72   }
73
74   public L2ConfigForL1 l2Config() {
75     return this.l2ConfigForL1;
76   }
77
78   public NewCommonL1Config commonL1Config() {
79     return this.commonL1Config;
80   }
81
82   public NewL1DSOConfig dsoL1Config() {
83     return this.dsoL1Config;
84   }
85 }
86
Popular Tags