KickJava   Java API By Example, From Geeks To Geeks.

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


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 NodeAgent matches the DTD element node-agent
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 NodeAgent 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 AUTH_REALM = "AuthRealm";
51     static public final String JavaDoc LOG_SERVICE = "LogService";
52     static public final String JavaDoc ELEMENT_PROPERTY = "ElementProperty";
53
54     public NodeAgent() {
55         this(Common.USE_DEFAULT_VALUES);
56     }
57
58     public NodeAgent(int options)
59     {
60         super(comparators, runtimeVersion);
61         // Properties (see root bean comments for the bean graph)
62
initPropertyTables(4);
63         this.createProperty("jmx-connector", JMX_CONNECTOR,
64             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
65             JmxConnector.class);
66         this.createAttribute(JMX_CONNECTOR, "name", "Name",
67                         AttrProp.CDATA | AttrProp.REQUIRED,
68                         null, null);
69         this.createAttribute(JMX_CONNECTOR, "enabled", "Enabled",
70                         AttrProp.CDATA,
71                         null, "true");
72         this.createAttribute(JMX_CONNECTOR, "protocol", "Protocol",
73                         AttrProp.CDATA,
74                         null, "rmi_jrmp");
75         this.createAttribute(JMX_CONNECTOR, "address", "Address",
76                         AttrProp.CDATA | AttrProp.REQUIRED,
77                         null, null);
78         this.createAttribute(JMX_CONNECTOR, "port", "Port",
79                         AttrProp.CDATA | AttrProp.REQUIRED,
80                         null, null);
81         this.createAttribute(JMX_CONNECTOR, "accept-all", "AcceptAll",
82                         AttrProp.CDATA,
83                         null, "false");
84         this.createAttribute(JMX_CONNECTOR, "auth-realm-name", "AuthRealmName",
85                         AttrProp.CDATA | AttrProp.REQUIRED,
86                         null, null);
87         this.createAttribute(JMX_CONNECTOR, "security-enabled", "SecurityEnabled",
88                         AttrProp.CDATA,
89                         null, "true");
90         this.createProperty("auth-realm", AUTH_REALM,
91             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
92             AuthRealm.class);
93         this.createAttribute(AUTH_REALM, "name", "Name",
94                         AttrProp.CDATA | AttrProp.REQUIRED,
95                         null, null);
96         this.createAttribute(AUTH_REALM, "classname", "Classname",
97                         AttrProp.CDATA | AttrProp.REQUIRED,
98                         null, null);
99         this.createProperty("log-service", LOG_SERVICE,
100             Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
101             LogService.class);
102         this.createAttribute(LOG_SERVICE, "file", "File",
103                         AttrProp.CDATA | AttrProp.IMPLIED,
104                         null, null);
105         this.createAttribute(LOG_SERVICE, "use-system-logging", "UseSystemLogging",
106                         AttrProp.CDATA,
107                         null, "false");
108         this.createAttribute(LOG_SERVICE, "log-handler", "LogHandler",
109                         AttrProp.CDATA | AttrProp.IMPLIED,
110                         null, null);
111         this.createAttribute(LOG_SERVICE, "log-filter", "LogFilter",
112                         AttrProp.CDATA | AttrProp.IMPLIED,
113                         null, null);
114         this.createAttribute(LOG_SERVICE, "log-to-console", "LogToConsole",
115                         AttrProp.CDATA,
116                         null, "false");
117         this.createAttribute(LOG_SERVICE, "log-rotation-limit-in-bytes", "LogRotationLimitInBytes",
118                         AttrProp.CDATA,
119                         null, "500000");
120         this.createAttribute(LOG_SERVICE, "log-rotation-timelimit-in-minutes", "LogRotationTimelimitInMinutes",
121                         AttrProp.CDATA,
122                         null, "0");
123         this.createAttribute(LOG_SERVICE, "alarms", "Alarms",
124                         AttrProp.CDATA,
125                         null, "false");
126         this.createAttribute(LOG_SERVICE, "retain-error-statistics-for-hours", "RetainErrorStatisticsForHours",
127                         AttrProp.CDATA,
128                         null, "5");
129         this.createProperty("property", ELEMENT_PROPERTY,
130             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
131             ElementProperty.class);
132         this.createAttribute(ELEMENT_PROPERTY, "name", "Name",
133                         AttrProp.CDATA | AttrProp.REQUIRED,
134                         null, null);
135         this.createAttribute(ELEMENT_PROPERTY, "value", "Value",
136                         AttrProp.CDATA | AttrProp.REQUIRED,
137                         null, null);
138         this.initialize(options);
139     }
140
141     // Setting the default values of the properties
142
void initialize(int options) {
143
144     }
145
146     // This attribute is optional
147
public void setJmxConnector(JmxConnector value) {
148         this.setValue(JMX_CONNECTOR, value);
149     }
150
151     // Get Method
152
public JmxConnector getJmxConnector() {
153         return (JmxConnector)this.getValue(JMX_CONNECTOR);
154     }
155
156     // This attribute is optional
157
public void setAuthRealm(AuthRealm value) {
158         this.setValue(AUTH_REALM, value);
159     }
160
161     // Get Method
162
public AuthRealm getAuthRealm() {
163         return (AuthRealm)this.getValue(AUTH_REALM);
164     }
165
166     // This attribute is mandatory
167
public void setLogService(LogService value) {
168         this.setValue(LOG_SERVICE, value);
169     }
170
171     // Get Method
172
public LogService getLogService() {
173         return (LogService)this.getValue(LOG_SERVICE);
174     }
175
176     // This attribute is an array, possibly empty
177
public void setElementProperty(int index, ElementProperty value) {
178         this.setValue(ELEMENT_PROPERTY, index, value);
179     }
180
181     // Get Method
182
public ElementProperty getElementProperty(int index) {
183         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
184     }
185
186     // This attribute is an array, possibly empty
187
public void setElementProperty(ElementProperty[] value) {
188         this.setValue(ELEMENT_PROPERTY, value);
189     }
190
191     // Getter Method
192
public ElementProperty[] getElementProperty() {
193         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
194     }
195
196     // Return the number of properties
197
public int sizeElementProperty() {
198         return this.size(ELEMENT_PROPERTY);
199     }
200
201     // Add a new element returning its index in the list
202
public int addElementProperty(ElementProperty value)
203             throws ConfigException{
204         return addElementProperty(value, true);
205     }
206
207     // Add a new element returning its index in the list with a boolean flag
208
public int addElementProperty(ElementProperty value, boolean overwrite)
209             throws ConfigException{
210         ElementProperty old = getElementPropertyByName(value.getName());
211         if(old != null) {
212             throw new ConfigException(StringManager.getManager(NodeAgent.class).getString("cannotAddDuplicate", "ElementProperty"));
213         }
214         return this.addValue(ELEMENT_PROPERTY, value, overwrite);
215     }
216
217     //
218
// Remove an element using its reference
219
// Returns the index the element had in the list
220
//
221
public int removeElementProperty(ElementProperty value){
222         return this.removeValue(ELEMENT_PROPERTY, value);
223     }
224
225     //
226
// Remove an element using its reference
227
// Returns the index the element had in the list
228
// with boolean overwrite
229
//
230
public int removeElementProperty(ElementProperty value, boolean overwrite)
231             throws StaleWriteConfigException{
232         return this.removeValue(ELEMENT_PROPERTY, value, overwrite);
233     }
234
235     public ElementProperty getElementPropertyByName(String JavaDoc id) {
236      if (null != id) { id = id.trim(); }
237     ElementProperty[] o = getElementProperty();
238      if (o == null) return null;
239
240      for (int i=0; i < o.length; i++) {
241          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
242              return o[i];
243          }
244      }
245
246         return null;
247         
248     }
249     /**
250     * Getter for Name of the Element node-agent
251     * @return the Name of the Element node-agent
252     */

