KickJava   Java API By Example, From Geeks To Geeks.

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


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 WebModule matches the DTD element web-module
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 WebModule 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 DESCRIPTION = "Description";
50     static public final String JavaDoc WEB_SERVICE_ENDPOINT = "WebServiceEndpoint";
51     static public final String JavaDoc ELEMENT_PROPERTY = "ElementProperty";
52
53     public WebModule() {
54         this(Common.USE_DEFAULT_VALUES);
55     }
56
57     public WebModule(int options)
58     {
59         super(comparators, runtimeVersion);
60         // Properties (see root bean comments for the bean graph)
61
initPropertyTables(3);
62         this.createProperty("description", DESCRIPTION,
63             Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY,
64             String JavaDoc.class);
65         this.createProperty("web-service-endpoint", WEB_SERVICE_ENDPOINT,
66             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
67             WebServiceEndpoint.class);
68         this.createAttribute(WEB_SERVICE_ENDPOINT, "name", "Name",
69                         AttrProp.CDATA | AttrProp.REQUIRED,
70                         null, null);
71         this.createAttribute(WEB_SERVICE_ENDPOINT, "monitoring", "Monitoring",
72                         AttrProp.CDATA,
73                         null, "OFF");
74         this.createAttribute(WEB_SERVICE_ENDPOINT, "max-history-size", "MaxHistorySize",
75                         AttrProp.CDATA,
76                         null, "25");
77         this.createAttribute(WEB_SERVICE_ENDPOINT, "jbi-enabled", "JbiEnabled",
78                         AttrProp.CDATA,
79                         null, "true");
80         this.createProperty("property", ELEMENT_PROPERTY,
81             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
82             ElementProperty.class);
83         this.createAttribute(ELEMENT_PROPERTY, "name", "Name",
84                         AttrProp.CDATA | AttrProp.REQUIRED,
85                         null, null);
86         this.createAttribute(ELEMENT_PROPERTY, "value", "Value",
87                         AttrProp.CDATA | AttrProp.REQUIRED,
88                         null, null);
89         this.initialize(options);
90     }
91
92     // Setting the default values of the properties
93
void initialize(int options) {
94
95     }
96
97     /**
98     * Return the Description of the Element web-module
99     */

100     public String JavaDoc getDescription() {
101         return (String JavaDoc) getValue(ServerTags.DESCRIPTION);
102     }
103     /**
104     * Modify the Description of the Element web-module
105     * @param v the new value
106     */

