KickJava   Java API By Example, From Geeks To Geeks.

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


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 EjbContainer matches the DTD element ejb-container
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 EjbContainer 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 EJB_TIMER_SERVICE = "EjbTimerService";
50     static public final String JavaDoc ELEMENT_PROPERTY = "ElementProperty";
51
52     public EjbContainer() {
53         this(Common.USE_DEFAULT_VALUES);
54     }
55
56     public EjbContainer(int options)
57     {
58         super(comparators, runtimeVersion);
59         // Properties (see root bean comments for the bean graph)
60
initPropertyTables(2);
61         this.createProperty("ejb-timer-service", EJB_TIMER_SERVICE,
62             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
63             EjbTimerService.class);
64         this.createAttribute(EJB_TIMER_SERVICE, "minimum-delivery-interval-in-millis", "MinimumDeliveryIntervalInMillis",
65                         AttrProp.CDATA,
66                         null, "7000");
67         this.createAttribute(EJB_TIMER_SERVICE, "max-redeliveries", "MaxRedeliveries",
68                         AttrProp.CDATA,
69                         null, "1");
70         this.createAttribute(EJB_TIMER_SERVICE, "timer-datasource", "TimerDatasource",
71                         AttrProp.CDATA | AttrProp.IMPLIED,
72                         null, null);
73         this.createAttribute(EJB_TIMER_SERVICE, "redelivery-interval-internal-in-millis", "RedeliveryIntervalInternalInMillis",
74                         AttrProp.CDATA,
75                         null, "5000");
76         this.createProperty("property", ELEMENT_PROPERTY,
77             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
78             ElementProperty.class);
79         this.createAttribute(ELEMENT_PROPERTY, "name", "Name",
80                         AttrProp.CDATA | AttrProp.REQUIRED,
81                         null, null);
82         this.createAttribute(ELEMENT_PROPERTY, "value", "Value",
83                         AttrProp.CDATA | AttrProp.REQUIRED,
84                         null, null);
85         this.initialize(options);
86     }
87
88     // Setting the default values of the properties
89
void initialize(int options) {
90
91     }
92
93     // This attribute is optional
94
public void setEjbTimerService(EjbTimerService value) {
95         this.setValue(EJB_TIMER_SERVICE, value);
96     }
97
98     // Get Method
99
public EjbTimerService getEjbTimerService() {
100         return (EjbTimerService)this.getValue(EJB_TIMER_SERVICE);
101     }
102
103     // This attribute is an array, possibly empty
104
public void setElementProperty(int index, ElementProperty value) {
105         this.setValue(ELEMENT_PROPERTY, index, value);
106     }
107
108     // Get Method
109
public ElementProperty getElementProperty(int index) {
110         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
111     }
112
113     // This attribute is an array, possibly empty
114
public void setElementProperty(ElementProperty[] value) {
115         this.setValue(ELEMENT_PROPERTY, value);
116     }
117
118     // Getter Method
119
public ElementProperty[] getElementProperty() {
120         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
121     }
122
123     // Return the number of properties
124
public int sizeElementProperty() {
125         return this.size(ELEMENT_PROPERTY);
126     }
127
128     // Add a new element returning its index in the list
129
public int addElementProperty(ElementProperty value)
130             throws ConfigException{
131         return addElementProperty(value, true);
132     }
133
134     // Add a new element returning its index in the list with a boolean flag
135
public int addElementProperty(ElementProperty value, boolean overwrite)
136             throws ConfigException{
137         ElementProperty old = getElementPropertyByName(value.getName());
138         if(old != null) {
139             throw new ConfigException(StringManager.getManager(EjbContainer.class).getString("cannotAddDuplicate", "ElementProperty"));
140         }
141         return this.addValue(ELEMENT_PROPERTY, value, overwrite);
142     }
143
144     //
145
// Remove an element using its reference
146
// Returns the index the element had in the list
147
//
148
public int removeElementProperty(ElementProperty value){
149         return this.removeValue(ELEMENT_PROPERTY, value);
150     }
151
152     //
153
// Remove an element using its reference
154
// Returns the index the element had in the list
155
// with boolean overwrite
156
//
157
public int removeElementProperty(ElementProperty value, boolean overwrite)
158             throws StaleWriteConfigException{
159         return this.removeValue(ELEMENT_PROPERTY, value, overwrite);
160     }
161
162     public ElementProperty getElementPropertyByName(String JavaDoc id) {
163      if (null != id) { id = id.trim(); }
164     ElementProperty[] o = getElementProperty();
165      if (o == null) return null;
166
167      for (int i=0; i < o.length; i++) {
168          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
169              return o[i];
170          }
171      }
172
173         return null;
174         
175     }
176     /**
177     * Getter for SteadyPoolSize of the Element ejb-container
178     * @return the SteadyPoolSize of the Element ejb-container
179     */

