KickJava   Java API By Example, From Geeks To Geeks.

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


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 Server matches the DTD element server
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 Server 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 APPLICATION_REF = "ApplicationRef";
50     static public final String JavaDoc RESOURCE_REF = "ResourceRef";
51     static public final String JavaDoc SYSTEM_PROPERTY = "SystemProperty";
52     static public final String JavaDoc ELEMENT_PROPERTY = "ElementProperty";
53
54     public Server() {
55         this(Common.USE_DEFAULT_VALUES);
56     }
57
58     public Server(int options)
59     {
60         super(comparators, runtimeVersion);
61         // Properties (see root bean comments for the bean graph)
62
initPropertyTables(4);
63         this.createProperty("application-ref", APPLICATION_REF,
64             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
65             ApplicationRef.class);
66         this.createAttribute(APPLICATION_REF, "enabled", "Enabled",
67                         AttrProp.CDATA,
68                         null, "true");
69         this.createAttribute(APPLICATION_REF, "virtual-servers", "VirtualServers",
70                         AttrProp.CDATA | AttrProp.IMPLIED,
71                         null, null);
72         this.createAttribute(APPLICATION_REF, "lb-enabled", "LbEnabled",
73                         AttrProp.CDATA,
74                         null, "false");
75         this.createAttribute(APPLICATION_REF, "disable-timeout-in-minutes", "DisableTimeoutInMinutes",
76                         AttrProp.CDATA,
77                         null, "30");
78         this.createAttribute(APPLICATION_REF, "ref", "Ref",
79                         AttrProp.CDATA | AttrProp.REQUIRED,
80                         null, null);
81         this.createProperty("resource-ref", RESOURCE_REF,
82             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
83             ResourceRef.class);
84         this.createAttribute(RESOURCE_REF, "enabled", "Enabled",
85                         AttrProp.CDATA,
86                         null, "true");
87         this.createAttribute(RESOURCE_REF, "ref", "Ref",
88                         AttrProp.CDATA | AttrProp.REQUIRED,
89                         null, null);
90         this.createProperty("system-property", SYSTEM_PROPERTY,
91             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
92             SystemProperty.class);
93         this.createAttribute(SYSTEM_PROPERTY, "name", "Name",
94                         AttrProp.CDATA | AttrProp.REQUIRED,
95                         null, null);
96         this.createAttribute(SYSTEM_PROPERTY, "value", "Value",
97                         AttrProp.CDATA | AttrProp.REQUIRED,
98                         null, null);
99         this.createProperty("property", ELEMENT_PROPERTY,
100             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
101             ElementProperty.class);
102         this.createAttribute(ELEMENT_PROPERTY, "name", "Name",
103                         AttrProp.CDATA | AttrProp.REQUIRED,
104                         null, null);
105         this.createAttribute(ELEMENT_PROPERTY, "value", "Value",
106                         AttrProp.CDATA | AttrProp.REQUIRED,
107                         null, null);
108         this.initialize(options);
109     }
110
111     // Setting the default values of the properties
112
void initialize(int options) {
113
114     }
115
116     // This attribute is an array, possibly empty
117
public void setApplicationRef(int index, ApplicationRef value) {
118         this.setValue(APPLICATION_REF, index, value);
119     }
120
121     // Get Method
122
public ApplicationRef getApplicationRef(int index) {
123         return (ApplicationRef)this.getValue(APPLICATION_REF, index);
124     }
125
126     // This attribute is an array, possibly empty
127
public void setApplicationRef(ApplicationRef[] value) {
128         this.setValue(APPLICATION_REF, value);
129     }
130
131     // Getter Method
132
public ApplicationRef[] getApplicationRef() {
133         return (ApplicationRef[])this.getValues(APPLICATION_REF);
134     }
135
136     // Return the number of properties
137
public int sizeApplicationRef() {
138         return this.size(APPLICATION_REF);
139     }
140
141     // Add a new element returning its index in the list
142
public int addApplicationRef(ApplicationRef value)
143             throws ConfigException{
144         return addApplicationRef(value, true);
145     }
146
147     // Add a new element returning its index in the list with a boolean flag
148
public int addApplicationRef(ApplicationRef value, boolean overwrite)
149             throws ConfigException{
150         ApplicationRef old = getApplicationRefByRef(value.getRef());
151         if(old != null) {
152             throw new ConfigException(StringManager.getManager(Server.class).getString("cannotAddDuplicate", "ApplicationRef"));
153         }
154         return this.addValue(APPLICATION_REF, value, overwrite);
155     }
156
157     //
158
// Remove an element using its reference
159
// Returns the index the element had in the list
160
//
161
public int removeApplicationRef(ApplicationRef value){
162         return this.removeValue(APPLICATION_REF, value);
163     }
164
165     //
166
// Remove an element using its reference
167
// Returns the index the element had in the list
168
// with boolean overwrite
169
//
170
public int removeApplicationRef(ApplicationRef value, boolean overwrite)
171             throws StaleWriteConfigException{
172         return this.removeValue(APPLICATION_REF, value, overwrite);
173     }
174
175     public ApplicationRef getApplicationRefByRef(String JavaDoc id) {
176      if (null != id) { id = id.trim(); }
177     ApplicationRef[] o = getApplicationRef();
178      if (o == null) return null;
179
180      for (int i=0; i < o.length; i++) {
181          if(o[i].getAttributeValue(Common.convertName(ServerTags.REF)).equals(id)) {
182              return o[i];
183          }
184      }
185
186         return null;
187         
188     }
189     // This attribute is an array, possibly empty
190
public void setResourceRef(int index, ResourceRef value) {
191         this.setValue(RESOURCE_REF, index, value);
192     }
193
194     // Get Method
195
public ResourceRef getResourceRef(int index) {
196         return (ResourceRef)this.getValue(RESOURCE_REF, index);
197     }
198
199     // This attribute is an array, possibly empty
200
public void setResourceRef(ResourceRef[] value) {
201         this.setValue(RESOURCE_REF, value);
202     }
203
204     // Getter Method
205
public ResourceRef[] getResourceRef() {
206         return (ResourceRef[])this.getValues(RESOURCE_REF);
207     }
208
209     // Return the number of properties
210
public int sizeResourceRef() {
211         return this.size(RESOURCE_REF);
212     }
213
214     // Add a new element returning its index in the list
215
public int addResourceRef(ResourceRef value)
216             throws ConfigException{
217         return addResourceRef(value, true);
218     }
219
220     // Add a new element returning its index in the list with a boolean flag
221
public int addResourceRef(ResourceRef value, boolean overwrite)
222             throws ConfigException{
223         ResourceRef old = getResourceRefByRef(value.getRef());
224         if(old != null) {
225             throw new ConfigException(StringManager.getManager(Server.class).getString("cannotAddDuplicate", "ResourceRef"));
226         }
227         return this.addValue(RESOURCE_REF, value, overwrite);
228     }
229
230     //
231
// Remove an element using its reference
232
// Returns the index the element had in the list
233
//
234
public int removeResourceRef(ResourceRef value){
235         return this.removeValue(RESOURCE_REF, value);
236     }
237
238     //
239
// Remove an element using its reference
240
// Returns the index the element had in the list
241
// with boolean overwrite
242
//
243
public int removeResourceRef(ResourceRef value, boolean overwrite)
244             throws StaleWriteConfigException{
245         return this.removeValue(RESOURCE_REF, value, overwrite);
246     }
247
248     public ResourceRef getResourceRefByRef(String JavaDoc id) {
249      if (null != id) { id = id.trim(); }
250     ResourceRef[] o = getResourceRef();
251      if (o == null) return null;
252
253      for (int i=0; i < o.length; i++) {
254          if(o[i].getAttributeValue(Common.convertName(ServerTags.REF)).equals(id)) {
255              return o[i];
256          }
257      }
258
259         return null;
260         
261     }
262     // This attribute is an array, possibly empty
263
public void setSystemProperty(int index, SystemProperty value) {
264         this.setValue(SYSTEM_PROPERTY, index, value);
265     }
266
267     // Get Method
268
public SystemProperty getSystemProperty(int index) {
269         return (SystemProperty)this.getValue(SYSTEM_PROPERTY, index);
270     }
271
272     // This attribute is an array, possibly empty
273
public void setSystemProperty(SystemProperty[] value) {
274         this.setValue(SYSTEM_PROPERTY, value);
275     }
276
277     // Getter Method
278
public SystemProperty[] getSystemProperty() {
279         return (SystemProperty[])this.getValues(SYSTEM_PROPERTY);
280     }
281
282     // Return the number of properties
283
public int sizeSystemProperty() {
284         return this.size(SYSTEM_PROPERTY);
285     }
286
287     // Add a new element returning its index in the list
288
public int addSystemProperty(SystemProperty value)
289             throws ConfigException{
290         return addSystemProperty(value, true);
291     }
292
293     // Add a new element returning its index in the list with a boolean flag
294
public int addSystemProperty(SystemProperty value, boolean overwrite)
295             throws ConfigException{
296         SystemProperty old = getSystemPropertyByName(value.getName());
297         if(old != null) {
298             throw new ConfigException(StringManager.getManager(Server.class).getString("cannotAddDuplicate", "SystemProperty"));
299         }
300         return this.addValue(SYSTEM_PROPERTY, value, overwrite);
301     }
302
303     //
304
// Remove an element using its reference
305
// Returns the index the element had in the list
306
//
307
public int removeSystemProperty(SystemProperty value){
308         return this.removeValue(SYSTEM_PROPERTY, value);
309     }
310
311     //
312
// Remove an element using its reference
313
// Returns the index the element had in the list
314
// with boolean overwrite
315
//
316
public int removeSystemProperty(SystemProperty value, boolean overwrite)
317             throws StaleWriteConfigException{
318         return this.removeValue(SYSTEM_PROPERTY, value, overwrite);
319     }
320
321     public SystemProperty getSystemPropertyByName(String JavaDoc id) {
322      if (null != id) { id = id.trim(); }
323     SystemProperty[] o = getSystemProperty();
324      if (o == null) return null;
325
326      for (int i=0; i < o.length; i++) {
327          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
328              return o[i];
329          }
330      }
331
332         return null;
333         
334     }
335     // This attribute is an array, possibly empty
336
public void setElementProperty(int index, ElementProperty value) {
337         this.setValue(ELEMENT_PROPERTY, index, value);
338     }
339
340     // Get Method
341
public ElementProperty getElementProperty(int index) {
342         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
343     }
344
345     // This attribute is an array, possibly empty
346
public void setElementProperty(ElementProperty[] value) {
347         this.setValue(ELEMENT_PROPERTY, value);
348     }
349
350     // Getter Method
351
public ElementProperty[] getElementProperty() {
352         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
353     }
354
355     // Return the number of properties
356
public int sizeElementProperty() {
357         return this.size(ELEMENT_PROPERTY);
358     }
359
360     // Add a new element returning its index in the list
361
public int addElementProperty(ElementProperty value)
362             throws ConfigException{
363         return addElementProperty(value, true);
364     }
365
366     // Add a new element returning its index in the list with a boolean flag
367
public int addElementProperty(ElementProperty value, boolean overwrite)
368             throws ConfigException{
369         ElementProperty old = getElementPropertyByName(value.getName());
370         if(old != null) {
371             throw new ConfigException(StringManager.getManager(Server.class).getString("cannotAddDuplicate", "ElementProperty"));
372         }
373         return this.addValue(ELEMENT_PROPERTY, value, overwrite);
374     }
375
376     //
377
// Remove an element using its reference
378
// Returns the index the element had in the list
379
//
380
public int removeElementProperty(ElementProperty value){
381         return this.removeValue(ELEMENT_PROPERTY, value);
382     }
383
384     //
385
// Remove an element using its reference
386
// Returns the index the element had in the list
387
// with boolean overwrite
388
//
389
public int removeElementProperty(ElementProperty value, boolean overwrite)
390             throws StaleWriteConfigException{
391         return this.removeValue(ELEMENT_PROPERTY, value, overwrite);
392     }
393
394     public ElementProperty getElementPropertyByName(String JavaDoc id) {
395      if (null != id) { id = id.trim(); }
396     ElementProperty[] o = getElementProperty();
397      if (o == null) return null;
398
399      for (int i=0; i < o.length; i++) {
400          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
401              return o[i];
402          }
403      }
404
405         return null;
406         
407     }
408     /**
409     * Getter for Name of the Element server
410     * @return the Name of the Element server
411     */

