KickJava   Java API By Example, From Geeks To Geeks.

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


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

174     public String JavaDoc getId() {
175         return getAttributeValue(ServerTags.ID);
176     }
177     /**
178     * Modify the Id of the Element virtual-server
179     * @param v the new value
180     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
181     */

182     public void setId(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
183         setAttributeValue(ServerTags.ID, v, overwrite);
184     }
185     /**
186     * Modify the Id of the Element virtual-server
187     * @param v the new value
188     */

189     public void setId(String JavaDoc v) {
190         setAttributeValue(ServerTags.ID, v);
191     }
192     /**
193     * Getter for HttpListeners of the Element virtual-server
194     * @return the HttpListeners of the Element virtual-server
195     */

196     public String JavaDoc getHttpListeners() {
197             return getAttributeValue(ServerTags.HTTP_LISTENERS);
198     }
199     /**
200     * Modify the HttpListeners of the Element virtual-server
201     * @param v the new value
202     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
203     */

204     public void setHttpListeners(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
205         setAttributeValue(ServerTags.HTTP_LISTENERS, v, overwrite);
206     }
207     /**
208     * Modify the HttpListeners of the Element virtual-server
209     * @param v the new value
210     */

211     public void setHttpListeners(String JavaDoc v) {
212         setAttributeValue(ServerTags.HTTP_LISTENERS, v);
213     }
214     /**
215     * Getter for DefaultWebModule of the Element virtual-server
216     * @return the DefaultWebModule of the Element virtual-server
217     */

218     public String JavaDoc getDefaultWebModule() {
219             return getAttributeValue(ServerTags.DEFAULT_WEB_MODULE);
220     }
221     /**
222     * Modify the DefaultWebModule of the Element virtual-server
223     * @param v the new value
224     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
225     */

226     public void setDefaultWebModule(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
227         setAttributeValue(ServerTags.DEFAULT_WEB_MODULE, v, overwrite);
228     }
229     /**
230     * Modify the DefaultWebModule of the Element virtual-server
231     * @param v the new value
232     */

233     public void setDefaultWebModule(String JavaDoc v) {
234         setAttributeValue(ServerTags.DEFAULT_WEB_MODULE, v);
235     }
236     /**
237     * Getter for Hosts of the Element virtual-server
238     * @return the Hosts of the Element virtual-server
239     */

240     public String JavaDoc getHosts() {
241         return getAttributeValue(ServerTags.HOSTS);
242     }
243     /**
244     * Modify the Hosts of the Element virtual-server
245     * @param v the new value
246     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
247     */

248     public void setHosts(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
249         setAttributeValue(ServerTags.HOSTS, v, overwrite);
250     }
251     /**
252     * Modify the Hosts of the Element virtual-server
253     * @param v the new value
254     */

255     public void setHosts(String JavaDoc v) {
256         setAttributeValue(ServerTags.HOSTS, v);
257     }
258     /**
259     * Getter for State of the Element virtual-server
260     * @return the State of the Element virtual-server
261     */

262     public String JavaDoc getState() {
263         return getAttributeValue(ServerTags.STATE);
264     }
265     /**
266     * Modify the State of the Element virtual-server
267     * @param v the new value
268     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
269     */

270     public void setState(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
271         setAttributeValue(ServerTags.STATE, v, overwrite);
272     }
273     /**
274     * Modify the State of the Element virtual-server
275     * @param v the new value
276     */

277     public void setState(String JavaDoc v) {
278         setAttributeValue(ServerTags.STATE, v);
279     }
280     /**
281     * Get the default value of State from dtd
282     */

283     public static String JavaDoc getDefaultState() {
284         return "on".trim();
285     }
286     /**
287     * Getter for Docroot of the Element virtual-server
288     * @return the Docroot of the Element virtual-server
289     */

290     public String JavaDoc getDocroot() {
291             return getAttributeValue(ServerTags.DOCROOT);
292     }
293     /**
294     * Modify the Docroot of the Element virtual-server
295     * @param v the new value
296     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
297     */

298     public void setDocroot(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
299         setAttributeValue(ServerTags.DOCROOT, v, overwrite);
300     }
301     /**
302     * Modify the Docroot of the Element virtual-server
303     * @param v the new value
304     */

305     public void setDocroot(String JavaDoc v) {
306         setAttributeValue(ServerTags.DOCROOT, v);
307     }
308     /**
309     * Getter for LogFile of the Element virtual-server
310     * @return the LogFile of the Element virtual-server
311     */

312     public String JavaDoc getLogFile() {
313         return getAttributeValue(ServerTags.LOG_FILE);
314     }
315     /**
316     * Modify the LogFile of the Element virtual-server
317     * @param v the new value
318     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
319     */

320     public void setLogFile(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
321         setAttributeValue(ServerTags.LOG_FILE, v, overwrite);
322     }
323     /**
324     * Modify the LogFile of the Element virtual-server
325     * @param v the new value
326     */

327     public void setLogFile(String JavaDoc v) {
328         setAttributeValue(ServerTags.LOG_FILE, v);
329     }
330     /**
331     * Get the default value of LogFile from dtd
332     */

333     public static String JavaDoc getDefaultLogFile() {
334         return "${com.sun.aas.instanceRoot}/logs/server.log".trim();
335     }
336     /**
337      * Create a new bean using it's default constructor.
338      * This does not add it to any bean graph.
339      */

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

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

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

366     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
367         if(attr == null) return null;
368         attr = attr.trim();
369         if(attr.equals(ServerTags.STATE)) return "on".trim();
370         if(attr.equals(ServerTags.LOG_FILE)) return "${com.sun.aas.instanceRoot}/logs/server.log".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("HttpAccessLog"); // NOI18N
392
n = (org.netbeans.modules.schema2beans.BaseBean) this.getHttpAccessLog();
393         if (n != null)
394             n.dump(str, indent + "\t"); // NOI18N
395
else
396             str.append(indent+"\tnull"); // NOI18N
397
this.dumpAttributes(HTTP_ACCESS_LOG, 0, str, indent);
398
399         str.append(indent);
400         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
401
for(int i=0; i<this.sizeElementProperty(); i++)
402         {
403             str.append(indent+"\t");
404             str.append("#"+i+":");
405             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
406             if (n != null)
407                 n.dump(str, indent + "\t"); // NOI18N
408
else
409                 str.append(indent+"\tnull"); // NOI18N
410
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
411         }
412
413     }
414     public String JavaDoc dumpBeanNode(){
415         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
416         str.append("VirtualServer\n"); // NOI18N
417
this.dump(str, "\n "); // NOI18N
418
return str.toString();
419     }}
420
421 // END_NOI18N
422

423
Popular Tags