KickJava   Java API By Example, From Geeks To Geeks.

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


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 J2eeApplication matches the DTD element j2ee-application
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 J2eeApplication 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 J2eeApplication() {
54         this(Common.USE_DEFAULT_VALUES);
55     }
56
57     public J2eeApplication(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 j2ee-application
99     */

100     public String JavaDoc getDescription() {
101         return (String JavaDoc) getValue(ServerTags.DESCRIPTION);
102     }
103     /**
104     * Modify the Description of the Element j2ee-application
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(J2eeApplication.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(J2eeApplication.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 j2ee-application
258     * @return the Name of the Element j2ee-application
259     */

260     public String JavaDoc getName() {
261         return getAttributeValue(ServerTags.NAME);
262     }
263     /**
264     * Modify the Name of the Element j2ee-application
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 j2ee-application
273     * @param v the new value
274     */

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

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

290     public void setLocation(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
291         setAttributeValue(ServerTags.LOCATION, v, overwrite);
292     }
293     /**
294     * Modify the Location of the Element j2ee-application
295     * @param v the new value
296     */

297     public void setLocation(String JavaDoc v) {
298         setAttributeValue(ServerTags.LOCATION, v);
299     }
300     /**
301     * Getter for ObjectType of the Element j2ee-application
302     * @return the ObjectType of the Element j2ee-application
303     */

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

312     public void setObjectType(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
313         setAttributeValue(ServerTags.OBJECT_TYPE, v, overwrite);
314     }
315     /**
316     * Modify the ObjectType of the Element j2ee-application
317     * @param v the new value
318     */

319     public void setObjectType(String JavaDoc v) {
320         setAttributeValue(ServerTags.OBJECT_TYPE, v);
321     }
322     /**
323     * Get the default value of ObjectType from dtd
324     */

325     public static String JavaDoc getDefaultObjectType() {
326         return "user".trim();
327     }
328     /**
329     * Getter for Enabled of the Element j2ee-application
330     * @return the Enabled of the Element j2ee-application
331     */

332     public boolean isEnabled() {
333         return toBoolean(getAttributeValue(ServerTags.ENABLED));
334     }
335     /**
336     * Modify the Enabled of the Element j2ee-application
337     * @param v the new value
338     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
339     */

340     public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
341         setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite);
342     }
343     /**
344     * Modify the Enabled of the Element j2ee-application
345     * @param v the new value
346     */

347     public void setEnabled(boolean v) {
348         setAttributeValue(ServerTags.ENABLED, ""+(v==true));
349     }
350     /**
351     * Get the default value of Enabled from dtd
352     */

353     public static String JavaDoc getDefaultEnabled() {
354         return "true".trim();
355     }
356     /**
357     * Getter for Libraries of the Element j2ee-application
358     * @return the Libraries of the Element j2ee-application
359     */

360     public String JavaDoc getLibraries() {
361             return getAttributeValue(ServerTags.LIBRARIES);
362     }
363     /**
364     * Modify the Libraries of the Element j2ee-application
365     * @param v the new value
366     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
367     */

368     public void setLibraries(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
369         setAttributeValue(ServerTags.LIBRARIES, v, overwrite);
370     }
371     /**
372     * Modify the Libraries of the Element j2ee-application
373     * @param v the new value
374     */

375     public void setLibraries(String JavaDoc v) {
376         setAttributeValue(ServerTags.LIBRARIES, v);
377     }
378     /**
379     * Getter for AvailabilityEnabled of the Element j2ee-application
380     * @return the AvailabilityEnabled of the Element j2ee-application
381     */

382     public boolean isAvailabilityEnabled() {
383         return toBoolean(getAttributeValue(ServerTags.AVAILABILITY_ENABLED));
384     }
385     /**
386     * Modify the AvailabilityEnabled of the Element j2ee-application
387     * @param v the new value
388     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
389     */

390     public void setAvailabilityEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
391         setAttributeValue(ServerTags.AVAILABILITY_ENABLED, ""+(v==true), overwrite);
392     }
393     /**
394     * Modify the AvailabilityEnabled of the Element j2ee-application
395     * @param v the new value
396     */

397     public void setAvailabilityEnabled(boolean v) {
398         setAttributeValue(ServerTags.AVAILABILITY_ENABLED, ""+(v==true));
399     }
400     /**
401     * Get the default value of AvailabilityEnabled from dtd
402     */

403     public static String JavaDoc getDefaultAvailabilityEnabled() {
404         return "false".trim();
405     }
406     /**
407     * Getter for DirectoryDeployed of the Element j2ee-application
408     * @return the DirectoryDeployed of the Element j2ee-application
409     */

410     public boolean isDirectoryDeployed() {
411         return toBoolean(getAttributeValue(ServerTags.DIRECTORY_DEPLOYED));
412     }
413     /**
414     * Modify the DirectoryDeployed of the Element j2ee-application
415     * @param v the new value
416     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
417     */

418     public void setDirectoryDeployed(boolean v, boolean overwrite) throws StaleWriteConfigException {
419         setAttributeValue(ServerTags.DIRECTORY_DEPLOYED, ""+(v==true), overwrite);
420     }
421     /**
422     * Modify the DirectoryDeployed of the Element j2ee-application
423     * @param v the new value
424     */

425     public void setDirectoryDeployed(boolean v) {
426         setAttributeValue(ServerTags.DIRECTORY_DEPLOYED, ""+(v==true));
427     }
428     /**
429     * Get the default value of DirectoryDeployed from dtd
430     */

431     public static String JavaDoc getDefaultDirectoryDeployed() {
432         return "false".trim();
433     }
434     /**
435     * Getter for JavaWebStartEnabled of the Element j2ee-application
436     * @return the JavaWebStartEnabled of the Element j2ee-application
437     */

438     public boolean isJavaWebStartEnabled() {
439         return toBoolean(getAttributeValue(ServerTags.JAVA_WEB_START_ENABLED));
440     }
441     /**
442     * Modify the JavaWebStartEnabled of the Element j2ee-application
443     * @param v the new value
444     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
445     */

446     public void setJavaWebStartEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
447         setAttributeValue(ServerTags.JAVA_WEB_START_ENABLED, ""+(v==true), overwrite);
448     }
449     /**
450     * Modify the JavaWebStartEnabled of the Element j2ee-application
451     * @param v the new value
452     */

453     public void setJavaWebStartEnabled(boolean v) {
454         setAttributeValue(ServerTags.JAVA_WEB_START_ENABLED, ""+(v==true));
455     }
456     /**
457     * Get the default value of JavaWebStartEnabled from dtd
458     */

459     public static String JavaDoc getDefaultJavaWebStartEnabled() {
460         return "true".trim();
461     }
462     /**
463      * Create a new bean using it's default constructor.
464      * This does not add it to any bean graph.
465      */

466     public WebServiceEndpoint newWebServiceEndpoint() {
467         return new WebServiceEndpoint();
468     }
469
470     /**
471      * Create a new bean using it's default constructor.
472      * This does not add it to any bean graph.
473      */

474     public ElementProperty newElementProperty() {
475         return new ElementProperty();
476     }
477
478     /**
479     * get the xpath representation for this element
480     * returns something like abc[@name='value'] or abc
481     * depending on the type of the bean
482     */

483     protected String JavaDoc getRelativeXPath() {
484         String JavaDoc ret = null;
485         ret = "j2ee-application" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ;
486         return (null != ret ? ret.trim() : null);
487     }
488
489     /*
490     * generic method to get default value from dtd
491     */

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

566
Popular Tags