KickJava   Java API By Example, From Geeks To Geeks.

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


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 JmsService matches the DTD element jms-service
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 JmsService 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 JMS_HOST = "JmsHost";
50     static public final String JavaDoc ELEMENT_PROPERTY = "ElementProperty";
51
52     public JmsService() {
53         this(Common.USE_DEFAULT_VALUES);
54     }
55
56     public JmsService(int options)
57     {
58         super(comparators, runtimeVersion);
59         // Properties (see root bean comments for the bean graph)
60
initPropertyTables(2);
61         this.createProperty("jms-host", JMS_HOST,
62             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
63             JmsHost.class);
64         this.createAttribute(JMS_HOST, "name", "Name",
65                         AttrProp.CDATA | AttrProp.REQUIRED,
66                         null, null);
67         this.createAttribute(JMS_HOST, "host", "Host",
68                         AttrProp.CDATA | AttrProp.IMPLIED,
69                         null, null);
70         this.createAttribute(JMS_HOST, "port", "Port",
71                         AttrProp.CDATA,
72                         null, "7676");
73         this.createAttribute(JMS_HOST, "admin-user-name", "AdminUserName",
74                         AttrProp.CDATA,
75                         null, "admin");
76         this.createAttribute(JMS_HOST, "admin-password", "AdminPassword",
77                         AttrProp.CDATA,
78                         null, "admin");
79         this.createProperty("property", ELEMENT_PROPERTY,
80             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
81             ElementProperty.class);
82         this.createAttribute(ELEMENT_PROPERTY, "name", "Name",
83                         AttrProp.CDATA | AttrProp.REQUIRED,
84                         null, null);
85         this.createAttribute(ELEMENT_PROPERTY, "value", "Value",
86                         AttrProp.CDATA | AttrProp.REQUIRED,
87                         null, null);
88         this.initialize(options);
89     }
90
91     // Setting the default values of the properties
92
void initialize(int options) {
93
94     }
95
96     // This attribute is an array, possibly empty
97
public void setJmsHost(int index, JmsHost value) {
98         this.setValue(JMS_HOST, index, value);
99     }
100
101     // Get Method
102
public JmsHost getJmsHost(int index) {
103         return (JmsHost)this.getValue(JMS_HOST, index);
104     }
105
106     // This attribute is an array, possibly empty
107
public void setJmsHost(JmsHost[] value) {
108         this.setValue(JMS_HOST, value);
109     }
110
111     // Getter Method
112
public JmsHost[] getJmsHost() {
113         return (JmsHost[])this.getValues(JMS_HOST);
114     }
115
116     // Return the number of properties
117
public int sizeJmsHost() {
118         return this.size(JMS_HOST);
119     }
120
121     // Add a new element returning its index in the list
122
public int addJmsHost(JmsHost value)
123             throws ConfigException{
124         return addJmsHost(value, true);
125     }
126
127     // Add a new element returning its index in the list with a boolean flag
128
public int addJmsHost(JmsHost value, boolean overwrite)
129             throws ConfigException{
130         JmsHost old = getJmsHostByName(value.getName());
131         if(old != null) {
132             throw new ConfigException(StringManager.getManager(JmsService.class).getString("cannotAddDuplicate", "JmsHost"));
133         }
134         return this.addValue(JMS_HOST, value, overwrite);
135     }
136
137     //
138
// Remove an element using its reference
139
// Returns the index the element had in the list
140
//
141
public int removeJmsHost(JmsHost value){
142         return this.removeValue(JMS_HOST, value);
143     }
144
145     //
146
// Remove an element using its reference
147
// Returns the index the element had in the list
148
// with boolean overwrite
149
//
150
public int removeJmsHost(JmsHost value, boolean overwrite)
151             throws StaleWriteConfigException{
152         return this.removeValue(JMS_HOST, value, overwrite);
153     }
154
155     public JmsHost getJmsHostByName(String JavaDoc id) {
156      if (null != id) { id = id.trim(); }
157     JmsHost[] o = getJmsHost();
158      if (o == null) return null;
159
160      for (int i=0; i < o.length; i++) {
161          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
162              return o[i];
163          }
164      }
165
166         return null;
167         
168     }
169     // This attribute is an array, possibly empty
170
public void setElementProperty(int index, ElementProperty value) {
171         this.setValue(ELEMENT_PROPERTY, index, value);
172     }
173
174     // Get Method
175
public ElementProperty getElementProperty(int index) {
176         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
177     }
178
179     // This attribute is an array, possibly empty
180
public void setElementProperty(ElementProperty[] value) {
181         this.setValue(ELEMENT_PROPERTY, value);
182     }
183
184     // Getter Method
185
public ElementProperty[] getElementProperty() {
186         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
187     }
188
189     // Return the number of properties
190
public int sizeElementProperty() {
191         return this.size(ELEMENT_PROPERTY);
192     }
193
194     // Add a new element returning its index in the list
195
public int addElementProperty(ElementProperty value)
196             throws ConfigException{
197         return addElementProperty(value, true);
198     }
199
200     // Add a new element returning its index in the list with a boolean flag
201
public int addElementProperty(ElementProperty value, boolean overwrite)
202             throws ConfigException{
203         ElementProperty old = getElementPropertyByName(value.getName());
204         if(old != null) {
205             throw new ConfigException(StringManager.getManager(JmsService.class).getString("cannotAddDuplicate", "ElementProperty"));
206         }
207         return this.addValue(ELEMENT_PROPERTY, value, overwrite);
208     }
209
210     //
211
// Remove an element using its reference
212
// Returns the index the element had in the list
213
//
214
public int removeElementProperty(ElementProperty value){
215         return this.removeValue(ELEMENT_PROPERTY, value);
216     }
217
218     //
219
// Remove an element using its reference
220
// Returns the index the element had in the list
221
// with boolean overwrite
222
//
223
public int removeElementProperty(ElementProperty value, boolean overwrite)
224             throws StaleWriteConfigException{
225         return this.removeValue(ELEMENT_PROPERTY, value, overwrite);
226     }
227
228     public ElementProperty getElementPropertyByName(String JavaDoc id) {
229      if (null != id) { id = id.trim(); }
230     ElementProperty[] o = getElementProperty();
231      if (o == null) return null;
232
233      for (int i=0; i < o.length; i++) {
234          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
235              return o[i];
236          }
237      }
238
239         return null;
240         
241     }
242     /**
243     * Getter for InitTimeoutInSeconds of the Element jms-service
244     * @return the InitTimeoutInSeconds of the Element jms-service
245     */

