KickJava   Java API By Example, From Geeks To Geeks.

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


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 ProviderConfig matches the DTD element provider-config
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 ProviderConfig 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 REQUEST_POLICY = "RequestPolicy";
50     static public final String JavaDoc RESPONSE_POLICY = "ResponsePolicy";
51     static public final String JavaDoc ELEMENT_PROPERTY = "ElementProperty";
52
53     public ProviderConfig() {
54         this(Common.USE_DEFAULT_VALUES);
55     }
56
57     public ProviderConfig(int options)
58     {
59         super(comparators, runtimeVersion);
60         // Properties (see root bean comments for the bean graph)
61
initPropertyTables(3);
62         this.createProperty("request-policy", REQUEST_POLICY,
63             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
64             RequestPolicy.class);
65         this.createAttribute(REQUEST_POLICY, "auth-source", "AuthSource",
66                         AttrProp.CDATA | AttrProp.IMPLIED,
67                         null, null);
68         this.createAttribute(REQUEST_POLICY, "auth-recipient", "AuthRecipient",
69                         AttrProp.CDATA | AttrProp.IMPLIED,
70                         null, null);
71         this.createProperty("response-policy", RESPONSE_POLICY,
72             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
73             ResponsePolicy.class);
74         this.createAttribute(RESPONSE_POLICY, "auth-source", "AuthSource",
75                         AttrProp.CDATA | AttrProp.IMPLIED,
76                         null, null);
77         this.createAttribute(RESPONSE_POLICY, "auth-recipient", "AuthRecipient",
78                         AttrProp.CDATA | AttrProp.IMPLIED,
79                         null, null);
80         this.createProperty("property", ELEMENT_PROPERTY,
81             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
82             ElementProperty.class);
83         this.createAttribute(ELEMENT_PROPERTY, "name", "Name",
84                         AttrProp.CDATA | AttrProp.REQUIRED,
85                         null, null);
86         this.createAttribute(ELEMENT_PROPERTY, "value", "Value",
87                         AttrProp.CDATA | AttrProp.REQUIRED,
88                         null, null);
89         this.initialize(options);
90     }
91
92     // Setting the default values of the properties
93
void initialize(int options) {
94
95     }
96
97     // This attribute is optional
98
public void setRequestPolicy(RequestPolicy value) {
99         this.setValue(REQUEST_POLICY, value);
100     }
101
102     // Get Method
103
public RequestPolicy getRequestPolicy() {
104         return (RequestPolicy)this.getValue(REQUEST_POLICY);
105     }
106
107     // This attribute is optional
108
public void setResponsePolicy(ResponsePolicy value) {
109         this.setValue(RESPONSE_POLICY, value);
110     }
111
112     // Get Method
113
public ResponsePolicy getResponsePolicy() {
114         return (ResponsePolicy)this.getValue(RESPONSE_POLICY);
115     }
116
117     // This attribute is an array, possibly empty
118
public void setElementProperty(int index, ElementProperty value) {
119         this.setValue(ELEMENT_PROPERTY, index, value);
120     }
121
122     // Get Method
123
public ElementProperty getElementProperty(int index) {
124         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
125     }
126
127     // This attribute is an array, possibly empty
128
public void setElementProperty(ElementProperty[] value) {
129         this.setValue(ELEMENT_PROPERTY, value);
130     }
131
132     // Getter Method
133
public ElementProperty[] getElementProperty() {
134         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
135     }
136
137     // Return the number of properties
138
public int sizeElementProperty() {
139         return this.size(ELEMENT_PROPERTY);
140     }
141
142     // Add a new element returning its index in the list
143
public int addElementProperty(ElementProperty value)
144             throws ConfigException{
145         return addElementProperty(value, true);
146     }
147
148     // Add a new element returning its index in the list with a boolean flag
149
public int addElementProperty(ElementProperty value, boolean overwrite)
150             throws ConfigException{
151         ElementProperty old = getElementPropertyByName(value.getName());
152         if(old != null) {
153             throw new ConfigException(StringManager.getManager(ProviderConfig.class).getString("cannotAddDuplicate", "ElementProperty"));
154         }
155         return this.addValue(ELEMENT_PROPERTY, value, overwrite);
156     }
157
158     //
159
// Remove an element using its reference
160
// Returns the index the element had in the list
161
//
162
public int removeElementProperty(ElementProperty value){
163         return this.removeValue(ELEMENT_PROPERTY, value);
164     }
165
166     //
167
// Remove an element using its reference
168
// Returns the index the element had in the list
169
// with boolean overwrite
170
//
171
public int removeElementProperty(ElementProperty value, boolean overwrite)
172             throws StaleWriteConfigException{
173         return this.removeValue(ELEMENT_PROPERTY, value, overwrite);
174     }
175
176     public ElementProperty getElementPropertyByName(String JavaDoc id) {
177      if (null != id) { id = id.trim(); }
178     ElementProperty[] o = getElementProperty();
179      if (o == null) return null;
180
181      for (int i=0; i < o.length; i++) {
182          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
183              return o[i];
184          }
185      }
186
187         return null;
188         
189     }
190     /**
191     * Getter for ProviderId of the Element provider-config
192     * @return the ProviderId of the Element provider-config
193     */

