KickJava   Java API By Example, From Geeks To Geeks.

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


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

166     public LbConfig newLbConfig() {
167         return new LbConfig();
168     }
169
170     /**
171     * get the xpath representation for this element
172     * returns something like abc[@name='value'] or abc
173     * depending on the type of the bean
174     */

175     protected String JavaDoc getRelativeXPath() {
176         String JavaDoc ret = null;
177         ret = "lb-configs";
178         return (null != ret ? ret.trim() : null);
179     }
180
181     /*
182     * generic method to get default value from dtd
183     */

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

230
Popular Tags