KickJava   Java API By Example, From Geeks To Geeks.

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


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

154     public String JavaDoc getMinimumDeliveryIntervalInMillis() {
155         return getAttributeValue(ServerTags.MINIMUM_DELIVERY_INTERVAL_IN_MILLIS);
156     }
157     /**
158     * Modify the MinimumDeliveryIntervalInMillis of the Element ejb-timer-service
159     * @param v the new value
160     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
161     */

162     public void setMinimumDeliveryIntervalInMillis(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
163         setAttributeValue(ServerTags.MINIMUM_DELIVERY_INTERVAL_IN_MILLIS, v, overwrite);
164     }
165     /**
166     * Modify the MinimumDeliveryIntervalInMillis of the Element ejb-timer-service
167     * @param v the new value
168     */

169     public void setMinimumDeliveryIntervalInMillis(String JavaDoc v) {
170         setAttributeValue(ServerTags.MINIMUM_DELIVERY_INTERVAL_IN_MILLIS, v);
171     }
172     /**
173     * Get the default value of MinimumDeliveryIntervalInMillis from dtd
174     */

175     public static String JavaDoc getDefaultMinimumDeliveryIntervalInMillis() {
176         return "7000".trim();
177     }
178     /**
179     * Getter for MaxRedeliveries of the Element ejb-timer-service
180     * @return the MaxRedeliveries of the Element ejb-timer-service
181     */

182     public String JavaDoc getMaxRedeliveries() {
183         return getAttributeValue(ServerTags.MAX_REDELIVERIES);
184     }
185     /**
186     * Modify the MaxRedeliveries of the Element ejb-timer-service
187     * @param v the new value
188     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
189     */

190     public void setMaxRedeliveries(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
191         setAttributeValue(ServerTags.MAX_REDELIVERIES, v, overwrite);
192     }
193     /**
194     * Modify the MaxRedeliveries of the Element ejb-timer-service
195     * @param v the new value
196     */

197     public void setMaxRedeliveries(String JavaDoc v) {
198         setAttributeValue(ServerTags.MAX_REDELIVERIES, v);
199     }
200     /**
201     * Get the default value of MaxRedeliveries from dtd
202     */

203     public static String JavaDoc getDefaultMaxRedeliveries() {
204         return "1".trim();
205     }
206     /**
207     * Getter for TimerDatasource of the Element ejb-timer-service
208     * @return the TimerDatasource of the Element ejb-timer-service
209     */

210     public String JavaDoc getTimerDatasource() {
211             return getAttributeValue(ServerTags.TIMER_DATASOURCE);
212     }
213     /**
214     * Modify the TimerDatasource of the Element ejb-timer-service
215     * @param v the new value
216     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
217     */

218     public void setTimerDatasource(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
219         setAttributeValue(ServerTags.TIMER_DATASOURCE, v, overwrite);
220     }
221     /**
222     * Modify the TimerDatasource of the Element ejb-timer-service
223     * @param v the new value
224     */

225     public void setTimerDatasource(String JavaDoc v) {
226         setAttributeValue(ServerTags.TIMER_DATASOURCE, v);
227     }
228     /**
229     * Getter for RedeliveryIntervalInternalInMillis of the Element ejb-timer-service
230     * @return the RedeliveryIntervalInternalInMillis of the Element ejb-timer-service
231     */

232     public String JavaDoc getRedeliveryIntervalInternalInMillis() {
233         return getAttributeValue(ServerTags.REDELIVERY_INTERVAL_INTERNAL_IN_MILLIS);
234     }
235     /**
236     * Modify the RedeliveryIntervalInternalInMillis of the Element ejb-timer-service
237     * @param v the new value
238     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
239     */

240     public void setRedeliveryIntervalInternalInMillis(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
241         setAttributeValue(ServerTags.REDELIVERY_INTERVAL_INTERNAL_IN_MILLIS, v, overwrite);
242     }
243     /**
244     * Modify the RedeliveryIntervalInternalInMillis of the Element ejb-timer-service
245     * @param v the new value
246     */

247     public void setRedeliveryIntervalInternalInMillis(String JavaDoc v) {
248         setAttributeValue(ServerTags.REDELIVERY_INTERVAL_INTERNAL_IN_MILLIS, v);
249     }
250     /**
251     * Get the default value of RedeliveryIntervalInternalInMillis from dtd
252     */

253     public static String JavaDoc getDefaultRedeliveryIntervalInternalInMillis() {
254         return "5000".trim();
255     }
256     /**
257      * Create a new bean using it's default constructor.
258      * This does not add it to any bean graph.
259      */

260     public ElementProperty newElementProperty() {
261         return new ElementProperty();
262     }
263
264     /**
265     * get the xpath representation for this element
266     * returns something like abc[@name='value'] or abc
267     * depending on the type of the bean
268     */

269     protected String JavaDoc getRelativeXPath() {
270         String JavaDoc ret = null;
271         ret = "ejb-timer-service";
272         return (null != ret ? ret.trim() : null);
273     }
274
275     /*
276     * generic method to get default value from dtd
277     */

278     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
279         if(attr == null) return null;
280         attr = attr.trim();
281         if(attr.equals(ServerTags.MINIMUM_DELIVERY_INTERVAL_IN_MILLIS)) return "7000".trim();
282         if(attr.equals(ServerTags.MAX_REDELIVERIES)) return "1".trim();
283         if(attr.equals(ServerTags.REDELIVERY_INTERVAL_INTERNAL_IN_MILLIS)) return "5000".trim();
284     return null;
285     }
286     //
287
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
288         comparators.add(c);
289     }
290
291     //
292
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
293         comparators.remove(c);
294     }
295     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
296     }
297
298     // Dump the content of this bean returning it as a String
299
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
300         String JavaDoc s;
301         Object JavaDoc o;
302         org.netbeans.modules.schema2beans.BaseBean n;
303         str.append(indent);
304         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
305
for(int i=0; i<this.sizeElementProperty(); i++)
306         {
307             str.append(indent+"\t");
308             str.append("#"+i+":");
309             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
310             if (n != null)
311                 n.dump(str, indent + "\t"); // NOI18N
312
else
313                 str.append(indent+"\tnull"); // NOI18N
314
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
315         }
316
317     }
318     public String JavaDoc dumpBeanNode(){
319         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
320         str.append("EjbTimerService\n"); // NOI18N
321
this.dump(str, "\n "); // NOI18N
322
return str.toString();
323     }}
324
325 // END_NOI18N
326

327
Popular Tags