253     public String JavaDoc getName() {
254         return getAttributeValue(ServerTags.NAME);
255     }
256     /**
257     * Modify the Name of the Element node-agent
258     * @param v the new value
259     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
260     */

261     public void setName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
262         setAttributeValue(ServerTags.NAME, v, overwrite);
263     }
264     /**
265     * Modify the Name of the Element node-agent
266     * @param v the new value
267     */

268     public void setName(String JavaDoc v) {
269         setAttributeValue(ServerTags.NAME, v);
270     }
271     /**
272     * Getter for SystemJmxConnectorName of the Element node-agent
273     * @return the SystemJmxConnectorName of the Element node-agent
274     */

275     public String JavaDoc getSystemJmxConnectorName() {
276             return getAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME);
277     }
278     /**
279     * Modify the SystemJmxConnectorName of the Element node-agent
280     * @param v the new value
281     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
282     */

283     public void setSystemJmxConnectorName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
284         setAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME, v, overwrite);
285     }
286     /**
287     * Modify the SystemJmxConnectorName of the Element node-agent
288     * @param v the new value
289     */

290     public void setSystemJmxConnectorName(String JavaDoc v) {
291         setAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME, v);
292     }
293     /**
294     * Getter for StartServersInStartup of the Element node-agent
295     * @return the StartServersInStartup of the Element node-agent
296     */

