KickJava   Java API By Example, From Geeks To Geeks.

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


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 AdminService matches the DTD element admin-service
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 AdminService 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 JMX_CONNECTOR = "JmxConnector";
50     static public final String JavaDoc DAS_CONFIG = "DasConfig";
51     static public final String JavaDoc ELEMENT_PROPERTY = "ElementProperty";
52
53     public AdminService() {
54         this(Common.USE_DEFAULT_VALUES);
55     }
56
57     public AdminService(int options)
58     {
59         super(comparators, runtimeVersion);
60         // Properties (see root bean comments for the bean graph)
61
initPropertyTables(3);
62         this.createProperty("jmx-connector", JMX_CONNECTOR,
63             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
64             JmxConnector.class);
65         this.createAttribute(JMX_CONNECTOR, "name", "Name",
66                         AttrProp.CDATA | AttrProp.REQUIRED,
67                         null, null);
68         this.createAttribute(JMX_CONNECTOR, "enabled", "Enabled",
69                         AttrProp.CDATA,
70                         null, "true");
71         this.createAttribute(JMX_CONNECTOR, "protocol", "Protocol",
72                         AttrProp.CDATA,
73                         null, "rmi_jrmp");
74         this.createAttribute(JMX_CONNECTOR, "address", "Address",
75                         AttrProp.CDATA | AttrProp.REQUIRED,
76                         null, null);
77         this.createAttribute(JMX_CONNECTOR, "port", "Port",
78                         AttrProp.CDATA | AttrProp.REQUIRED,
79                         null, null);
80         this.createAttribute(JMX_CONNECTOR, "accept-all", "AcceptAll",
81                         AttrProp.CDATA,
82                         null, "false");
83         this.createAttribute(JMX_CONNECTOR, "auth-realm-name", "AuthRealmName",
84                         AttrProp.CDATA | AttrProp.REQUIRED,
85                         null, null);
86         this.createAttribute(JMX_CONNECTOR, "security-enabled", "SecurityEnabled",
87                         AttrProp.CDATA,
88                         null, "true");
89         this.createProperty("das-config", DAS_CONFIG,
90             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
91             DasConfig.class);
92         this.createAttribute(DAS_CONFIG, "dynamic-reload-enabled", "DynamicReloadEnabled",
93                         AttrProp.CDATA,
94                         null, "false");
95         this.createAttribute(DAS_CONFIG, "dynamic-reload-poll-interval-in-seconds", "DynamicReloadPollIntervalInSeconds",
96                         AttrProp.CDATA,
97                         null, "2");
98         this.createAttribute(DAS_CONFIG, "autodeploy-enabled", "AutodeployEnabled",
99                         AttrProp.CDATA,
100                         null, "false");
101         this.createAttribute(DAS_CONFIG, "autodeploy-polling-interval-in-seconds", "AutodeployPollingIntervalInSeconds",
102                         AttrProp.CDATA,
103                         null, "2");
104         this.createAttribute(DAS_CONFIG, "autodeploy-dir", "AutodeployDir",
105                         AttrProp.CDATA,
106                         null, "autodeploy");
107         this.createAttribute(DAS_CONFIG, "autodeploy-verifier-enabled", "AutodeployVerifierEnabled",
108                         AttrProp.CDATA,
109                         null, "false");
110         this.createAttribute(DAS_CONFIG, "autodeploy-jsp-precompilation-enabled", "AutodeployJspPrecompilationEnabled",
111                         AttrProp.CDATA,
112                         null, "false");
113         this.createAttribute(DAS_CONFIG, "deploy-xml-validation", "DeployXmlValidation",
114                         AttrProp.CDATA,
115                         null, "full");
116         this.createAttribute(DAS_CONFIG, "admin-session-timeout-in-minutes", "AdminSessionTimeoutInMinutes",
117                         AttrProp.CDATA,
118                         null, "60");
119         this.createProperty("property", ELEMENT_PROPERTY,
120             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
121             ElementProperty.class);
122         this.createAttribute(ELEMENT_PROPERTY, "name", "Name",
123                         AttrProp.CDATA | AttrProp.REQUIRED,
124                         null, null);
125         this.createAttribute(ELEMENT_PROPERTY, "value", "Value",
126                         AttrProp.CDATA | AttrProp.REQUIRED,
127                         null, null);
128         this.initialize(options);
129     }
130
131     // Setting the default values of the properties
132
void initialize(int options) {
133
134     }
135
136     // This attribute is an array, possibly empty
137
public void setJmxConnector(int index, JmxConnector value) {
138         this.setValue(JMX_CONNECTOR, index, value);
139     }
140
141     // Get Method
142
public JmxConnector getJmxConnector(int index) {
143         return (JmxConnector)this.getValue(JMX_CONNECTOR, index);
144     }
145
146     // This attribute is an array, possibly empty
147
public void setJmxConnector(JmxConnector[] value) {
148         this.setValue(JMX_CONNECTOR, value);
149     }
150
151     // Getter Method
152
public JmxConnector[] getJmxConnector() {
153         return (JmxConnector[])this.getValues(JMX_CONNECTOR);
154     }
155
156     // Return the number of properties
157
public int sizeJmxConnector() {
158         return this.size(JMX_CONNECTOR);
159     }
160
161     // Add a new element returning its index in the list
162
public int addJmxConnector(JmxConnector value)
163             throws ConfigException{
164         return addJmxConnector(value, true);
165     }
166
167     // Add a new element returning its index in the list with a boolean flag
168
public int addJmxConnector(JmxConnector value, boolean overwrite)
169             throws ConfigException{
170         JmxConnector old = getJmxConnectorByName(value.getName());
171         if(old != null) {
172             throw new ConfigException(StringManager.getManager(AdminService.class).getString("cannotAddDuplicate", "JmxConnector"));
173         }
174         return this.addValue(JMX_CONNECTOR, value, overwrite);
175     }
176
177     //
178
// Remove an element using its reference
179
// Returns the index the element had in the list
180
//
181
public int removeJmxConnector(JmxConnector value){
182         return this.removeValue(JMX_CONNECTOR, value);
183     }
184
185     //
186
// Remove an element using its reference
187
// Returns the index the element had in the list
188
// with boolean overwrite
189
//
190
public int removeJmxConnector(JmxConnector value, boolean overwrite)
191             throws StaleWriteConfigException{
192         return this.removeValue(JMX_CONNECTOR, value, overwrite);
193     }
194
195     public JmxConnector getJmxConnectorByName(String JavaDoc id) {
196      if (null != id) { id = id.trim(); }
197     JmxConnector[] o = getJmxConnector();
198      if (o == null) return null;
199
200      for (int i=0; i < o.length; i++) {
201          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
202              return o[i];
203          }
204      }
205
206         return null;
207         
208     }
209     // This attribute is optional
210
public void setDasConfig(DasConfig value) {
211         this.setValue(DAS_CONFIG, value);
212     }
213
214     // Get Method
215
public DasConfig getDasConfig() {
216         return (DasConfig)this.getValue(DAS_CONFIG);
217     }
218
219     // This attribute is an array, possibly empty
220
public void setElementProperty(int index, ElementProperty value) {
221         this.setValue(ELEMENT_PROPERTY, index, value);
222     }
223
224     // Get Method
225
public ElementProperty getElementProperty(int index) {
226         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
227     }
228
229     // This attribute is an array, possibly empty
230
public void setElementProperty(ElementProperty[] value) {
231         this.setValue(ELEMENT_PROPERTY, value);
232     }
233
234     // Getter Method
235
public ElementProperty[] getElementProperty() {
236         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
237     }
238
239     // Return the number of properties
240
public int sizeElementProperty() {
241         return this.size(ELEMENT_PROPERTY);
242     }
243
244     // Add a new element returning its index in the list
245
public int addElementProperty(ElementProperty value)
246             throws ConfigException{
247         return addElementProperty(value, true);
248     }
249
250     // Add a new element returning its index in the list with a boolean flag
251
public int addElementProperty(ElementProperty value, boolean overwrite)
252             throws ConfigException{
253         ElementProperty old = getElementPropertyByName(value.getName());
254         if(old != null) {
255             throw new ConfigException(StringManager.getManager(AdminService.class).getString("cannotAddDuplicate", "ElementProperty"));
256         }
257         return this.addValue(ELEMENT_PROPERTY, value, overwrite);
258     }
259
260     //
261
// Remove an element using its reference
262
// Returns the index the element had in the list
263
//
264
public int removeElementProperty(ElementProperty value){
265         return this.removeValue(ELEMENT_PROPERTY, value);
266     }
267
268     //
269
// Remove an element using its reference
270
// Returns the index the element had in the list
271
// with boolean overwrite
272
//
273
public int removeElementProperty(ElementProperty value, boolean overwrite)
274             throws StaleWriteConfigException{
275         return this.removeValue(ELEMENT_PROPERTY, value, overwrite);
276     }
277
278     public ElementProperty getElementPropertyByName(String JavaDoc id) {
279      if (null != id) { id = id.trim(); }
280     ElementProperty[] o = getElementProperty();
281      if (o == null) return null;
282
283      for (int i=0; i < o.length; i++) {
284          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
285              return o[i];
286          }
287      }
288
289         return null;
290         
291     }
292     /**
293     * Getter for Type of the Element admin-service
294     * @return the Type of the Element admin-service
295     */

