KickJava   Java API By Example, From Geeks To Geeks.

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


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 SunConnector matches the schema element sun-connector
26  *
27  * Generated on Thu Jul 31 18:16:39 PDT 2003
28  *
29  * This class matches the root element of the DTD,
30  * and is the root of the following bean graph:
31  *
32  * sun-connector : SunConnector
33  * resource-adapter : ResourceAdapter
34  * [attr: jndi-name CDATA #REQUIRED ]
35  * [attr: max-pool-size CDATA 32]
36  * [attr: steady-pool-size CDATA 4]
37  * [attr: max-wait-time-in-millis CDATA 10000]
38  * [attr: idle-timeout-in-seconds CDATA 1000]
39  * description : String?
40  * property : Boolean[0,n]
41  * [attr: name CDATA #REQUIRED ]
42  * [attr: value CDATA #REQUIRED ]
43  * EMPTY : String
44  * role-map : RoleMap?
45  * [attr: map-id CDATA #REQUIRED ]
46  * description : String?
47  * map-element : MapElement[0,n]
48  * principal : Principal[1,n]
49  * [attr: user-name CDATA #REQUIRED ]
50  * description : String?
51  * backend-principal : Boolean
52  * [attr: user-name CDATA #REQUIRED ]
53  * [attr: password CDATA #REQUIRED ]
54  * [attr: credential CDATA #REQUIRED ]
55  * EMPTY : String
56  *
57  */

58
59 package com.sun.enterprise.tools.common.dd.connector;
60
61 import org.w3c.dom.*;
62 import org.netbeans.modules.schema2beans.*;
63 import java.beans.*;
64 import java.util.*;
65 import java.io.*;
66
67 // BEGIN_NOI18N
68

69 public class SunConnector extends com.sun.enterprise.tools.common.dd.SunBaseBean
70 {
71
72     static Vector comparators = new Vector();
73
74     static public final String JavaDoc RESOURCE_ADAPTER = "ResourceAdapter"; // NOI18N
75
static public final String JavaDoc ROLE_MAP = "RoleMap"; // NOI18N
76

77     public SunConnector() throws org.netbeans.modules.schema2beans.Schema2BeansException {
78         this(null, Common.USE_DEFAULT_VALUES);
79     }
80
81     public SunConnector(org.w3c.dom.Node JavaDoc doc, int options) throws org.netbeans.modules.schema2beans.Schema2BeansException {
82         this(Common.NO_DEFAULT_VALUES);
83         initFromNode(doc, options);
84     }
85     protected void initFromNode(org.w3c.dom.Node JavaDoc doc, int options) throws Schema2BeansException
86     {
87         if (doc == null)
88         {
89             doc = GraphManager.createRootElementNode("sun-connector"); // NOI18N
90
if (doc == null)
91                 throw new Schema2BeansException(Common.getMessage(
92                     "CantCreateDOMRoot_msg", "sun-connector"));
93         }
94         Node n = GraphManager.getElementNode("sun-connector", doc); // NOI18N
95
if (n == null)
96             throw new Schema2BeansException(Common.getMessage(
97                 "DocRootNotInDOMGraph_msg", "sun-connector", doc.getFirstChild().getNodeName()));
98
99         this.graphManager.setXmlDocument(doc);
100
101         // Entry point of the createBeans() recursive calls
102
this.createBean(n, this.graphManager());
103         this.initialize(options);
104     }
105     public SunConnector(int options)
106     {
107         super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
108         initOptions(options);
109     }
110     protected void initOptions(int options)
111     {
112         // The graph manager is allocated in the bean root
113
this.graphManager = new GraphManager(this);
114         this.createRoot("sun-connector", "SunConnector", // NOI18N
115
Common.TYPE_1 | Common.TYPE_BEAN, SunConnector.class);
116
117         // Properties (see root bean comments for the bean graph)
118
this.createProperty("resource-adapter", // NOI18N
119
RESOURCE_ADAPTER,
120             Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
121             ResourceAdapter.class);
122         this.createAttribute(RESOURCE_ADAPTER, "jndi-name", "JndiName",
123                         AttrProp.CDATA | AttrProp.REQUIRED,
124                         null, null);
125         this.createAttribute(RESOURCE_ADAPTER, "max-pool-size", "MaxPoolSize",
126                         AttrProp.CDATA,
127                         null, "32");
128         this.createAttribute(RESOURCE_ADAPTER, "steady-pool-size", "SteadyPoolSize",
129                         AttrProp.CDATA,
130                         null, "4");
131         this.createAttribute(RESOURCE_ADAPTER, "max-wait-time-in-millis", "MaxWaitTimeInMillis",
132                         AttrProp.CDATA,
133                         null, "10000");
134         this.createAttribute(RESOURCE_ADAPTER, "idle-timeout-in-seconds", "IdleTimeoutInSeconds",
135                         AttrProp.CDATA,
136                         null, "1000");
137         this.createProperty("role-map", // NOI18N
138
ROLE_MAP,
139             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
140             RoleMap.class);
141         this.createAttribute(ROLE_MAP, "map-id", "MapId",
142                         AttrProp.CDATA | AttrProp.REQUIRED,
143                         null, null);
144         this.initialize(options);
145     }
146
147     // Setting the default values of the properties
148
void initialize(int options)
149     {
150
151     }
152
153     // This attribute is mandatory
154
public void setResourceAdapter(ResourceAdapter value) {
155         this.setValue(RESOURCE_ADAPTER, value);
156     }
157
158     //
159
public ResourceAdapter getResourceAdapter() {
160         return (ResourceAdapter)this.getValue(RESOURCE_ADAPTER);
161     }
162
163     // This attribute is optional
164
public void setRoleMap(RoleMap value) {
165         this.setValue(ROLE_MAP, value);
166     }
167
168     //
169
public RoleMap getRoleMap() {
170         return (RoleMap)this.getValue(ROLE_MAP);
171     }
172
173     //
174
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
175         comparators.add(c);
176     }
177
178     //
179
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
180         comparators.remove(c);
181     }
182     //
183
// This method returns the root of the bean graph
184
// Each call creates a new bean graph from the specified DOM graph
185
//
186
public static SunConnector createGraph(org.w3c.dom.Node JavaDoc doc) throws org.netbeans.modules.schema2beans.Schema2BeansException {
187         return new SunConnector(doc, Common.NO_DEFAULT_VALUES);
188     }
189
190     public static SunConnector createGraph(java.io.InputStream JavaDoc in) throws org.netbeans.modules.schema2beans.Schema2BeansException {
191         return createGraph(in, false);
192     }
193
194     public static SunConnector createGraph(java.io.InputStream JavaDoc in, boolean validate) throws org.netbeans.modules.schema2beans.Schema2BeansException {
195         Document doc = GraphManager.createXmlDocument(in, validate);
196         return createGraph(doc);
197     }
198
199     //
200
// This method returns the root for a new empty bean graph
201
//
202
public static SunConnector createGraph() {
203         try {
204             return new SunConnector();
205         }
206         catch (Schema2BeansException e) {
207             throw new RuntimeException JavaDoc(e.getMessage());
208         }
209     }
210
211     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
212         boolean restrictionFailure = false;
213         // Validating property resourceAdapter
214
if (getResourceAdapter() == null) {
215             throw new org.netbeans.modules.schema2beans.ValidateException("getResourceAdapter() == null", "resourceAdapter", this); // NOI18N
216
}
217         getResourceAdapter().validate();
218         // Validating property roleMap
219
if (getRoleMap() != null) {
220             getRoleMap().validate();
221         }
222     }
223
224     // Special serializer: output XML as serialization
225
private void writeObject(java.io.ObjectOutputStream JavaDoc out) throws java.io.IOException JavaDoc{
226         ByteArrayOutputStream baos = new ByteArrayOutputStream();
227         write(baos);
228         String JavaDoc str = baos.toString();;
229         // System.out.println("str='"+str+"'");
230
out.writeUTF(str);
231     }
232     // Special deserializer: read XML as deserialization
233
private void readObject(java.io.ObjectInputStream JavaDoc in) throws java.io.IOException JavaDoc, ClassNotFoundException JavaDoc{
234         try{
235             init(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
236             String JavaDoc strDocument = in.readUTF();
237             // System.out.println("strDocument='"+strDocument+"'");
238
ByteArrayInputStream bais = new ByteArrayInputStream(strDocument.getBytes());
239             Document doc = GraphManager.createXmlDocument(bais, false);
240             initOptions(Common.NO_DEFAULT_VALUES);
241             initFromNode(doc, Common.NO_DEFAULT_VALUES);
242         }
243         catch (Schema2BeansException e) {
244             e.printStackTrace();
245             throw new RuntimeException JavaDoc(e.getMessage());
246         }
247     }
248
249     // Dump the content of this bean returning it as a String
250
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
251         String JavaDoc s;
252         Object JavaDoc o;
253         org.netbeans.modules.schema2beans.BaseBean n;
254         str.append(indent);
255         str.append("ResourceAdapter"); // NOI18N
256
n = (org.netbeans.modules.schema2beans.BaseBean) this.getResourceAdapter();
257         if (n != null)
258             n.dump(str, indent + "\t"); // NOI18N
259
else
260             str.append(indent+"\tnull"); // NOI18N
261
this.dumpAttributes(RESOURCE_ADAPTER, 0, str, indent);
262
263         str.append(indent);
264         str.append("RoleMap"); // NOI18N
265
n = (org.netbeans.modules.schema2beans.BaseBean) this.getRoleMap();
266         if (n != null)
267             n.dump(str, indent + "\t"); // NOI18N
268
else
269             str.append(indent+"\tnull"); // NOI18N
270
this.dumpAttributes(ROLE_MAP, 0, str, indent);
271
272     }
273     public String JavaDoc dumpBeanNode(){
274         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
275         str.append("SunConnector\n"); // NOI18N
276
this.dump(str, "\n "); // NOI18N
277
return str.toString();
278     }}
279
280 // END_NOI18N
281

282
283 /*
284         The following schema file has been used for generation:
285
286 <!--
287   XML DTD for Sun ONE Application Server specific J2EE Resource Adapter
288   deployment descriptor. This is a companion DTD to connector_1_5.xsd
289
290   $Revision: 1.3 $
291 -->
292
293 <!-- Each deployed Resource Adapter (RAR) Module, will have ias-ra.xml
294      associated with it, which specifies several dynamic configuration
295      properties. Key aspects are pool sizing and security role maps.
296  -->
297 <!ELEMENT sun-connector (resource-adapter, role-map?)>
298
299 <!-- Resource adapter configuration
300
301      jndi-name name by which, this adapter will appear in JNDI tree
302      max-pool-size maximum size of connection to EIS
303      steady-pool-size initial and minimum number of connections to be maintained
304      max-wait-in-millis if a connection is not readily found, caller will have to
305                         wait this long, before a connection is created. A value of
306                         0 implies, wait till a connection becomes available. If the
307                         pool is completely utilized and the timer expires, an
308                         exception will be delivered to the application.
309
310      idle-timeout-in-seconds A timer thread periodically removed unused connections.
311                              The interval at which this thread runs. All idle
312                              connections will be removed, while mainataining
313                              the configured steady-pool-size.
314 -->
315 <!ELEMENT resource-adapter (description?, property*)>
316 <!ATTLIST resource-adapter jndi-name CDATA #REQUIRED
317                            max-pool-size CDATA "32"
318                            steady-pool-size CDATA "4"
319                            max-wait-time-in-millis CDATA "10000"
320                            idle-timeout-in-seconds CDATA "1000">
321
322 <!-- Perform mapping from principal received during Servlet/EJB
323      authentication, to credentials accepted by the EIS. This
324      mapping is optional. The map consists of several 2-tuples
325      map-id is the name of the mapping
326  -->
327 <!ELEMENT role-map (description?, map-element*)>
328 <!ATTLIST role-map map-id CDATA #REQUIRED>
329                 
330
331 <!-- It is possible to map multiple (server) principal to the
332      same backend principal.
333 -->
334 <!ELEMENT map-element (principal+, backend-principal)>
335
336 <!-- Principal of the Servlet and EJB client -->
337 <!ELEMENT principal (description?)>
338 <!ATTLIST principal user-name CDATA #REQUIRED>
339  
340 <!-- Backend EIS principal -->
341 <!ELEMENT backend-principal EMPTY>
342 <!ATTLIST backend-principal user-name CDATA #REQUIRED
343                             password CDATA #REQUIRED
344                             credential CDATA #REQUIRED>
345
346 <!ELEMENT description (#PCDATA)>
347
348 <!-- Syntax for supplying properties as name value pairs -->
349 <!ELEMENT property EMPTY>
350 <!ATTLIST property name CDATA #REQUIRED
351                    value CDATA #REQUIRED>
352
353 */

354
Popular Tags