1 23 24 71 72 package com.sun.enterprise.tools.common.dd.appclient; 73 74 import org.w3c.dom.*; 75 import org.netbeans.modules.schema2beans.*; 76 import java.beans.*; 77 import java.util.*; 78 import java.io.*; 79 import com.sun.enterprise.tools.common.dd.EjbRef; 80 import com.sun.enterprise.tools.common.dd.ResourceEnvRef; 81 import com.sun.enterprise.tools.common.dd.ResourceRef; 82 import com.sun.enterprise.tools.common.dd.ServiceRef; 83 import com.sun.enterprise.tools.common.dd.MessageDestination; 84 import com.sun.enterprise.tools.common.dd.PluginData; 85 86 88 public class SunApplicationClient extends com.sun.enterprise.tools.common.dd.SunBaseBean 89 { 90 91 static Vector comparators = new Vector(); 92 93 static public final String EJB_REF = "EjbRef"; static public final String RESOURCE_REF = "ResourceRef"; static public final String RESOURCE_ENV_REF = "ResourceEnvRef"; static public final String SERVICE_REF = "ServiceRef"; static public final String MESSAGE_DESTINATION = "MessageDestination"; 99 public SunApplicationClient() throws org.netbeans.modules.schema2beans.Schema2BeansException { 100 this(null, Common.USE_DEFAULT_VALUES); 101 } 102 103 public SunApplicationClient(org.w3c.dom.Node doc, int options) throws org.netbeans.modules.schema2beans.Schema2BeansException { 104 this(Common.NO_DEFAULT_VALUES); 105 initFromNode(doc, options); 106 } 107 protected void initFromNode(org.w3c.dom.Node doc, int options) throws Schema2BeansException 108 { 109 if (doc == null) 110 { 111 doc = GraphManager.createRootElementNode("sun-application-client"); if (doc == null) 113 throw new Schema2BeansException(Common.getMessage( 114 "CantCreateDOMRoot_msg", "sun-application-client")); 115 } 116 Node n = GraphManager.getElementNode("sun-application-client", doc); if (n == null) 118 throw new Schema2BeansException(Common.getMessage( 119 "DocRootNotInDOMGraph_msg", "sun-application-client", doc.getFirstChild().getNodeName())); 120 121 this.graphManager.setXmlDocument(doc); 122 123 this.createBean(n, this.graphManager()); 125 this.initialize(options); 126 } 127 public SunApplicationClient(int options) 128 { 129 super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 130 initOptions(options); 131 } 132 protected void initOptions(int options) 133 { 134 this.graphManager = new GraphManager(this); 136 this.createRoot("sun-application-client", "SunApplicationClient", Common.TYPE_1 | Common.TYPE_BEAN, SunApplicationClient.class); 138 139 this.createProperty("ejb-ref", EJB_REF, 142 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 143 EjbRef.class); 144 this.createProperty("resource-ref", RESOURCE_REF, 146 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 147 ResourceRef.class); 148 this.createProperty("resource-env-ref", RESOURCE_ENV_REF, 150 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 151 ResourceEnvRef.class); 152 this.createProperty("service-ref", SERVICE_REF, 154 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 155 ServiceRef.class); 156 this.createProperty("message-destination", MESSAGE_DESTINATION, 158 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 159 MessageDestination.class); 160 this.initialize(options); 161 } 162 163 void initialize(int options) 165 { 166 167 } 168 169 public void setEjbRef(int index, EjbRef value) { 171 this.setValue(EJB_REF, index, value); 172 } 173 174 public EjbRef getEjbRef(int index) { 176 return (EjbRef)this.getValue(EJB_REF, index); 177 } 178 179 public void setEjbRef(EjbRef[] value) { 181 this.setValue(EJB_REF, value); 182 } 183 184 public EjbRef[] getEjbRef() { 186 return (EjbRef[])this.getValues(EJB_REF); 187 } 188 189 public int sizeEjbRef() { 191 return this.size(EJB_REF); 192 } 193 194 public int addEjbRef(EjbRef value) { 196 return this.addValue(EJB_REF, value); 197 } 198 199 public int removeEjbRef(EjbRef value) { 204 return this.removeValue(EJB_REF, value); 205 } 206 207 public void setResourceRef(int index, ResourceRef value) { 209 this.setValue(RESOURCE_REF, index, value); 210 } 211 212 public ResourceRef getResourceRef(int index) { 214 return (ResourceRef)this.getValue(RESOURCE_REF, index); 215 } 216 217 public void setResourceRef(ResourceRef[] value) { 219 this.setValue(RESOURCE_REF, value); 220 } 221 222 public ResourceRef[] getResourceRef() { 224 return (ResourceRef[])this.getValues(RESOURCE_REF); 225 } 226 227 public int sizeResourceRef() { 229 return this.size(RESOURCE_REF); 230 } 231 232 public int addResourceRef(ResourceRef value) { 234 return this.addValue(RESOURCE_REF, value); 235 } 236 237 public int removeResourceRef(ResourceRef value) { 242 return this.removeValue(RESOURCE_REF, value); 243 } 244 245 public void setResourceEnvRef(int index, ResourceEnvRef value) { 247 this.setValue(RESOURCE_ENV_REF, index, value); 248 } 249 250 public ResourceEnvRef getResourceEnvRef(int index) { 252 return (ResourceEnvRef)this.getValue(RESOURCE_ENV_REF, index); 253 } 254 255 public void setResourceEnvRef(ResourceEnvRef[] value) { 257 this.setValue(RESOURCE_ENV_REF, value); 258 } 259 260 public ResourceEnvRef[] getResourceEnvRef() { 262 return (ResourceEnvRef[])this.getValues(RESOURCE_ENV_REF); 263 } 264 265 public int sizeResourceEnvRef() { 267 return this.size(RESOURCE_ENV_REF); 268 } 269 270 public int addResourceEnvRef(ResourceEnvRef value) { 272 return this.addValue(RESOURCE_ENV_REF, value); 273 } 274 275 public int removeResourceEnvRef(ResourceEnvRef value) { 280 return this.removeValue(RESOURCE_ENV_REF, value); 281 } 282 283 public void setServiceRef(int index, ServiceRef value) { 285 this.setValue(SERVICE_REF, index, value); 286 } 287 288 public ServiceRef getServiceRef(int index) { 290 return (ServiceRef)this.getValue(SERVICE_REF, index); 291 } 292 293 public void setServiceRef(ServiceRef[] value) { 295 this.setValue(SERVICE_REF, value); 296 } 297 298 public ServiceRef[] getServiceRef() { 300 return (ServiceRef[])this.getValues(SERVICE_REF); 301 } 302 303 public int sizeServiceRef() { 305 return this.size(SERVICE_REF); 306 } 307 308 public int addServiceRef(ServiceRef value) { 310 return this.addValue(SERVICE_REF, value); 311 } 312 313 public int removeServiceRef(ServiceRef value) { 318 return this.removeValue(SERVICE_REF, value); 319 } 320 321 public void setMessageDestination(int index, MessageDestination value) { 323 this.setValue(MESSAGE_DESTINATION, index, value); 324 } 325 326 public MessageDestination getMessageDestination(int index) { 328 return (MessageDestination)this.getValue(MESSAGE_DESTINATION, index); 329 } 330 331 public void setMessageDestination(MessageDestination[] value) { 333 this.setValue(MESSAGE_DESTINATION, value); 334 } 335 336 public MessageDestination[] getMessageDestination() { 338 return (MessageDestination[])this.getValues(MESSAGE_DESTINATION); 339 } 340 341 public int sizeMessageDestination() { 343 return this.size(MESSAGE_DESTINATION); 344 } 345 346 public int addMessageDestination(MessageDestination value) { 348 return this.addValue(MESSAGE_DESTINATION, value); 349 } 350 351 public int removeMessageDestination(MessageDestination value) { 356 return this.removeValue(MESSAGE_DESTINATION, value); 357 } 358 359 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 361 comparators.add(c); 362 } 363 364 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 366 comparators.remove(c); 367 } 368 public static SunApplicationClient createGraph(org.w3c.dom.Node doc) throws org.netbeans.modules.schema2beans.Schema2BeansException { 373 return new SunApplicationClient(doc, Common.NO_DEFAULT_VALUES); 374 } 375 376 public static SunApplicationClient createGraph(java.io.InputStream in) throws org.netbeans.modules.schema2beans.Schema2BeansException { 377 return createGraph(in, false); 378 } 379 380 public static SunApplicationClient createGraph(java.io.InputStream in, boolean validate) throws org.netbeans.modules.schema2beans.Schema2BeansException { 381 Document doc = GraphManager.createXmlDocument(in, validate); 382 return createGraph(doc); 383 } 384 385 public static SunApplicationClient createGraph() { 389 try { 390 return new SunApplicationClient(); 391 } 392 catch (Schema2BeansException e) { 393 throw new RuntimeException (e.getMessage()); 394 } 395 } 396 397 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 398 boolean restrictionFailure = false; 399 for (int _index = 0; _index < sizeEjbRef(); ++_index) { 401 EjbRef element = getEjbRef(_index); 402 if (element != null) { 403 element.validate(); 404 } 405 } 406 for (int _index = 0; _index < sizeResourceRef(); ++_index) { 408 ResourceRef element = getResourceRef(_index); 409 if (element != null) { 410 element.validate(); 411 } 412 } 413 for (int _index = 0; _index < sizeResourceEnvRef(); ++_index) { 415 ResourceEnvRef element = getResourceEnvRef(_index); 416 if (element != null) { 417 element.validate(); 418 } 419 } 420 for (int _index = 0; _index < sizeServiceRef(); ++_index) { 422 ServiceRef element = getServiceRef(_index); 423 if (element != null) { 424 element.validate(); 425 } 426 } 427 for (int _index = 0; _index < sizeMessageDestination(); ++_index) { 429 MessageDestination element = getMessageDestination(_index); 430 if (element != null) { 431 element.validate(); 432 } 433 } 434 } 435 436 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { 438 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 439 write(baos); 440 String str = baos.toString();; 441 out.writeUTF(str); 443 } 444 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException , ClassNotFoundException { 446 try{ 447 init(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 448 String strDocument = in.readUTF(); 449 ByteArrayInputStream bais = new ByteArrayInputStream(strDocument.getBytes()); 451 Document doc = GraphManager.createXmlDocument(bais, false); 452 initOptions(Common.NO_DEFAULT_VALUES); 453 initFromNode(doc, Common.NO_DEFAULT_VALUES); 454 } 455 catch (Schema2BeansException e) { 456 e.printStackTrace(); 457 throw new RuntimeException (e.getMessage()); 458 } 459 } 460 461 public void dump(StringBuffer str, String indent){ 463 String s; 464 Object o; 465 org.netbeans.modules.schema2beans.BaseBean n; 466 str.append(indent); 467 str.append("EjbRef["+this.sizeEjbRef()+"]"); for(int i=0; i<this.sizeEjbRef(); i++) 469 { 470 str.append(indent+"\t"); 471 str.append("#"+i+":"); 472 n = (org.netbeans.modules.schema2beans.BaseBean) this.getEjbRef(i); 473 if (n != null) 474 n.dump(str, indent + "\t"); else 476 str.append(indent+"\tnull"); this.dumpAttributes(EJB_REF, i, str, indent); 478 } 479 480 str.append(indent); 481 str.append("ResourceRef["+this.sizeResourceRef()+"]"); for(int i=0; i<this.sizeResourceRef(); i++) 483 { 484 str.append(indent+"\t"); 485 str.append("#"+i+":"); 486 n = (org.netbeans.modules.schema2beans.BaseBean) this.getResourceRef(i); 487 if (n != null) 488 n.dump(str, indent + "\t"); else 490 str.append(indent+"\tnull"); this.dumpAttributes(RESOURCE_REF, i, str, indent); 492 } 493 494 str.append(indent); 495 str.append("ResourceEnvRef["+this.sizeResourceEnvRef()+"]"); for(int i=0; i<this.sizeResourceEnvRef(); i++) 497 { 498 str.append(indent+"\t"); 499 str.append("#"+i+":"); 500 n = (org.netbeans.modules.schema2beans.BaseBean) this.getResourceEnvRef(i); 501 if (n != null) 502 n.dump(str, indent + "\t"); else 504 str.append(indent+"\tnull"); this.dumpAttributes(RESOURCE_ENV_REF, i, str, indent); 506 } 507 508 str.append(indent); 509 str.append("ServiceRef["+this.sizeServiceRef()+"]"); for(int i=0; i<this.sizeServiceRef(); i++) 511 { 512 str.append(indent+"\t"); 513 str.append("#"+i+":"); 514 n = (org.netbeans.modules.schema2beans.BaseBean) this.getServiceRef(i); 515 if (n != null) 516 n.dump(str, indent + "\t"); else 518 str.append(indent+"\tnull"); this.dumpAttributes(SERVICE_REF, i, str, indent); 520 } 521 522 str.append(indent); 523 str.append("MessageDestination["+this.sizeMessageDestination()+"]"); for(int i=0; i<this.sizeMessageDestination(); i++) 525 { 526 str.append(indent+"\t"); 527 str.append("#"+i+":"); 528 n = (org.netbeans.modules.schema2beans.BaseBean) this.getMessageDestination(i); 529 if (n != null) 530 n.dump(str, indent + "\t"); else 532 str.append(indent+"\tnull"); this.dumpAttributes(MESSAGE_DESTINATION, i, str, indent); 534 } 535 536 } 537 public String dumpBeanNode(){ 538 StringBuffer str = new StringBuffer (); 539 str.append("SunApplicationClient\n"); this.dump(str, "\n "); return str.toString(); 542 }} 543 544 546 547 747 | Popular Tags |