296     public String JavaDoc getType() {
297         return getAttributeValue(ServerTags.TYPE);
298     }
299     /**
300     * Modify the Type of the Element admin-service
301     * @param v the new value
302     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
303     */

304     public void setType(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
305         setAttributeValue(ServerTags.TYPE, v, overwrite);
306     }
307     /**
308     * Modify the Type of the Element admin-service
309     * @param v the new value
310     */

311     public void setType(String JavaDoc v) {
312         setAttributeValue(ServerTags.TYPE, v);
313     }
314     /**
315     * Get the default value of Type from dtd
316     */

317     public static String JavaDoc getDefaultType() {
318         return "server".trim();
319     }
320     /**
321     * Getter for SystemJmxConnectorName of the Element admin-service
322     * @return the SystemJmxConnectorName of the Element admin-service
323     */

324     public String JavaDoc getSystemJmxConnectorName() {
325             return getAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME);
326     }
327     /**
328     * Modify the SystemJmxConnectorName of the Element admin-service
329     * @param v the new value
330     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
331     */

332     public void setSystemJmxConnectorName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
333         setAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME, v, overwrite);
334     }
335     /**
336     * Modify the SystemJmxConnectorName of the Element admin-service
337     * @param v the new value
338     */

339     public void setSystemJmxConnectorName(String JavaDoc v) {
340         setAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME, v);
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 JmxConnector newJmxConnector() {
347         return new JmxConnector();
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 DasConfig newDasConfig() {
355         return new DasConfig();
356     }
357
358     /**
359      * Create a new bean using it's default constructor.
360      * This does not add it to any bean graph.
361      */

362     public ElementProperty newElementProperty() {
363         return new ElementProperty();
364     }
365
366     /**
367     * get the xpath representation for this element
368     * returns something like abc[@name='value'] or abc
369     * depending on the type of the bean
370     */

371     protected String JavaDoc getRelativeXPath() {
372         String JavaDoc ret = null;
373         ret = "admin-service";
374         return (null != ret ? ret.trim() : null);
375     }
376
377     /*
378     * generic method to get default value from dtd
379     */

380     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
381         if(attr == null) return null;
382         attr = attr.trim();
383         if(attr.equals(ServerTags.TYPE)) return "server".trim();
384     return null;
385     }
386     //
387
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
388         comparators.add(c);
389     }
390
391     //
392
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
393         comparators.remove(c);
394     }
395     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
396     }
397
398     // Dump the content of this bean returning it as a String
399
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
400         String JavaDoc s;
401         Object JavaDoc o;
402         org.netbeans.modules.schema2beans.BaseBean n;
403         str.append(indent);
404         str.append("JmxConnector["+this.sizeJmxConnector()+"]"); // NOI18N
405
for(int i=0; i<this.sizeJmxConnector(); i++)
406         {
407             str.append(indent+"\t");
408             str.append("#"+i+":");
409             n = (org.netbeans.modules.schema2beans.BaseBean) this.getJmxConnector(i);
410             if (n != null)
411                 n.dump(str, indent + "\t"); // NOI18N
412
else
413                 str.append(indent+"\tnull"); // NOI18N
414
this.dumpAttributes(JMX_CONNECTOR, i, str, indent);
415         }
416
417         str.append(indent);
418         str.append("DasConfig"); // NOI18N
419
n = (org.netbeans.modules.schema2beans.BaseBean) this.getDasConfig();
420         if (n != null)
421             n.dump(str, indent + "\t"); // NOI18N
422
else
423             str.append(indent+"\tnull"); // NOI18N
424
this.dumpAttributes(DAS_CONFIG, 0, str, indent);
425
426         str.append(indent);
427         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
428
for(int i=0; i<this.sizeElementProperty(); i++)
429         {
430             str.append(indent+"\t");
431             str.append("#"+i+":");
432             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
433             if (n != null)
434                 n.dump(str, indent + "\t"); // NOI18N
435
else
436                 str.append(indent+"\tnull"); // NOI18N
437
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
438         }
439
440     }
441     public String JavaDoc dumpBeanNode(){
442         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
443         str.append("AdminService\n"); // NOI18N
444
this.dump(str, "\n "); // NOI18N
445
return str.toString();
446     }}
447
448 // END_NOI18N
449

450
Popular Tags