01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.config.schema.setup;
06:
07: import org.apache.xmlbeans.XmlObject;
08:
09: 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
30: BaseTVSConfigurationSetupManager implements
31: L1TVSConfigurationSetupManager {
32: private final ConfigurationCreator configurationCreator;
33: private final NewCommonL1Config commonL1Config;
34: private final L2ConfigForL1 l2ConfigForL1;
35: private final NewL1DSOConfig dsoL1Config;
36: private boolean loadedFromTrustedSource;
37:
38: public StandardL1TVSConfigurationSetupManager(
39: ConfigurationCreator configurationCreator,
40: DefaultValueProvider defaultValueProvider,
41: XmlObjectComparator xmlObjectComparator,
42: IllegalConfigurationChangeHandler illegalConfigChangeHandler)
43: throws ConfigurationSetupException {
44: super (defaultValueProvider, xmlObjectComparator,
45: illegalConfigChangeHandler);
46:
47: Assert.assertNotNull(configurationCreator);
48:
49: this .configurationCreator = configurationCreator;
50: runConfigurationCreator(this .configurationCreator);
51: loadedFromTrustedSource = this .configurationCreator
52: .loadedFromTrustedSource();
53:
54: commonL1Config = new NewCommonL1ConfigObject(createContext(
55: clientBeanRepository(), null));
56: l2ConfigForL1 = new L2ConfigForL1Object(createContext(
57: serversBeanRepository(), null), createContext(
58: systemBeanRepository(), null));
59: dsoL1Config = new NewL1DSOConfigObject(createContext(
60: new ChildBeanRepository(clientBeanRepository(),
61: DsoClientData.class, new ChildBeanFetcher() {
62: public XmlObject getChild(XmlObject parent) {
63: return ((Client) parent).getDso();
64: }
65: }), null));
66:
67: }
68:
69: public void setupLogging() {
70: FileConfigItem logsPath = commonL1Config().logsPath();
71: TCLogging.setLogDirectory(logsPath.getFile(),
72: TCLogging.PROCESS_TYPE_L1);
73: logsPath.addListener(new LogSettingConfigItemListener(
74: TCLogging.PROCESS_TYPE_L1));
75: }
76:
77: public boolean loadedFromTrustedSource() {
78: return this .loadedFromTrustedSource;
79: }
80:
81: public L2ConfigForL1 l2Config() {
82: return this .l2ConfigForL1;
83: }
84:
85: public NewCommonL1Config commonL1Config() {
86: return this .commonL1Config;
87: }
88:
89: public NewL1DSOConfig dsoL1Config() {
90: return this.dsoL1Config;
91: }
92: }
|