246     public String JavaDoc getInitTimeoutInSeconds() {
247         return getAttributeValue(ServerTags.INIT_TIMEOUT_IN_SECONDS);
248     }
249     /**
250     * Modify the InitTimeoutInSeconds of the Element jms-service
251     * @param v the new value
252     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
253     */

254     public void setInitTimeoutInSeconds(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
255         setAttributeValue(ServerTags.INIT_TIMEOUT_IN_SECONDS, v, overwrite);
256     }
257     /**
258     * Modify the InitTimeoutInSeconds of the Element jms-service
259     * @param v the new value
260     */

261     public void setInitTimeoutInSeconds(String JavaDoc v) {
262         setAttributeValue(ServerTags.INIT_TIMEOUT_IN_SECONDS, v);
263     }
264     /**
265     * Get the default value of InitTimeoutInSeconds from dtd
266     */

267     public static String JavaDoc getDefaultInitTimeoutInSeconds() {
268         return "60".trim();
269     }
270     /**
271     * Getter for Type of the Element jms-service
272     * @return the Type of the Element jms-service
273     */

274     public String JavaDoc getType() {
275         return getAttributeValue(ServerTags.TYPE);
276     }
277     /**
278     * Modify the Type of the Element jms-service
279     * @param v the new value
280     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
281     */

282     public void setType(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
283         setAttributeValue(ServerTags.TYPE, v, overwrite);
284     }
285     /**
286     * Modify the Type of the Element jms-service
287     * @param v the new value
288     */

289     public void setType(String JavaDoc v) {
290         setAttributeValue(ServerTags.TYPE, v);
291     }
292     /**
293     * Getter for StartArgs of the Element jms-service
294     * @return the StartArgs of the Element jms-service
295     */

296     public String JavaDoc getStartArgs() {
297             return getAttributeValue(ServerTags.START_ARGS);
298     }
299     /**
300     * Modify the StartArgs of the Element jms-service
301     * @param v the new value
302     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
303     */

304     public void setStartArgs(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
305         setAttributeValue(ServerTags.START_ARGS, v, overwrite);
306     }
307     /**
308     * Modify the StartArgs of the Element jms-service
309     * @param v the new value
310     */

311     public void setStartArgs(String JavaDoc v) {
312         setAttributeValue(ServerTags.START_ARGS, v);
313     }
314     /**
315     * Getter for DefaultJmsHost of the Element jms-service
316     * @return the DefaultJmsHost of the Element jms-service
317     */

318     public String JavaDoc getDefaultJmsHost() {
319             return getAttributeValue(ServerTags.DEFAULT_JMS_HOST);
320     }
321     /**
322     * Modify the DefaultJmsHost of the Element jms-service
323     * @param v the new value
324     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
325     */

326     public void setDefaultJmsHost(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
327         setAttributeValue(ServerTags.DEFAULT_JMS_HOST, v, overwrite);
328     }
329     /**
330     * Modify the DefaultJmsHost of the Element jms-service
331     * @param v the new value
332     */

