1 17 package org.apache.geronimo.connector.deployment.jsr88; 18 19 import org.apache.geronimo.deployment.plugin.DConfigBeanSupport; 20 import org.apache.geronimo.xbeans.geronimo.GerAdminobjectType; 21 import org.apache.geronimo.xbeans.geronimo.GerAdminobjectInstanceType; 22 import org.apache.xmlbeans.SchemaTypeLoader; 23 24 import javax.enterprise.deploy.model.DDBean ; 25 26 38 public class AdminObjectDCB extends DConfigBeanSupport { 39 private AdminObjectInstance[] adminObjectInstance = new AdminObjectInstance[0]; 40 41 public AdminObjectDCB(DDBean adminobjectDDBean, final GerAdminobjectType adminobject) { 42 super(adminobjectDDBean, adminobject); 43 configure(adminobjectDDBean, adminobject); 45 } 46 47 private void configure(DDBean adminDDBean, GerAdminobjectType adminXml) { 48 adminXml.setAdminobjectClass(adminDDBean.getText("adminobject-class")[0]); 49 adminXml.setAdminobjectInterface(adminDDBean.getText("adminobject-interface")[0]); 50 GerAdminobjectInstanceType[] xmls = adminXml.getAdminobjectInstanceArray(); 51 adminObjectInstance = new AdminObjectInstance[xmls.length]; 52 for (int i = 0; i < xmls.length; i++) { 53 adminObjectInstance[i] = new AdminObjectInstance(adminDDBean, xmls[i]); 54 } 55 } 56 57 GerAdminobjectType getAdminObject() { 58 return (GerAdminobjectType) getXmlObject(); 59 } 60 61 void addAdminObjectInstance(GerAdminobjectInstanceType xml) { 62 AdminObjectInstance instance = new AdminObjectInstance(getDDBean(), xml); 63 AdminObjectInstance[] result = new AdminObjectInstance[adminObjectInstance.length+1]; 64 System.arraycopy(adminObjectInstance, 0, result, 0, adminObjectInstance.length); 65 result[adminObjectInstance.length] = instance; 66 setAdminObjectInstance(result); 67 } 68 69 71 public String getAdminObjectInterface() { 72 return getAdminObject().getAdminobjectInterface(); 73 } 74 75 public String getAdminObjectClass() { 76 return getAdminObject().getAdminobjectClass(); 77 } 78 79 public AdminObjectInstance[] getAdminObjectInstance() { 80 return adminObjectInstance; 81 } 82 83 public void setAdminObjectInstance(AdminObjectInstance[] adminObjectInstance) { 84 AdminObjectInstance[] old = getAdminObjectInstance(); 85 for (int i = 0; i < adminObjectInstance.length; i++) { 87 AdminObjectInstance instance = adminObjectInstance[i]; 88 if(instance.getAdminInstance() == null) { 89 instance.configure(getDDBean(), getAdminObject().addNewAdminobjectInstance()); 90 } 91 } 92 this.adminObjectInstance = adminObjectInstance; 93 pcs.firePropertyChange("adminObjectInstance", old, adminObjectInstance); 94 } 95 96 public AdminObjectInstance getAdminObjectInstance(int index) { 97 return adminObjectInstance[index]; 98 } 99 100 public void setAdminObjectInstance(int index, AdminObjectInstance adminObjectInstance) { 101 AdminObjectInstance[] old = getAdminObjectInstance(); 102 if(adminObjectInstance.getAdminInstance() == null) { 104 adminObjectInstance.configure(getDDBean(), getAdminObject().addNewAdminobjectInstance()); 105 } 106 this.adminObjectInstance[index] = adminObjectInstance; 107 pcs.firePropertyChange("adminObjectInstance", old, adminObjectInstance); 109 } 110 111 113 protected SchemaTypeLoader getSchemaTypeLoader() { 114 return Connector15DCBRoot.SCHEMA_TYPE_LOADER; 115 } 116 } 117 | Popular Tags |