107     public void setDescription(String JavaDoc v){
108         setValue(ServerTags.DESCRIPTION, (null != v ? v.trim() : null));
109         }
110     // This attribute is an array, possibly empty
111
public void setWebServiceEndpoint(int index, WebServiceEndpoint value) {
112         this.setValue(WEB_SERVICE_ENDPOINT, index, value);
113     }
114
115     // Get Method
116
public WebServiceEndpoint getWebServiceEndpoint(int index) {
117         return (WebServiceEndpoint)this.getValue(WEB_SERVICE_ENDPOINT, index);
118     }
119
120     // This attribute is an array, possibly empty
121
public void setWebServiceEndpoint(WebServiceEndpoint[] value) {
122         this.setValue(WEB_SERVICE_ENDPOINT, value);
123     }
124
125     // Getter Method
126
public WebServiceEndpoint[] getWebServiceEndpoint() {
127         return (WebServiceEndpoint[])this.getValues(WEB_SERVICE_ENDPOINT);
128     }
129
130     // Return the number of properties
131
public int sizeWebServiceEndpoint() {
132         return this.size(WEB_SERVICE_ENDPOINT);
133     }
134
135     // Add a new element returning its index in the list
136
public int addWebServiceEndpoint(WebServiceEndpoint value)
137             throws ConfigException{
138         return addWebServiceEndpoint(value, true);
139     }
140
141     // Add a new element returning its index in the list with a boolean flag
142
public int addWebServiceEndpoint(WebServiceEndpoint value, boolean overwrite)
143             throws ConfigException{
144         WebServiceEndpoint old = getWebServiceEndpointByName(value.getName());
145         if(old != null) {
146             throw new ConfigException(StringManager.getManager(WebModule.class).getString("cannotAddDuplicate", "WebServiceEndpoint"));
147         }
148         return this.addValue(WEB_SERVICE_ENDPOINT, 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 removeWebServiceEndpoint(WebServiceEndpoint value){
156         return this.removeValue(WEB_SERVICE_ENDPOINT, 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 removeWebServiceEndpoint(WebServiceEndpoint value, boolean overwrite)
165             throws StaleWriteConfigException{
166         return this.removeValue(WEB_SERVICE_ENDPOINT, value, overwrite);
167     }
168
169     public WebServiceEndpoint getWebServiceEndpointByName(String JavaDoc id) {
170      if (null != id) { id = id.trim(); }
171     WebServiceEndpoint[] o = getWebServiceEndpoint();
172      if (o == null) return null;
173
174      for (int i=0; i < o.length; i++) {
175          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).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 setElementProperty(int index, ElementProperty value) {
185         this.setValue(ELEMENT_PROPERTY, index, value);
186     }
187
188     // Get Method
189
public ElementProperty getElementProperty(int index) {
190         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
191     }
192
193     // This attribute is an array, possibly empty
194
public void setElementProperty(ElementProperty[] value) {
195         this.setValue(ELEMENT_PROPERTY, value);
196     }
197
198     // Getter Method
199
public ElementProperty[] getElementProperty() {
200         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
201     }
202
203     // Return the number of properties
204
public int sizeElementProperty() {
205         return this.size(ELEMENT_PROPERTY);
206     }
207
208     // Add a new element returning its index in the list
209
public int addElementProperty(ElementProperty value)
210             throws ConfigException{
211         return addElementProperty(value, true);
212     }
213
214     // Add a new element returning its index in the list with a boolean flag
215
public int addElementProperty(ElementProperty value, boolean overwrite)
216             throws ConfigException{
217         ElementProperty old = getElementPropertyByName(value.getName());
218         if(old != null) {
219             throw new ConfigException(StringManager.getManager(WebModule.class).getString("cannotAddDuplicate", "ElementProperty"));
220         }
221         return this.addValue(ELEMENT_PROPERTY, value, overwrite);
222     }
223
224     //
225
// Remove an element using its reference
226
// Returns the index the element had in the list
227
//
228
public int removeElementProperty(ElementProperty value){
229         return this.removeValue(ELEMENT_PROPERTY, value);
230     }
231
232     //
233
// Remove an element using its reference
234
// Returns the index the element had in the list
235
// with boolean overwrite
236
//
237
public int removeElementProperty(ElementProperty value, boolean overwrite)
238             throws StaleWriteConfigException{
239         return this.removeValue(ELEMENT_PROPERTY, value, overwrite);
240     }
241
242     public ElementProperty getElementPropertyByName(String JavaDoc id) {
243      if (null != id) { id = id.trim(); }
244     ElementProperty[] o = getElementProperty();
245      if (o == null) return null;
246
247      for (int i=0; i < o.length; i++) {
248          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
249              return o[i];
250          }
251      }
252
253         return null;
254         
255     }
256     /**
257     * Getter for Name of the Element web-module
258     * @return the Name of the Element web-module
259     */

260     public String JavaDoc getName() {
261         return getAttributeValue(ServerTags.NAME);
262     }
263     /**
264     * Modify the Name of the Element web-module
265     * @param v the new value
266     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
267     */

268     public void setName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
269         setAttributeValue(ServerTags.NAME, v, overwrite);
270     }
271     /**
272     * Modify the Name of the Element web-module
273     * @param v the new value
274     */

275     public void setName(String JavaDoc v) {
276         setAttributeValue(ServerTags.NAME, v);
277     }
278     /**
279     * Getter for ContextRoot of the Element web-module
280     * @return the ContextRoot of the Element web-module
281     */

282     public String JavaDoc getContextRoot() {
283         return getAttributeValue(ServerTags.CONTEXT_ROOT);
284     }
285     /**
286     * Modify the ContextRoot of the Element web-module
287     * @param v the new value
288     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
289     */

290     public void setContextRoot(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
291         setAttributeValue(ServerTags.CONTEXT_ROOT, v, overwrite);
292     }
293     /**
294     * Modify the ContextRoot of the Element web-module
295     * @param v the new value
296     */

297     public void setContextRoot(String JavaDoc v) {
298         setAttributeValue(ServerTags.CONTEXT_ROOT, v);
299     }
300     /**
301     * Getter for Location of the Element web-module
302     * @return the Location of the Element web-module
303     */

304     public String JavaDoc getLocation() {
305         return getAttributeValue(ServerTags.LOCATION);
306     }
307     /**
308     * Modify the Location of the Element web-module
309     * @param v the new value
310     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
311     */

312     public void setLocation(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
313         setAttributeValue(ServerTags.LOCATION, v, overwrite);
314     }
315     /**
316     * Modify the Location of the Element web-module
317     * @param v the new value
318     */

319     public void setLocation(String JavaDoc v) {
320         setAttributeValue(ServerTags.LOCATION, v);
321     }
322     /**
323     * Getter for ObjectType of the Element web-module
324     * @return the ObjectType of the Element web-module
325     */

326     public String JavaDoc getObjectType() {
327         return getAttributeValue(ServerTags.OBJECT_TYPE);
328     }
329     /**
330     * Modify the ObjectType of the Element web-module
331     * @param v the new value
332     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
333     */

334     public void setObjectType(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
335         setAttributeValue(ServerTags.OBJECT_TYPE, v, overwrite);
336     }
337     /**
338     * Modify the ObjectType of the Element web-module
339     * @param v the new value
340     */

341     public void setObjectType(String JavaDoc v) {
342         setAttributeValue(ServerTags.OBJECT_TYPE, v);
343     }
344     /**
345     * Get the default value of ObjectType from dtd
346     */

347     public static String JavaDoc getDefaultObjectType() {
348         return "user".trim();
349     }
350     /**
351     * Getter for Enabled of the Element web-module
352     * @return the Enabled of the Element web-module
353     */

354     public boolean isEnabled() {
355         return toBoolean(getAttributeValue(ServerTags.ENABLED));
356     }
357     /**
358     * Modify the Enabled of the Element web-module
359     * @param v the new value
360     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
361     */

362     public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
363         setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite);
364     }
365     /**
366     * Modify the Enabled of the Element web-module
367     * @param v the new value
368     */

369     public void setEnabled(boolean v) {
370         setAttributeValue(ServerTags.ENABLED, ""+(v==true));
371     }
372     /**
373     * Get the default value of Enabled from dtd
374     */

375     public static String JavaDoc getDefaultEnabled() {
376         return "true".trim();
377     }
378     /**
379     * Getter for Libraries of the Element web-module
380     * @return the Libraries of the Element web-module
381     */

382     public String JavaDoc getLibraries() {
383             return getAttributeValue(ServerTags.LIBRARIES);
384     }
385     /**
386     * Modify the Libraries of the Element web-module
387     * @param v the new value
388     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
389     */

390     public void setLibraries(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
391         setAttributeValue(ServerTags.LIBRARIES, v, overwrite);
392     }
393     /**
394     * Modify the Libraries of the Element web-module
395     * @param v the new value
396     */

397     public void setLibraries(String JavaDoc v) {
398         setAttributeValue(ServerTags.LIBRARIES, v);
399     }
400     /**
401     * Getter for AvailabilityEnabled of the Element web-module
402     * @return the AvailabilityEnabled of the Element web-module
403     */

404     public boolean isAvailabilityEnabled() {
405         return toBoolean(getAttributeValue(ServerTags.AVAILABILITY_ENABLED));
406     }
407     /**
408     * Modify the AvailabilityEnabled of the Element web-module
409     * @param v the new value
410     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
411     */

412     public void setAvailabilityEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
413         setAttributeValue(ServerTags.AVAILABILITY_ENABLED, ""+(v==true), overwrite);
414     }
415     /**
416     * Modify the AvailabilityEnabled of the Element web-module
417     * @param v the new value
418     */

