1 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 31 public class WSWebExt extends DDXmi{ 32 private static final String ROOT=TYPE_WEB_APP_EXT_ID; 33 34 private static final String ROOT_NAME="WebApplicationExt"; 35 36 37 public WSWebExt() { 38 this(null, Common.USE_DEFAULT_VALUES); 39 } 40 public WSWebExt(org.w3c.dom.Node doc, int options) { 41 this(Common.NO_DEFAULT_VALUES); 42 try { 43 initFromNode(doc, options); 44 } catch (Schema2BeansException e) { 45 throw new RuntimeException (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 doc, int options) throws Schema2BeansException { 58 if (doc == null) { 59 doc = GraphManager.createRootElementNode(ROOT); if (doc == null) 61 throw new Schema2BeansException(Common.getMessage( 62 "CantCreateDOMRoot_msg", ROOT)); } 64 Node n = GraphManager.getElementNode(ROOT, doc); 65 if (n == null) { 66 throw new Schema2BeansException(Common.getMessage("DocRootNotInDOMGraph_msg", ROOT, doc.getFirstChild().getNodeName())); } 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 } 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, 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, WEB_APPLICATION, 139 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY, 140 java.lang.String .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 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 public int removeExtendedServlets(ExtendedServletsType value) { 172 return this.removeValue(EXTENDED_SERVLETS, value); 173 } 174 175 176 public void setDefaultErrorPage(String value) { 177 this.setAttributeValue(DEFAULT_ERROR_PAGE,value); 178 } 179 public String getDefaultErrorPage() { 180 return (String ) 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 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); } 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); } 204 if (getNsWebApp()==null) { 205 throw new org.netbeans.modules.schema2beans.ValidateException("getNsWebApp() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 207 if (getNsWebAppExt()==null) { 208 throw new org.netbeans.modules.schema2beans.ValidateException("getNsWebAppExt() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 210 if (getNsXmi()==null) { 211 throw new org.netbeans.modules.schema2beans.ValidateException("getNsXmi() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 213 if(getXmiId()==null) { 214 throw new org.netbeans.modules.schema2beans.ValidateException("getXmiId() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 216 if(getXmiVersion()==null) { 217 throw new org.netbeans.modules.schema2beans.ValidateException("getXmiVersion() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 219 220 } 221 222 public void dump(StringBuffer str, String indent){ 223 String s; 224 Object o; 225 BaseBean n; 226 227 str.append(indent); 228 str.append(WEB_APPLICATION); str.append(indent+"\t"); str.append("<"); o = this.getApplication(); 232 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(WEB_APPLICATION, 0, str, indent); 235 236 str.append(indent); 237 str.append(EXTENDED_SERVLETS+"["+this.sizeExtendedServlets()+"]"); 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"); else 245 str.append(indent+"\tnull"); this.dumpAttributes(EXTENDED_SERVLETS, i, str, indent); 247 } 248 249 } 250 public String dumpBeanNode(){ 251 StringBuffer str = new StringBuffer (); 252 str.append(getClass().getName()); this.dump(str, "\n "); return str.toString(); 255 } 256 } 257 | Popular Tags |