KickJava   Java API By Example, From Geeks To Geeks.

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


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 LbConfig matches the DTD element lb-config
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 LbConfig 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 CLUSTER_REF = "ClusterRef";
50     static public final String JavaDoc SERVER_REF = "ServerRef";
51     static public final String JavaDoc ELEMENT_PROPERTY = "ElementProperty";
52
53     public LbConfig() {
54         this(Common.USE_DEFAULT_VALUES);
55     }
56
57     public LbConfig(int options)
58     {
59         super(comparators, runtimeVersion);
60         // Properties (see root bean comments for the bean graph)
61
initPropertyTables(3);
62         this.createProperty("cluster-ref", CLUSTER_REF, Common.SEQUENCE_OR |
63             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
64             ClusterRef.class);
65         this.createAttribute(CLUSTER_REF, "ref", "Ref",
66                         AttrProp.CDATA | AttrProp.REQUIRED,
67                         null, null);
68         this.createAttribute(CLUSTER_REF, "lb-policy", "LbPolicy",
69                         AttrProp.CDATA,
70                         null, "round-robin");
71         this.createAttribute(CLUSTER_REF, "lb-policy-module", "LbPolicyModule",
72                         AttrProp.CDATA | AttrProp.IMPLIED,
73                         null, null);
74         this.createProperty("server-ref", SERVER_REF, Common.SEQUENCE_OR |
75             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
76             ServerRef.class);
77         this.createAttribute(SERVER_REF, "ref", "Ref",
78                         AttrProp.CDATA | AttrProp.REQUIRED,
79                         null, null);
80         this.createAttribute(SERVER_REF, "disable-timeout-in-minutes", "DisableTimeoutInMinutes",
81                         AttrProp.CDATA,
82                         null, "30");
83         this.createAttribute(SERVER_REF, "lb-enabled", "LbEnabled",
84                         AttrProp.CDATA,
85                         null, "false");
86         this.createAttribute(SERVER_REF, "enabled", "Enabled",
87                         AttrProp.CDATA,
88                         null, "true");
89         this.createProperty("property", ELEMENT_PROPERTY,
90             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
91             ElementProperty.class);
92         this.createAttribute(ELEMENT_PROPERTY, "name", "Name",
93                         AttrProp.CDATA | AttrProp.REQUIRED,
94                         null, null);
95         this.createAttribute(ELEMENT_PROPERTY, "value", "Value",
96                         AttrProp.CDATA | AttrProp.REQUIRED,
97                         null, null);
98         this.initialize(options);
99     }
100
101     // Setting the default values of the properties
102
void initialize(int options) {
103
104     }
105
106     // This attribute is an array, possibly empty
107
public void setClusterRef(int index, ClusterRef value) {
108         this.setValue(CLUSTER_REF, index, value);
109     }
110
111     // Get Method
112
public ClusterRef getClusterRef(int index) {
113         return (ClusterRef)this.getValue(CLUSTER_REF, index);
114     }
115
116     // This attribute is an array, possibly empty
117
public void setClusterRef(ClusterRef[] value) {
118         this.setValue(CLUSTER_REF, value);
119         if (value != null && value.length > 0) {
120             // It's a mutually exclusive property.
121
setServerRef(null);
122         }
123     }
124
125     // Getter Method
126
public ClusterRef[] getClusterRef() {
127         return (ClusterRef[])this.getValues(CLUSTER_REF);
128     }
129
130     // Return the number of properties
131
public int sizeClusterRef() {
132         return this.size(CLUSTER_REF);
133     }
134
135     // Add a new element returning its index in the list
136
public int addClusterRef(ClusterRef value)
137             throws ConfigException{
138         return addClusterRef(value, true);
139     }
140
141     // Add a new element returning its index in the list with a boolean flag
142
public int addClusterRef(ClusterRef value, boolean overwrite)
143             throws ConfigException{
144         ClusterRef old = getClusterRefByRef(value.getRef());
145         if(old != null) {
146             throw new ConfigException(StringManager.getManager(LbConfig.class).getString("cannotAddDuplicate", "ClusterRef"));
147         }
148         return this.addValue(CLUSTER_REF, value, overwrite);
149     }
150
151     //
152
// Remove an element using its reference
153
// Returns the index the element had in the list
154
//
155
public int removeClusterRef(ClusterRef value){
156         return this.removeValue(CLUSTER_REF, value);
157     }
158
159     //
160
// Remove an element using its reference
161
// Returns the index the element had in the list
162
// with boolean overwrite
163
//
164
public int removeClusterRef(ClusterRef value, boolean overwrite)
165             throws StaleWriteConfigException{
166         return this.removeValue(CLUSTER_REF, value, overwrite);
167     }
168
169     public ClusterRef getClusterRefByRef(String JavaDoc id) {
170      if (null != id) { id = id.trim(); }
171     ClusterRef[] o = getClusterRef();
172      if (o == null) return null;
173
174      for (int i=0; i < o.length; i++) {
175          if(o[i].getAttributeValue(Common.convertName(ServerTags.REF)).equals(id)) {
176              return o[i];
177          }
178      }
179
180         return null;
181         
182     }
183     // This attribute is an array, possibly empty
184
public void setServerRef(int index, ServerRef value) {
185         this.setValue(SERVER_REF, index, value);
186     }
187
188     // Get Method
189
public ServerRef getServerRef(int index) {
190         return (ServerRef)this.getValue(SERVER_REF, index);
191     }
192
193     // This attribute is an array, possibly empty
194
public void setServerRef(ServerRef[] value) {
195         this.setValue(SERVER_REF, value);
196         if (value != null && value.length > 0) {
197             // It's a mutually exclusive property.
198
setClusterRef(null);
199         }
200     }
201
202     // Getter Method
203
public ServerRef[] getServerRef() {
204         return (ServerRef[])this.getValues(SERVER_REF);
205     }
206
207     // Return the number of properties
208
public int sizeServerRef() {
209         return this.size(SERVER_REF);
210     }
211
212     // Add a new element returning its index in the list
213
public int addServerRef(ServerRef value)
214             throws ConfigException{
215         return addServerRef(value, true);
216     }
217
218     // Add a new element returning its index in the list with a boolean flag
219
public int addServerRef(ServerRef value, boolean overwrite)
220             throws ConfigException{
221         ServerRef old = getServerRefByRef(value.getRef());
222         if(old != null) {
223             throw new ConfigException(StringManager.getManager(LbConfig.class).getString("cannotAddDuplicate", "ServerRef"));
224         }
225         return this.addValue(SERVER_REF, value, overwrite);
226     }
227
228     //
229
// Remove an element using its reference
230
// Returns the index the element had in the list
231
//
232
public int removeServerRef(ServerRef value){
233         return this.removeValue(SERVER_REF, value);
234     }
235
236     //
237
// Remove an element using its reference
238
// Returns the index the element had in the list
239
// with boolean overwrite
240
//
241
public int removeServerRef(ServerRef value, boolean overwrite)
242             throws StaleWriteConfigException{
243         return this.removeValue(SERVER_REF, value, overwrite);
244     }
245
246     public ServerRef getServerRefByRef(String JavaDoc id) {
247      if (null != id) { id = id.trim(); }
248     ServerRef[] o = getServerRef();
249      if (o == null) return null;
250
251      for (int i=0; i < o.length; i++) {
252          if(o[i].getAttributeValue(Common.convertName(ServerTags.REF)).equals(id)) {
253              return o[i];
254          }
255      }
256
257         return null;
258         
259     }
260     // This attribute is an array, possibly empty
261
public void setElementProperty(int index, ElementProperty value) {
262         this.setValue(ELEMENT_PROPERTY, index, value);
263     }
264
265     // Get Method
266
public ElementProperty getElementProperty(int index) {
267         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
268     }
269
270     // This attribute is an array, possibly empty
271
public void setElementProperty(ElementProperty[] value) {
272         this.setValue(ELEMENT_PROPERTY, value);
273     }
274
275     // Getter Method
276
public ElementProperty[] getElementProperty() {
277         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
278     }
279
280     // Return the number of properties
281
public int sizeElementProperty() {
282         return this.size(ELEMENT_PROPERTY);
283     }
284
285     // Add a new element returning its index in the list
286
public int addElementProperty(ElementProperty value)
287             throws ConfigException{
288         return addElementProperty(value, true);
289     }
290
291     // Add a new element returning its index in the list with a boolean flag
292
public int addElementProperty(ElementProperty value, boolean overwrite)
293             throws ConfigException{
294         ElementProperty old = getElementPropertyByName(value.getName());
295         if(old != null) {
296             throw new ConfigException(StringManager.getManager(LbConfig.class).getString("cannotAddDuplicate", "ElementProperty"));
297         }
298         return this.addValue(ELEMENT_PROPERTY, value, overwrite);
299     }
300
301     //
302
// Remove an element using its reference
303
// Returns the index the element had in the list
304
//
305
public int removeElementProperty(ElementProperty value){
306         return this.removeValue(ELEMENT_PROPERTY, value);
307     }
308
309     //
310
// Remove an element using its reference
311
// Returns the index the element had in the list
312
// with boolean overwrite
313
//
314
public int removeElementProperty(ElementProperty value, boolean overwrite)
315             throws StaleWriteConfigException{
316         return this.removeValue(ELEMENT_PROPERTY, value, overwrite);
317     }
318
319     public ElementProperty getElementPropertyByName(String JavaDoc id) {
320      if (null != id) { id = id.trim(); }
321     ElementProperty[] o = getElementProperty();
322      if (o == null) return null;
323
324      for (int i=0; i < o.length; i++) {
325          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
326              return o[i];
327          }
328      }
329
330         return null;
331         
332     }
333     /**
334     * Getter for Name of the Element lb-config
335     * @return the Name of the Element lb-config
336     */

