KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > deployment > jsr88 > ConfigPropertySetting


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.connector.deployment.jsr88;
18
19 import javax.enterprise.deploy.model.DDBean JavaDoc;
20 import org.apache.geronimo.deployment.plugin.XmlBeanSupport;
21 import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
22 import org.apache.xmlbeans.SchemaTypeLoader;
23
24 /**
25  * Represents /connector/resourceadapter/resourceadapter-instance/config-property-setting
26  * or /connector/resourceadapter/outbound-resourceadapter/connection-definition/connectiondefinition-instance/config-property-setting
27  * or /connector/adminobject/adminobject-instance/config-property-setting in the
28  * Geronimo Connector deployment plan.
29  *
30  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
31  */

32 public class ConfigPropertySetting extends XmlBeanSupport {
33     private DDBean JavaDoc configProperty;
34     private String JavaDoc defaultValue;
35
36     public ConfigPropertySetting() {
37         super(null);
38     }
39
40     public ConfigPropertySetting(DDBean JavaDoc 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 JavaDoc getDDBean() {
50         return configProperty;
51     }
52
53     void configure(DDBean JavaDoc configProperty, GerConfigPropertySettingType property, boolean setDefault) {
54         this.configProperty = configProperty;
55         setXmlObject(property);
56         final String JavaDoc name = configProperty.getText("config-property-name")[0];
57         getPropertySetting().setName(name);
58         String JavaDoc[] 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 JavaDoc value = getValue();
71         return (defaultValue == null && value == null) ||
72                 (defaultValue != null && value != null && defaultValue.equals(value));
73     }
74
75     // ----------------------- JavaBean Properties for config-property-setting ----------------------
76

77     public String JavaDoc getName() {
78         return getPropertySetting().getName();
79     }
80
81     // Not public -- should always be kept in sync with matching config-property
82
void setName(String JavaDoc name) {
83         String JavaDoc old = getName();
84         getPropertySetting().setName(name);
85         pcs.firePropertyChange("name", old, name);
86     }
87
88     public String JavaDoc getValue() {
89         return getPropertySetting().isNil() ? null : getPropertySetting().getStringValue();
90     }
91
92     public void setValue(String JavaDoc value) {
93         String JavaDoc old = getValue();
94         getPropertySetting().setStringValue(value);
95         pcs.firePropertyChange("value", old, value);
96     }
97
98     // ----------------------- End of JavaBean Properties ----------------------
99

100     protected SchemaTypeLoader getSchemaTypeLoader() {
101         return Connector15DCBRoot.SCHEMA_TYPE_LOADER;
102     }
103 }
104
Popular Tags