180     public String JavaDoc getSteadyPoolSize() {
181         return getAttributeValue(ServerTags.STEADY_POOL_SIZE);
182     }
183     /**
184     * Modify the SteadyPoolSize of the Element ejb-container
185     * @param v the new value
186     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
187     */

188     public void setSteadyPoolSize(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
189         setAttributeValue(ServerTags.STEADY_POOL_SIZE, v, overwrite);
190     }
191     /**
192     * Modify the SteadyPoolSize of the Element ejb-container
193     * @param v the new value
194     */

195     public void setSteadyPoolSize(String JavaDoc v) {
196         setAttributeValue(ServerTags.STEADY_POOL_SIZE, v);
197     }
198     /**
199     * Get the default value of SteadyPoolSize from dtd
200     */

201     public static String JavaDoc getDefaultSteadyPoolSize() {
202         return "32".trim();
203     }
204     /**
205     * Getter for PoolResizeQuantity of the Element ejb-container
206     * @return the PoolResizeQuantity of the Element ejb-container
207     */

208     public String JavaDoc getPoolResizeQuantity() {
209         return getAttributeValue(ServerTags.POOL_RESIZE_QUANTITY);
210     }
211     /**
212     * Modify the PoolResizeQuantity of the Element ejb-container
213     * @param v the new value
214     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
215     */

216     public void setPoolResizeQuantity(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
217         setAttributeValue(ServerTags.POOL_RESIZE_QUANTITY, v, overwrite);
218     }
219     /**
220     * Modify the PoolResizeQuantity of the Element ejb-container
221     * @param v the new value
222     */

223     public void setPoolResizeQuantity(String JavaDoc v) {
224         setAttributeValue(ServerTags.POOL_RESIZE_QUANTITY, v);
225     }
226     /**
227     * Get the default value of PoolResizeQuantity from dtd
228     */

229     public static String JavaDoc getDefaultPoolResizeQuantity() {
230         return "16".trim();
231     }
232     /**
233     * Getter for MaxPoolSize of the Element ejb-container
234     * @return the MaxPoolSize of the Element ejb-container
235     */

236     public String JavaDoc getMaxPoolSize() {
237         return getAttributeValue(ServerTags.MAX_POOL_SIZE);
238     }
239     /**
240     * Modify the MaxPoolSize of the Element ejb-container
241     * @param v the new value
242     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
243     */

244     public void setMaxPoolSize(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
245         setAttributeValue(ServerTags.MAX_POOL_SIZE, v, overwrite);
246     }
247     /**
248     * Modify the MaxPoolSize of the Element ejb-container
249     * @param v the new value
250     */

251     public void setMaxPoolSize(String JavaDoc v) {
252         setAttributeValue(ServerTags.MAX_POOL_SIZE, v);
253     }
254     /**
255     * Get the default value of MaxPoolSize from dtd
256     */

257     public static String JavaDoc getDefaultMaxPoolSize() {
258         return "64".trim();
259     }
260     /**
261     * Getter for CacheResizeQuantity of the Element ejb-container
262     * @return the CacheResizeQuantity of the Element ejb-container
263     */

