001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.connector.deployment.jsr88;
017:
018: import javax.enterprise.deploy.model.DDBean;
019: import org.apache.geronimo.deployment.plugin.XmlBeanSupport;
020: import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
021: import org.apache.xmlbeans.SchemaTypeLoader;
022:
023: /**
024: * Represents /connector/resourceadapter/resourceadapter-instance/config-property-setting
025: * or /connector/resourceadapter/outbound-resourceadapter/connection-definition/connectiondefinition-instance/config-property-setting
026: * or /connector/adminobject/adminobject-instance/config-property-setting in the
027: * Geronimo Connector deployment plan.
028: *
029: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
030: */
031: public class ConfigPropertySetting extends XmlBeanSupport {
032: private DDBean configProperty;
033: private String defaultValue;
034:
035: public ConfigPropertySetting() {
036: super (null);
037: }
038:
039: public ConfigPropertySetting(DDBean configProperty,
040: GerConfigPropertySettingType property, boolean setDefault) {
041: super (null);
042: configure(configProperty, property, setDefault);
043: }
044:
045: protected GerConfigPropertySettingType getPropertySetting() {
046: return (GerConfigPropertySettingType) getXmlObject();
047: }
048:
049: DDBean getDDBean() {
050: return configProperty;
051: }
052:
053: void configure(DDBean configProperty,
054: GerConfigPropertySettingType property, boolean setDefault) {
055: this .configProperty = configProperty;
056: setXmlObject(property);
057: final String name = configProperty
058: .getText("config-property-name")[0];
059: getPropertySetting().setName(name);
060: String[] test = configProperty.getText("config-property-value");
061: if (test != null && test.length == 1) {
062: defaultValue = test[0];
063: } else {
064: defaultValue = null;
065: }
066: if (setDefault) {
067: getPropertySetting().setStringValue(defaultValue);
068: }
069: }
070:
071: boolean isSetToDefault() {
072: String value = getValue();
073: return (defaultValue == null && value == null)
074: || (defaultValue != null && value != null && defaultValue
075: .equals(value));
076: }
077:
078: // ----------------------- JavaBean Properties for config-property-setting ----------------------
079:
080: public String getName() {
081: return getPropertySetting().getName();
082: }
083:
084: // Not public -- should always be kept in sync with matching config-property
085: void setName(String name) {
086: String old = getName();
087: getPropertySetting().setName(name);
088: pcs.firePropertyChange("name", old, name);
089: }
090:
091: public String getValue() {
092: return getPropertySetting().isNil() ? null
093: : getPropertySetting().getStringValue();
094: }
095:
096: public void setValue(String value) {
097: String old = getValue();
098: getPropertySetting().setStringValue(value);
099: pcs.firePropertyChange("value", old, value);
100: }
101:
102: // ----------------------- End of JavaBean Properties ----------------------
103:
104: protected SchemaTypeLoader getSchemaTypeLoader() {
105: return Connector15DCBRoot.SCHEMA_TYPE_LOADER;
106: }
107: }
|