419     public void setAvailabilityEnabled(boolean v) {
420         setAttributeValue(ServerTags.AVAILABILITY_ENABLED, ""+(v==true));
421     }
422     /**
423     * Get the default value of AvailabilityEnabled from dtd
424     */

425     public static String JavaDoc getDefaultAvailabilityEnabled() {
426         return "false".trim();
427     }
428     /**
429     * Getter for DirectoryDeployed of the Element web-module
430     * @return the DirectoryDeployed of the Element web-module
431     */

432     public boolean isDirectoryDeployed() {
433         return toBoolean(getAttributeValue(ServerTags.DIRECTORY_DEPLOYED));
434     }
435     /**
436     * Modify the DirectoryDeployed of the Element web-module
437     * @param v the new value
438     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
439     */

440     public void setDirectoryDeployed(boolean v, boolean overwrite) throws StaleWriteConfigException {
441         setAttributeValue(ServerTags.DIRECTORY_DEPLOYED, ""+(v==true), overwrite);
442     }
443     /**
444     * Modify the DirectoryDeployed of the Element web-module
445     * @param v the new value
446     */

447     public void setDirectoryDeployed(boolean v) {
448         setAttributeValue(ServerTags.DIRECTORY_DEPLOYED, ""+(v==true));
449     }
450     /**
451     * Get the default value of DirectoryDeployed from dtd
452     */

