KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > ServerRef


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /**
25  * This generated bean class ServerRef matches the DTD element server-ref
26  *
27  */

28
29 package com.sun.enterprise.config.serverbeans;
30
31 import org.w3c.dom.*;
32 import org.netbeans.modules.schema2beans.*;
33 import java.beans.*;
34 import java.util.*;
35 import java.io.Serializable JavaDoc;
36 import com.sun.enterprise.config.ConfigBean;
37 import com.sun.enterprise.config.ConfigException;
38 import com.sun.enterprise.config.StaleWriteConfigException;
39 import com.sun.enterprise.util.i18n.StringManager;
40
41 // BEGIN_NOI18N
42

43 public class ServerRef extends ConfigBean implements Serializable JavaDoc
44 {
45
46     static Vector comparators = new Vector();
47     private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0);
48
49     static public final String JavaDoc HEALTH_CHECKER = "HealthChecker";
50
51     public ServerRef() {
52         this(Common.USE_DEFAULT_VALUES);
53     }
54
55     public ServerRef(int options)
56     {
57         super(comparators, runtimeVersion);
58         // Properties (see root bean comments for the bean graph)
59
initPropertyTables(1);
60         this.createProperty("health-checker", HEALTH_CHECKER,
61             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
62             HealthChecker.class);
63         this.createAttribute(HEALTH_CHECKER, "url", "Url",
64                         AttrProp.CDATA,
65                         null, "/");
66         this.createAttribute(HEALTH_CHECKER, "interval-in-seconds", "IntervalInSeconds",
67                         AttrProp.CDATA,
68                         null, "30");
69         this.createAttribute(HEALTH_CHECKER, "timeout-in-seconds", "TimeoutInSeconds",
70                         AttrProp.CDATA,
71                         null, "10");
72         this.initialize(options);
73     }
74
75     // Setting the default values of the properties
76
void initialize(int options) {
77
78     }
79
80     // This attribute is optional
81
public void setHealthChecker(HealthChecker value) {
82         this.setValue(HEALTH_CHECKER, value);
83     }
84
85     // Get Method
86
public HealthChecker getHealthChecker() {
87         return (HealthChecker)this.getValue(HEALTH_CHECKER);
88     }
89
90     /**
91     * Getter for Ref of the Element server-ref
92     * @return the Ref of the Element server-ref
93     */

94     public String JavaDoc getRef() {
95         return getAttributeValue(ServerTags.REF);
96     }
97     /**
98     * Modify the Ref of the Element server-ref
99     * @param v the new value
100     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
101     */

102     public void setRef(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
103         setAttributeValue(ServerTags.REF, v, overwrite);
104     }
105     /**
106     * Modify the Ref of the Element server-ref
107     * @param v the new value
108     */

109     public void setRef(String JavaDoc v) {
110         setAttributeValue(ServerTags.REF, v);
111     }
112     /**
113     * Getter for DisableTimeoutInMinutes of the Element server-ref
114     * @return the DisableTimeoutInMinutes of the Element server-ref
115     */

116     public String JavaDoc getDisableTimeoutInMinutes() {
117         return getAttributeValue(ServerTags.DISABLE_TIMEOUT_IN_MINUTES);
118     }
119     /**
120     * Modify the DisableTimeoutInMinutes of the Element server-ref
121     * @param v the new value
122     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
123     */

124     public void setDisableTimeoutInMinutes(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
125         setAttributeValue(ServerTags.DISABLE_TIMEOUT_IN_MINUTES, v, overwrite);
126     }
127     /**
128     * Modify the DisableTimeoutInMinutes of the Element server-ref
129     * @param v the new value
130     */

131     public void setDisableTimeoutInMinutes(String JavaDoc v) {
132         setAttributeValue(ServerTags.DISABLE_TIMEOUT_IN_MINUTES, v);
133     }
134     /**
135     * Get the default value of DisableTimeoutInMinutes from dtd
136     */