337     public String JavaDoc getName() {
338         return getAttributeValue(ServerTags.NAME);
339     }
340     /**
341     * Modify the Name of the Element lb-config
342     * @param v the new value
343     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
344     */

345     public void setName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
346         setAttributeValue(ServerTags.NAME, v, overwrite);
347     }
348     /**
349     * Modify the Name of the Element lb-config
350     * @param v the new value
351     */

352     public void setName(String JavaDoc v) {
353         setAttributeValue(ServerTags.NAME, v);
354     }
355     /**
356     * Getter for ResponseTimeoutInSeconds of the Element lb-config
357     * @return the ResponseTimeoutInSeconds of the Element lb-config
358     */

359     public String JavaDoc getResponseTimeoutInSeconds() {
360         return getAttributeValue(ServerTags.RESPONSE_TIMEOUT_IN_SECONDS);
361     }
362     /**
363     * Modify the ResponseTimeoutInSeconds of the Element lb-config
364     * @param v the new value
365     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
366     */

367     public void setResponseTimeoutInSeconds(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
368         setAttributeValue(ServerTags.RESPONSE_TIMEOUT_IN_SECONDS, v, overwrite);
369     }
370     /**
371     * Modify the ResponseTimeoutInSeconds of the Element lb-config
372     * @param v the new value
373     */