453     public static String JavaDoc getDefaultDirectoryDeployed() {
454         return "false".trim();
455     }
456     /**
457      * Create a new bean using it's default constructor.
458      * This does not add it to any bean graph.
459      */

460     public WebServiceEndpoint newWebServiceEndpoint() {
461         return new WebServiceEndpoint();
462     }
463
464     /**
465      * Create a new bean using it's default constructor.
466      * This does not add it to any bean graph.
467      */

468     public ElementProperty newElementProperty() {
469         return new ElementProperty();
470     }
471
472     /**
473     * get the xpath representation for this element
474     * returns something like abc[@name='value'] or abc
475     * depending on the type of the bean
476     */

477     protected String JavaDoc getRelativeXPath() {
478         String JavaDoc ret = null;
479         ret = "web-module" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ;
480         return (null != ret ? ret.trim() : null);
481     }
482
483     /*
484     * generic method to get default value from dtd
485     */

486     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
487         if(attr == null) return null;
488         attr = attr.trim();
489         if(attr.equals(ServerTags.OBJECT_TYPE)) return "user".trim();
490         if(attr.equals(ServerTags.ENABLED)) return "true".trim();
491         if(attr.equals(ServerTags.AVAILABILITY_ENABLED)) return "false".trim();
492         if(attr.equals(ServerTags.DIRECTORY_DEPLOYED)) return "false".trim();
493     return null;
494     }
495     //
496
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
497         comparators.add(c);
498     }
499
500     //
501
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
502         comparators.remove(c);
503     }
504     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
505     }
506
507     // Dump the content of this bean returning it as a String
508
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
509         String JavaDoc s;
510         Object JavaDoc o;
511         org.netbeans.modules.schema2beans.BaseBean n;
512         str.append(indent);
513         str.append("Description"); // NOI18N
514
str.append(indent+"\t"); // NOI18N
515
str.append("<"); // NOI18N
516
o = this.getDescription();
517         str.append((o==null?"null":o.toString().trim())); // NOI18N
518
str.append(">\n"); // NOI18N
519
this.dumpAttributes(DESCRIPTION, 0, str, indent);
520
521         str.append(indent);
522         str.append("WebServiceEndpoint["+this.sizeWebServiceEndpoint()+"]"); // NOI18N
523
for(int i=0; i<this.sizeWebServiceEndpoint(); i++)
524         {
525             str.append(indent+"\t");
526             str.append("#"+i+":");
527             n = (org.netbeans.modules.schema2beans.BaseBean) this.getWebServiceEndpoint(i);
528             if (n != null)
529                 n.dump(str, indent + "\t"); // NOI18N
530
else
531                 str.append(indent+"\tnull"); // NOI18N
532
this.dumpAttributes(WEB_SERVICE_ENDPOINT, i, str, indent);
533         }
534
535         str.append(indent);
536         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
537
for(int i=0; i<this.sizeElementProperty(); i++)
538         {
539             str.append(indent+"\t");
540             str.append("#"+i+":");
541             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
542             if (n != null)
543                 n.dump(str, indent + "\t"); // NOI18N
544
else
545                 str.append(indent+"\tnull"); // NOI18N
546
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
547         }
548
549     }
550     public String JavaDoc dumpBeanNode(){
551         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
552         str.append("WebModule\n"); // NOI18N
553
this.dump(str, "\n "); // NOI18N
554
return str.toString();
555     }}
556
557 // END_NOI18N
558

559
Popular Tags