KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

260     public String JavaDoc getName() {
261         return getAttributeValue(ServerTags.NAME);
262     }
263     /**
264     * Modify the Name of the Element ejb-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 ejb-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 Location of the Element ejb-module
280     * @return the Location of the Element ejb-module
281     */

282     public String JavaDoc getLocation() {
283         return getAttributeValue(ServerTags.LOCATION);
284     }
285     /**
286     * Modify the Location of the Element ejb-module
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 ejb-module
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 ejb-module
302     * @return the ObjectType of the Element ejb-module
303     */

304     public String JavaDoc getObjectType() {
305         return getAttributeValue(ServerTags.OBJECT_TYPE);
306     }
307     /**
308     * Modify the ObjectType of the Element ejb-module
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 ejb-module
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 ejb-module
330     * @return the Enabled of the Element ejb-module
331     */

332     public boolean isEnabled() {
333         return toBoolean(getAttributeValue(ServerTags.ENABLED));
334     }
335     /**
336     * Modify the Enabled of the Element ejb-module
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 ejb-module
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 ejb-module
358     * @return the Libraries of the Element ejb-module
359     */

360     public String JavaDoc getLibraries() {
361             return getAttributeValue(ServerTags.LIBRARIES);
362     }
363     /**
364     * Modify the Libraries of the Element ejb-module
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 ejb-module
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 ejb-module
380     * @return the AvailabilityEnabled of the Element ejb-module
381     */

382     public boolean isAvailabilityEnabled() {
383         return toBoolean(getAttributeValue(ServerTags.AVAILABILITY_ENABLED));
384     }
385     /**
386     * Modify the AvailabilityEnabled of the Element ejb-module
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 ejb-module
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 ejb-module
408     * @return the DirectoryDeployed of the Element ejb-module
409     */

410     public boolean isDirectoryDeployed() {
411         return toBoolean(getAttributeValue(ServerTags.DIRECTORY_DEPLOYED));
412     }
413     /**
414     * Modify the DirectoryDeployed of the Element ejb-module
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 ejb-module
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      * Create a new bean using it's default constructor.
436      * This does not add it to any bean graph.
437      */

438     public WebServiceEndpoint newWebServiceEndpoint() {
439         return new WebServiceEndpoint();
440     }
441
442     /**
443      * Create a new bean using it's default constructor.
444      * This does not add it to any bean graph.
445      */

446     public ElementProperty newElementProperty() {
447         return new ElementProperty();
448     }
449
450     /**
451     * get the xpath representation for this element
452     * returns something like abc[@name='value'] or abc
453     * depending on the type of the bean
454     */

455     protected String JavaDoc getRelativeXPath() {
456         String JavaDoc ret = null;
457         ret = "ejb-module" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ;
458         return (null != ret ? ret.trim() : null);
459     }
460
461     /*
462     * generic method to get default value from dtd
463     */

464     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
465         if(attr == null) return null;
466         attr = attr.trim();
467         if(attr.equals(ServerTags.OBJECT_TYPE)) return "user".trim();
468         if(attr.equals(ServerTags.ENABLED)) return "true".trim();
469         if(attr.equals(ServerTags.AVAILABILITY_ENABLED)) return "false".trim();
470         if(attr.equals(ServerTags.DIRECTORY_DEPLOYED)) return "false".trim();
471     return null;
472     }
473     //
474
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
475         comparators.add(c);
476     }
477
478     //
479
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
480         comparators.remove(c);
481     }
482     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
483     }
484
485     // Dump the content of this bean returning it as a String
486
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
487         String JavaDoc s;
488         Object JavaDoc o;
489         org.netbeans.modules.schema2beans.BaseBean n;
490         str.append(indent);
491         str.append("Description"); // NOI18N
492
str.append(indent+"\t"); // NOI18N
493
str.append("<"); // NOI18N
494
o = this.getDescription();
495         str.append((o==null?"null":o.toString().trim())); // NOI18N
496
str.append(">\n"); // NOI18N
497
this.dumpAttributes(DESCRIPTION, 0, str, indent);
498
499         str.append(indent);
500         str.append("WebServiceEndpoint["+this.sizeWebServiceEndpoint()+"]"); // NOI18N
501
for(int i=0; i<this.sizeWebServiceEndpoint(); i++)
502         {
503             str.append(indent+"\t");
504             str.append("#"+i+":");
505             n = (org.netbeans.modules.schema2beans.BaseBean) this.getWebServiceEndpoint(i);
506             if (n != null)
507                 n.dump(str, indent + "\t"); // NOI18N
508
else
509                 str.append(indent+"\tnull"); // NOI18N
510
this.dumpAttributes(WEB_SERVICE_ENDPOINT, i, str, indent);
511         }
512
513         str.append(indent);
514         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
515
for(int i=0; i<this.sizeElementProperty(); i++)
516         {
517             str.append(indent+"\t");
518             str.append("#"+i+":");
519             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
520             if (n != null)
521                 n.dump(str, indent + "\t"); // NOI18N
522
else
523                 str.append(indent+"\tnull"); // NOI18N
524
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
525         }
526
527     }
528     public String JavaDoc dumpBeanNode(){
529         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
530         str.append("EjbModule\n"); // NOI18N
531
this.dump(str, "\n "); // NOI18N
532
return str.toString();
533     }}
534
535 // END_NOI18N
536

537
Popular Tags