KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > dd > connector > ResourceAdapter


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 ResourceAdapter matches the schema element resource-adapter
26  *
27  * Generated on Thu Jul 31 18:16:39 PDT 2003
28  */

29
30 package com.sun.enterprise.tools.common.dd.connector;
31
32 import org.w3c.dom.*;
33 import org.netbeans.modules.schema2beans.*;
34 import java.beans.*;
35 import java.util.*;
36
37 // BEGIN_NOI18N
38

39 public class ResourceAdapter extends com.sun.enterprise.tools.common.dd.SunBaseBean
40 {
41
42     static Vector comparators = new Vector();
43
44     static public final String JavaDoc JNDINAME = "JndiName"; // NOI18N
45
static public final String JavaDoc MAXPOOLSIZE = "MaxPoolSize"; // NOI18N
46
static public final String JavaDoc STEADYPOOLSIZE = "SteadyPoolSize"; // NOI18N
47
static public final String JavaDoc MAXWAITTIMEINMILLIS = "MaxWaitTimeInMillis"; // NOI18N
48
static public final String JavaDoc IDLETIMEOUTINSECONDS = "IdleTimeoutInSeconds"; // NOI18N
49
static public final String JavaDoc DESCRIPTION = "Description"; // NOI18N
50
static public final String JavaDoc PROPERTY = "PropertyElement"; // NOI18N
51
static public final String JavaDoc PROPERTYELEMENTNAME = "PropertyElementName"; // NOI18N
52
static public final String JavaDoc PROPERTYELEMENTVALUE = "PropertyElementValue"; // NOI18N
53

54     public ResourceAdapter() {
55         this(Common.USE_DEFAULT_VALUES);
56     }
57
58     public ResourceAdapter(int options)
59     {
60         super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
61         // Properties (see root bean comments for the bean graph)
62
this.createProperty("description", // NOI18N
63
DESCRIPTION,
64             Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY,
65             String JavaDoc.class);
66         this.createProperty("property", // NOI18N
67
PROPERTY,
68             Common.TYPE_0_N | Common.TYPE_BOOLEAN | Common.TYPE_KEY,
69             Boolean JavaDoc.class);
70         this.createAttribute(PROPERTY, "name", "Name",
71                         AttrProp.CDATA | AttrProp.REQUIRED,
72                         null, null);
73         this.createAttribute(PROPERTY, "value", "Value",
74                         AttrProp.CDATA | AttrProp.REQUIRED,
75                         null, null);
76         this.initialize(options);
77     }
78
79     // Setting the default values of the properties
80
void initialize(int options)
81     {
82         
83     }
84
85     // This attribute is mandatory
86
public void setJndiName(java.lang.String JavaDoc value) {
87         setAttributeValue(JNDINAME, value);
88     }
89
90     //
91
public java.lang.String JavaDoc getJndiName() {
92         return getAttributeValue(JNDINAME);
93     }
94
95     // This attribute is mandatory
96
public void setMaxPoolSize(java.lang.String JavaDoc value) {
97         setAttributeValue(MAXPOOLSIZE, value);
98     }
99
100     //
101
public java.lang.String JavaDoc getMaxPoolSize() {
102         return getAttributeValue(MAXPOOLSIZE);
103     }
104
105     // This attribute is mandatory
106
public void setSteadyPoolSize(java.lang.String JavaDoc value) {
107         setAttributeValue(STEADYPOOLSIZE, value);
108     }
109
110     //
111
public java.lang.String JavaDoc getSteadyPoolSize() {
112         return getAttributeValue(STEADYPOOLSIZE);
113     }
114
115     // This attribute is mandatory
116
public void setMaxWaitTimeInMillis(java.lang.String JavaDoc value) {
117         setAttributeValue(MAXWAITTIMEINMILLIS, value);
118     }
119
120     //
121
public java.lang.String JavaDoc getMaxWaitTimeInMillis() {
122         return getAttributeValue(MAXWAITTIMEINMILLIS);
123     }
124
125     // This attribute is mandatory
126
public void setIdleTimeoutInSeconds(java.lang.String JavaDoc value) {
127         setAttributeValue(IDLETIMEOUTINSECONDS, value);
128     }
129
130     //
131
public java.lang.String JavaDoc getIdleTimeoutInSeconds() {
132         return getAttributeValue(IDLETIMEOUTINSECONDS);
133     }
134
135     // This attribute is optional
136
public void setDescription(String JavaDoc value) {
137         this.setValue(DESCRIPTION, value);
138     }
139
140     //
141
public String JavaDoc getDescription() {
142         return (String JavaDoc)this.getValue(DESCRIPTION);
143     }
144
145     // This attribute is an array, possibly empty
146
public void setPropertyElement(int index, boolean value) {
147         this.setValue(PROPERTY, index, (value ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE));
148     }
149
150     //
151
public boolean isPropertyElement(int index) {
152         Boolean JavaDoc ret = (Boolean JavaDoc)this.getValue(PROPERTY, index);
153         if (ret == null)
154             ret = (Boolean JavaDoc)Common.defaultScalarValue(Common.TYPE_BOOLEAN);
155         return ((java.lang.Boolean JavaDoc)ret).booleanValue();
156     }
157
158     // This attribute is an array, possibly empty
159
public void setPropertyElement(boolean[] value) {
160         Boolean JavaDoc[] values = null;
161         if (value != null)
162         {
163             values = new Boolean JavaDoc[value.length];
164             for (int i=0; i<value.length; i++)
165                 values[i] = new Boolean JavaDoc(value[i]);
166         }
167         this.setValue(PROPERTY, values);
168     }
169
170     //
171
public boolean[] getPropertyElement() {
172         boolean[] ret = null;
173         Boolean JavaDoc[] values = (Boolean JavaDoc[])this.getValues(PROPERTY);
174         if (values != null)
175         {
176             ret = new boolean[values.length];
177             for (int i=0; i<values.length; i++)
178                 ret[i] = values[i].booleanValue();
179         }
180         return ret;
181     }
182
183     // Return the number of properties
184
public int sizePropertyElement() {
185         return this.size(PROPERTY);
186     }
187
188     // Add a new element returning its index in the list
189
public int addPropertyElement(boolean value) {
190         return this.addValue(PROPERTY, (value ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE));
191     }
192
193     //
194
// Remove an element using its reference
195
// Returns the index the element had in the list
196
//
197
public int removePropertyElement(boolean value) {
198         return this.removeValue(PROPERTY, (value ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE));
199     }
200
201     //
202
// Remove an element using its index
203
//
204
public void removePropertyElement(int index) {
205         this.removeValue(PROPERTY, index);
206     }
207
208     // This attribute is an array, possibly empty
209
public void setPropertyElementName(int index, java.lang.String JavaDoc value) {
210         // Make sure we've got a place to put this attribute.
211
if (size(PROPERTY) == 0) {
212             addValue(PROPERTY, "");
213         }
214         setAttributeValue(PROPERTY, index, "Name", value);
215     }
216
217     //
218
public java.lang.String JavaDoc getPropertyElementName(int index) {
219         // If our element does not exist, then the attribute does not exist.
220
if (size(PROPERTY) == 0) {
221             return null;
222         } else {
223             return getAttributeValue(PROPERTY, index, "Name");
224         }
225     }
226
227     // This attribute is an array, possibly empty
228
public void setPropertyElementValue(int index, java.lang.String JavaDoc value) {
229         // Make sure we've got a place to put this attribute.
230
if (size(PROPERTY) == 0) {
231             addValue(PROPERTY, "");
232         }
233         setAttributeValue(PROPERTY, index, "Value", value);
234     }
235
236     //
237
public java.lang.String JavaDoc getPropertyElementValue(int index) {
238         // If our element does not exist, then the attribute does not exist.
239
if (size(PROPERTY) == 0) {
240             return null;
241         } else {
242             return getAttributeValue(PROPERTY, index, "Value");
243         }
244     }
245
246     //
247
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
248         comparators.add(c);
249     }
250
251     //
252
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
253         comparators.remove(c);
254     }
255     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
256         boolean restrictionFailure = false;
257         // Validating property jndiName
258
if (getJndiName() == null) {
259             throw new org.netbeans.modules.schema2beans.ValidateException("getJndiName() == null", "jndiName", this); // NOI18N
260
}
261         // Validating property maxPoolSize
262
if (getMaxPoolSize() == null) {
263             throw new org.netbeans.modules.schema2beans.ValidateException("getMaxPoolSize() == null", "maxPoolSize", this); // NOI18N
264
}
265         // Validating property steadyPoolSize
266
if (getSteadyPoolSize() == null) {
267             throw new org.netbeans.modules.schema2beans.ValidateException("getSteadyPoolSize() == null", "steadyPoolSize", this); // NOI18N
268
}
269         // Validating property maxWaitTimeInMillis
270
if (getMaxWaitTimeInMillis() == null) {
271             throw new org.netbeans.modules.schema2beans.ValidateException("getMaxWaitTimeInMillis() == null", "maxWaitTimeInMillis", this); // NOI18N
272
}
273         // Validating property idleTimeoutInSeconds
274
if (getIdleTimeoutInSeconds() == null) {
275             throw new org.netbeans.modules.schema2beans.ValidateException("getIdleTimeoutInSeconds() == null", "idleTimeoutInSeconds", this); // NOI18N
276
}
277         // Validating property description
278
if (getDescription() != null) {
279         }
280         // Validating property propertyElement
281
for (int _index = 0; _index < sizePropertyElement(); ++_index) {
282             boolean element = isPropertyElement(_index);
283         }
284         // Validating property propertyElementName
285
// Validating property propertyElementValue
286
}
287
288     // Dump the content of this bean returning it as a String
289
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
290         String JavaDoc s;
291         Object JavaDoc o;
292         org.netbeans.modules.schema2beans.BaseBean n;
293         str.append(indent);
294         str.append("Description"); // NOI18N
295
str.append(indent+"\t"); // NOI18N
296
str.append("<"); // NOI18N
297
s = this.getDescription();
298         str.append((s==null?"null":s.trim())); // NOI18N
299
str.append(">\n"); // NOI18N
300
this.dumpAttributes(DESCRIPTION, 0, str, indent);
301
302         str.append(indent);
303         str.append("PropertyElement["+this.sizePropertyElement()+"]"); // NOI18N
304
for(int i=0; i<this.sizePropertyElement(); i++)
305         {
306             str.append(indent+"\t");
307             str.append("#"+i+":");
308             str.append(indent+"\t"); // NOI18N
309
str.append((this.isPropertyElement(i)?"true":"false"));
310             this.dumpAttributes(PROPERTY, i, str, indent);
311         }
312
313     }
314     public String JavaDoc dumpBeanNode(){
315         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
316         str.append("ResourceAdapter\n"); // NOI18N
317
this.dump(str, "\n "); // NOI18N
318
return str.toString();
319     }}
320
321 // END_NOI18N
322

