1 23 24 194 195 package com.sun.enterprise.tools.common.dd.ejb; 196 197 import org.w3c.dom.*; 198 import org.netbeans.modules.schema2beans.*; 199 import java.beans.*; 200 import java.util.*; 201 import java.io.*; 202 import com.sun.enterprise.tools.common.dd.SecurityRoleMapping; 203 204 206 public class SunEjbJar extends com.sun.enterprise.tools.common.dd.SunBaseBean 207 { 208 209 static Vector comparators = new Vector(); 210 211 static public final String SECURITY_ROLE_MAPPING = "SecurityRoleMapping"; static public final String ENTERPRISE_BEANS = "EnterpriseBeans"; 214 public SunEjbJar() throws org.netbeans.modules.schema2beans.Schema2BeansException { 215 this(null, Common.USE_DEFAULT_VALUES); 216 } 217 218 public SunEjbJar(org.w3c.dom.Node doc, int options) throws org.netbeans.modules.schema2beans.Schema2BeansException { 219 this(Common.NO_DEFAULT_VALUES); 220 initFromNode(doc, options); 221 } 222 protected void initFromNode(org.w3c.dom.Node doc, int options) throws Schema2BeansException 223 { 224 if (doc == null) 225 { 226 doc = GraphManager.createRootElementNode("sun-ejb-jar"); if (doc == null) 228 throw new Schema2BeansException(Common.getMessage( 229 "CantCreateDOMRoot_msg", "sun-ejb-jar")); 230 } 231 Node n = GraphManager.getElementNode("sun-ejb-jar", doc); if (n == null) 233 throw new Schema2BeansException(Common.getMessage( 234 "DocRootNotInDOMGraph_msg", "sun-ejb-jar", doc.getFirstChild().getNodeName())); 235 236 this.graphManager.setXmlDocument(doc); 237 238 this.createBean(n, this.graphManager()); 240 this.initialize(options); 241 } 242 public SunEjbJar(int options) 243 { 244 super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 245 initOptions(options); 246 } 247 protected void initOptions(int options) 248 { 249 this.graphManager = new GraphManager(this); 251 this.createRoot("sun-ejb-jar", "SunEjbJar", Common.TYPE_1 | Common.TYPE_BEAN, SunEjbJar.class); 253 254 this.createProperty("security-role-mapping", SECURITY_ROLE_MAPPING, 257 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 258 SecurityRoleMapping.class); 259 this.createProperty("enterprise-beans", ENTERPRISE_BEANS, 261 Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 262 EnterpriseBeans.class); 263 this.initialize(options); 264 } 265 266 void initialize(int options) 268 { 269 270 } 271 272 public void setSecurityRoleMapping(int index, SecurityRoleMapping value) { 274 this.setValue(SECURITY_ROLE_MAPPING, index, value); 275 } 276 277 public SecurityRoleMapping getSecurityRoleMapping(int index) { 279 return (SecurityRoleMapping)this.getValue(SECURITY_ROLE_MAPPING, index); 280 } 281 282 public void setSecurityRoleMapping(SecurityRoleMapping[] value) { 284 this.setValue(SECURITY_ROLE_MAPPING, value); 285 } 286 287 public SecurityRoleMapping[] getSecurityRoleMapping() { 289 return (SecurityRoleMapping[])this.getValues(SECURITY_ROLE_MAPPING); 290 } 291 292 public int sizeSecurityRoleMapping() { 294 return this.size(SECURITY_ROLE_MAPPING); 295 } 296 297 public int addSecurityRoleMapping(SecurityRoleMapping value) { 299 return this.addValue(SECURITY_ROLE_MAPPING, value); 300 } 301 302 public int removeSecurityRoleMapping(SecurityRoleMapping value) { 307 return this.removeValue(SECURITY_ROLE_MAPPING, value); 308 } 309 310 public void setEnterpriseBeans(EnterpriseBeans value) { 312 this.setValue(ENTERPRISE_BEANS, value); 313 } 314 315 public EnterpriseBeans getEnterpriseBeans() { 317 return (EnterpriseBeans)this.getValue(ENTERPRISE_BEANS); 318 } 319 320 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 322 comparators.add(c); 323 } 324 325 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 327 comparators.remove(c); 328 } 329 public static SunEjbJar createGraph(org.w3c.dom.Node doc) throws org.netbeans.modules.schema2beans.Schema2BeansException { 334 return new SunEjbJar(doc, Common.NO_DEFAULT_VALUES); 335 } 336 337 public static SunEjbJar createGraph(java.io.InputStream in) throws org.netbeans.modules.schema2beans.Schema2BeansException { 338 return createGraph(in, false); 339 } 340 341 public static SunEjbJar createGraph(java.io.InputStream in, boolean validate) throws org.netbeans.modules.schema2beans.Schema2BeansException { 342 Document doc = GraphManager.createXmlDocument(in, validate); 343 return createGraph(doc); 344 } 345 346 public static SunEjbJar createGraph() { 350 try { 351 return new SunEjbJar(); 352 } 353 catch (Schema2BeansException e) { 354 throw new RuntimeException (e.getMessage()); 355 } 356 } 357 358 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 359 boolean restrictionFailure = false; 360 for (int _index = 0; _index < sizeSecurityRoleMapping(); ++_index) { 362 SecurityRoleMapping element = getSecurityRoleMapping(_index); 363 if (element != null) { 364 element.validate(); 365 } 366 } 367 if (getEnterpriseBeans() == null) { 369 throw new org.netbeans.modules.schema2beans.ValidateException("getEnterpriseBeans() == null", "enterpriseBeans", this); } 371 getEnterpriseBeans().validate(); 372 } 373 374 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { 376 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 377 write(baos); 378 String str = baos.toString();; 379 out.writeUTF(str); 381 } 382 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException , ClassNotFoundException { 384 try{ 385 init(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 386 String strDocument = in.readUTF(); 387 ByteArrayInputStream bais = new ByteArrayInputStream(strDocument.getBytes()); 389 Document doc = GraphManager.createXmlDocument(bais, false); 390 initOptions(Common.NO_DEFAULT_VALUES); 391 initFromNode(doc, Common.NO_DEFAULT_VALUES); 392 } 393 catch (Schema2BeansException e) { 394 e.printStackTrace(); 395 throw new RuntimeException (e.getMessage()); 396 } 397 } 398 399 public void dump(StringBuffer str, String indent){ 401 String s; 402 Object o; 403 org.netbeans.modules.schema2beans.BaseBean n; 404 str.append(indent); 405 str.append("SecurityRoleMapping["+this.sizeSecurityRoleMapping()+"]"); for(int i=0; i<this.sizeSecurityRoleMapping(); i++) 407 { 408 str.append(indent+"\t"); 409 str.append("#"+i+":"); 410 n = (org.netbeans.modules.schema2beans.BaseBean) this.getSecurityRoleMapping(i); 411 if (n != null) 412 n.dump(str, indent + "\t"); else 414 str.append(indent+"\tnull"); this.dumpAttributes(SECURITY_ROLE_MAPPING, i, str, indent); 416 } 417 418 str.append(indent); 419 str.append("EnterpriseBeans"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getEnterpriseBeans(); 421 if (n != null) 422 n.dump(str, indent + "\t"); else 424 str.append(indent+"\tnull"); this.dumpAttributes(ENTERPRISE_BEANS, 0, str, indent); 426 427 } 428 public String dumpBeanNode(){ 429 StringBuffer str = new StringBuffer (); 430 str.append("SunEjbJar\n"); this.dump(str, "\n "); return str.toString(); 433 }} 434 435 437 438 1282 | Popular Tags |