001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003: * notice. All rights reserved.
004: */
005: package com.tc.config.schema.test;
006:
007: /**
008: * Allows you to build valid config for an L2. This class <strong>MUST NOT</strong> invoke the actual XML beans to do
009: * its work; one of its purposes is, in fact, to test that those beans are set up correctly.
010: */
011: public class L2ConfigBuilder extends BaseConfigBuilder {
012:
013: private String name;
014:
015: public L2ConfigBuilder() {
016: super (3, ALL_PROPERTIES);
017: }
018:
019: public void setName(String data) {
020: this .name = data;
021: }
022:
023: String getName() {
024: return this .name;
025: }
026:
027: public void setData(String data) {
028: setProperty("data", data);
029: }
030:
031: public void setLogs(String logs) {
032: setProperty("logs", logs);
033: }
034:
035: public void setDSOPort(int data) {
036: setProperty("dso-port", data);
037: }
038:
039: public void setJMXPort(int data) {
040: setProperty("jmx-port", data);
041: }
042:
043: public void setJMXPort(String data) {
044: setProperty("jmx-port", data);
045: }
046:
047: public void setL2GroupPort(int data) {
048: setProperty("l2-group-port", data);
049: }
050:
051: public void setPasswordFile(String data) {
052: setProperty("password-file", data);
053: }
054:
055: public void setAccessFile(String data) {
056: setProperty("access-file", data);
057: }
058:
059: public static final String PERSISTENCE_MODE_TEMPORARY_SWAP_ONLY = "temporary-swap-only";
060: public static final String PERSISTENCE_MODE_PERMANENT_STORE = "permanent-store";
061:
062: public void setPersistenceMode(String data) {
063: setProperty("mode", data);
064: }
065:
066: public void setGCEnabled(boolean data) {
067: setProperty("enabled", data);
068: }
069:
070: public void setGCEnabled(String data) {
071: setProperty("enabled", data);
072: }
073:
074: public void setGCVerbose(boolean data) {
075: setProperty("verbose", data);
076: }
077:
078: public void setGCVerbose(String data) {
079: setProperty("verbose", data);
080: }
081:
082: public void setGCInterval(int data) {
083: setProperty("interval", data);
084: }
085:
086: public void setGCInterval(String data) {
087: setProperty("interval", data);
088: }
089:
090: private static final String[] L2 = new String[] { "data", "logs",
091: "dso-port", "jmx-port", "l2-group-port" };
092:
093: private static final String[] DSO_PERSISTENCE = new String[] { "mode" };
094: private static final String[] DSO_GC = new String[] { "enabled",
095: "verbose", "interval" };
096: private static final String[] AUTHENTICATION = new String[] {
097: "password-file", "access-file" };
098: private static final String[] DSO = concat(new Object[] {
099: DSO_PERSISTENCE, DSO_GC });
100:
101: private static final String[] ALL_PROPERTIES = concat(new Object[] {
102: L2, AUTHENTICATION, DSO });
103:
104: public String toString() {
105: String out = "";
106:
107: out += indent()
108: + "<server"
109: + (this .name != null ? " name=\"" + this .name + "\""
110: : "") + ">\n";
111:
112: out += elements(L2)
113: + elementGroup("authentication", AUTHENTICATION)
114: + openElement("dso", DSO)
115: + elementGroup("persistence", DSO_PERSISTENCE)
116: + elementGroup("garbage-collection", DSO_GC)
117: + closeElement("dso", DSO);
118:
119: out += closeElement("server");
120:
121: return out;
122: }
123:
124: public static L2ConfigBuilder newMinimalInstance() {
125: return new L2ConfigBuilder();
126: }
127:
128: }
|