1 17 package org.apache.geronimo.connector.deployment.jsr88; 18 19 import javax.enterprise.deploy.model.DDBean ; 20 import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType; 21 import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType; 22 import org.apache.geronimo.naming.deployment.jsr88.GBeanLocator; 23 import org.apache.xmlbeans.SchemaTypeLoader; 24 25 31 public class ConnectionDefinitionInstance extends ConfigHolder { 32 private DDBean connectionDefinition; 33 private ConnectionManager manager; 34 35 public ConnectionDefinitionInstance() { 36 } 37 38 public ConnectionDefinitionInstance(DDBean connectionDefinition, GerConnectiondefinitionInstanceType instance) { 39 configure(connectionDefinition, instance); 40 } 41 42 protected GerConnectiondefinitionInstanceType getConnectionInstance() { 43 return (GerConnectiondefinitionInstanceType) getXmlObject(); 44 } 45 46 public void reconfigure() { 47 configure(connectionDefinition, getConnectionInstance()); 48 } 49 50 void configure(DDBean connectionDefinition, GerConnectiondefinitionInstanceType definition) { 51 this.connectionDefinition = connectionDefinition; 52 super.configure(connectionDefinition, definition); 53 if(connectionDefinition != null) { 54 DDBean parent = connectionDefinition.getChildBean("..")[0]; 55 ConnectionManager oldMgr = manager; 56 if(oldMgr == null) { 57 if(definition.getConnectionmanager() != null) { 58 manager = new ConnectionManager(parent, definition.getConnectionmanager()); 59 } else { 60 manager = new ConnectionManager(parent, definition.addNewConnectionmanager()); 61 } 62 } else { 63 if(definition.getConnectionmanager() != null) { 64 manager.configure(parent, definition.getConnectionmanager()); 65 } else { 66 manager.configure(parent, definition.addNewConnectionmanager()); 67 } 68 } 69 pcs.firePropertyChange("connectionManager", oldMgr, manager); 70 } 71 } 72 73 DDBean getDDBean() { 74 return connectionDefinition; 75 } 76 77 protected GerConfigPropertySettingType createConfigProperty() { 78 return getConnectionInstance().addNewConfigPropertySetting(); 79 } 80 81 protected GerConfigPropertySettingType[] getConfigProperties() { 82 return getConnectionInstance().getConfigPropertySettingArray(); 83 } 84 85 protected void removeConfigProperty(int index) { 86 getConnectionInstance().removeConfigPropertySetting(index); 87 } 88 89 91 public String getName() { 92 return getConnectionInstance().getName(); 93 } 94 95 public void setName(String name) { 96 String old = getName(); 97 getConnectionInstance().setName(name); 98 pcs.firePropertyChange("name", old, name); 99 } 100 101 public String [] getImplementedInterface() { 102 return getConnectionInstance().getImplementedInterfaceArray(); 103 } 104 105 public String getImplementedInterface(int index) { 106 return getConnectionInstance().getImplementedInterfaceArray(index); 107 } 108 109 public void setImplementedInterface(String [] list) { 110 String [] old = getImplementedInterface(); 111 getConnectionInstance().setImplementedInterfaceArray(list); 112 pcs.firePropertyChange("implementedInterface", old, list); 113 } 114 115 public void setImplementedInterface(int index, String iface) { 116 String [] old = getImplementedInterface(); 117 getConnectionInstance().setImplementedInterfaceArray(index, iface); 118 pcs.firePropertyChange("implementedInterface", old, getImplementedInterface()); 119 } 120 121 public ConnectionManager getConnectionManager() { 122 return manager; 123 } 124 125 127 protected SchemaTypeLoader getSchemaTypeLoader() { 128 return Connector15DCBRoot.SCHEMA_TYPE_LOADER; 129 } 130 } 131 | Popular Tags |