KickJava   Java API By Example, From Geeks To Geeks.

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


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 WebServiceEndpoint matches the DTD element web-service-endpoint
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 WebServiceEndpoint 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 REGISTRY_LOCATION = "RegistryLocation";
50     static public final String JavaDoc TRANSFORMATION_RULE = "TransformationRule";
51
52     public WebServiceEndpoint() {
53         this(Common.USE_DEFAULT_VALUES);
54     }
55
56     public WebServiceEndpoint(int options)
57     {
58         super(comparators, runtimeVersion);
59         // Properties (see root bean comments for the bean graph)
60
initPropertyTables(2);
61         this.createProperty("registry-location", REGISTRY_LOCATION,
62             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
63             RegistryLocation.class);
64         this.createAttribute(REGISTRY_LOCATION, "connector-resource-jndi-name", "ConnectorResourceJndiName",
65                         AttrProp.CDATA | AttrProp.REQUIRED,
66                         null, null);
67         this.createProperty("transformation-rule", TRANSFORMATION_RULE,
68             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
69             TransformationRule.class);
70         this.createAttribute(TRANSFORMATION_RULE, "name", "Name",
71                         AttrProp.CDATA | AttrProp.REQUIRED,
72                         null, null);
73         this.createAttribute(TRANSFORMATION_RULE, "enabled", "Enabled",
74                         AttrProp.CDATA,
75                         null, "true");
76         this.createAttribute(TRANSFORMATION_RULE, "apply-to", "ApplyTo",
77                         AttrProp.CDATA,
78                         null, "request");
79         this.createAttribute(TRANSFORMATION_RULE, "rule-file-location", "RuleFileLocation",
80                         AttrProp.CDATA | AttrProp.REQUIRED,
81                         null, null);
82         this.initialize(options);
83     }
84
85     // Setting the default values of the properties
86
void initialize(int options) {
87
88     }
89
90     // This attribute is an array, possibly empty
91
public void setRegistryLocation(int index, RegistryLocation value) {
92         this.setValue(REGISTRY_LOCATION, index, value);
93     }
94
95     // Get Method
96
public RegistryLocation getRegistryLocation(int index) {
97         return (RegistryLocation)this.getValue(REGISTRY_LOCATION, index);
98     }
99
100     // This attribute is an array, possibly empty
101
public void setRegistryLocation(RegistryLocation[] value) {
102         this.setValue(REGISTRY_LOCATION, value);
103     }
104
105     // Getter Method
106
public RegistryLocation[] getRegistryLocation() {
107         return (RegistryLocation[])this.getValues(REGISTRY_LOCATION);
108     }
109
110     // Return the number of properties
111
public int sizeRegistryLocation() {
112         return this.size(REGISTRY_LOCATION);
113     }
114
115     // Add a new element returning its index in the list
116
public int addRegistryLocation(RegistryLocation value)
117             throws ConfigException{
118         return addRegistryLocation(value, true);
119     }
120
121     // Add a new element returning its index in the list with a boolean flag
122
public int addRegistryLocation(RegistryLocation value, boolean overwrite)
123             throws ConfigException{
124         RegistryLocation old = getRegistryLocationByConnectorResourceJndiName(value.getConnectorResourceJndiName());
125         if(old != null) {
126             throw new ConfigException(StringManager.getManager(WebServiceEndpoint.class).getString("cannotAddDuplicate", "RegistryLocation"));
127         }
128         return this.addValue(REGISTRY_LOCATION, value, overwrite);
129     }
130
131     //
132
// Remove an element using its reference
133
// Returns the index the element had in the list
134
//
135
public int removeRegistryLocation(RegistryLocation value){
136         return this.removeValue(REGISTRY_LOCATION, value);
137     }
138
139     //
140
// Remove an element using its reference
141
// Returns the index the element had in the list
142
// with boolean overwrite
143
//
144
public int removeRegistryLocation(RegistryLocation value, boolean overwrite)
145             throws StaleWriteConfigException{
146         return this.removeValue(REGISTRY_LOCATION, value, overwrite);
147     }
148
149     public RegistryLocation getRegistryLocationByConnectorResourceJndiName(String JavaDoc id) {
150      if (null != id) { id = id.trim(); }
151     RegistryLocation[] o = getRegistryLocation();
152      if (o == null) return null;
153
154      for (int i=0; i < o.length; i++) {
155          if(o[i].getAttributeValue(Common.convertName(ServerTags.CONNECTOR_RESOURCE_JNDI_NAME)).equals(id)) {
156              return o[i];
157          }
158      }
159
160         return null;
161         
162     }
163     // This attribute is an array, possibly empty
164
public void setTransformationRule(int index, TransformationRule value) {
165         this.setValue(TRANSFORMATION_RULE, index, value);
166     }
167
168     // Get Method
169
public TransformationRule getTransformationRule(int index) {
170         return (TransformationRule)this.getValue(TRANSFORMATION_RULE, index);
171     }
172
173     // This attribute is an array, possibly empty
174
public void setTransformationRule(TransformationRule[] value) {
175         this.setValue(TRANSFORMATION_RULE, value);
176     }
177
178     // Getter Method
179
public TransformationRule[] getTransformationRule() {
180         return (TransformationRule[])this.getValues(TRANSFORMATION_RULE);
181     }
182
183     // Return the number of properties
184
public int sizeTransformationRule() {
185         return this.size(TRANSFORMATION_RULE);
186     }
187
188     // Add a new element returning its index in the list
189
public int addTransformationRule(TransformationRule value)
190             throws ConfigException{
191         return addTransformationRule(value, true);
192     }
193
194     // Add a new element returning its index in the list with a boolean flag
195
public int addTransformationRule(TransformationRule value, boolean overwrite)
196             throws ConfigException{
197         TransformationRule old = getTransformationRuleByName(value.getName());
198         if(old != null) {
199             throw new ConfigException(StringManager.getManager(WebServiceEndpoint.class).getString("cannotAddDuplicate", "TransformationRule"));
200         }
201         return this.addValue(TRANSFORMATION_RULE, value, overwrite);
202     }
203
204     //
205
// Remove an element using its reference
206
// Returns the index the element had in the list
207
//
208
public int removeTransformationRule(TransformationRule value){
209         return this.removeValue(TRANSFORMATION_RULE, value);
210     }
211
212     //
213
// Remove an element using its reference
214
// Returns the index the element had in the list
215
// with boolean overwrite
216
//
217
public int removeTransformationRule(TransformationRule value, boolean overwrite)
218             throws StaleWriteConfigException{
219         return this.removeValue(TRANSFORMATION_RULE, value, overwrite);
220     }
221
222     public TransformationRule getTransformationRuleByName(String JavaDoc id) {
223      if (null != id) { id = id.trim(); }
224     TransformationRule[] o = getTransformationRule();
225      if (o == null) return null;
226
227      for (int i=0; i < o.length; i++) {
228          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
229              return o[i];
230          }
231      }
232
233         return null;
234         
235     }
236     /**
237     * Getter for Name of the Element web-service-endpoint
238     * @return the Name of the Element web-service-endpoint
239     */

