01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.config.schema.test;
05:
06: /**
07: * Allows you to build valid config for the entire system. This class <strong>MUST NOT</strong> invoke the actual XML
08: * beans to do its work; one of its purposes is, in fact, to test that those beans are set up correctly.
09: */
10: public class TerracottaConfigBuilder extends BaseConfigBuilder {
11:
12: public TerracottaConfigBuilder() {
13: super (0, ALL_PROPERTIES);
14: }
15:
16: public void setSystem(String value) {
17: setProperty("system", value);
18: }
19:
20: public void setSystem(SystemConfigBuilder value) {
21: setProperty("system", value);
22: }
23:
24: public SystemConfigBuilder getSystem() {
25: if (!isSet("system"))
26: setSystem(SystemConfigBuilder.newMinimalInstance());
27: return (SystemConfigBuilder) getRawProperty("system");
28: }
29:
30: public void setClient(String value) {
31: setProperty("clients", value);
32: }
33:
34: public void setClient(L1ConfigBuilder value) {
35: setProperty("clients", value);
36: }
37:
38: public L1ConfigBuilder getClient() {
39: if (!isSet("clients"))
40: setClient(L1ConfigBuilder.newMinimalInstance());
41: return (L1ConfigBuilder) getRawProperty("clients");
42: }
43:
44: // public void setServers(String value) {
45: // setProperty("servers", value);
46: // }
47:
48: public void setServers(L2SConfigBuilder value) {
49: setProperty("servers", value);
50: }
51:
52: public L2SConfigBuilder getServers() {
53: if (!isSet("servers"))
54: setServers(L2SConfigBuilder.newMinimalInstance());
55: return (L2SConfigBuilder) getRawProperty("servers");
56: }
57:
58: public void setApplication(String value) {
59: setProperty("application", value);
60: }
61:
62: public void setApplication(ApplicationConfigBuilder value) {
63: setProperty("application", value);
64: }
65:
66: public ApplicationConfigBuilder getApplication() {
67: if (!isSet("application"))
68: setApplication(ApplicationConfigBuilder
69: .newMinimalInstance());
70: return (ApplicationConfigBuilder) getRawProperty("application");
71: }
72:
73: public static final String[] ALL_PROPERTIES = new String[] {
74: "system", "clients", "servers", "application" };
75:
76: public String toString() {
77: return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n\n"
78: + "<tc:tc-config xmlns:tc=\"http://www.terracotta.org/config\">\n"
79: + elements(ALL_PROPERTIES) + "</tc:tc-config>";
80: }
81:
82: public static TerracottaConfigBuilder newMinimalInstance() {
83: SystemConfigBuilder system = SystemConfigBuilder
84: .newMinimalInstance();
85: L2SConfigBuilder l2s = L2SConfigBuilder.newMinimalInstance();
86: ApplicationConfigBuilder app = ApplicationConfigBuilder
87: .newMinimalInstance();
88: TerracottaConfigBuilder out = new TerracottaConfigBuilder();
89: out.setSystem(system);
90: out.setServers(l2s);
91: out.setApplication(app);
92: return out;
93: }
94:
95: public static void main(String[] args) {
96: System.err.println(newMinimalInstance());
97: }
98:
99: }
|