333     public void setDefaultJmsHost(String JavaDoc v) {
334         setAttributeValue(ServerTags.DEFAULT_JMS_HOST, v);
335     }
336     /**
337     * Getter for ReconnectIntervalInSeconds of the Element jms-service
338     * @return the ReconnectIntervalInSeconds of the Element jms-service
339     */

340     public String JavaDoc getReconnectIntervalInSeconds() {
341         return getAttributeValue(ServerTags.RECONNECT_INTERVAL_IN_SECONDS);
342     }
343     /**
344     * Modify the ReconnectIntervalInSeconds of the Element jms-service
345     * @param v the new value
346     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
347     */

348     public void setReconnectIntervalInSeconds(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
349         setAttributeValue(ServerTags.RECONNECT_INTERVAL_IN_SECONDS, v, overwrite);
350     }
351     /**
352     * Modify the ReconnectIntervalInSeconds of the Element jms-service
353     * @param v the new value
354     */

355     public void setReconnectIntervalInSeconds(String JavaDoc v) {
356         setAttributeValue(ServerTags.RECONNECT_INTERVAL_IN_SECONDS, v);
357     }
358     /**
359     * Get the default value of ReconnectIntervalInSeconds from dtd
360     */

361     public static String JavaDoc getDefaultReconnectIntervalInSeconds() {
362         return "5".trim();
363     }
364     /**
365     * Getter for ReconnectAttempts of the Element jms-service
366     * @return the ReconnectAttempts of the Element jms-service
367     */

368     public String JavaDoc getReconnectAttempts() {
369         return getAttributeValue(ServerTags.RECONNECT_ATTEMPTS);
370     }
371     /**
372     * Modify the ReconnectAttempts of the Element jms-service
373     * @param v the new value
374     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
375     */

376     public void setReconnectAttempts(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
377         setAttributeValue(ServerTags.RECONNECT_ATTEMPTS, v, overwrite);
378     }
379     /**
380     * Modify the ReconnectAttempts of the Element jms-service
381     * @param v the new value
382     */

383     public void setReconnectAttempts(String JavaDoc v) {
384         setAttributeValue(ServerTags.RECONNECT_ATTEMPTS, v);
385     }
386     /**
387     * Get the default value of ReconnectAttempts from dtd
388     */

389     public static String JavaDoc getDefaultReconnectAttempts() {
390         return "3".trim();
391     }
392     /**
393     * Getter for ReconnectEnabled of the Element jms-service
394     * @return the ReconnectEnabled of the Element jms-service
395     */

396     public boolean isReconnectEnabled() {
397         return toBoolean(getAttributeValue(ServerTags.RECONNECT_ENABLED));
398     }
399     /**
400     * Modify the ReconnectEnabled of the Element jms-service
401     * @param v the new value
402     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
403     */

404     public void setReconnectEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
405         setAttributeValue(ServerTags.RECONNECT_ENABLED, ""+(v==true), overwrite);
406     }
407     /**
408     * Modify the ReconnectEnabled of the Element jms-service
409     * @param v the new value
410     */

411     public void setReconnectEnabled(boolean v) {
412         setAttributeValue(ServerTags.RECONNECT_ENABLED, ""+(v==true));
413     }
414     /**
415     * Get the default value of ReconnectEnabled from dtd
416     */

417     public static String JavaDoc getDefaultReconnectEnabled() {
418         return "true".trim();
419     }
420     /**
421     * Getter for AddresslistBehavior of the Element jms-service
422     * @return the AddresslistBehavior of the Element jms-service
423     */

424     public String JavaDoc getAddresslistBehavior() {
425         return getAttributeValue(ServerTags.ADDRESSLIST_BEHAVIOR);
426     }
427     /**
428     * Modify the AddresslistBehavior of the Element jms-service
429     * @param v the new value
430     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
431     */

432     public void setAddresslistBehavior(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
433         setAttributeValue(ServerTags.ADDRESSLIST_BEHAVIOR, v, overwrite);
434     }
435     /**
436     * Modify the AddresslistBehavior of the Element jms-service
437     * @param v the new value
438     */

439     public void setAddresslistBehavior(String JavaDoc v) {
440         setAttributeValue(ServerTags.ADDRESSLIST_BEHAVIOR, v);
441     }
442     /**
443     * Get the default value of AddresslistBehavior from dtd
444     */

445     public static String JavaDoc getDefaultAddresslistBehavior() {
446         return "random".trim();
447     }
448     /**
449     * Getter for AddresslistIterations of the Element jms-service
450     * @return the AddresslistIterations of the Element jms-service
451     */

452     public String JavaDoc getAddresslistIterations() {
453         return getAttributeValue(ServerTags.ADDRESSLIST_ITERATIONS);
454     }
455     /**
456     * Modify the AddresslistIterations of the Element jms-service
457     * @param v the new value
458     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
459     */