240     public String JavaDoc getName() {
241         return getAttributeValue(ServerTags.NAME);
242     }
243     /**
244     * Modify the Name of the Element web-service-endpoint
245     * @param v the new value
246     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
247     */

248     public void setName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
249         setAttributeValue(ServerTags.NAME, v, overwrite);
250     }
251     /**
252     * Modify the Name of the Element web-service-endpoint
253     * @param v the new value
254     */

255     public void setName(String JavaDoc v) {
256         setAttributeValue(ServerTags.NAME, v);
257     }
258     /**
259     * Getter for Monitoring of the Element web-service-endpoint
260     * @return the Monitoring of the Element web-service-endpoint
261     */

262     public String JavaDoc getMonitoring() {
263         return getAttributeValue(ServerTags.MONITORING);
264     }
265     /**
266     * Modify the Monitoring of the Element web-service-endpoint
267     * @param v the new value
268     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
269     */

270     public void setMonitoring(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
271         setAttributeValue(ServerTags.MONITORING, v, overwrite);
272     }
273     /**
274     * Modify the Monitoring of the Element web-service-endpoint
275     * @param v the new value
276     */

277     public void setMonitoring(String JavaDoc v) {
278         setAttributeValue(ServerTags.MONITORING, v);
279     }
280     /**
281     * Get the default value of Monitoring from dtd
282     */

283     public static String JavaDoc getDefaultMonitoring() {
284         return "OFF".trim();
285     }
286     /**
287     * Getter for MaxHistorySize of the Element web-service-endpoint
288     * @return the MaxHistorySize of the Element web-service-endpoint
289     */

290     public String JavaDoc getMaxHistorySize() {
291         return getAttributeValue(ServerTags.MAX_HISTORY_SIZE);
292     }
293     /**
294     * Modify the MaxHistorySize of the Element web-service-endpoint
295     * @param v the new value
296     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
297     */

