KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > dd > application > SunApplication


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 SunApplication matches the schema element sun-application
26  *
27  * Generated on Thu Jul 31 15:31:46 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-application : SunApplication
33  * web : Web[0,n]
34  * web-uri : String
35  * context-root : String
36  * pass-by-reference : String?
37  * unique-id : String?
38  * security-role-mapping : SecurityRoleMapping[0,n]
39  * role-name : String
40  * (
41  * | principal-name : String
42  * | group-name : String
43  * )[1,n]
44  * realm : String?
45  *
46  */

47
48 package com.sun.enterprise.tools.common.dd.application;
49
50 import org.w3c.dom.*;
51 import org.netbeans.modules.schema2beans.*;
52 import java.beans.*;
53 import java.util.*;
54 import java.io.*;
55 import com.sun.enterprise.tools.common.dd.SecurityRoleMapping;
56 import com.sun.enterprise.tools.common.dd.PluginData;
57
58 // BEGIN_NOI18N
59

60 public class SunApplication extends com.sun.enterprise.tools.common.dd.SunBaseBean
61 {
62
63     static Vector comparators = new Vector();
64
65     static public final String JavaDoc WEB = "Web"; // NOI18N
66
static public final String JavaDoc PASS_BY_REFERENCE = "PassByReference"; // NOI18N
67
static public final String JavaDoc UNIQUE_ID = "UniqueId"; // NOI18N
68
static public final String JavaDoc SECURITY_ROLE_MAPPING = "SecurityRoleMapping"; // NOI18N
69
static public final String JavaDoc REALM = "Realm"; // NOI18N
70

71     public SunApplication() throws org.netbeans.modules.schema2beans.Schema2BeansException {
72         this(null, Common.USE_DEFAULT_VALUES);
73     }
74
75     public SunApplication(org.w3c.dom.Node JavaDoc doc, int options) throws org.netbeans.modules.schema2beans.Schema2BeansException {
76         this(Common.NO_DEFAULT_VALUES);
77         initFromNode(doc, options);
78     }
79     protected void initFromNode(org.w3c.dom.Node JavaDoc doc, int options) throws Schema2BeansException
80     {
81         if (doc == null)
82         {
83             doc = GraphManager.createRootElementNode("sun-application"); // NOI18N
84
if (doc == null)
85                 throw new Schema2BeansException(Common.getMessage(
86                     "CantCreateDOMRoot_msg", "sun-application"));
87         }
88         Node n = GraphManager.getElementNode("sun-application", doc); // NOI18N
89
if (n == null)
90             throw new Schema2BeansException(Common.getMessage(
91                 "DocRootNotInDOMGraph_msg", "sun-application", doc.getFirstChild().getNodeName()));
92
93         this.graphManager.setXmlDocument(doc);
94
95         // Entry point of the createBeans() recursive calls
96
this.createBean(n, this.graphManager());
97         this.initialize(options);
98     }
99     public SunApplication(int options)
100     {
101         super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
102         initOptions(options);
103     }
104     protected void initOptions(int options)
105     {
106         // The graph manager is allocated in the bean root
107
this.graphManager = new GraphManager(this);
108         this.createRoot("sun-application", "SunApplication", // NOI18N
109
Common.TYPE_1 | Common.TYPE_BEAN, SunApplication.class);
110
111         // Properties (see root bean comments for the bean graph)
112
this.createProperty("web", // NOI18N
113
WEB,
114             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
115             Web.class);
116         this.createProperty("pass-by-reference", // NOI18N
117
PASS_BY_REFERENCE,
118             Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY,
119             String JavaDoc.class);
120         this.createProperty("unique-id", // NOI18N
121
UNIQUE_ID,
122             Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY,
123             String JavaDoc.class);
124         this.createProperty("security-role-mapping", // NOI18N
125
SECURITY_ROLE_MAPPING,
126             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
127             SecurityRoleMapping.class);
128         this.createProperty("realm", // NOI18N
129
REALM,
130             Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY,
131             String JavaDoc.class);
132         this.initialize(options);
133     }
134
135     // Setting the default values of the properties
136
void initialize(int options)
137     {
138             
139     }
140
141     // This attribute is an array, possibly empty
142
public void setWeb(int index, Web value) {
143         this.setValue(WEB, index, value);
144     }
145
146     //
147
public Web getWeb(int index) {
148         return (Web)this.getValue(WEB, index);
149     }
150
151     // This attribute is an array, possibly empty
152
public void setWeb(Web[] value) {
153         this.setValue(WEB, value);
154     }
155
156     //
157
public Web[] getWeb() {
158         return (Web[])this.getValues(WEB);
159     }
160
161     // Return the number of properties
162
public int sizeWeb() {
163         return this.size(WEB);
164     }
165
166     // Add a new element returning its index in the list
167
public int addWeb(com.sun.enterprise.tools.common.dd.application.Web value) {
168         return this.addValue(WEB, value);
169     }
170
171     //
172
// Remove an element using its reference
173
// Returns the index the element had in the list
174
//
175
public int removeWeb(com.sun.enterprise.tools.common.dd.application.Web value) {
176         return this.removeValue(WEB, value);
177     }
178
179     // This attribute is optional
180
public void setPassByReference(String JavaDoc value) {
181         this.setValue(PASS_BY_REFERENCE, value);
182     }
183
184     //
185
public String JavaDoc getPassByReference() {
186         return (String JavaDoc)this.getValue(PASS_BY_REFERENCE);
187     }
188
189     // This attribute is optional
190
public void setUniqueId(String JavaDoc value) {
191         this.setValue(UNIQUE_ID, value);
192     }
193
194     //
195
public String JavaDoc getUniqueId() {
196         return (String JavaDoc)this.getValue(UNIQUE_ID);
197     }
198
199     // This attribute is an array, possibly empty
200
public void setSecurityRoleMapping(int index, SecurityRoleMapping value) {
201         this.setValue(SECURITY_ROLE_MAPPING, index, value);
202     }
203
204     //
205
public SecurityRoleMapping getSecurityRoleMapping(int index) {
206         return (SecurityRoleMapping)this.getValue(SECURITY_ROLE_MAPPING, index);
207     }
208
209     // This attribute is an array, possibly empty
210
public void setSecurityRoleMapping(SecurityRoleMapping[] value) {
211         this.setValue(SECURITY_ROLE_MAPPING, value);
212     }
213
214     //
215
public SecurityRoleMapping[] getSecurityRoleMapping() {
216         return (SecurityRoleMapping[])this.getValues(SECURITY_ROLE_MAPPING);
217     }
218
219     // Return the number of properties
220
public int sizeSecurityRoleMapping() {
221         return this.size(SECURITY_ROLE_MAPPING);
222     }
223
224     // Add a new element returning its index in the list
225
public int addSecurityRoleMapping(SecurityRoleMapping value) {
226         return this.addValue(SECURITY_ROLE_MAPPING, value);
227     }
228
229     //
230
// Remove an element using its reference
231
// Returns the index the element had in the list
232
//
233
public int removeSecurityRoleMapping(SecurityRoleMapping value) {
234         return this.removeValue(SECURITY_ROLE_MAPPING, value);
235     }
236
237     // This attribute is optional
238
public void setRealm(String JavaDoc value) {
239         this.setValue(REALM, value);
240     }
241
242     //
243
public String JavaDoc getRealm() {
244         return (String JavaDoc)this.getValue(REALM);
245     }
246
247     //
248
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
249         comparators.add(c);
250     }
251
252     //
253
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
254         comparators.remove(c);
255     }
256     //
257
// This method returns the root of the bean graph
258
// Each call creates a new bean graph from the specified DOM graph
259
//
260
public static SunApplication createGraph(org.w3c.dom.Node JavaDoc doc) throws org.netbeans.modules.schema2beans.Schema2BeansException {
261         return new SunApplication(doc, Common.NO_DEFAULT_VALUES);
262     }
263
264     public static SunApplication createGraph(java.io.InputStream JavaDoc in) throws org.netbeans.modules.schema2beans.Schema2BeansException {
265         return createGraph(in, false);
266     }
267
268     public static SunApplication createGraph(java.io.InputStream JavaDoc in, boolean validate) throws org.netbeans.modules.schema2beans.Schema2BeansException {
269         Document doc = GraphManager.createXmlDocument(in, validate);
270         return createGraph(doc);
271     }
272
273     //
274
// This method returns the root for a new empty bean graph
275
//
276
public static SunApplication createGraph() {
277         try {
278             return new SunApplication();
279         }
280         catch (Schema2BeansException e) {
281             throw new RuntimeException JavaDoc(e.getMessage());
282         }
283     }
284
285     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
286         boolean restrictionFailure = false;
287         // Validating property web
288
for (int _index = 0; _index < sizeWeb(); ++_index) {
289             com.sun.enterprise.tools.common.dd.application.Web element = getWeb(_index);
290             if (element != null) {
291                 element.validate();
292             }
293         }
294         // Validating property passByReference
295
if (getPassByReference() != null) {
296         }
297         // Validating property uniqueId
298
if (getUniqueId() != null) {
299         }
300         // Validating property securityRoleMapping
301
for (int _index = 0; _index < sizeSecurityRoleMapping(); ++_index) {
302             SecurityRoleMapping element = getSecurityRoleMapping(_index);
303             if (element != null) {
304                 element.validate();
305             }
306         }
307         // Validating property realm
308
if (getRealm() != null) {
309         }
310     }
311
312     // Special serializer: output XML as serialization
313
private void writeObject(java.io.ObjectOutputStream JavaDoc out) throws java.io.IOException JavaDoc{
314         ByteArrayOutputStream baos = new ByteArrayOutputStream();
315         write(baos);
316         String JavaDoc str = baos.toString();;
317         // System.out.println("str='"+str+"'");
318
out.writeUTF(str);
319     }
320     // Special deserializer: read XML as deserialization
321
private void readObject(java.io.ObjectInputStream JavaDoc in) throws java.io.IOException JavaDoc, ClassNotFoundException JavaDoc{
322         try{
323             init(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
324             String JavaDoc strDocument = in.readUTF();
325             // System.out.println("strDocument='"+strDocument+"'");
326
ByteArrayInputStream bais = new ByteArrayInputStream(strDocument.getBytes());
327             Document doc = GraphManager.createXmlDocument(bais, false);
328             initOptions(Common.NO_DEFAULT_VALUES);
329             initFromNode(doc, Common.NO_DEFAULT_VALUES);
330         }
331         catch (Schema2BeansException e) {
332             e.printStackTrace();
333             throw new RuntimeException JavaDoc(e.getMessage());
334         }
335     }
336
337     // Dump the content of this bean returning it as a String
338
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
339         String JavaDoc s;
340         Object JavaDoc o;
341         org.netbeans.modules.schema2beans.BaseBean n;
342         str.append(indent);
343         str.append("Web["+this.sizeWeb()+"]"); // NOI18N
344
for(int i=0; i<this.sizeWeb(); i++)
345         {
346             str.append(indent+"\t");
347             str.append("#"+i+":");
348             n = (org.netbeans.modules.schema2beans.BaseBean) this.getWeb(i);
349             if (n != null)
350                 n.dump(str, indent + "\t"); // NOI18N
351
else
352                 str.append(indent+"\tnull"); // NOI18N
353
this.dumpAttributes(WEB, i, str, indent);
354         }
355
356         str.append(indent);
357         str.append("PassByReference"); // NOI18N
358
str.append(indent+"\t"); // NOI18N
359
str.append("<"); // NOI18N
360
s = this.getPassByReference();
361         str.append((s==null?"null":s.trim())); // NOI18N
362
str.append(">\n"); // NOI18N
363
this.dumpAttributes(PASS_BY_REFERENCE, 0, str, indent);
364
365         str.append(indent);
366         str.append("UniqueId"); // NOI18N
367
str.append(indent+"\t"); // NOI18N
368
str.append("<"); // NOI18N
369
s = this.getUniqueId();
370         str.append((s==null?"null":s.trim())); // NOI18N
371
str.append(">\n"); // NOI18N
372
this.dumpAttributes(UNIQUE_ID, 0, str, indent);
373
374         str.append(indent);
375         str.append("SecurityRoleMapping["+this.sizeSecurityRoleMapping()+"]"); // NOI18N
376
for(int i=0; i<this.sizeSecurityRoleMapping(); i++)
377         {
378             str.append(indent+"\t");
379             str.append("#"+i+":");
380             n = (org.netbeans.modules.schema2beans.BaseBean) this.getSecurityRoleMapping(i);
381             if (n != null)
382                 n.dump(str, indent + "\t"); // NOI18N
383
else
384                 str.append(indent+"\tnull"); // NOI18N
385
this.dumpAttributes(SECURITY_ROLE_MAPPING, i, str, indent);
386         }
387
388         str.append(indent);
389         str.append("Realm"); // NOI18N
390
str.append(indent+"\t"); // NOI18N
391
str.append("<"); // NOI18N
392
s = this.getRealm();
393         str.append((s==null?"null":s.trim())); // NOI18N
394
str.append(">\n"); // NOI18N
395
this.dumpAttributes(REALM, 0, str, indent);
396
397     }
398     public String JavaDoc dumpBeanNode(){
399         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
400         str.append("SunApplication\n"); // NOI18N
401
this.dump(str, "\n "); // NOI18N
402
return str.toString();
403     }}
404
405 // END_NOI18N
406