297     public boolean isStartServersInStartup() {
298         return toBoolean(getAttributeValue(ServerTags.START_SERVERS_IN_STARTUP));
299     }
300     /**
301     * Modify the StartServersInStartup of the Element node-agent
302     * @param v the new value
303     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
304     */

305     public void setStartServersInStartup(boolean v, boolean overwrite) throws StaleWriteConfigException {
306         setAttributeValue(ServerTags.START_SERVERS_IN_STARTUP, ""+(v==true), overwrite);
307     }
308     /**
309     * Modify the StartServersInStartup of the Element node-agent
310     * @param v the new value
311     */

312     public void setStartServersInStartup(boolean v) {
313         setAttributeValue(ServerTags.START_SERVERS_IN_STARTUP, ""+(v==true));
314     }
315     /**
316     * Get the default value of StartServersInStartup from dtd
317     */

318     public static String JavaDoc getDefaultStartServersInStartup() {
319         return "true".trim();
320     }
321     /**
322      * Create a new bean using it's default constructor.
323      * This does not add it to any bean graph.
324      */

325     public JmxConnector newJmxConnector() {
326         return new JmxConnector();
327     }
328
329     /**
330      * Create a new bean using it's default constructor.
331      * This does not add it to any bean graph.
332      */

333     public AuthRealm newAuthRealm() {
334         return new AuthRealm();
335     }
336
337     /**
338      * Create a new bean using it's default constructor.
339      * This does not add it to any bean graph.
340      */

341     public LogService newLogService() {
342         return new LogService();
343     }
344
345     /**
346      * Create a new bean using it's default constructor.
347      * This does not add it to any bean graph.
348      */

349     public ElementProperty newElementProperty() {
350         return new ElementProperty();
351     }
352
353     /**
354     * get the xpath representation for this element
355     * returns something like abc[@name='value'] or abc
356     * depending on the type of the bean
357     */

358     protected String JavaDoc getRelativeXPath() {
359         String JavaDoc ret = null;
360         ret = "node-agent" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ;
361         return (null != ret ? ret.trim() : null);
362     }
363
364     /*
365     * generic method to get default value from dtd
366     */

367     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
368         if(attr == null) return null;
369         attr = attr.trim();
370         if(attr.equals(ServerTags.START_SERVERS_IN_STARTUP)) return "true".trim();
371     return null;
372     }
373     //
374
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
375         comparators.add(c);
376     }
377
378     //
379
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
380         comparators.remove(c);
381     }
382     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
383     }
384
385     // Dump the content of this bean returning it as a String
386
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
387         String JavaDoc s;
388         Object JavaDoc o;
389         org.netbeans.modules.schema2beans.BaseBean n;
390         str.append(indent);
391         str.append("JmxConnector"); // NOI18N
392
n = (org.netbeans.modules.schema2beans.BaseBean) this.getJmxConnector();
393         if (n != null)
394             n.dump(str, indent + "\t"); // NOI18N
395
else
396             str.append(indent+"\tnull"); // NOI18N
397
this.dumpAttributes(JMX_CONNECTOR, 0, str, indent);
398
399         str.append(indent);
400         str.append("AuthRealm"); // NOI18N
401
n = (org.netbeans.modules.schema2beans.BaseBean) this.getAuthRealm();
402         if (n != null)
403             n.dump(str, indent + "\t"); // NOI18N
404
else
405             str.append(indent+"\tnull"); // NOI18N
406
this.dumpAttributes(AUTH_REALM, 0, str, indent);
407
408         str.append(indent);
409         str.append("LogService"); // NOI18N
410
n = (org.netbeans.modules.schema2beans.BaseBean) this.getLogService();
411         if (n != null)
412             n.dump(str, indent + "\t"); // NOI18N
413
else
414             str.append(indent+"\tnull"); // NOI18N
415
this.dumpAttributes(LOG_SERVICE, 0, str, indent);
416
417         str.append(indent);
418         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
419
for(int i=0; i<this.sizeElementProperty(); i++)
420         {
421             str.append(indent+"\t");
422             str.append("#"+i+":");
423             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
424             if (n != null)
425                 n.dump(str, indent + "\t"); // NOI18N
426
else
427                 str.append(indent+"\tnull"); // NOI18N
428
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
429         }
430
431     }
432     public String JavaDoc dumpBeanNode(){
433         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
434         str.append("NodeAgent\n"); // NOI18N
435
this.dump(str, "\n "); // NOI18N
436
return str.toString();
437     }}
438
439 // END_NOI18N
440

441
Popular Tags