137     public static String JavaDoc getDefaultDisableTimeoutInMinutes() {
138         return "30".trim();
139     }
140     /**
141     * Getter for LbEnabled of the Element server-ref
142     * @return the LbEnabled of the Element server-ref
143     */

144     public boolean isLbEnabled() {
145         return toBoolean(getAttributeValue(ServerTags.LB_ENABLED));
146     }
147     /**
148     * Modify the LbEnabled of the Element server-ref
149     * @param v the new value
150     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
151     */

152     public void setLbEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
153         setAttributeValue(ServerTags.LB_ENABLED, ""+(v==true), overwrite);
154     }
155     /**
156     * Modify the LbEnabled of the Element server-ref
157     * @param v the new value
158     */

159     public void setLbEnabled(boolean v) {
160         setAttributeValue(ServerTags.LB_ENABLED, ""+(v==true));
161     }
162     /**
163     * Get the default value of LbEnabled from dtd
164     */

165     public static String JavaDoc getDefaultLbEnabled() {
166         return "false".trim();
167     }
168     /**
169     * Getter for Enabled of the Element server-ref
170     * @return the Enabled of the Element server-ref
171     */

172     public boolean isEnabled() {
173         return toBoolean(getAttributeValue(ServerTags.ENABLED));
174     }
175     /**
176     * Modify the Enabled of the Element server-ref
177     * @param v the new value
178     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
179     */

180     public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
181         setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite);
182     }
183     /**
184     * Modify the Enabled of the Element server-ref
185     * @param v the new value
186     */

187     public void setEnabled(boolean v) {
188         setAttributeValue(ServerTags.ENABLED, ""+(v==true));
189     }
190     /**
191     * Get the default value of Enabled from dtd
192     */

193     public static String JavaDoc getDefaultEnabled() {
194         return "true".trim();
195     }
196     /**
197      * Create a new bean using it's default constructor.
198      * This does not add it to any bean graph.
199      */

200     public HealthChecker newHealthChecker() {
201         return new HealthChecker();
202     }
203
204     /**
205     * get the xpath representation for this element
206     * returns something like abc[@name='value'] or abc
207     * depending on the type of the bean
208     */

209     protected String JavaDoc getRelativeXPath() {
210         String JavaDoc ret = null;
211         ret = "server-ref" + (canHaveSiblings() ? "[@ref='" + getAttributeValue("ref") +"']" : "") ;
212         return (null != ret ? ret.trim() : null);
213     }
214
215     /*
216     * generic method to get default value from dtd
217     */

218     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
219         if(attr == null) return null;
220         attr = attr.trim();
221         if(attr.equals(ServerTags.DISABLE_TIMEOUT_IN_MINUTES)) return "30".trim();
222         if(attr.equals(ServerTags.LB_ENABLED)) return "false".trim();
223         if(attr.equals(ServerTags.ENABLED)) return "true".trim();
224     return null;
225     }
226     //
227
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
228         comparators.add(c);
229     }
230
231     //
232
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
233         comparators.remove(c);
234     }
235     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
236     }
237
238     // Dump the content of this bean returning it as a String
239
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
240         String JavaDoc s;
241         Object JavaDoc o;
242         org.netbeans.modules.schema2beans.BaseBean n;
243         str.append(indent);
244         str.append("HealthChecker"); // NOI18N
245
n = (org.netbeans.modules.schema2beans.BaseBean) this.getHealthChecker();
246         if (n != null)
247             n.dump(str, indent + "\t"); // NOI18N
248
else
249             str.append(indent+"\tnull"); // NOI18N
250
this.dumpAttributes(HEALTH_CHECKER, 0, str, indent);
251
252     }
253     public String JavaDoc dumpBeanNode(){
254         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
255         str.append("ServerRef\n"); // NOI18N
256
this.dump(str, "\n "); // NOI18N
257
return str.toString();
258     }}
259
260 // END_NOI18N
261

262
Popular Tags