KickJava   Java API By Example, From Geeks To Geeks.

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


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

192     public String JavaDoc getId() {
193         return getAttributeValue(ServerTags.ID);
194     }
195     /**
196     * Modify the Id of the Element http-listener
197     * @param v the new value
198     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
199     */

200     public void setId(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
201         setAttributeValue(ServerTags.ID, v, overwrite);
202     }
203     /**
204     * Modify the Id of the Element http-listener
205     * @param v the new value
206     */

207     public void setId(String JavaDoc v) {
208         setAttributeValue(ServerTags.ID, v);
209     }
210     /**
211     * Getter for Address of the Element http-listener
212     * @return the Address of the Element http-listener
213     */

214     public String JavaDoc getAddress() {
215         return getAttributeValue(ServerTags.ADDRESS);
216     }
217     /**
218     * Modify the Address of the Element http-listener
219     * @param v the new value
220     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
221     */

222     public void setAddress(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
223         setAttributeValue(ServerTags.ADDRESS, v, overwrite);
224     }
225     /**
226     * Modify the Address of the Element http-listener
227     * @param v the new value
228     */

229     public void setAddress(String JavaDoc v) {
230         setAttributeValue(ServerTags.ADDRESS, v);
231     }
232     /**
233     * Getter for Port of the Element http-listener
234     * @return the Port of the Element http-listener
235     */

236     public String JavaDoc getPort() {
237         return getAttributeValue(ServerTags.PORT);
238     }
239     /**
240     * Modify the Port of the Element http-listener
241     * @param v the new value
242     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
243     */

244     public void setPort(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
245         setAttributeValue(ServerTags.PORT, v, overwrite);
246     }
247     /**
248     * Modify the Port of the Element http-listener
249     * @param v the new value
250     */

251     public void setPort(String JavaDoc v) {
252         setAttributeValue(ServerTags.PORT, v);
253     }
254     /**
255     * Getter for ExternalPort of the Element http-listener
256     * @return the ExternalPort of the Element http-listener
257     */

258     public String JavaDoc getExternalPort() {
259             return getAttributeValue(ServerTags.EXTERNAL_PORT);
260     }
261     /**
262     * Modify the ExternalPort of the Element http-listener
263     * @param v the new value
264     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
265     */

266     public void setExternalPort(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
267         setAttributeValue(ServerTags.EXTERNAL_PORT, v, overwrite);
268     }
269     /**
270     * Modify the ExternalPort of the Element http-listener
271     * @param v the new value
272     */

273     public void setExternalPort(String JavaDoc v) {
274         setAttributeValue(ServerTags.EXTERNAL_PORT, v);
275     }
276     /**
277     * Getter for Family of the Element http-listener
278     * @return the Family of the Element http-listener
279     */

280     public String JavaDoc getFamily() {
281         return getAttributeValue(ServerTags.FAMILY);
282     }
283     /**
284     * Modify the Family of the Element http-listener
285     * @param v the new value
286     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
287     */

288     public void setFamily(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
289         setAttributeValue(ServerTags.FAMILY, v, overwrite);
290     }
291     /**
292     * Modify the Family of the Element http-listener
293     * @param v the new value
294     */

295     public void setFamily(String JavaDoc v) {
296         setAttributeValue(ServerTags.FAMILY, v);
297     }
298     /**
299     * Get the default value of Family from dtd
300     */

301     public static String JavaDoc getDefaultFamily() {
302         return "inet".trim();
303     }
304     /**
305     * Getter for BlockingEnabled of the Element http-listener
306     * @return the BlockingEnabled of the Element http-listener
307     */

308     public boolean isBlockingEnabled() {
309         return toBoolean(getAttributeValue(ServerTags.BLOCKING_ENABLED));
310     }
311     /**
312     * Modify the BlockingEnabled of the Element http-listener
313     * @param v the new value
314     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
315     */

316     public void setBlockingEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
317         setAttributeValue(ServerTags.BLOCKING_ENABLED, ""+(v==true), overwrite);
318     }
319     /**
320     * Modify the BlockingEnabled of the Element http-listener
321     * @param v the new value
322     */

323     public void setBlockingEnabled(boolean v) {
324         setAttributeValue(ServerTags.BLOCKING_ENABLED, ""+(v==true));
325     }
326     /**
327     * Get the default value of BlockingEnabled from dtd
328     */

329     public static String JavaDoc getDefaultBlockingEnabled() {
330         return "false".trim();
331     }
332     /**
333     * Getter for AcceptorThreads of the Element http-listener
334     * @return the AcceptorThreads of the Element http-listener
335     */

