KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > beans > WSWebExt


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.websphere6.dd.beans;
20
21 import org.w3c.dom.*;
22 import org.netbeans.modules.schema2beans.*;
23 import java.beans.*;
24 import java.util.*;
25 import java.io.*;
26
27 /**
28  *
29  * @author dlm198383
30  */

31 public class WSWebExt extends DDXmi{
32     private static final String JavaDoc ROOT=TYPE_WEB_APP_EXT_ID;
33
34     private static final String JavaDoc ROOT_NAME="WebApplicationExt";
35
36     /** Creates a new instance of WSAWebExt */
37     public WSWebExt() {
38         this(null, Common.USE_DEFAULT_VALUES);
39     }
40     public WSWebExt(org.w3c.dom.Node JavaDoc doc, int options) {
41         this(Common.NO_DEFAULT_VALUES);
42         try {
43             initFromNode(doc, options);
44         } catch (Schema2BeansException e) {
45             throw new RuntimeException JavaDoc(e);
46         }
47     }
48     
49      public WSWebExt(File f,boolean validate) throws IOException{
50         this(GraphManager.createXmlDocument(new FileInputStream(f), validate), Common.NO_DEFAULT_VALUES);
51     }
52     
53     public WSWebExt(InputStream in, boolean validate) {
54         this(GraphManager.createXmlDocument(in, validate), Common.NO_DEFAULT_VALUES);
55     }
56     
57     protected void initFromNode(org.w3c.dom.Node JavaDoc doc, int options) throws Schema2BeansException {
58         if (doc == null) {
59             doc = GraphManager.createRootElementNode(ROOT); // NOI18N
60
if (doc == null)
61                 throw new Schema2BeansException(Common.getMessage(
62                         "CantCreateDOMRoot_msg", ROOT)); // NOI18N
63
}
64         Node n = GraphManager.getElementNode(ROOT, doc);
65         if (n == null) {
66             throw new Schema2BeansException(Common.getMessage("DocRootNotInDOMGraph_msg", ROOT, doc.getFirstChild().getNodeName())); // NOI18N
67
}
68         this.graphManager.setXmlDocument(doc);
69         this.createBean(n, this.graphManager());
70         this.initialize(options);
71     };
72     
73     public WSWebExt(int options) {
74         super(options,ROOT);
75        // initOptions(options);
76
}
77     
78     
79     
80     public void initialize(int options) {
81         
82     }
83     
84     public void setDefaults() {
85         setXmiVersion();
86         setNsXmi();
87         setNsWebAppExt();
88         setNsWebApp();
89         setNsXsi();
90         setXmiId("WebAppExtension");
91         setReload(true);
92         setReloadInterval("3");
93         setAdditionalClassPath("");
94         setFileServingEnabled(true);
95         setDirectoryBrowsing();
96         setServeServletsByClassname(true);
97         setPrecompileJSPs(false);
98         setWebApplication("");
99         setWebApplicationHref("WebApp");
100         setDefaultErrorPage("");
101         setAutoLoadFilters(false);
102         setAutoRequestEncoding(true);
103         setAutoResponseEncoding(true);
104     }
105     
106     
107     protected void initOptions(int options) {
108         this.graphManager = new GraphManager(this);
109         this.createRoot(ROOT, ROOT_NAME, // NOI18N
110
Common.TYPE_1 | Common.TYPE_BEAN, WSWebExt.class);
111         
112         initPropertyTables(2);
113         this.createAttribute(XMI_ID_ID, XMI_ID, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
114         this.createAttribute(NS_WEB_APP_ID, NS_WEB_APP, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
115         this.createAttribute(NS_WEB_APP_EXT_ID,NS_WEB_APP_EXT, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
116         this.createAttribute(NS_XMI_ID, NS_XMI, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
117         this.createAttribute(NS_XSI_ID, NS_XSI, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
118         this.createAttribute(XMI_VERSION_ID, XMI_VERSION, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
119         this.createAttribute(RELOAD_INTERVAL_ID,RELOAD_INTERVAL, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
120         this.createAttribute(RELOAD_ENABLED_ID,RELOAD_ENABLED, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
121         this.createAttribute(DEFAULT_ERROR_PAGE_ID,DEFAULT_ERROR_PAGE, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
122         this.createAttribute(ADDITIONAL_CLASSPATH_ID,ADDITIONAL_CLASSPATH, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
123         this.createAttribute(FILE_SERVING_ENABLED_ID,FILE_SERVING_ENABLED, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
124         this.createAttribute(DIRECTORY_BROWSING_ENABLED_ID,DIRECTORY_BROWSING_ENABLED, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
125         this.createAttribute(SERVE_SERVLETS_ID,SERVE_SERVLETS, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
126         this.createAttribute(PRECOMPILE_JSPS_ID,PRECOMPILE_JSPS,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
127         this.createAttribute(AUTO_REQUEST_ENCODING_ID,AUTO_REQUEST_ENCODING,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
128         this.createAttribute(AUTO_RESPONSE_ENCODING_ID,AUTO_RESPONSE_ENCODING,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
129         this.createAttribute(AUTO_LOAD_FILTERS_ID,AUTO_LOAD_FILTERS,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
130         
131         this.createProperty(EXTENDED_SERVLETS_ID,
132                 EXTENDED_SERVLETS,
133                 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
134                 ExtendedServletsType.class);
135         this.createAttribute(EXTENDED_SERVLETS,XMI_ID_ID ,EXTENDED_SERVLETS_XMI_ID ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
136         
137         this.createProperty(WEB_APPLICATION_ID, // NOI18N
138
WEB_APPLICATION,
139                 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
140                 java.lang.String JavaDoc.class);
141         this.createAttribute(WEB_APPLICATION,HREF_ID,WEB_APPLICATION_HREF,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
142         this.initialize(options);
143     }
144     
145     public void setExtendedServlets(int index,ExtendedServletsType value) {
146         this.setValue(EXTENDED_SERVLETS, index,value);
147     }
148     
149     public void setExtendedServlets(ExtendedServletsType[]value) {
150         this.setValue(EXTENDED_SERVLETS, value);
151     }
152 //
153
public ExtendedServletsType[] getExtendedServlets() {
154         return (ExtendedServletsType[])this.getValues(EXTENDED_SERVLETS);
155     }
156     public ExtendedServletsType getExtendedServlets(int index) {
157         return (ExtendedServletsType)this.getValue(EXTENDED_SERVLETS,index);
158     }
159     public int sizeExtendedServlets() {
160         return this.size(EXTENDED_SERVLETS);
161     }
162     public int addExtendedServlets(ExtendedServletsType value) {
163         int positionOfNewItem = this.addValue(EXTENDED_SERVLETS, value);
164         return positionOfNewItem;
165     }
166     
167 //
168
// Remove an element using its reference
169
// Returns the index the element had in the list
170
//
171
public int removeExtendedServlets(ExtendedServletsType value) {
172         return this.removeValue(EXTENDED_SERVLETS, value);
173     }
174
175     
176     public void setDefaultErrorPage(String JavaDoc value) {
177         this.setAttributeValue(DEFAULT_ERROR_PAGE,value);
178     }
179     public String JavaDoc getDefaultErrorPage() {
180         return (String JavaDoc) this.getAttributeValue(DEFAULT_ERROR_PAGE);
181     }
182     
183     
184     
185     
186     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
187         
188         if (getExtendedServlets()!= null) {
189             // Validating property jdbcConnectionPool
190
for (int _index = 0; _index < sizeExtendedServlets(); ++_index) {
191                 ExtendedServletsType element = getExtendedServlets(_index);
192                 if (element != null) {
193                     element.validate();
194                 }
195                 
196             }
197         }
198         if (getWebApplication()== null) {
199             throw new org.netbeans.modules.schema2beans.ValidateException("getWebApplication() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, WEB_APPLICATION, this); // NOI18N
200
}
201         if (getWebApplicationHref()==null) {
202             throw new org.netbeans.modules.schema2beans.ValidateException("getWebApplicationHref() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, WEB_APPLICATION, this); // NOI18N
203
}
204         if (getNsWebApp()==null) {
205             throw new org.netbeans.modules.schema2beans.ValidateException("getNsWebApp() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
206
}
207         if (getNsWebAppExt()==null) {
208             throw new org.netbeans.modules.schema2beans.ValidateException("getNsWebAppExt() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
209
}
210         if (getNsXmi()==null) {
211             throw new org.netbeans.modules.schema2beans.ValidateException("getNsXmi() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
212
}
213         if(getXmiId()==null) {
214             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiId() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
215
}
216         if(getXmiVersion()==null) {
217             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiVersion() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
218
}
219         
220     }
221     
222     public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
223         String JavaDoc s;
224         Object JavaDoc o;
225         BaseBean n;
226         
227         str.append(indent);
228         str.append(WEB_APPLICATION); // NOI18N
229
str.append(indent+"\t"); // NOI18N
230
str.append("<"); // NOI18N
231
o = this.getApplication();
232         str.append((o==null?"null":o.toString().trim())); // NOI18N
233
str.append(">\n"); // NOI18N
234
this.dumpAttributes(WEB_APPLICATION, 0, str, indent);
235         
236         str.append(indent);
237         str.append(EXTENDED_SERVLETS+"["+this.sizeExtendedServlets()+"]"); // NOI18N
238
for(int i=0; i<this.sizeExtendedServlets(); i++) {
239             str.append(indent+"\t");
240             str.append("#"+i+":");
241             n = (BaseBean) this.getExtendedServlets(i);
242             if (n != null)
243                 n.dump(str, indent + "\t"); // NOI18N
244
else
245                 str.append(indent+"\tnull"); // NOI18N
246
this.dumpAttributes(EXTENDED_SERVLETS, i, str, indent);
247         }
248         
249     }
250     public String JavaDoc dumpBeanNode(){
251         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
252         str.append(getClass().getName()); // NOI18N
253
this.dump(str, "\n "); // NOI18N
254
return str.toString();
255     }
256 }
257
Popular Tags