264     public String JavaDoc getCacheResizeQuantity() {
265         return getAttributeValue(ServerTags.CACHE_RESIZE_QUANTITY);
266     }
267     /**
268     * Modify the CacheResizeQuantity of the Element ejb-container
269     * @param v the new value
270     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
271     */

272     public void setCacheResizeQuantity(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
273         setAttributeValue(ServerTags.CACHE_RESIZE_QUANTITY, v, overwrite);
274     }
275     /**
276     * Modify the CacheResizeQuantity of the Element ejb-container
277     * @param v the new value
278     */

279     public void setCacheResizeQuantity(String JavaDoc v) {
280         setAttributeValue(ServerTags.CACHE_RESIZE_QUANTITY, v);
281     }
282     /**
283     * Get the default value of CacheResizeQuantity from dtd
284     */

285     public static String JavaDoc getDefaultCacheResizeQuantity() {
286         return "32".trim();
287     }
288     /**
289     * Getter for MaxCacheSize of the Element ejb-container
290     * @return the MaxCacheSize of the Element ejb-container
291     */

292     public String JavaDoc getMaxCacheSize() {
293         return getAttributeValue(ServerTags.MAX_CACHE_SIZE);
294     }
295     /**
296     * Modify the MaxCacheSize of the Element ejb-container
297     * @param v the new value
298     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
299     */

300     public void setMaxCacheSize(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
301         setAttributeValue(ServerTags.MAX_CACHE_SIZE, v, overwrite);
302     }
303     /**
304     * Modify the MaxCacheSize of the Element ejb-container
305     * @param v the new value
306     */

307     public void setMaxCacheSize(String JavaDoc v) {
308         setAttributeValue(ServerTags.MAX_CACHE_SIZE, v);
309     }
310     /**
311     * Get the default value of MaxCacheSize from dtd
312     */

313     public static String JavaDoc getDefaultMaxCacheSize() {
314         return "512".trim();
315     }
316     /**
317     * Getter for PoolIdleTimeoutInSeconds of the Element ejb-container
318     * @return the PoolIdleTimeoutInSeconds of the Element ejb-container
319     */

320     public String JavaDoc getPoolIdleTimeoutInSeconds() {
321         return getAttributeValue(ServerTags.POOL_IDLE_TIMEOUT_IN_SECONDS);
322     }
323     /**
324     * Modify the PoolIdleTimeoutInSeconds of the Element ejb-container
325     * @param v the new value
326     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
327     */

328     public void setPoolIdleTimeoutInSeconds(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
329         setAttributeValue(ServerTags.POOL_IDLE_TIMEOUT_IN_SECONDS, v, overwrite);
330     }
331     /**
332     * Modify the PoolIdleTimeoutInSeconds of the Element ejb-container
333     * @param v the new value
334     */

335     public void setPoolIdleTimeoutInSeconds(String JavaDoc v) {
336         setAttributeValue(ServerTags.POOL_IDLE_TIMEOUT_IN_SECONDS, v);
337     }
338     /**
339     * Get the default value of PoolIdleTimeoutInSeconds from dtd
340     */

341     public static String JavaDoc getDefaultPoolIdleTimeoutInSeconds() {
342         return "600".trim();
343     }
344     /**
345     * Getter for CacheIdleTimeoutInSeconds of the Element ejb-container
346     * @return the CacheIdleTimeoutInSeconds of the Element ejb-container
347     */

348     public String JavaDoc getCacheIdleTimeoutInSeconds() {
349         return getAttributeValue(ServerTags.CACHE_IDLE_TIMEOUT_IN_SECONDS);
350     }
351     /**
352     * Modify the CacheIdleTimeoutInSeconds of the Element ejb-container
353     * @param v the new value
354     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
355     */

356     public void setCacheIdleTimeoutInSeconds(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
357         setAttributeValue(ServerTags.CACHE_IDLE_TIMEOUT_IN_SECONDS, v, overwrite);
358     }
359     /**
360     * Modify the CacheIdleTimeoutInSeconds of the Element ejb-container
361     * @param v the new value
362     */