336     public String JavaDoc getAcceptorThreads() {
337         return getAttributeValue(ServerTags.ACCEPTOR_THREADS);
338     }
339     /**
340     * Modify the AcceptorThreads of the Element http-listener
341     * @param v the new value
342     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
343     */

344     public void setAcceptorThreads(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
345         setAttributeValue(ServerTags.ACCEPTOR_THREADS, v, overwrite);
346     }
347     /**
348     * Modify the AcceptorThreads of the Element http-listener
349     * @param v the new value
350     */

351     public void setAcceptorThreads(String JavaDoc v) {
352         setAttributeValue(ServerTags.ACCEPTOR_THREADS, v);
353     }
354     /**
355     * Get the default value of AcceptorThreads from dtd
356     */

357     public static String JavaDoc getDefaultAcceptorThreads() {
358         return "1".trim();
359     }
360     /**
361     * Getter for SecurityEnabled of the Element http-listener
362     * @return the SecurityEnabled of the Element http-listener
363     */

364     public boolean isSecurityEnabled() {
365         return toBoolean(getAttributeValue(ServerTags.SECURITY_ENABLED));
366     }
367     /**
368     * Modify the SecurityEnabled of the Element http-listener
369     * @param v the new value
370     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
371     */

372     public void setSecurityEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
373         setAttributeValue(ServerTags.SECURITY_ENABLED, ""+(v==true), overwrite);
374     }
375     /**
376     * Modify the SecurityEnabled of the Element http-listener
377     * @param v the new value
378     */

379     public void setSecurityEnabled(boolean v) {
380         setAttributeValue(ServerTags.SECURITY_ENABLED, ""+(v==true));
381     }
382     /**
383     * Get the default value of SecurityEnabled from dtd
384     */

385     public static String JavaDoc getDefaultSecurityEnabled() {
386         return "false".trim();
387     }
388     /**
389     * Getter for DefaultVirtualServer of the Element http-listener
390     * @return the DefaultVirtualServer of the Element http-listener
391     */

392     public String JavaDoc getDefaultVirtualServer() {
393         return getAttributeValue(ServerTags.DEFAULT_VIRTUAL_SERVER);
394     }
395     /**
396     * Modify the DefaultVirtualServer of the Element http-listener
397     * @param v the new value
398     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
399     */

400     public void setDefaultVirtualServer(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
401         setAttributeValue(ServerTags.DEFAULT_VIRTUAL_SERVER, v, overwrite);
402     }
403     /**
404     * Modify the DefaultVirtualServer of the Element http-listener
405     * @param v the new value
406     */

407     public void setDefaultVirtualServer(String JavaDoc v) {
408         setAttributeValue(ServerTags.DEFAULT_VIRTUAL_SERVER, v);
409     }
410     /**
411     * Getter for ServerName of the Element http-listener
412     * @return the ServerName of the Element http-listener
413     */

414     public String JavaDoc getServerName() {
415         return getAttributeValue(ServerTags.SERVER_NAME);
416     }
417     /**
418     * Modify the ServerName of the Element http-listener
419     * @param v the new value
420     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
421     */

422     public void setServerName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
423         setAttributeValue(ServerTags.SERVER_NAME, v, overwrite);
424     }
425     /**
426     * Modify the ServerName of the Element http-listener
427     * @param v the new value
428     */

429     public void setServerName(String JavaDoc v) {
430         setAttributeValue(ServerTags.SERVER_NAME, v);
431     }
432     /**
433     * Getter for RedirectPort of the Element http-listener
434     * @return the RedirectPort of the Element http-listener
435     */

436     public String JavaDoc getRedirectPort() {
437             return getAttributeValue(ServerTags.REDIRECT_PORT);
438     }
439     /**
440     * Modify the RedirectPort of the Element http-listener
441     * @param v the new value
442     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
443     */

444     public void setRedirectPort(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
445         setAttributeValue(ServerTags.REDIRECT_PORT, v, overwrite);
446     }
447     /**
448     * Modify the RedirectPort of the Element http-listener
449     * @param v the new value
450     */

451     public void setRedirectPort(String JavaDoc v) {
452         setAttributeValue(ServerTags.REDIRECT_PORT, v);
453     }
454     /**
455     * Getter for XpoweredBy of the Element http-listener
456     * @return the XpoweredBy of the Element http-listener
457     */

