KickJava   Java API By Example, From Geeks To Geeks.

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


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 NodeAgents matches the DTD element node-agents
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 NodeAgents 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 NODE_AGENT = "NodeAgent";
50
51     public NodeAgents() {
52         this(Common.USE_DEFAULT_VALUES);
53     }
54
55     public NodeAgents(int options)
56     {
57         super(comparators, runtimeVersion);
58         // Properties (see root bean comments for the bean graph)
59
initPropertyTables(1);
60         this.createProperty("node-agent", NODE_AGENT,
61             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
62             NodeAgent.class);
63         this.createAttribute(NODE_AGENT, "name", "Name",
64                         AttrProp.CDATA | AttrProp.REQUIRED,
65                         null, null);
66         this.createAttribute(NODE_AGENT, "system-jmx-connector-name", "SystemJmxConnectorName",
67                         AttrProp.CDATA | AttrProp.IMPLIED,
68                         null, null);
69         this.createAttribute(NODE_AGENT, "start-servers-in-startup", "StartServersInStartup",
70                         AttrProp.CDATA,
71                         null, "true");
72         this.initialize(options);
73     }
74
75     // Setting the default values of the properties
76
void initialize(int options) {
77
78     }
79
80     // This attribute is an array, possibly empty
81
public void setNodeAgent(int index, NodeAgent value) {
82         this.setValue(NODE_AGENT, index, value);
83     }
84
85     // Get Method
86
public NodeAgent getNodeAgent(int index) {
87         return (NodeAgent)this.getValue(NODE_AGENT, index);
88     }
89
90     // This attribute is an array, possibly empty
91
public void setNodeAgent(NodeAgent[] value) {
92         this.setValue(NODE_AGENT, value);
93     }
94
95     // Getter Method
96
public NodeAgent[] getNodeAgent() {
97         return (NodeAgent[])this.getValues(NODE_AGENT);
98     }
99
100     // Return the number of properties
101
public int sizeNodeAgent() {
102         return this.size(NODE_AGENT);
103     }
104
105     // Add a new element returning its index in the list
106
public int addNodeAgent(NodeAgent value)
107             throws ConfigException{
108         return addNodeAgent(value, true);
109     }
110
111     // Add a new element returning its index in the list with a boolean flag
112
public int addNodeAgent(NodeAgent value, boolean overwrite)
113             throws ConfigException{
114         NodeAgent old = getNodeAgentByName(value.getName());
115         if(old != null) {
116             throw new ConfigException(StringManager.getManager(NodeAgents.class).getString("cannotAddDuplicate", "NodeAgent"));
117         }
118         return this.addValue(NODE_AGENT, value, overwrite);
119     }
120
121     //
122
// Remove an element using its reference
123
// Returns the index the element had in the list
124
//
125
public int removeNodeAgent(NodeAgent value){
126         return this.removeValue(NODE_AGENT, value);
127     }
128
129     //
130
// Remove an element using its reference
131
// Returns the index the element had in the list
132
// with boolean overwrite
133
//
134
public int removeNodeAgent(NodeAgent value, boolean overwrite)
135             throws StaleWriteConfigException{
136         return this.removeValue(NODE_AGENT, value, overwrite);
137     }
138
139     public NodeAgent getNodeAgentByName(String JavaDoc id) {
140      if (null != id) { id = id.trim(); }
141     NodeAgent[] o = getNodeAgent();
142      if (o == null) return null;
143
144      for (int i=0; i < o.length; i++) {
145          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
146              return o[i];
147          }
148      }
149
150         return null;
151         
152     }
153     /**
154      * Create a new bean using it's default constructor.
155      * This does not add it to any bean graph.
156      */

157     public NodeAgent newNodeAgent() {
158         return new NodeAgent();
159     }
160
161     /**
162     * get the xpath representation for this element
163     * returns something like abc[@name='value'] or abc
164     * depending on the type of the bean
165     */

166     protected String JavaDoc getRelativeXPath() {
167         String JavaDoc ret = null;
168         ret = "node-agents";
169         return (null != ret ? ret.trim() : null);
170     }
171
172     /*
173     * generic method to get default value from dtd
174     */

175     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
176         if(attr == null) return null;
177         attr = attr.trim();
178     return null;
179     }
180     //
181
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
182         comparators.add(c);
183     }
184
185     //
186
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
187         comparators.remove(c);
188     }
189     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
190     }
191
192     // Dump the content of this bean returning it as a String
193
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
194         String JavaDoc s;
195         Object JavaDoc o;
196         org.netbeans.modules.schema2beans.BaseBean n;
197         str.append(indent);
198         str.append("NodeAgent["+this.sizeNodeAgent()+"]"); // NOI18N
199
for(int i=0; i<this.sizeNodeAgent(); i++)
200         {
201             str.append(indent+"\t");
202             str.append("#"+i+":");
203             n = (org.netbeans.modules.schema2beans.BaseBean) this.getNodeAgent(i);
204             if (n != null)
205                 n.dump(str, indent + "\t"); // NOI18N
206
else
207                 str.append(indent+"\tnull"); // NOI18N
208
this.dumpAttributes(NODE_AGENT, i, str, indent);
209         }
210
211     }
212     public String JavaDoc dumpBeanNode(){
213         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
214         str.append("NodeAgents\n"); // NOI18N
215
this.dump(str, "\n "); // NOI18N
216
return str.toString();
217     }}
218
219 // END_NOI18N
220

221
Popular Tags