374     public void setResponseTimeoutInSeconds(String JavaDoc v) {
375         setAttributeValue(ServerTags.RESPONSE_TIMEOUT_IN_SECONDS, v);
376     }
377     /**
378     * Get the default value of ResponseTimeoutInSeconds from dtd
379     */

380     public static String JavaDoc getDefaultResponseTimeoutInSeconds() {
381         return "60".trim();
382     }
383     /**
384     * Getter for HttpsRouting of the Element lb-config
385     * @return the HttpsRouting of the Element lb-config
386     */

387     public boolean isHttpsRouting() {
388         return toBoolean(getAttributeValue(ServerTags.HTTPS_ROUTING));
389     }
390     /**
391     * Modify the HttpsRouting of the Element lb-config
392     * @param v the new value
393     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
394     */

395     public void setHttpsRouting(boolean v, boolean overwrite) throws StaleWriteConfigException {
396         setAttributeValue(ServerTags.HTTPS_ROUTING, ""+(v==true), overwrite);
397     }
398     /**
399     * Modify the HttpsRouting of the Element lb-config
400     * @param v the new value
401     */

402     public void setHttpsRouting(boolean v) {
403         setAttributeValue(ServerTags.HTTPS_ROUTING, ""+(v==true));
404     }
405     /**
406     * Get the default value of HttpsRouting from dtd
407     */

