KickJava   Java API By Example, From Geeks To Geeks.

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


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 ExternalJndiResource matches the DTD element external-jndi-resource
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 ExternalJndiResource 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 ELEMENT_PROPERTY = "ElementProperty";
51
52     public ExternalJndiResource() {
53         this(Common.USE_DEFAULT_VALUES);
54     }
55
56     public ExternalJndiResource(int options)
57     {
58         super(comparators, runtimeVersion);
59         // Properties (see root bean comments for the bean graph)
60
initPropertyTables(2);
61         this.createProperty("description", DESCRIPTION,
62             Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY,
63             String JavaDoc.class);
64         this.createProperty("property", ELEMENT_PROPERTY,
65             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
66             ElementProperty.class);
67         this.createAttribute(ELEMENT_PROPERTY, "name", "Name",
68                         AttrProp.CDATA | AttrProp.REQUIRED,
69                         null, null);
70         this.createAttribute(ELEMENT_PROPERTY, "value", "Value",
71                         AttrProp.CDATA | AttrProp.REQUIRED,
72                         null, null);
73         this.initialize(options);
74     }
75
76     // Setting the default values of the properties
77
void initialize(int options) {
78
79     }
80
81     /**
82     * Return the Description of the Element external-jndi-resource
83     */

84     public String JavaDoc getDescription() {
85         return (String JavaDoc) getValue(ServerTags.DESCRIPTION);
86     }
87     /**
88     * Modify the Description of the Element external-jndi-resource
89     * @param v the new value
90     */

91     public void setDescription(String JavaDoc v){
92         setValue(ServerTags.DESCRIPTION, (null != v ? v.trim() : null));
93         }
94     // This attribute is an array, possibly empty
95
public void setElementProperty(int index, ElementProperty value) {
96         this.setValue(ELEMENT_PROPERTY, index, value);
97     }
98
99     // Get Method
100
public ElementProperty getElementProperty(int index) {
101         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
102     }
103
104     // This attribute is an array, possibly empty
105
public void setElementProperty(ElementProperty[] value) {
106         this.setValue(ELEMENT_PROPERTY, value);
107     }
108
109     // Getter Method
110
public ElementProperty[] getElementProperty() {
111         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
112     }
113
114     // Return the number of properties
115
public int sizeElementProperty() {
116         return this.size(ELEMENT_PROPERTY);
117     }
118
119     // Add a new element returning its index in the list
120
public int addElementProperty(ElementProperty value)
121             throws ConfigException{
122         return addElementProperty(value, true);
123     }
124
125     // Add a new element returning its index in the list with a boolean flag
126
public int addElementProperty(ElementProperty value, boolean overwrite)
127             throws ConfigException{
128         ElementProperty old = getElementPropertyByName(value.getName());
129         if(old != null) {
130             throw new ConfigException(StringManager.getManager(ExternalJndiResource.class).getString("cannotAddDuplicate", "ElementProperty"));
131         }
132         return this.addValue(ELEMENT_PROPERTY, value, overwrite);
133     }
134
135     //
136
// Remove an element using its reference
137
// Returns the index the element had in the list
138
//
139
public int removeElementProperty(ElementProperty value){
140         return this.removeValue(ELEMENT_PROPERTY, value);
141     }
142
143     //
144
// Remove an element using its reference
145
// Returns the index the element had in the list
146
// with boolean overwrite
147
//
148
public int removeElementProperty(ElementProperty value, boolean overwrite)
149             throws StaleWriteConfigException{
150         return this.removeValue(ELEMENT_PROPERTY, value, overwrite);
151     }
152
153     public ElementProperty getElementPropertyByName(String JavaDoc id) {
154      if (null != id) { id = id.trim(); }
155     ElementProperty[] o = getElementProperty();
156      if (o == null) return null;
157
158      for (int i=0; i < o.length; i++) {
159          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
160              return o[i];
161          }
162      }
163
164         return null;
165         
166     }
167     /**
168     * Getter for JndiName of the Element external-jndi-resource
169     * @return the JndiName of the Element external-jndi-resource
170     */

171     public String JavaDoc getJndiName() {
172         return getAttributeValue(ServerTags.JNDI_NAME);
173     }
174     /**
175     * Modify the JndiName of the Element external-jndi-resource
176     * @param v the new value
177     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
178     */

179     public void setJndiName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
180         setAttributeValue(ServerTags.JNDI_NAME, v, overwrite);
181     }
182     /**
183     * Modify the JndiName of the Element external-jndi-resource
184     * @param v the new value
185     */

186     public void setJndiName(String JavaDoc v) {
187         setAttributeValue(ServerTags.JNDI_NAME, v);
188     }
189     /**
190     * Getter for JndiLookupName of the Element external-jndi-resource
191     * @return the JndiLookupName of the Element external-jndi-resource
192     */

193     public String JavaDoc getJndiLookupName() {
194         return getAttributeValue(ServerTags.JNDI_LOOKUP_NAME);
195     }
196     /**
197     * Modify the JndiLookupName of the Element external-jndi-resource
198     * @param v the new value
199     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
200     */

201     public void setJndiLookupName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
202         setAttributeValue(ServerTags.JNDI_LOOKUP_NAME, v, overwrite);
203     }
204     /**
205     * Modify the JndiLookupName of the Element external-jndi-resource
206     * @param v the new value
207     */

208     public void setJndiLookupName(String JavaDoc v) {
209         setAttributeValue(ServerTags.JNDI_LOOKUP_NAME, v);
210     }
211     /**
212     * Getter for ResType of the Element external-jndi-resource
213     * @return the ResType of the Element external-jndi-resource
214     */

