1 17 18 package org.apache.geronimo.connector.deployment.dconfigbean; 19 20 import javax.enterprise.deploy.model.DDBean ; 21 import javax.enterprise.deploy.model.XpathListener ; 22 23 import org.apache.geronimo.deployment.plugin.XmlBeanSupport; 24 import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType; 25 import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType; 26 import org.apache.geronimo.xbeans.geronimo.GerConnectionmanagerType; 27 import org.apache.xmlbeans.SchemaTypeLoader; 28 import org.apache.xmlbeans.XmlBeans; 29 30 33 public class ConnectionDefinitionInstance extends XmlBeanSupport { 34 private final static SchemaTypeLoader SCHEMA_TYPE_LOADER = XmlBeans.getContextTypeLoader(); 35 private ConfigPropertySettings[] configs = new ConfigPropertySettings[0]; 36 private ConnectionDefinitionDConfigBean parent; 37 private XpathListener configListener; 38 39 public ConnectionDefinitionInstance() { 40 super(null); 41 } 42 43 void initialize(GerConnectiondefinitionInstanceType xmlObject, ConnectionDefinitionDConfigBean parent) { 44 setXmlObject(xmlObject); 45 this.parent = parent; 46 DDBean parentDDBean = parent.getDDBean(); 47 configListener = ConfigPropertiesHelper.initialize(parentDDBean, new ConfigPropertiesHelper.ConfigPropertiesSource() { 48 public GerConfigPropertySettingType[] getConfigPropertySettingArray() { 49 return getConnectiondefinitionInstance().getConfigPropertySettingArray(); 50 } 51 52 public GerConfigPropertySettingType addNewConfigPropertySetting() { 53 return getConnectiondefinitionInstance().addNewConfigPropertySetting(); 54 } 55 56 public void removeConfigPropertySetting(int j) { 57 getConnectiondefinitionInstance().removeConfigPropertySetting(j); 58 } 59 60 public ConfigPropertySettings[] getConfigPropertySettings() { 61 return configs; 62 } 63 64 public void setConfigPropertySettings(ConfigPropertySettings[] configs) { 65 setConfigProperty(configs); 66 } 67 68 }, "config-property", "config-property-name"); 69 } 70 71 72 boolean hasParent() { 73 return parent != null; 74 } 75 76 void dispose() { 77 if (configs != null) { 78 for (int i = 0; i < configs.length; i++) { 79 configs[i].dispose(); 80 } 81 } 82 if (parent != null) { 83 parent.getDDBean().removeXpathListener("config-property", configListener); 84 } 85 configs = null; 86 configListener = null; 87 parent = null; 88 } 89 90 92 GerConnectiondefinitionInstanceType getConnectiondefinitionInstance() { 93 return (GerConnectiondefinitionInstanceType) getXmlObject(); 94 } 95 96 GerConnectionmanagerType getConnectionManager() { 97 return getConnectiondefinitionInstance().getConnectionmanager(); 98 } 99 100 public ConfigPropertySettings[] getConfigProperty() { 101 return configs; 102 } 103 104 private void setConfigProperty(ConfigPropertySettings[] configs) { ConfigPropertySettings[] old = getConfigProperty(); 106 this.configs = configs; 107 pcs.firePropertyChange("configProperty", old, configs); 108 } 109 110 public String getName() { 111 return getConnectiondefinitionInstance().getName(); 112 } 113 114 public void setName(String name) { 115 String old = getName(); 116 getConnectiondefinitionInstance().setName(name); 117 pcs.firePropertyChange("name", old, name); 118 } 119 120 130 202 public boolean isContainerManagedSecurity() { 203 return getConnectionManager().isSetContainerManagedSecurity(); 204 } 205 206 public void setContainerManagedSecurity(boolean containerManagedSecurity) { 207 boolean old = isContainerManagedSecurity(); 208 if (old && !containerManagedSecurity) { 209 getConnectionManager().setContainerManagedSecurity(null); 210 } else if (!old && containerManagedSecurity) { 211 getConnectionManager().addNewContainerManagedSecurity(); 212 } 213 pcs.firePropertyChange("containerManagedSecurity", old, containerManagedSecurity); 214 } 215 216 public String toString() { 217 return "Connection "+getName(); 218 } 219 } 220 | Popular Tags |