408     public static String JavaDoc getDefaultHttpsRouting() {
409         return "false".trim();
410     }
411     /**
412     * Getter for ReloadPollIntervalInSeconds of the Element lb-config
413     * @return the ReloadPollIntervalInSeconds of the Element lb-config
414     */

415     public String JavaDoc getReloadPollIntervalInSeconds() {
416         return getAttributeValue(ServerTags.RELOAD_POLL_INTERVAL_IN_SECONDS);
417     }
418     /**
419     * Modify the ReloadPollIntervalInSeconds of the Element lb-config
420     * @param v the new value
421     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
422     */

423     public void setReloadPollIntervalInSeconds(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
424         setAttributeValue(ServerTags.RELOAD_POLL_INTERVAL_IN_SECONDS, v, overwrite);
425     }
426     /**
427     * Modify the ReloadPollIntervalInSeconds of the Element lb-config
428     * @param v the new value
429     */

430     public void setReloadPollIntervalInSeconds(String JavaDoc v) {
431         setAttributeValue(ServerTags.RELOAD_POLL_INTERVAL_IN_SECONDS, v);
432     }
433     /**
434     * Get the default value of ReloadPollIntervalInSeconds from dtd
435     */

436     public static String JavaDoc getDefaultReloadPollIntervalInSeconds() {
437         return "60".trim();
438     }
439     /**
440     * Getter for MonitoringEnabled of the Element lb-config
441     * @return the MonitoringEnabled of the Element lb-config
442     */

443     public boolean isMonitoringEnabled() {
444         return toBoolean(getAttributeValue(ServerTags.MONITORING_ENABLED));
445     }
446     /**
447     * Modify the MonitoringEnabled of the Element lb-config
448     * @param v the new value
449     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
450     */

451     public void setMonitoringEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
452         setAttributeValue(ServerTags.MONITORING_ENABLED, ""+(v==true), overwrite);
453     }
454     /**
455     * Modify the MonitoringEnabled of the Element lb-config
456     * @param v the new value
457     */

458     public void setMonitoringEnabled(boolean v) {
459         setAttributeValue(ServerTags.MONITORING_ENABLED, ""+(v==true));
460     }
461     /**
462     * Get the default value of MonitoringEnabled from dtd
463     */

464     public static String JavaDoc getDefaultMonitoringEnabled() {
465         return "false".trim();
466     }
467     /**
468     * Getter for RouteCookieEnabled of the Element lb-config
469     * @return the RouteCookieEnabled of the Element lb-config
470     */

471     public boolean isRouteCookieEnabled() {
472         return toBoolean(getAttributeValue(ServerTags.ROUTE_COOKIE_ENABLED));
473     }
474     /**
475     * Modify the RouteCookieEnabled of the Element lb-config
476     * @param v the new value
477     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
478     */

479     public void setRouteCookieEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
480         setAttributeValue(ServerTags.ROUTE_COOKIE_ENABLED, ""+(v==true), overwrite);
481     }
482     /**
483     * Modify the RouteCookieEnabled of the Element lb-config
484     * @param v the new value
485     */

486     public void setRouteCookieEnabled(boolean v) {
487         setAttributeValue(ServerTags.ROUTE_COOKIE_ENABLED, ""+(v==true));
488     }
489     /**
490     * Get the default value of RouteCookieEnabled from dtd
491     */

