KickJava   Java API By Example, From Geeks To Geeks.

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


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 ManagementRule matches the DTD element management-rule
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 ManagementRule 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 EVENT = "Event";
50     static public final String JavaDoc ACTION = "Action";
51     static public final String JavaDoc DESCRIPTION = "Description";
52
53     public ManagementRule() {
54         this(Common.USE_DEFAULT_VALUES);
55     }
56
57     public ManagementRule(int options)
58     {
59         super(comparators, runtimeVersion);
60         // Properties (see root bean comments for the bean graph)
61
initPropertyTables(3);
62         this.createProperty("event", EVENT,
63             Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
64             Event.class);
65         this.createAttribute(EVENT, "type", "Type",
66                         AttrProp.CDATA | AttrProp.REQUIRED,
67                         null, null);
68         this.createAttribute(EVENT, "record-event", "RecordEvent",
69                         AttrProp.CDATA,
70                         null, "true");
71         this.createAttribute(EVENT, "level", "Level",
72                         AttrProp.CDATA,
73                         null, "INFO");
74         this.createProperty("action", ACTION,
75             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
76             Action.class);
77         this.createAttribute(ACTION, "action-mbean-name", "ActionMbeanName",
78                         AttrProp.CDATA | AttrProp.REQUIRED,
79                         null, null);
80         this.createProperty("description", DESCRIPTION,
81             Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY,
82             String JavaDoc.class);
83         this.initialize(options);
84     }
85
86     // Setting the default values of the properties
87
void initialize(int options) {
88
89     }
90
91     // This attribute is mandatory
92
public void setEvent(Event value) {
93         this.setValue(EVENT, value);
94     }
95
96     // Get Method
97
public Event getEvent() {
98         return (Event)this.getValue(EVENT);
99     }
100
101     // This attribute is optional
102
public void setAction(Action value) {
103         this.setValue(ACTION, value);
104     }
105
106     // Get Method
107
public Action getAction() {
108         return (Action)this.getValue(ACTION);
109     }
110
111     /**
112     * Return the Description of the Element management-rule
113     */

114     public String JavaDoc getDescription() {
115         return (String JavaDoc) getValue(ServerTags.DESCRIPTION);
116     }
117     /**
118     * Modify the Description of the Element management-rule
119     * @param v the new value
120     */

121     public void setDescription(String JavaDoc v){
122         setValue(ServerTags.DESCRIPTION, (null != v ? v.trim() : null));
123         }
124     /**
125     * Getter for Name of the Element management-rule
126     * @return the Name of the Element management-rule
127     */

128     public String JavaDoc getName() {
129         return getAttributeValue(ServerTags.NAME);
130     }
131     /**
132     * Modify the Name of the Element management-rule
133     * @param v the new value
134     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
135     */

136     public void setName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
137         setAttributeValue(ServerTags.NAME, v, overwrite);
138     }
139     /**
140     * Modify the Name of the Element management-rule
141     * @param v the new value
142     */

143     public void setName(String JavaDoc v) {
144         setAttributeValue(ServerTags.NAME, v);
145     }
146     /**
147     * Getter for Enabled of the Element management-rule
148     * @return the Enabled of the Element management-rule
149     */

150     public boolean isEnabled() {
151         return toBoolean(getAttributeValue(ServerTags.ENABLED));
152     }
153     /**
154     * Modify the Enabled of the Element management-rule
155     * @param v the new value
156     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
157     */

158     public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
159         setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite);
160     }
161     /**
162     * Modify the Enabled of the Element management-rule
163     * @param v the new value
164     */

165     public void setEnabled(boolean v) {
166         setAttributeValue(ServerTags.ENABLED, ""+(v==true));
167     }
168     /**
169     * Get the default value of Enabled from dtd
170     */

171     public static String JavaDoc getDefaultEnabled() {
172         return "true".trim();
173     }
174     /**
175      * Create a new bean using it's default constructor.
176      * This does not add it to any bean graph.
177      */

178     public Event newEvent() {
179         return new Event();
180     }
181
182     /**
183      * Create a new bean using it's default constructor.
184      * This does not add it to any bean graph.
185      */

186     public Action newAction() {
187         return new Action();
188     }
189
190     /**
191     * get the xpath representation for this element
192     * returns something like abc[@name='value'] or abc
193     * depending on the type of the bean
194     */

195     protected String JavaDoc getRelativeXPath() {
196         String JavaDoc ret = null;
197         ret = "management-rule" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ;
198         return (null != ret ? ret.trim() : null);
199     }
200
201     /*
202     * generic method to get default value from dtd
203     */

204     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
205         if(attr == null) return null;
206         attr = attr.trim();
207         if(attr.equals(ServerTags.ENABLED)) return "true".trim();
208     return null;
209     }
210     //
211
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
212         comparators.add(c);
213     }
214
215     //
216
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
217         comparators.remove(c);
218     }
219     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
220     }
221
222     // Dump the content of this bean returning it as a String
223
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
224         String JavaDoc s;
225         Object JavaDoc o;
226         org.netbeans.modules.schema2beans.BaseBean n;
227         str.append(indent);
228         str.append("Event"); // NOI18N
229
n = (org.netbeans.modules.schema2beans.BaseBean) this.getEvent();
230         if (n != null)
231             n.dump(str, indent + "\t"); // NOI18N
232
else
233             str.append(indent+"\tnull"); // NOI18N
234
this.dumpAttributes(EVENT, 0, str, indent);
235
236         str.append(indent);
237         str.append("Action"); // NOI18N
238
n = (org.netbeans.modules.schema2beans.BaseBean) this.getAction();
239         if (n != null)
240             n.dump(str, indent + "\t"); // NOI18N
241
else
242             str.append(indent+"\tnull"); // NOI18N
243
this.dumpAttributes(ACTION, 0, str, indent);
244
245         str.append(indent);
246         str.append("Description"); // NOI18N
247
str.append(indent+"\t"); // NOI18N
248
str.append("<"); // NOI18N
249
o = this.getDescription();
250         str.append((o==null?"null":o.toString().trim())); // NOI18N
251
str.append(">\n"); // NOI18N
252
this.dumpAttributes(DESCRIPTION, 0, str, indent);
253
254     }
255     public String JavaDoc dumpBeanNode(){
256         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
257         str.append("ManagementRule\n"); // NOI18N
258
this.dump(str, "\n "); // NOI18N
259
return str.toString();
260     }}
261
262 // END_NOI18N
263

264
Popular Tags