215     public String JavaDoc getResType() {
216         return getAttributeValue(ServerTags.RES_TYPE);
217     }
218     /**
219     * Modify the ResType of the Element external-jndi-resource
220     * @param v the new value
221     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
222     */

223     public void setResType(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
224         setAttributeValue(ServerTags.RES_TYPE, v, overwrite);
225     }
226     /**
227     * Modify the ResType of the Element external-jndi-resource
228     * @param v the new value
229     */

230     public void setResType(String JavaDoc v) {
231         setAttributeValue(ServerTags.RES_TYPE, v);
232     }
233     /**
234     * Getter for FactoryClass of the Element external-jndi-resource
235     * @return the FactoryClass of the Element external-jndi-resource
236     */

237     public String JavaDoc getFactoryClass() {
238         return getAttributeValue(ServerTags.FACTORY_CLASS);
239     }
240     /**
241     * Modify the FactoryClass of the Element external-jndi-resource
242     * @param v the new value
243     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
244     */

245     public void setFactoryClass(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
246         setAttributeValue(ServerTags.FACTORY_CLASS, v, overwrite);
247     }
248     /**
249     * Modify the FactoryClass of the Element external-jndi-resource
250     * @param v the new value
251     */

252     public void setFactoryClass(String JavaDoc v) {
253         setAttributeValue(ServerTags.FACTORY_CLASS, v);
254     }
255     /**
256     * Getter for ObjectType of the Element external-jndi-resource
257     * @return the ObjectType of the Element external-jndi-resource
258     */

259     public String JavaDoc getObjectType() {
260         return getAttributeValue(ServerTags.OBJECT_TYPE);
261     }
262     /**
263     * Modify the ObjectType of the Element external-jndi-resource
264     * @param v the new value
265     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
266     */

267     public void setObjectType(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
268         setAttributeValue(ServerTags.OBJECT_TYPE, v, overwrite);
269     }
270     /**
271     * Modify the ObjectType of the Element external-jndi-resource
272     * @param v the new value
273     */

274     public void setObjectType(String JavaDoc v) {
275         setAttributeValue(ServerTags.OBJECT_TYPE, v);
276     }
277     /**
278     * Get the default value of ObjectType from dtd
279     */

280     public static String JavaDoc getDefaultObjectType() {
281         return "user".trim();
282     }
283     /**
284     * Getter for Enabled of the Element external-jndi-resource
285     * @return the Enabled of the Element external-jndi-resource
286     */

287     public boolean isEnabled() {
288         return toBoolean(getAttributeValue(ServerTags.ENABLED));
289     }
290     /**
291     * Modify the Enabled of the Element external-jndi-resource
292     * @param v the new value
293     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
294     */

295     public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
296         setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite);
297     }
298     /**
299     * Modify the Enabled of the Element external-jndi-resource
300     * @param v the new value
301     */

302     public void setEnabled(boolean v) {
303         setAttributeValue(ServerTags.ENABLED, ""+(v==true));
304     }
305     /**
306     * Get the default value of Enabled from dtd
307     */

308     public static String JavaDoc getDefaultEnabled() {
309         return "true".trim();
310     }
311     /**
312      * Create a new bean using it's default constructor.
313      * This does not add it to any bean graph.
314      */

315     public ElementProperty newElementProperty() {
316         return new ElementProperty();
317     }
318
319     /**
320     * get the xpath representation for this element
321     * returns something like abc[@name='value'] or abc
322     * depending on the type of the bean
323     */

324     protected String JavaDoc getRelativeXPath() {
325         String JavaDoc ret = null;
326         ret = "external-jndi-resource" + (canHaveSiblings() ? "[@jndi-name='" + getAttributeValue("jndi-name") +"']" : "") ;
327         return (null != ret ? ret.trim() : null);
328     }
329
330     /*
331     * generic method to get default value from dtd
332     */

333     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
334         if(attr == null) return null;
335         attr = attr.trim();
336         if(attr.equals(ServerTags.OBJECT_TYPE)) return "user".trim();
337         if(attr.equals(ServerTags.ENABLED)) return "true".trim();
338     return null;
339     }
340     //
341
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
342         comparators.add(c);
343     }
344
345     //
346
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
347         comparators.remove(c);
348     }
349     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
350     }
351
352     // Dump the content of this bean returning it as a String
353
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
354         String JavaDoc s;
355         Object JavaDoc o;
356         org.netbeans.modules.schema2beans.BaseBean n;
357         str.append(indent);
358         str.append("Description"); // NOI18N
359
str.append(indent+"\t"); // NOI18N
360
str.append("<"); // NOI18N
361
o = this.getDescription();
362         str.append((o==null?"null":o.toString().trim())); // NOI18N
363
str.append(">\n"); // NOI18N
364
this.dumpAttributes(DESCRIPTION, 0, str, indent);
365
366         str.append(indent);
367         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
368
for(int i=0; i<this.sizeElementProperty(); i++)
369         {
370             str.append(indent+"\t");
371             str.append("#"+i+":");
372             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
373             if (n != null)
374                 n.dump(str, indent + "\t"); // NOI18N
375
else
376                 str.append(indent+"\tnull"); // NOI18N
377
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
378         }
379
380     }
381     public String JavaDoc dumpBeanNode(){
382         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
383         str.append("ExternalJndiResource\n"); // NOI18N
384
this.dump(str, "\n "); // NOI18N
385
return str.toString();
386     }}
387
388 // END_NOI18N
389

390
Popular Tags