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.object.config.schema;
06:
07: import org.apache.xmlbeans.XmlObject;
08:
09: import com.tc.config.schema.BaseNewConfigObject;
10: import com.tc.config.schema.context.ConfigContext;
11: import com.tc.config.schema.dynamic.BooleanConfigItem;
12: import com.tc.config.schema.dynamic.ConfigItem;
13: import com.tc.config.schema.dynamic.IntConfigItem;
14: import com.tc.config.schema.dynamic.StringConfigItem;
15: import com.tc.config.schema.dynamic.XPathBasedConfigItem;
16: import com.tc.util.Assert;
17: import com.terracottatech.config.PersistenceMode;
18: import com.terracottatech.config.Server;
19:
20: /**
21: * The standard implementation of {@link NewL2DSOConfig}.
22: */
23: public class NewL2DSOConfigObject extends BaseNewConfigObject implements
24: NewL2DSOConfig {
25:
26: private final ConfigItem persistenceMode;
27: private final BooleanConfigItem garbageCollectionEnabled;
28: private final BooleanConfigItem garbageCollectionVerbose;
29: private final IntConfigItem garbageCollectionInterval;
30: private final IntConfigItem listenPort;
31: private final IntConfigItem l2GroupPort;
32: private final IntConfigItem clientReconnectWindow;
33: private final StringConfigItem host;
34:
35: public NewL2DSOConfigObject(ConfigContext context) {
36: super (context);
37:
38: this .context.ensureRepositoryProvides(Server.class);
39:
40: this .persistenceMode = new XPathBasedConfigItem(this .context,
41: "dso/persistence/mode") {
42: protected Object fetchDataFromXmlObject(XmlObject xmlObject) {
43: if (xmlObject == null)
44: return null;
45: if (((PersistenceMode) xmlObject).enumValue() == PersistenceMode.TEMPORARY_SWAP_ONLY)
46: return com.tc.object.config.schema.PersistenceMode.TEMPORARY_SWAP_ONLY;
47: if (((PersistenceMode) xmlObject).enumValue() == PersistenceMode.PERMANENT_STORE)
48: return com.tc.object.config.schema.PersistenceMode.PERMANENT_STORE;
49: throw Assert.failure("Persistence mode " + xmlObject
50: + " is not anything in the enum?");
51: }
52: };
53:
54: this .garbageCollectionEnabled = this .context
55: .booleanItem("dso/garbage-collection/enabled");
56: this .garbageCollectionVerbose = this .context
57: .booleanItem("dso/garbage-collection/verbose");
58: this .garbageCollectionInterval = this .context
59: .intItem("dso/garbage-collection/interval");
60: this .clientReconnectWindow = this .context
61: .intItem("dso/client-reconnect-window");
62: this .listenPort = this .context.intItem("dso-port");
63: this .l2GroupPort = this .context.intItem("l2-group-port");
64: this .host = this .context.stringItem("@host");
65: }
66:
67: public IntConfigItem listenPort() {
68: return this .listenPort;
69: }
70:
71: public IntConfigItem l2GroupPort() {
72: return this .l2GroupPort;
73: }
74:
75: public StringConfigItem host() {
76: return host;
77: }
78:
79: public ConfigItem persistenceMode() {
80: return this .persistenceMode;
81: }
82:
83: public BooleanConfigItem garbageCollectionEnabled() {
84: return this .garbageCollectionEnabled;
85: }
86:
87: public BooleanConfigItem garbageCollectionVerbose() {
88: return this .garbageCollectionVerbose;
89: }
90:
91: public IntConfigItem garbageCollectionInterval() {
92: return this .garbageCollectionInterval;
93: }
94:
95: public IntConfigItem clientReconnectWindow() {
96: return this.clientReconnectWindow;
97: }
98:
99: }
|