194     public String JavaDoc getProviderId() {
195         return getAttributeValue(ServerTags.PROVIDER_ID);
196     }
197     /**
198     * Modify the ProviderId of the Element provider-config
199     * @param v the new value
200     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
201     */

202     public void setProviderId(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
203         setAttributeValue(ServerTags.PROVIDER_ID, v, overwrite);
204     }
205     /**
206     * Modify the ProviderId of the Element provider-config
207     * @param v the new value
208     */

209     public void setProviderId(String JavaDoc v) {
210         setAttributeValue(ServerTags.PROVIDER_ID, v);
211     }
212     /**
213     * Getter for ProviderType of the Element provider-config
214     * @return the ProviderType of the Element provider-config
215     */

216     public String JavaDoc getProviderType() {
217         return getAttributeValue(ServerTags.PROVIDER_TYPE);
218     }
219     /**
220     * Modify the ProviderType of the Element provider-config
221     * @param v the new value
222     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
223     */

224     public void setProviderType(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
225         setAttributeValue(ServerTags.PROVIDER_TYPE, v, overwrite);
226     }
227     /**
228     * Modify the ProviderType of the Element provider-config
229     * @param v the new value
230     */

231     public void setProviderType(String JavaDoc v) {
232         setAttributeValue(ServerTags.PROVIDER_TYPE, v);
233     }
234     /**
235     * Getter for ClassName of the Element provider-config
236     * @return the ClassName of the Element provider-config
237     */

238     public String JavaDoc getClassName() {
239         return getAttributeValue(ServerTags.CLASS_NAME);
240     }
241     /**
242     * Modify the ClassName of the Element provider-config
243     * @param v the new value
244     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
245     */

246     public void setClassName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
247         setAttributeValue(ServerTags.CLASS_NAME, v, overwrite);
248     }
249     /**
250     * Modify the ClassName of the Element provider-config
251     * @param v the new value
252     */

253     public void setClassName(String JavaDoc v) {
254         setAttributeValue(ServerTags.CLASS_NAME, v);
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 RequestPolicy newRequestPolicy() {
261         return new RequestPolicy();
262     }
263
264     /**
265      * Create a new bean using it's default constructor.
266      * This does not add it to any bean graph.
267      */

268     public ResponsePolicy newResponsePolicy() {
269         return new ResponsePolicy();
270     }
271
272     /**
273      * Create a new bean using it's default constructor.
274      * This does not add it to any bean graph.
275      */

276     public ElementProperty newElementProperty() {
277         return new ElementProperty();
278     }
279
280     /**
281     * get the xpath representation for this element
282     * returns something like abc[@name='value'] or abc
283     * depending on the type of the bean
284     */

285     protected String JavaDoc getRelativeXPath() {
286         String JavaDoc ret = null;
287         ret = "provider-config" + (canHaveSiblings() ? "[@provider-id='" + getAttributeValue("provider-id") +"']" : "") ;
288         return (null != ret ? ret.trim() : null);
289     }
290
291     /*
292     * generic method to get default value from dtd
293     */

294     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
295         if(attr == null) return null;
296         attr = attr.trim();
297     return null;
298     }
299     //
300
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
301         comparators.add(c);
302     }
303
304     //
305
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
306         comparators.remove(c);
307     }
308     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
309     }
310
311     // Dump the content of this bean returning it as a String
312
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
313         String JavaDoc s;
314         Object JavaDoc o;
315         org.netbeans.modules.schema2beans.BaseBean n;
316         str.append(indent);
317         str.append("RequestPolicy"); // NOI18N
318
n = (org.netbeans.modules.schema2beans.BaseBean) this.getRequestPolicy();
319         if (n != null)
320             n.dump(str, indent + "\t"); // NOI18N
321
else
322             str.append(indent+"\tnull"); // NOI18N
323
this.dumpAttributes(REQUEST_POLICY, 0, str, indent);
324
325         str.append(indent);
326         str.append("ResponsePolicy"); // NOI18N
327
n = (org.netbeans.modules.schema2beans.BaseBean) this.getResponsePolicy();
328         if (n != null)
329             n.dump(str, indent + "\t"); // NOI18N
330
else
331             str.append(indent+"\tnull"); // NOI18N
332
this.dumpAttributes(RESPONSE_POLICY, 0, str, indent);
333
334         str.append(indent);
335         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
336
for(int i=0; i<this.sizeElementProperty(); i++)
337         {
338             str.append(indent+"\t");
339             str.append("#"+i+":");
340             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
341             if (n != null)
342                 n.dump(str, indent + "\t"); // NOI18N
343
else
344                 str.append(indent+"\tnull"); // NOI18N
345
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
346         }
347
348     }
349     public String JavaDoc dumpBeanNode(){
350         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
351         str.append("ProviderConfig\n"); // NOI18N
352
this.dump(str, "\n "); // NOI18N
353
return str.toString();
354     }}
355
356 // END_NOI18N
357

358
Popular Tags