KickJava   Java API By Example, From Geeks To Geeks.

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


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

203     public String JavaDoc getName() {
204         return getAttributeValue(ServerTags.NAME);
205     }
206     /**
207     * Modify the Name of the Element profiler
208     * @param v the new value
209     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
210     */

211     public void setName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
212         setAttributeValue(ServerTags.NAME, v, overwrite);
213     }
214     /**
215     * Modify the Name of the Element profiler
216     * @param v the new value
217     */

218     public void setName(String JavaDoc v) {
219         setAttributeValue(ServerTags.NAME, v);
220     }
221     /**
222     * Getter for Classpath of the Element profiler
223     * @return the Classpath of the Element profiler
224     */

225     public String JavaDoc getClasspath() {
226             return getAttributeValue(ServerTags.CLASSPATH);
227     }
228     /**
229     * Modify the Classpath of the Element profiler
230     * @param v the new value
231     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
232     */

233     public void setClasspath(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
234         setAttributeValue(ServerTags.CLASSPATH, v, overwrite);
235     }
236     /**
237     * Modify the Classpath of the Element profiler
238     * @param v the new value
239     */

240     public void setClasspath(String JavaDoc v) {
241         setAttributeValue(ServerTags.CLASSPATH, v);
242     }
243     /**
244     * Getter for NativeLibraryPath of the Element profiler
245     * @return the NativeLibraryPath of the Element profiler
246     */

247     public String JavaDoc getNativeLibraryPath() {
248             return getAttributeValue(ServerTags.NATIVE_LIBRARY_PATH);
249     }
250     /**
251     * Modify the NativeLibraryPath of the Element profiler
252     * @param v the new value
253     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
254     */

255     public void setNativeLibraryPath(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
256         setAttributeValue(ServerTags.NATIVE_LIBRARY_PATH, v, overwrite);
257     }
258     /**
259     * Modify the NativeLibraryPath of the Element profiler
260     * @param v the new value
261     */

262     public void setNativeLibraryPath(String JavaDoc v) {
263         setAttributeValue(ServerTags.NATIVE_LIBRARY_PATH, v);
264     }
265     /**
266     * Getter for Enabled of the Element profiler
267     * @return the Enabled of the Element profiler
268     */

269     public boolean isEnabled() {
270         return toBoolean(getAttributeValue(ServerTags.ENABLED));
271     }
272     /**
273     * Modify the Enabled of the Element profiler
274     * @param v the new value
275     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
276     */

277     public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
278         setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite);
279     }
280     /**
281     * Modify the Enabled of the Element profiler
282     * @param v the new value
283     */

284     public void setEnabled(boolean v) {
285         setAttributeValue(ServerTags.ENABLED, ""+(v==true));
286     }
287     /**
288     * Get the default value of Enabled from dtd
289     */

290     public static String JavaDoc getDefaultEnabled() {
291         return "true".trim();
292     }
293     /**
294      * Create a new bean using it's default constructor.
295      * This does not add it to any bean graph.
296      */

297     public ElementProperty newElementProperty() {
298         return new ElementProperty();
299     }
300
301     /**
302     * get the xpath representation for this element
303     * returns something like abc[@name='value'] or abc
304     * depending on the type of the bean
305     */

306     protected String JavaDoc getRelativeXPath() {
307         String JavaDoc ret = null;
308         ret = "profiler" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ;
309         return (null != ret ? ret.trim() : null);
310     }
311
312     /*
313     * generic method to get default value from dtd
314     */

315     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
316         if(attr == null) return null;
317         attr = attr.trim();
318         if(attr.equals(ServerTags.ENABLED)) return "true".trim();
319     return null;
320     }
321     //
322
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
323         comparators.add(c);
324     }
325
326     //
327
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
328         comparators.remove(c);
329     }
330     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
331     }
332
333     // Dump the content of this bean returning it as a String
334
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
335         String JavaDoc s;
336         Object JavaDoc o;
337         org.netbeans.modules.schema2beans.BaseBean n;
338         str.append(indent);
339         str.append("JvmOptions["+this.sizeJvmOptions()+"]"); // NOI18N
340
for(int i=0; i<this.sizeJvmOptions(); i++)
341         {
342             str.append(indent+"\t");
343             str.append("#"+i+":");
344             str.append(indent+"\t"); // NOI18N
345
str.append("<"); // NOI18N
346
o = this.getValue(JVM_OPTIONS, i);
347             str.append((o==null?"null":o.toString().trim())); // NOI18N
348
str.append(">\n"); // NOI18N
349
this.dumpAttributes(JVM_OPTIONS, i, str, indent);
350         }
351
352         str.append(indent);
353         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
354
for(int i=0; i<this.sizeElementProperty(); i++)
355         {
356             str.append(indent+"\t");
357             str.append("#"+i+":");
358             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
359             if (n != null)
360                 n.dump(str, indent + "\t"); // NOI18N
361
else
362                 str.append(indent+"\tnull"); // NOI18N
363
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
364         }
365
366     }
367     public String JavaDoc dumpBeanNode(){
368         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
369         str.append("Profiler\n"); // NOI18N
370
this.dump(str, "\n "); // NOI18N
371
return str.toString();
372     }}
373
374 // END_NOI18N
375

376
Popular Tags