458     public boolean isXpoweredBy() {
459         return toBoolean(getAttributeValue(ServerTags.XPOWERED_BY));
460     }
461     /**
462     * Modify the XpoweredBy of the Element http-listener
463     * @param v the new value
464     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
465     */

466     public void setXpoweredBy(boolean v, boolean overwrite) throws StaleWriteConfigException {
467         setAttributeValue(ServerTags.XPOWERED_BY, ""+(v==true), overwrite);
468     }
469     /**
470     * Modify the XpoweredBy of the Element http-listener
471     * @param v the new value
472     */

473     public void setXpoweredBy(boolean v) {
474         setAttributeValue(ServerTags.XPOWERED_BY, ""+(v==true));
475     }
476     /**
477     * Get the default value of XpoweredBy from dtd
478     */

479     public static String JavaDoc getDefaultXpoweredBy() {
480         return "true".trim();
481     }
482     /**
483     * Getter for Enabled of the Element http-listener
484     * @return the Enabled of the Element http-listener
485     */

486     public boolean isEnabled() {
487         return toBoolean(getAttributeValue(ServerTags.ENABLED));
488     }
489     /**
490     * Modify the Enabled of the Element http-listener
491     * @param v the new value
492     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
493     */

494     public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException {
495         setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite);
496     }
497     /**
498     * Modify the Enabled of the Element http-listener
499     * @param v the new value
500     */

501     public void setEnabled(boolean v) {
502         setAttributeValue(ServerTags.ENABLED, ""+(v==true));
503     }
504     /**
505     * Get the default value of Enabled from dtd
506     */

507     public static String JavaDoc getDefaultEnabled() {
508         return "true".trim();
509     }
510     /**
511      * Create a new bean using it's default constructor.
512      * This does not add it to any bean graph.
513      */

514     public Ssl newSsl() {
515         return new Ssl();
516     }
517
518     /**
519      * Create a new bean using it's default constructor.
520      * This does not add it to any bean graph.
521      */

522     public ElementProperty newElementProperty() {
523         return new ElementProperty();
524     }
525
526     /**
527     * get the xpath representation for this element
528     * returns something like abc[@name='value'] or abc
529     * depending on the type of the bean
530     */

531     protected String JavaDoc getRelativeXPath() {
532         String JavaDoc ret = null;
533         ret = "http-listener" + (canHaveSiblings() ? "[@id='" + getAttributeValue("id") +"']" : "") ;
534         return (null != ret ? ret.trim() : null);
535     }
536
537     /*
538     * generic method to get default value from dtd
539     */

540     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
541         if(attr == null) return null;
542         attr = attr.trim();
543         if(attr.equals(ServerTags.FAMILY)) return "inet".trim();
544         if(attr.equals(ServerTags.BLOCKING_ENABLED)) return "false".trim();
545         if(attr.equals(ServerTags.ACCEPTOR_THREADS)) return "1".trim();
546         if(attr.equals(ServerTags.SECURITY_ENABLED)) return "false".trim();
547         if(attr.equals(ServerTags.XPOWERED_BY)) return "true".trim();
548         if(attr.equals(ServerTags.ENABLED)) return "true".trim();
549     return null;
550     }
551     //
552
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
553         comparators.add(c);
554     }
555
556     //
557
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
558         comparators.remove(c);
559     }
560     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
561     }
562
563     // Dump the content of this bean returning it as a String
564
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
565         String JavaDoc s;
566         Object JavaDoc o;
567         org.netbeans.modules.schema2beans.BaseBean n;
568         str.append(indent);
569         str.append("Ssl"); // NOI18N
570
n = (org.netbeans.modules.schema2beans.BaseBean) this.getSsl();
571         if (n != null)
572             n.dump(str, indent + "\t"); // NOI18N
573
else
574             str.append(indent+"\tnull"); // NOI18N
575
this.dumpAttributes(SSL, 0, str, indent);
576
577         str.append(indent);
578         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
579
for(int i=0; i<this.sizeElementProperty(); i++)
580         {
581             str.append(indent+"\t");
582             str.append("#"+i+":");
583             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
584             if (n != null)
585                 n.dump(str, indent + "\t"); // NOI18N
586
else
587                 str.append(indent+"\tnull"); // NOI18N
588
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
589         }
590
591     }
592     public String JavaDoc dumpBeanNode(){
593         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
594         str.append("HttpListener\n"); // NOI18N
595
this.dump(str, "\n "); // NOI18N
596
return str.toString();
597     }}
598
599 // END_NOI18N
600

601
Popular Tags