363     public void setCacheIdleTimeoutInSeconds(String JavaDoc v) {
364         setAttributeValue(ServerTags.CACHE_IDLE_TIMEOUT_IN_SECONDS, v);
365     }
366     /**
367     * Get the default value of CacheIdleTimeoutInSeconds from dtd
368     */

369     public static String JavaDoc getDefaultCacheIdleTimeoutInSeconds() {
370         return "600".trim();
371     }
372     /**
373     * Getter for RemovalTimeoutInSeconds of the Element ejb-container
374     * @return the RemovalTimeoutInSeconds of the Element ejb-container
375     */

376     public String JavaDoc getRemovalTimeoutInSeconds() {
377         return getAttributeValue(ServerTags.REMOVAL_TIMEOUT_IN_SECONDS);
378     }
379     /**
380     * Modify the RemovalTimeoutInSeconds of the Element ejb-container
381     * @param v the new value
382     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
383     */

384     public void setRemovalTimeoutInSeconds(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
385         setAttributeValue(ServerTags.REMOVAL_TIMEOUT_IN_SECONDS, v, overwrite);
386     }
387     /**
388     * Modify the RemovalTimeoutInSeconds of the Element ejb-container
389     * @param v the new value
390     */

391     public void setRemovalTimeoutInSeconds(String JavaDoc v) {
392         setAttributeValue(ServerTags.REMOVAL_TIMEOUT_IN_SECONDS, v);
393     }
394     /**
395     * Get the default value of RemovalTimeoutInSeconds from dtd
396     */

397     public static String JavaDoc getDefaultRemovalTimeoutInSeconds() {
398         return "5400".trim();
399     }
400     /**
401     * Getter for VictimSelectionPolicy of the Element ejb-container
402     * @return the VictimSelectionPolicy of the Element ejb-container
403     */

404     public String JavaDoc getVictimSelectionPolicy() {
405         return getAttributeValue(ServerTags.VICTIM_SELECTION_POLICY);
406     }
407     /**
408     * Modify the VictimSelectionPolicy of the Element ejb-container
409     * @param v the new value
410     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
411     */

412     public void setVictimSelectionPolicy(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
413         setAttributeValue(ServerTags.VICTIM_SELECTION_POLICY, v, overwrite);
414     }
415     /**
416     * Modify the VictimSelectionPolicy of the Element ejb-container
417     * @param v the new value
418     */

419     public void setVictimSelectionPolicy(String JavaDoc v) {
420         setAttributeValue(ServerTags.VICTIM_SELECTION_POLICY, v);
421     }
422     /**
423     * Get the default value of VictimSelectionPolicy from dtd
424     */

425     public static String JavaDoc getDefaultVictimSelectionPolicy() {
426         return "nru".trim();
427     }
428     /**
429     * Getter for CommitOption of the Element ejb-container
430     * @return the CommitOption of the Element ejb-container
431     */

432     public String JavaDoc getCommitOption() {
433         return getAttributeValue(ServerTags.COMMIT_OPTION);
434     }
435     /**
436     * Modify the CommitOption of the Element ejb-container
437     * @param v the new value
438     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
439     */

440     public void setCommitOption(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
441         setAttributeValue(ServerTags.COMMIT_OPTION, v, overwrite);
442     }
443     /**
444     * Modify the CommitOption of the Element ejb-container
445     * @param v the new value
446     */

447     public void setCommitOption(String JavaDoc v) {
448         setAttributeValue(ServerTags.COMMIT_OPTION, v);
449     }
450     /**
451     * Get the default value of CommitOption from dtd
452     */

453     public static String JavaDoc getDefaultCommitOption() {
454         return "B".trim();
455     }
456     /**
457     * Getter for SessionStore of the Element ejb-container
458     * @return the SessionStore of the Element ejb-container
459     */

