KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > config > schema > NewL2DSOConfigObject


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

4 package com.tc.object.config.schema;
5
6 import org.apache.xmlbeans.XmlObject;
7
8 import com.tc.config.schema.BaseNewConfigObject;
9 import com.tc.config.schema.context.ConfigContext;
10 import com.tc.config.schema.dynamic.BooleanConfigItem;
11 import com.tc.config.schema.dynamic.ConfigItem;
12 import com.tc.config.schema.dynamic.IntConfigItem;
13 import com.tc.config.schema.dynamic.XPathBasedConfigItem;
14 import com.tc.util.Assert;
15 import com.terracottatech.config.PersistenceMode;
16 import com.terracottatech.config.Server;
17
18 /**
19  * The standard implementation of {@link NewL2DSOConfig}.
20  */

21 public class NewL2DSOConfigObject extends BaseNewConfigObject implements NewL2DSOConfig {
22
23   private final ConfigItem persistenceMode;
24   private final BooleanConfigItem garbageCollectionEnabled;
25   private final BooleanConfigItem garbageCollectionVerbose;
26   private final IntConfigItem garbageCollectionInterval;
27   private final IntConfigItem listenPort;
28   private final IntConfigItem clientReconnectWindow;
29
30   public NewL2DSOConfigObject(ConfigContext context) {
31     super(context);
32
33     this.context.ensureRepositoryProvides(Server.class);
34
35     this.persistenceMode = new XPathBasedConfigItem(this.context, "dso/persistence/mode") {
36       protected Object JavaDoc fetchDataFromXmlObject(XmlObject xmlObject) {
37         if (xmlObject == null) return null;
38         if (((PersistenceMode) xmlObject).enumValue() == PersistenceMode.TEMPORARY_SWAP_ONLY) return com.tc.object.config.schema.PersistenceMode.TEMPORARY_SWAP_ONLY;
39         if (((PersistenceMode) xmlObject).enumValue() == PersistenceMode.PERMANENT_STORE) return com.tc.object.config.schema.PersistenceMode.PERMANENT_STORE;
40         throw Assert.failure("Persistence mode " + xmlObject + " is not anything in the enum?");
41       }
42     };
43
44     this.garbageCollectionEnabled = this.context.booleanItem("dso/garbage-collection/enabled");
45     this.garbageCollectionVerbose = this.context.booleanItem("dso/garbage-collection/verbose");
46     this.garbageCollectionInterval = this.context.intItem("dso/garbage-collection/interval");
47     this.clientReconnectWindow = this.context.intItem("dso/client-reconnect-window");
48     this.listenPort = this.context.intItem("dso-port");
49   }
50
51   public IntConfigItem listenPort() {
52     return this.listenPort;
53   }
54
55   public ConfigItem persistenceMode() {
56     return this.persistenceMode;
57   }
58
59   public BooleanConfigItem garbageCollectionEnabled() {
60     return this.garbageCollectionEnabled;
61   }
62
63   public BooleanConfigItem garbageCollectionVerbose() {
64     return this.garbageCollectionVerbose;
65   }
66
67   public IntConfigItem garbageCollectionInterval() {
68     return this.garbageCollectionInterval;
69   }
70
71   public IntConfigItem clientReconnectWindow() {
72     return this.clientReconnectWindow;
73   }
74
75 }
76
Popular Tags