KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > config > schema > test > L2ConfigBuilder


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.config.schema.test;
5
6 /**
7  * Allows you to build valid config for an L2. This class <strong>MUST NOT</strong> invoke the actual XML beans to do
8  * its work; one of its purposes is, in fact, to test that those beans are set up correctly.
9  */

10 public class L2ConfigBuilder extends BaseConfigBuilder {
11
12   private String JavaDoc name;
13
14   public L2ConfigBuilder() {
15     super(3, ALL_PROPERTIES);
16   }
17
18   public void setName(String JavaDoc data) {
19     this.name = data;
20   }
21
22   String JavaDoc getName() {
23     return this.name;
24   }
25
26   public void setData(String JavaDoc data) {
27     setProperty("data", data);
28   }
29
30   public void setLogs(String JavaDoc logs) {
31     setProperty("logs", logs);
32   }
33
34   public void setDSOPort(int data) {
35     setProperty("dso-port", data);
36   }
37
38   public void setJMXPort(int data) {
39     setProperty("jmx-port", data);
40   }
41
42   public void setJMXPort(String JavaDoc data) {
43     setProperty("jmx-port", data);
44   }
45
46   public static final String JavaDoc PERSISTENCE_MODE_TEMPORARY_SWAP_ONLY = "temporary-swap-only";
47   public static final String JavaDoc PERSISTENCE_MODE_PERMANENT_STORE = "permanent-store";
48
49   public void setPersistenceMode(String JavaDoc data) {
50     setProperty("mode", data);
51   }
52
53   public void setGCEnabled(boolean data) {
54     setProperty("enabled", data);
55   }
56
57   public void setGCEnabled(String JavaDoc data) {
58     setProperty("enabled", data);
59   }
60
61   public void setGCVerbose(boolean data) {
62     setProperty("verbose", data);
63   }
64
65   public void setGCVerbose(String JavaDoc data) {
66     setProperty("verbose", data);
67   }
68
69   public void setGCInterval(int data) {
70     setProperty("interval", data);
71   }
72
73   public void setGCInterval(String JavaDoc data) {
74     setProperty("interval", data);
75   }
76
77   private static final String JavaDoc[] L2 = new String JavaDoc[] { "data", "logs", "dso-port", "jmx-port" };
78
79   private static final String JavaDoc[] DSO_PERSISTENCE = new String JavaDoc[] { "mode" };
80   private static final String JavaDoc[] DSO_GC = new String JavaDoc[] { "enabled", "verbose", "interval" };
81   private static final String JavaDoc[] DSO = concat(new Object JavaDoc[] { DSO_PERSISTENCE, DSO_GC, });
82
83   private static final String JavaDoc[] ALL_PROPERTIES = concat(new Object JavaDoc[] { L2, DSO });
84
85   public String JavaDoc toString() {
86     String JavaDoc out = "";
87
88     out += indent() + "<server" + (this.name != null ? " name=\"" + this.name + "\"" : "") + ">\n";
89
90     out += elements(L2) + openElement("dso", DSO) + elementGroup("persistence", DSO_PERSISTENCE)
91            + elementGroup("garbage-collection", DSO_GC) + closeElement("dso", DSO);
92
93     out += closeElement("server");
94
95     return out;
96   }
97
98   public static L2ConfigBuilder newMinimalInstance() {
99     return new L2ConfigBuilder();
100   }
101
102 }
103
Popular Tags