323
324 /*
325         The following schema file has been used for generation:
326
327 <!--
328   XML DTD for Sun ONE Application Server specific J2EE Resource Adapter
329   deployment descriptor. This is a companion DTD to connector_1_5.xsd
330
331   $Revision: 1.3 $
332 -->
333
334 <!-- Each deployed Resource Adapter (RAR) Module, will have ias-ra.xml
335      associated with it, which specifies several dynamic configuration
336      properties. Key aspects are pool sizing and security role maps.
337  -->
338 <!ELEMENT sun-connector (resource-adapter, role-map?)>
339
340 <!-- Resource adapter configuration
341
342      jndi-name name by which, this adapter will appear in JNDI tree
343      max-pool-size maximum size of connection to EIS
344      steady-pool-size initial and minimum number of connections to be maintained
345      max-wait-in-millis if a connection is not readily found, caller will have to
346                         wait this long, before a connection is created. A value of
347                         0 implies, wait till a connection becomes available. If the
348                         pool is completely utilized and the timer expires, an
349                         exception will be delivered to the application.
350
351      idle-timeout-in-seconds A timer thread periodically removed unused connections.
352                              The interval at which this thread runs. All idle
353                              connections will be removed, while mainataining
354                              the configured steady-pool-size.
355 -->
356 <!ELEMENT resource-adapter (description?, property*)>
357 <!ATTLIST resource-adapter jndi-name CDATA #REQUIRED
358                            max-pool-size CDATA "32"
359                            steady-pool-size CDATA "4"
360                            max-wait-time-in-millis CDATA "10000"
361                            idle-timeout-in-seconds CDATA "1000">
362
363 <!-- Perform mapping from principal received during Servlet/EJB
364      authentication, to credentials accepted by the EIS. This
365      mapping is optional. The map consists of several 2-tuples
366      map-id is the name of the mapping
367  -->
368 <!ELEMENT role-map (description?, map-element*)>
369 <!ATTLIST role-map map-id CDATA #REQUIRED>
370                 
371
372 <!-- It is possible to map multiple (server) principal to the
373      same backend principal.
374 -->
375 <!ELEMENT map-element (principal+, backend-principal)>
376
377 <!-- Principal of the Servlet and EJB client -->
378 <!ELEMENT principal (description?)>
379 <!ATTLIST principal user-name CDATA #REQUIRED>
380  
381 <!-- Backend EIS principal -->
382 <!ELEMENT backend-principal EMPTY>
383 <!ATTLIST backend-principal user-name CDATA #REQUIRED
384                             password CDATA #REQUIRED
385                             credential CDATA #REQUIRED>
386
387 <!ELEMENT description (#PCDATA)>
388
389 <!-- Syntax for supplying properties as name value pairs -->
390 <!ELEMENT property EMPTY>
391 <!ATTLIST property name CDATA #REQUIRED
392                    value CDATA #REQUIRED>
393
394 */

395
Popular Tags