1 23 24 47 48 package com.sun.enterprise.tools.common.dd.application; 49 50 import org.w3c.dom.*; 51 import org.netbeans.modules.schema2beans.*; 52 import java.beans.*; 53 import java.util.*; 54 import java.io.*; 55 import com.sun.enterprise.tools.common.dd.SecurityRoleMapping; 56 import com.sun.enterprise.tools.common.dd.PluginData; 57 58 60 public class SunApplication extends com.sun.enterprise.tools.common.dd.SunBaseBean 61 { 62 63 static Vector comparators = new Vector(); 64 65 static public final String WEB = "Web"; static public final String PASS_BY_REFERENCE = "PassByReference"; static public final String UNIQUE_ID = "UniqueId"; static public final String SECURITY_ROLE_MAPPING = "SecurityRoleMapping"; static public final String REALM = "Realm"; 71 public SunApplication() throws org.netbeans.modules.schema2beans.Schema2BeansException { 72 this(null, Common.USE_DEFAULT_VALUES); 73 } 74 75 public SunApplication(org.w3c.dom.Node doc, int options) throws org.netbeans.modules.schema2beans.Schema2BeansException { 76 this(Common.NO_DEFAULT_VALUES); 77 initFromNode(doc, options); 78 } 79 protected void initFromNode(org.w3c.dom.Node doc, int options) throws Schema2BeansException 80 { 81 if (doc == null) 82 { 83 doc = GraphManager.createRootElementNode("sun-application"); if (doc == null) 85 throw new Schema2BeansException(Common.getMessage( 86 "CantCreateDOMRoot_msg", "sun-application")); 87 } 88 Node n = GraphManager.getElementNode("sun-application", doc); if (n == null) 90 throw new Schema2BeansException(Common.getMessage( 91 "DocRootNotInDOMGraph_msg", "sun-application", doc.getFirstChild().getNodeName())); 92 93 this.graphManager.setXmlDocument(doc); 94 95 this.createBean(n, this.graphManager()); 97 this.initialize(options); 98 } 99 public SunApplication(int options) 100 { 101 super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 102 initOptions(options); 103 } 104 protected void initOptions(int options) 105 { 106 this.graphManager = new GraphManager(this); 108 this.createRoot("sun-application", "SunApplication", Common.TYPE_1 | Common.TYPE_BEAN, SunApplication.class); 110 111 this.createProperty("web", WEB, 114 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 115 Web.class); 116 this.createProperty("pass-by-reference", PASS_BY_REFERENCE, 118 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 119 String .class); 120 this.createProperty("unique-id", UNIQUE_ID, 122 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 123 String .class); 124 this.createProperty("security-role-mapping", SECURITY_ROLE_MAPPING, 126 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 127 SecurityRoleMapping.class); 128 this.createProperty("realm", REALM, 130 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 131 String .class); 132 this.initialize(options); 133 } 134 135 void initialize(int options) 137 { 138 139 } 140 141 public void setWeb(int index, Web value) { 143 this.setValue(WEB, index, value); 144 } 145 146 public Web getWeb(int index) { 148 return (Web)this.getValue(WEB, index); 149 } 150 151 public void setWeb(Web[] value) { 153 this.setValue(WEB, value); 154 } 155 156 public Web[] getWeb() { 158 return (Web[])this.getValues(WEB); 159 } 160 161 public int sizeWeb() { 163 return this.size(WEB); 164 } 165 166 public int addWeb(com.sun.enterprise.tools.common.dd.application.Web value) { 168 return this.addValue(WEB, value); 169 } 170 171 public int removeWeb(com.sun.enterprise.tools.common.dd.application.Web value) { 176 return this.removeValue(WEB, value); 177 } 178 179 public void setPassByReference(String value) { 181 this.setValue(PASS_BY_REFERENCE, value); 182 } 183 184 public String getPassByReference() { 186 return (String )this.getValue(PASS_BY_REFERENCE); 187 } 188 189 public void setUniqueId(String value) { 191 this.setValue(UNIQUE_ID, value); 192 } 193 194 public String getUniqueId() { 196 return (String )this.getValue(UNIQUE_ID); 197 } 198 199 public void setSecurityRoleMapping(int index, SecurityRoleMapping value) { 201 this.setValue(SECURITY_ROLE_MAPPING, index, value); 202 } 203 204 public SecurityRoleMapping getSecurityRoleMapping(int index) { 206 return (SecurityRoleMapping)this.getValue(SECURITY_ROLE_MAPPING, index); 207 } 208 209 public void setSecurityRoleMapping(SecurityRoleMapping[] value) { 211 this.setValue(SECURITY_ROLE_MAPPING, value); 212 } 213 214 public SecurityRoleMapping[] getSecurityRoleMapping() { 216 return (SecurityRoleMapping[])this.getValues(SECURITY_ROLE_MAPPING); 217 } 218 219 public int sizeSecurityRoleMapping() { 221 return this.size(SECURITY_ROLE_MAPPING); 222 } 223 224 public int addSecurityRoleMapping(SecurityRoleMapping value) { 226 return this.addValue(SECURITY_ROLE_MAPPING, value); 227 } 228 229 public int removeSecurityRoleMapping(SecurityRoleMapping value) { 234 return this.removeValue(SECURITY_ROLE_MAPPING, value); 235 } 236 237 public void setRealm(String value) { 239 this.setValue(REALM, value); 240 } 241 242 public String getRealm() { 244 return (String )this.getValue(REALM); 245 } 246 247 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 249 comparators.add(c); 250 } 251 252 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 254 comparators.remove(c); 255 } 256 public static SunApplication createGraph(org.w3c.dom.Node doc) throws org.netbeans.modules.schema2beans.Schema2BeansException { 261 return new SunApplication(doc, Common.NO_DEFAULT_VALUES); 262 } 263 264 public static SunApplication createGraph(java.io.InputStream in) throws org.netbeans.modules.schema2beans.Schema2BeansException { 265 return createGraph(in, false); 266 } 267 268 public static SunApplication createGraph(java.io.InputStream in, boolean validate) throws org.netbeans.modules.schema2beans.Schema2BeansException { 269 Document doc = GraphManager.createXmlDocument(in, validate); 270 return createGraph(doc); 271 } 272 273 public static SunApplication createGraph() { 277 try { 278 return new SunApplication(); 279 } 280 catch (Schema2BeansException e) { 281 throw new RuntimeException (e.getMessage()); 282 } 283 } 284 285 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 286 boolean restrictionFailure = false; 287 for (int _index = 0; _index < sizeWeb(); ++_index) { 289 com.sun.enterprise.tools.common.dd.application.Web element = getWeb(_index); 290 if (element != null) { 291 element.validate(); 292 } 293 } 294 if (getPassByReference() != null) { 296 } 297 if (getUniqueId() != null) { 299 } 300 for (int _index = 0; _index < sizeSecurityRoleMapping(); ++_index) { 302 SecurityRoleMapping element = getSecurityRoleMapping(_index); 303 if (element != null) { 304 element.validate(); 305 } 306 } 307 if (getRealm() != null) { 309 } 310 } 311 312 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { 314 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 315 write(baos); 316 String str = baos.toString();; 317 out.writeUTF(str); 319 } 320 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException , ClassNotFoundException { 322 try{ 323 init(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 324 String strDocument = in.readUTF(); 325 ByteArrayInputStream bais = new ByteArrayInputStream(strDocument.getBytes()); 327 Document doc = GraphManager.createXmlDocument(bais, false); 328 initOptions(Common.NO_DEFAULT_VALUES); 329 initFromNode(doc, Common.NO_DEFAULT_VALUES); 330 } 331 catch (Schema2BeansException e) { 332 e.printStackTrace(); 333 throw new RuntimeException (e.getMessage()); 334 } 335 } 336 337 public void dump(StringBuffer str, String indent){ 339 String s; 340 Object o; 341 org.netbeans.modules.schema2beans.BaseBean n; 342 str.append(indent); 343 str.append("Web["+this.sizeWeb()+"]"); for(int i=0; i<this.sizeWeb(); i++) 345 { 346 str.append(indent+"\t"); 347 str.append("#"+i+":"); 348 n = (org.netbeans.modules.schema2beans.BaseBean) this.getWeb(i); 349 if (n != null) 350 n.dump(str, indent + "\t"); else 352 str.append(indent+"\tnull"); this.dumpAttributes(WEB, i, str, indent); 354 } 355 356 str.append(indent); 357 str.append("PassByReference"); str.append(indent+"\t"); str.append("<"); s = this.getPassByReference(); 361 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(PASS_BY_REFERENCE, 0, str, indent); 364 365 str.append(indent); 366 str.append("UniqueId"); str.append(indent+"\t"); str.append("<"); s = this.getUniqueId(); 370 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(UNIQUE_ID, 0, str, indent); 373 374 str.append(indent); 375 str.append("SecurityRoleMapping["+this.sizeSecurityRoleMapping()+"]"); for(int i=0; i<this.sizeSecurityRoleMapping(); i++) 377 { 378 str.append(indent+"\t"); 379 str.append("#"+i+":"); 380 n = (org.netbeans.modules.schema2beans.BaseBean) this.getSecurityRoleMapping(i); 381 if (n != null) 382 n.dump(str, indent + "\t"); else 384 str.append(indent+"\tnull"); this.dumpAttributes(SECURITY_ROLE_MAPPING, i, str, indent); 386 } 387 388 str.append(indent); 389 str.append("Realm"); str.append(indent+"\t"); str.append("<"); s = this.getRealm(); 393 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(REALM, 0, str, indent); 396 397 } 398 public String dumpBeanNode(){ 399 StringBuffer str = new StringBuffer (); 400 str.append("SunApplication\n"); this.dump(str, "\n "); return str.toString(); 403 }} 404 405 407 408 466 | Popular Tags |