412     public String JavaDoc getName() {
413         return getAttributeValue(ServerTags.NAME);
414     }
415     /**
416     * Modify the Name of the Element server
417     * @param v the new value
418     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
419     */

420     public void setName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
421         setAttributeValue(ServerTags.NAME, v, overwrite);
422     }
423     /**
424     * Modify the Name of the Element server
425     * @param v the new value
426     */

427     public void setName(String JavaDoc v) {
428         setAttributeValue(ServerTags.NAME, v);
429     }
430     /**
431     * Getter for ConfigRef of the Element server
432     * @return the ConfigRef of the Element server
433     */

434     public String JavaDoc getConfigRef() {
435             return getAttributeValue(ServerTags.CONFIG_REF);
436     }
437     /**
438     * Modify the ConfigRef of the Element server
439     * @param v the new value
440     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
441     */

442     public void setConfigRef(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
443         setAttributeValue(ServerTags.CONFIG_REF, v, overwrite);
444     }
445     /**
446     * Modify the ConfigRef of the Element server
447     * @param v the new value
448     */

449     public void setConfigRef(String JavaDoc v) {
450         setAttributeValue(ServerTags.CONFIG_REF, v);
451     }
452     /**
453     * Getter for NodeAgentRef of the Element server
454     * @return the NodeAgentRef of the Element server
455     */

