1 17 18 package org.apache.geronimo.connector.deployment.dconfigbean; 19 20 import javax.enterprise.deploy.model.DDBean ; 21 22 import org.apache.geronimo.deployment.plugin.DConfigBeanSupport; 23 import org.apache.geronimo.xbeans.geronimo.GerAdminobjectInstanceType; 24 import org.apache.geronimo.xbeans.geronimo.GerAdminobjectType; 25 import org.apache.xmlbeans.SchemaTypeLoader; 26 27 33 public class AdminObjectDConfigBean extends DConfigBeanSupport { 34 private AdminObjectInstance[] instances = new AdminObjectInstance[0]; 35 36 public AdminObjectDConfigBean(DDBean ddBean, GerAdminobjectType adminObject) { 37 super(ddBean, adminObject); 38 String adminObjectInterface = ddBean.getText("adminobject-interface")[0]; 39 if (adminObject.getAdminobjectInterface() == null) { 40 adminObject.setAdminobjectInterface(adminObjectInterface); 41 } else { 42 assert adminObjectInterface.equals(adminObject.getAdminobjectInterface()); 43 } 44 String adminObjectClass = ddBean.getText("adminobject-class")[0]; 45 if (adminObject.getAdminobjectClass() == null) { 46 adminObject.setAdminobjectClass(adminObjectClass); 47 } else { 48 assert adminObjectClass.equals(adminObject.getAdminobjectClass()); 49 } 50 GerAdminobjectInstanceType[] xmlInstances = getAdminObject().getAdminobjectInstanceArray(); 52 instances = new AdminObjectInstance[xmlInstances.length]; 53 for (int i = 0; i < instances.length; i++) { 54 instances[i] = new AdminObjectInstance(); 55 instances[i].initialize(xmlInstances[i], this); 56 } 57 } 58 59 GerAdminobjectType getAdminObject() { 60 return (GerAdminobjectType) getXmlObject(); 61 } 62 63 public AdminObjectInstance[] getAdminObjectInstance() { 64 return instances; 65 } 66 67 public void setAdminObjectInstance(AdminObjectInstance[] instances) { 68 AdminObjectInstance[] old = getAdminObjectInstance(); 69 this.instances = instances; 70 for (int i = 0; i < instances.length; i++) { AdminObjectInstance instance = instances[i]; 72 if (!instance.hasParent()) { 73 GerAdminobjectInstanceType xmlObject = getAdminObject().addNewAdminobjectInstance(); 74 instance.initialize(xmlObject, this); 75 } 76 } 77 for (int i = 0; i < old.length; i++) { AdminObjectInstance instance = old[i]; 79 boolean found = false; 80 for (int j = 0; j < instances.length; j++) { 81 if (instances[j] == instance) { 82 found = true; 83 break; 84 } 85 } 86 if (!found) { 87 for (int j = 0; j < getAdminObject().getAdminobjectInstanceArray().length; j++) { 89 GerAdminobjectInstanceType test = getAdminObject().getAdminobjectInstanceArray(j); 90 if (test == instance.getAdminobjectInstance()) { 91 getAdminObject().removeAdminobjectInstance(j); 92 break; 93 } 94 } 95 instance.dispose(); 97 } 98 } 99 pcs.firePropertyChange("adminObjectInstance", old, instances); 100 } 101 102 protected SchemaTypeLoader getSchemaTypeLoader() { 103 return ResourceAdapterDConfigRoot.SCHEMA_TYPE_LOADER; 104 } 105 106 } 107 | Popular Tags |