460     public String JavaDoc getSessionStore() {
461             return getAttributeValue(ServerTags.SESSION_STORE);
462     }
463     /**
464     * Modify the SessionStore of the Element ejb-container
465     * @param v the new value
466     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
467     */

468     public void setSessionStore(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
469         setAttributeValue(ServerTags.SESSION_STORE, v, overwrite);
470     }
471     /**
472     * Modify the SessionStore of the Element ejb-container
473     * @param v the new value
474     */

475     public void setSessionStore(String JavaDoc v) {
476         setAttributeValue(ServerTags.SESSION_STORE, v);
477     }
478     /**
479      * Create a new bean using it's default constructor.
480      * This does not add it to any bean graph.
481      */

482     public EjbTimerService newEjbTimerService() {
483         return new EjbTimerService();
484     }
485
486     /**
487      * Create a new bean using it's default constructor.
488      * This does not add it to any bean graph.
489      */

490     public ElementProperty newElementProperty() {
491         return new ElementProperty();
492     }
493
494     /**
495     * get the xpath representation for this element
496     * returns something like abc[@name='value'] or abc
497     * depending on the type of the bean
498     */

499     protected String JavaDoc getRelativeXPath() {
500         String JavaDoc ret = null;
501         ret = "ejb-container";
502         return (null != ret ? ret.trim() : null);
503     }
504
505     /*
506     * generic method to get default value from dtd
507     */

508     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
509         if(attr == null) return null;
510         attr = attr.trim();
511         if(attr.equals(ServerTags.STEADY_POOL_SIZE)) return "32".trim();
512         if(attr.equals(ServerTags.POOL_RESIZE_QUANTITY)) return "16".trim();
513         if(attr.equals(ServerTags.MAX_POOL_SIZE)) return "64".trim();
514         if(attr.equals(ServerTags.CACHE_RESIZE_QUANTITY)) return "32".trim();
515         if(attr.equals(ServerTags.MAX_CACHE_SIZE)) return "512".trim();
516         if(attr.equals(ServerTags.POOL_IDLE_TIMEOUT_IN_SECONDS)) return "600".trim();
517         if(attr.equals(ServerTags.CACHE_IDLE_TIMEOUT_IN_SECONDS)) return "600".trim();
518         if(attr.equals(ServerTags.REMOVAL_TIMEOUT_IN_SECONDS)) return "5400".trim();
519         if(attr.equals(ServerTags.VICTIM_SELECTION_POLICY)) return "nru".trim();
520         if(attr.equals(ServerTags.COMMIT_OPTION)) return "B".trim();
521     return null;
522     }
523     //
524
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
525         comparators.add(c);
526     }
527
528     //
529
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
530         comparators.remove(c);
531     }
532     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
533     }
534
535     // Dump the content of this bean returning it as a String
536
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
537         String JavaDoc s;
538         Object JavaDoc o;
539         org.netbeans.modules.schema2beans.BaseBean n;
540         str.append(indent);
541         str.append("EjbTimerService"); // NOI18N
542
n = (org.netbeans.modules.schema2beans.BaseBean) this.getEjbTimerService();
543         if (n != null)
544             n.dump(str, indent + "\t"); // NOI18N
545
else
546             str.append(indent+"\tnull"); // NOI18N
547
this.dumpAttributes(EJB_TIMER_SERVICE, 0, str, indent);
548
549         str.append(indent);
550         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
551
for(int i=0; i<this.sizeElementProperty(); i++)
552         {
553             str.append(indent+"\t");
554             str.append("#"+i+":");
555             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
556             if (n != null)
557                 n.dump(str, indent + "\t"); // NOI18N
558
else
559                 str.append(indent+"\tnull"); // NOI18N
560
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
561         }
562
563     }
564     public String JavaDoc dumpBeanNode(){
565         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
566         str.append("EjbContainer\n"); // NOI18N
567
this.dump(str, "\n "); // NOI18N
568
return str.toString();
569     }}
570
571 // END_NOI18N
572

573
Popular Tags