456     public String JavaDoc getNodeAgentRef() {
457             return getAttributeValue(ServerTags.NODE_AGENT_REF);
458     }
459     /**
460     * Modify the NodeAgentRef of the Element server
461     * @param v the new value
462     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
463     */

464     public void setNodeAgentRef(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
465         setAttributeValue(ServerTags.NODE_AGENT_REF, v, overwrite);
466     }
467     /**
468     * Modify the NodeAgentRef of the Element server
469     * @param v the new value
470     */

471     public void setNodeAgentRef(String JavaDoc v) {
472         setAttributeValue(ServerTags.NODE_AGENT_REF, v);
473     }
474     /**
475     * Getter for LbWeight of the Element server
476     * @return the LbWeight of the Element server
477     */

478     public String JavaDoc getLbWeight() {
479         return getAttributeValue(ServerTags.LB_WEIGHT);
480     }
481     /**
482     * Modify the LbWeight of the Element server
483     * @param v the new value
484     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
485     */

486     public void setLbWeight(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
487         setAttributeValue(ServerTags.LB_WEIGHT, v, overwrite);
488     }
489     /**
490     * Modify the LbWeight of the Element server
491     * @param v the new value
492     */

493     public void setLbWeight(String JavaDoc v) {
494         setAttributeValue(ServerTags.LB_WEIGHT, v);
495     }
496     /**
497     * Get the default value of LbWeight from dtd
498     */

