1 17 package org.apache.geronimo.connector.deployment.jsr88; 18 19 import javax.enterprise.deploy.model.DDBean ; 20 import org.apache.geronimo.deployment.plugin.XmlBeanSupport; 21 import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType; 22 import org.apache.xmlbeans.SchemaTypeLoader; 23 24 32 public class ConfigPropertySetting extends XmlBeanSupport { 33 private DDBean configProperty; 34 private String defaultValue; 35 36 public ConfigPropertySetting() { 37 super(null); 38 } 39 40 public ConfigPropertySetting(DDBean configProperty, GerConfigPropertySettingType property, boolean setDefault) { 41 super(null); 42 configure(configProperty, property, setDefault); 43 } 44 45 protected GerConfigPropertySettingType getPropertySetting() { 46 return (GerConfigPropertySettingType) getXmlObject(); 47 } 48 49 DDBean getDDBean() { 50 return configProperty; 51 } 52 53 void configure(DDBean configProperty, GerConfigPropertySettingType property, boolean setDefault) { 54 this.configProperty = configProperty; 55 setXmlObject(property); 56 final String name = configProperty.getText("config-property-name")[0]; 57 getPropertySetting().setName(name); 58 String [] test = configProperty.getText("config-property-value"); 59 if(test != null && test.length == 1) { 60 defaultValue = test[0]; 61 } else { 62 defaultValue = null; 63 } 64 if(setDefault) { 65 getPropertySetting().setStringValue(defaultValue); 66 } 67 } 68 69 boolean isSetToDefault() { 70 String value = getValue(); 71 return (defaultValue == null && value == null) || 72 (defaultValue != null && value != null && defaultValue.equals(value)); 73 } 74 75 77 public String getName() { 78 return getPropertySetting().getName(); 79 } 80 81 void setName(String name) { 83 String old = getName(); 84 getPropertySetting().setName(name); 85 pcs.firePropertyChange("name", old, name); 86 } 87 88 public String getValue() { 89 return getPropertySetting().isNil() ? null : getPropertySetting().getStringValue(); 90 } 91 92 public void setValue(String value) { 93 String old = getValue(); 94 getPropertySetting().setStringValue(value); 95 pcs.firePropertyChange("value", old, value); 96 } 97 98 100 protected SchemaTypeLoader getSchemaTypeLoader() { 101 return Connector15DCBRoot.SCHEMA_TYPE_LOADER; 102 } 103 } 104 | Popular Tags |