KickJava   Java API By Example, From Geeks To Geeks.

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


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 the entire system. This class <strong>MUST NOT</strong> invoke the actual XML
8  * beans to do its work; one of its purposes is, in fact, to test that those beans are set up correctly.
9  */

10 public class TerracottaConfigBuilder extends BaseConfigBuilder {
11
12   public TerracottaConfigBuilder() {
13     super(0, ALL_PROPERTIES);
14   }
15
16   public void setSystem(String JavaDoc 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")) setSystem(SystemConfigBuilder.newMinimalInstance());
26     return (SystemConfigBuilder) getRawProperty("system");
27   }
28
29   public void setClient(String JavaDoc value) {
30     setProperty("clients", value);
31   }
32
33   public void setClient(L1ConfigBuilder value) {
34     setProperty("clients", value);
35   }
36
37   public L1ConfigBuilder getClient() {
38     if (!isSet("clients")) setClient(L1ConfigBuilder.newMinimalInstance());
39     return (L1ConfigBuilder) getRawProperty("clients");
40   }
41
42   public void setServers(String JavaDoc value) {
43     setProperty("servers", value);
44   }
45
46   public void setServers(L2SConfigBuilder value) {
47     setProperty("servers", value);
48   }
49
50   public L2SConfigBuilder getServers() {
51     if (!isSet("servers")) setServers(L2SConfigBuilder.newMinimalInstance());
52     return (L2SConfigBuilder) getRawProperty("servers");
53   }
54
55   public void setApplication(String JavaDoc value) {
56     setProperty("application", value);
57   }
58
59   public void setApplication(ApplicationConfigBuilder value) {
60     setProperty("application", value);
61   }
62
63   public ApplicationConfigBuilder getApplication() {
64     if (!isSet("application")) setApplication(ApplicationConfigBuilder.newMinimalInstance());
65     return (ApplicationConfigBuilder) getRawProperty("application");
66   }
67
68   public static final String JavaDoc[] ALL_PROPERTIES = new String JavaDoc[] { "system", "clients", "servers", "application" };
69
70   public String JavaDoc toString() {
71     return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n\n"
72            + "<tc:tc-config xmlns:tc=\"http://www.terracotta.org/config\">\n" + elements(ALL_PROPERTIES)
73            + "</tc:tc-config>";
74   }
75
76   public static TerracottaConfigBuilder newMinimalInstance() {
77     SystemConfigBuilder system = SystemConfigBuilder.newMinimalInstance();
78     L2SConfigBuilder l2s = L2SConfigBuilder.newMinimalInstance();
79     ApplicationConfigBuilder app = ApplicationConfigBuilder.newMinimalInstance();
80     TerracottaConfigBuilder out = new TerracottaConfigBuilder();
81     out.setSystem(system);
82     out.setServers(l2s);
83     out.setApplication(app);
84     return out;
85   }
86
87   public static void main(String JavaDoc[] args) {
88     System.err.println(newMinimalInstance());
89   }
90
91 }
92
Popular Tags