492     public static String JavaDoc getDefaultRouteCookieEnabled() {
493         return "true".trim();
494     }
495     /**
496      * Create a new bean using it's default constructor.
497      * This does not add it to any bean graph.
498      */

499     public ClusterRef newClusterRef() {
500         return new ClusterRef();
501     }
502
503     /**
504      * Create a new bean using it's default constructor.
505      * This does not add it to any bean graph.
506      */

507     public ServerRef newServerRef() {
508         return new ServerRef();
509     }
510
511     /**
512      * Create a new bean using it's default constructor.
513      * This does not add it to any bean graph.
514      */

515     public ElementProperty newElementProperty() {
516         return new ElementProperty();
517     }
518
519     /**
520     * get the xpath representation for this element
521     * returns something like abc[@name='value'] or abc
522     * depending on the type of the bean
523     */

524     protected String JavaDoc getRelativeXPath() {
525         String JavaDoc ret = null;
526         ret = "lb-config" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ;
527         return (null != ret ? ret.trim() : null);
528     }
529
530     /*
531     * generic method to get default value from dtd
532     */

533     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
534         if(attr == null) return null;
535         attr = attr.trim();
536         if(attr.equals(ServerTags.RESPONSE_TIMEOUT_IN_SECONDS)) return "60".trim();
537         if(attr.equals(ServerTags.HTTPS_ROUTING)) return "false".trim();
538         if(attr.equals(ServerTags.RELOAD_POLL_INTERVAL_IN_SECONDS)) return "60".trim();
539         if(attr.equals(ServerTags.MONITORING_ENABLED)) return "false".trim();
540         if(attr.equals(ServerTags.ROUTE_COOKIE_ENABLED)) return "true".trim();
541     return null;
542     }
543     //
544
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
545         comparators.add(c);
546     }
547
548     //
549
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
550         comparators.remove(c);
551     }
552     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
553     }
554
555     // Dump the content of this bean returning it as a String
556
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
557         String JavaDoc s;
558         Object JavaDoc o;
559         org.netbeans.modules.schema2beans.BaseBean n;
560         str.append(indent);
561         str.append("ClusterRef["+this.sizeClusterRef()+"]"); // NOI18N
562
for(int i=0; i<this.sizeClusterRef(); i++)
563         {
564             str.append(indent+"\t");
565             str.append("#"+i+":");
566             n = (org.netbeans.modules.schema2beans.BaseBean) this.getClusterRef(i);
567             if (n != null)
568                 n.dump(str, indent + "\t"); // NOI18N
569
else
570                 str.append(indent+"\tnull"); // NOI18N
571
this.dumpAttributes(CLUSTER_REF, i, str, indent);
572         }
573
574         str.append(indent);
575         str.append("ServerRef["+this.sizeServerRef()+"]"); // NOI18N
576
for(int i=0; i<this.sizeServerRef(); i++)
577         {
578             str.append(indent+"\t");
579             str.append("#"+i+":");
580             n = (org.netbeans.modules.schema2beans.BaseBean) this.getServerRef(i);
581             if (n != null)
582                 n.dump(str, indent + "\t"); // NOI18N
583
else
584                 str.append(indent+"\tnull"); // NOI18N
585
this.dumpAttributes(SERVER_REF, i, str, indent);
586         }
587
588         str.append(indent);
589         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
590
for(int i=0; i<this.sizeElementProperty(); i++)
591         {
592             str.append(indent+"\t");
593             str.append("#"+i+":");
594             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
595             if (n != null)
596                 n.dump(str, indent + "\t"); // NOI18N
597
else
598                 str.append(indent+"\tnull"); // NOI18N
599
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
600         }
601
602     }
603     public String JavaDoc dumpBeanNode(){
604         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
605         str.append("LbConfig\n"); // NOI18N
606
this.dump(str, "\n "); // NOI18N
607
return str.toString();
608     }}
609
610 // END_NOI18N
611

612
Popular Tags