460     public void setAddresslistIterations(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
461         setAttributeValue(ServerTags.ADDRESSLIST_ITERATIONS, v, overwrite);
462     }
463     /**
464     * Modify the AddresslistIterations of the Element jms-service
465     * @param v the new value
466     */

467     public void setAddresslistIterations(String JavaDoc v) {
468         setAttributeValue(ServerTags.ADDRESSLIST_ITERATIONS, v);
469     }
470     /**
471     * Get the default value of AddresslistIterations from dtd
472     */

473     public static String JavaDoc getDefaultAddresslistIterations() {
474         return "3".trim();
475     }
476     /**
477     * Getter for MqScheme of the Element jms-service
478     * @return the MqScheme of the Element jms-service
479     */

480     public String JavaDoc getMqScheme() {
481             return getAttributeValue(ServerTags.MQ_SCHEME);
482     }
483     /**
484     * Modify the MqScheme of the Element jms-service
485     * @param v the new value
486     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
487     */

488     public void setMqScheme(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
489         setAttributeValue(ServerTags.MQ_SCHEME, v, overwrite);
490     }
491     /**
492     * Modify the MqScheme of the Element jms-service
493     * @param v the new value
494     */

495     public void setMqScheme(String JavaDoc v) {
496         setAttributeValue(ServerTags.MQ_SCHEME, v);
497     }
498     /**
499     * Getter for MqService of the Element jms-service
500     * @return the MqService of the Element jms-service
501     */

502     public String JavaDoc getMqService() {
503             return getAttributeValue(ServerTags.MQ_SERVICE);
504     }
505     /**
506     * Modify the MqService of the Element jms-service
507     * @param v the new value
508     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
509     */

510     public void setMqService(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
511         setAttributeValue(ServerTags.MQ_SERVICE, v, overwrite);
512     }
513     /**
514     * Modify the MqService of the Element jms-service
515     * @param v the new value
516     */

517     public void setMqService(String JavaDoc v) {
518         setAttributeValue(ServerTags.MQ_SERVICE, v);
519     }
520     /**
521      * Create a new bean using it's default constructor.
522      * This does not add it to any bean graph.
523      */

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

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

541     protected String JavaDoc getRelativeXPath() {
542         String JavaDoc ret = null;
543         ret = "jms-service";
544         return (null != ret ? ret.trim() : null);
545     }
546
547     /*
548     * generic method to get default value from dtd
549     */

550     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
551         if(attr == null) return null;
552         attr = attr.trim();
553         if(attr.equals(ServerTags.INIT_TIMEOUT_IN_SECONDS)) return "60".trim();
554         if(attr.equals(ServerTags.RECONNECT_INTERVAL_IN_SECONDS)) return "5".trim();
555         if(attr.equals(ServerTags.RECONNECT_ATTEMPTS)) return "3".trim();
556         if(attr.equals(ServerTags.RECONNECT_ENABLED)) return "true".trim();
557         if(attr.equals(ServerTags.ADDRESSLIST_BEHAVIOR)) return "random".trim();
558         if(attr.equals(ServerTags.ADDRESSLIST_ITERATIONS)) return "3".trim();
559     return null;
560     }
561     //
562
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
563         comparators.add(c);
564     }
565
566     //
567
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
568         comparators.remove(c);
569     }
570     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
571     }
572
573     // Dump the content of this bean returning it as a String
574
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
575         String JavaDoc s;
576         Object JavaDoc o;
577         org.netbeans.modules.schema2beans.BaseBean n;
578         str.append(indent);
579         str.append("JmsHost["+this.sizeJmsHost()+"]"); // NOI18N
580
for(int i=0; i<this.sizeJmsHost(); i++)
581         {
582             str.append(indent+"\t");
583             str.append("#"+i+":");
584             n = (org.netbeans.modules.schema2beans.BaseBean) this.getJmsHost(i);
585             if (n != null)
586                 n.dump(str, indent + "\t"); // NOI18N
587
else
588                 str.append(indent+"\tnull"); // NOI18N
589
this.dumpAttributes(JMS_HOST, i, str, indent);
590         }
591
592         str.append(indent);
593         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
594
for(int i=0; i<this.sizeElementProperty(); i++)
595         {
596             str.append(indent+"\t");
597             str.append("#"+i+":");
598             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
599             if (n != null)
600                 n.dump(str, indent + "\t"); // NOI18N
601
else
602                 str.append(indent+"\tnull"); // NOI18N
603
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
604         }
605
606     }
607     public String JavaDoc dumpBeanNode(){
608         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
609         str.append("JmsService\n"); // NOI18N
610
this.dump(str, "\n "); // NOI18N
611
return str.toString();
612     }}
613
614 // END_NOI18N
615

616
Popular Tags