298     public void setMaxHistorySize(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
299         setAttributeValue(ServerTags.MAX_HISTORY_SIZE, v, overwrite);
300     }
301     /**
302     * Modify the MaxHistorySize of the Element web-service-endpoint
303     * @param v the new value
304     */

305     public void setMaxHistorySize(String JavaDoc v) {
306         setAttributeValue(ServerTags.MAX_HISTORY_SIZE, v);
307     }
308     /**
309     * Get the default value of MaxHistorySize from dtd
310     */

311     public static String JavaDoc getDefaultMaxHistorySize() {
312         return "25".trim();
313     }
314     /**
315     * Getter for JbiEnabled of the Element web-service-endpoint
316     * @return the JbiEnabled of the Element web-service-endpoint
317     */

318     public boolean isJbiEnabled() {
319         return toBoolean(getAttributeValue(ServerTags.JBI_ENABLED));
320     }
321     /**
322     * Modify the JbiEnabled of the Element web-service-endpoint
323     * @param v the new value
324     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
325     */

326     public void setJbiEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
327         setAttributeValue(ServerTags.JBI_ENABLED, ""+(v==true), overwrite);
328     }
329     /**
330     * Modify the JbiEnabled of the Element web-service-endpoint
331     * @param v the new value
332     */

333     public void setJbiEnabled(boolean v) {
334         setAttributeValue(ServerTags.JBI_ENABLED, ""+(v==true));
335     }
336     /**
337     * Get the default value of JbiEnabled from dtd
338     */

339     public static String JavaDoc getDefaultJbiEnabled() {
340         return "true".trim();
341     }
342     /**
343      * Create a new bean using it's default constructor.
344      * This does not add it to any bean graph.
345      */

346     public RegistryLocation newRegistryLocation() {
347         return new RegistryLocation();
348     }
349
350     /**
351      * Create a new bean using it's default constructor.
352      * This does not add it to any bean graph.
353      */

354     public TransformationRule newTransformationRule() {
355         return new TransformationRule();
356     }
357
358     /**
359     * get the xpath representation for this element
360     * returns something like abc[@name='value'] or abc
361     * depending on the type of the bean
362     */

363     protected String JavaDoc getRelativeXPath() {
364         String JavaDoc ret = null;
365         ret = "web-service-endpoint" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ;
366         return (null != ret ? ret.trim() : null);
367     }
368
369     /*
370     * generic method to get default value from dtd
371     */

372     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
373         if(attr == null) return null;
374         attr = attr.trim();
375         if(attr.equals(ServerTags.MONITORING)) return "OFF".trim();
376         if(attr.equals(ServerTags.MAX_HISTORY_SIZE)) return "25".trim();
377         if(attr.equals(ServerTags.JBI_ENABLED)) return "true".trim();
378     return null;
379     }
380     //
381
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
382         comparators.add(c);
383     }
384
385     //
386
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
387         comparators.remove(c);
388     }
389     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
390     }
391
392     // Dump the content of this bean returning it as a String
393
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
394         String JavaDoc s;
395         Object JavaDoc o;
396         org.netbeans.modules.schema2beans.BaseBean n;
397         str.append(indent);
398         str.append("RegistryLocation["+this.sizeRegistryLocation()+"]"); // NOI18N
399
for(int i=0; i<this.sizeRegistryLocation(); i++)
400         {
401             str.append(indent+"\t");
402             str.append("#"+i+":");
403             n = (org.netbeans.modules.schema2beans.BaseBean) this.getRegistryLocation(i);
404             if (n != null)
405                 n.dump(str, indent + "\t"); // NOI18N
406
else
407                 str.append(indent+"\tnull"); // NOI18N
408
this.dumpAttributes(REGISTRY_LOCATION, i, str, indent);
409         }
410
411         str.append(indent);
412         str.append("TransformationRule["+this.sizeTransformationRule()+"]"); // NOI18N
413
for(int i=0; i<this.sizeTransformationRule(); i++)
414         {
415             str.append(indent+"\t");
416             str.append("#"+i+":");
417             n = (org.netbeans.modules.schema2beans.BaseBean) this.getTransformationRule(i);
418             if (n != null)
419                 n.dump(str, indent + "\t"); // NOI18N
420
else
421                 str.append(indent+"\tnull"); // NOI18N
422
this.dumpAttributes(TRANSFORMATION_RULE, i, str, indent);
423         }
424
425     }
426     public String JavaDoc dumpBeanNode(){
427         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
428         str.append("WebServiceEndpoint\n"); // NOI18N
429
this.dump(str, "\n "); // NOI18N
430
return str.toString();
431     }}
432
433 // END_NOI18N
434

435
Popular Tags