407
408 /*
409         The following schema file has been used for generation:
410
411 <!--
412   XML DTD for Sun ONE Application Server specific J2EE Application
413   deployment descriptor. This is a companion DTD to application_1.4.xsd
414
415   $Revision: 1.3 $
416 -->
417
418 <!--
419 This is the root element of the runtime descriptor document.
420 -->
421 <!ELEMENT sun-application (web*, pass-by-reference?, unique-id?, security-role-mapping*, realm?) >
422
423 <!ELEMENT web (web-uri, context-root)>
424 <!ELEMENT web-uri (#PCDATA)>
425 <!ELEMENT context-root (#PCDATA)>
426
427 <!-- Pass by Reference semantics: EJB spec requires pass by value,
428      which will be the default mode of operation. This can be set
429      to true for non-compliant and possibly higher performance.
430      For a stand-alone, this can be set at this level. By setting
431      a similarly named element at sun-application, it can apply to
432      all the enclosed ejb modules. Allowed values are true and
433      false. Default will be false.
434  -->
435 <!ELEMENT pass-by-reference (#PCDATA)>
436
437 <!-- Automatically generated and updated at deployment/redeployment
438      Needs to be unqiue in the system.
439   -->
440 <!ELEMENT unique-id (#PCDATA)>
441
442 <!ELEMENT security-role-mapping (role-name, (principal-name | group-name)+)>
443
444 <!ELEMENT role-name (#PCDATA)>
445 <!ELEMENT principal-name (#PCDATA)>
446 <!ELEMENT group-name (#PCDATA)>
447
448 <!--
449   realm: Allows specifying an optional authentication realm name which will
450     be used to process all authentication requests associated with this
451     application. If this element is not specified (or if it is given but
452     does not match the name of a configured realm) then the default realm
453     set in the server instances security-service element will be used
454     instead.
455 -->
456 <!ELEMENT realm (#PCDATA)>
457
458 <!-- This information is used, only by Studio-plugin;it is NOT the part of the real DTD.
459 -->
460 <!ELEMENT plugin-data ( auto-generate-sql?, client-jar-path?, client-args? )>
461 <!ELEMENT auto-generate-sql (#PCDATA)>
462 <!ELEMENT client-jar-path (#PCDATA)>
463 <!ELEMENT client-args (#PCDATA)>
464
465 */

466
Popular Tags