499     public static String JavaDoc getDefaultLbWeight() {
500         return "100".trim();
501     }
502     /**
503      * Create a new bean using it's default constructor.
504      * This does not add it to any bean graph.
505      */

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

514     public ResourceRef newResourceRef() {
515         return new ResourceRef();
516     }
517
518     /**
519      * Create a new bean using it's default constructor.
520      * This does not add it to any bean graph.
521      */

522     public SystemProperty newSystemProperty() {
523         return new SystemProperty();
524     }
525
526     /**
527      * Create a new bean using it's default constructor.
528      * This does not add it to any bean graph.
529      */

530     public ElementProperty newElementProperty() {
531         return new ElementProperty();
532     }
533
534     /**
535     * get the xpath representation for this element
536     * returns something like abc[@name='value'] or abc
537     * depending on the type of the bean
538     */

539     protected String JavaDoc getRelativeXPath() {
540         String JavaDoc ret = null;
541         ret = "server" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ;
542         return (null != ret ? ret.trim() : null);
543     }
544
545     /*
546     * generic method to get default value from dtd
547     */

548     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
549         if(attr == null) return null;
550         attr = attr.trim();
551         if(attr.equals(ServerTags.LB_WEIGHT)) return "100".trim();
552     return null;
553     }
554     //
555
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
556         comparators.add(c);
557     }
558
559     //
560
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
561         comparators.remove(c);
562     }
563     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
564     }
565
566     // Dump the content of this bean returning it as a String
567
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
568         String JavaDoc s;
569         Object JavaDoc o;
570         org.netbeans.modules.schema2beans.BaseBean n;
571         str.append(indent);
572         str.append("ApplicationRef["+this.sizeApplicationRef()+"]"); // NOI18N
573
for(int i=0; i<this.sizeApplicationRef(); i++)
574         {
575             str.append(indent+"\t");
576             str.append("#"+i+":");
577             n = (org.netbeans.modules.schema2beans.BaseBean) this.getApplicationRef(i);
578             if (n != null)
579                 n.dump(str, indent + "\t"); // NOI18N
580
else
581                 str.append(indent+"\tnull"); // NOI18N
582
this.dumpAttributes(APPLICATION_REF, i, str, indent);
583         }
584
585         str.append(indent);
586         str.append("ResourceRef["+this.sizeResourceRef()+"]"); // NOI18N
587
for(int i=0; i<this.sizeResourceRef(); i++)
588         {
589             str.append(indent+"\t");
590             str.append("#"+i+":");
591             n = (org.netbeans.modules.schema2beans.BaseBean) this.getResourceRef(i);
592             if (n != null)
593                 n.dump(str, indent + "\t"); // NOI18N
594
else
595                 str.append(indent+"\tnull"); // NOI18N
596
this.dumpAttributes(RESOURCE_REF, i, str, indent);
597         }
598
599         str.append(indent);
600         str.append("SystemProperty["+this.sizeSystemProperty()+"]"); // NOI18N
601
for(int i=0; i<this.sizeSystemProperty(); i++)
602         {
603             str.append(indent+"\t");
604             str.append("#"+i+":");
605             n = (org.netbeans.modules.schema2beans.BaseBean) this.getSystemProperty(i);
606             if (n != null)
607                 n.dump(str, indent + "\t"); // NOI18N
608
else
609                 str.append(indent+"\tnull"); // NOI18N
610
this.dumpAttributes(SYSTEM_PROPERTY, i, str, indent);
611         }
612
613         str.append(indent);
614         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
615
for(int i=0; i<this.sizeElementProperty(); i++)
616         {
617             str.append(indent+"\t");
618             str.append("#"+i+":");
619             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
620             if (n != null)
621                 n.dump(str, indent + "\t"); // NOI18N
622
else
623                 str.append(indent+"\tnull"); // NOI18N
624
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
625         }
626
627     }
628     public String JavaDoc dumpBeanNode(){
629         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
630         str.append("Server\n"); // NOI18N
631
this.dump(str, "\n "); // NOI18N
632
return str.toString();
633     }}
634
635 // END_NOI18N
636

637
Popular Tags