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.dconfigbean;
017:
018: import javax.enterprise.deploy.model.DDBean;
019: import javax.enterprise.deploy.model.XpathListener;
020:
021: import org.apache.geronimo.deployment.plugin.XmlBeanSupport;
022: import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
023: import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType;
024: import org.apache.geronimo.xbeans.geronimo.GerConnectionmanagerType;
025: import org.apache.xmlbeans.SchemaTypeLoader;
026: import org.apache.xmlbeans.XmlBeans;
027:
028: /**
029: * @version $Revision 1.0$ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
030: */
031: public class ConnectionDefinitionInstance extends XmlBeanSupport {
032: private final static SchemaTypeLoader SCHEMA_TYPE_LOADER = XmlBeans
033: .getContextTypeLoader();
034: private ConfigPropertySettings[] configs = new ConfigPropertySettings[0];
035: private ConnectionDefinitionDConfigBean parent;
036: private XpathListener configListener;
037:
038: public ConnectionDefinitionInstance() {
039: super (null);
040: }
041:
042: void initialize(GerConnectiondefinitionInstanceType xmlObject,
043: ConnectionDefinitionDConfigBean parent) {
044: setXmlObject(xmlObject);
045: this .parent = parent;
046: DDBean parentDDBean = parent.getDDBean();
047: configListener = ConfigPropertiesHelper.initialize(
048: parentDDBean,
049: new ConfigPropertiesHelper.ConfigPropertiesSource() {
050: public GerConfigPropertySettingType[] getConfigPropertySettingArray() {
051: return getConnectiondefinitionInstance()
052: .getConfigPropertySettingArray();
053: }
054:
055: public GerConfigPropertySettingType addNewConfigPropertySetting() {
056: return getConnectiondefinitionInstance()
057: .addNewConfigPropertySetting();
058: }
059:
060: public void removeConfigPropertySetting(int j) {
061: getConnectiondefinitionInstance()
062: .removeConfigPropertySetting(j);
063: }
064:
065: public ConfigPropertySettings[] getConfigPropertySettings() {
066: return configs;
067: }
068:
069: public void setConfigPropertySettings(
070: ConfigPropertySettings[] configs) {
071: setConfigProperty(configs);
072: }
073:
074: }, "config-property", "config-property-name");
075: }
076:
077: boolean hasParent() {
078: return parent != null;
079: }
080:
081: void dispose() {
082: if (configs != null) {
083: for (int i = 0; i < configs.length; i++) {
084: configs[i].dispose();
085: }
086: }
087: if (parent != null) {
088: parent.getDDBean().removeXpathListener("config-property",
089: configListener);
090: }
091: configs = null;
092: configListener = null;
093: parent = null;
094: }
095:
096: // JavaBean properties for this object (with a couple helper methods)
097:
098: GerConnectiondefinitionInstanceType getConnectiondefinitionInstance() {
099: return (GerConnectiondefinitionInstanceType) getXmlObject();
100: }
101:
102: GerConnectionmanagerType getConnectionManager() {
103: return getConnectiondefinitionInstance().getConnectionmanager();
104: }
105:
106: public ConfigPropertySettings[] getConfigProperty() {
107: return configs;
108: }
109:
110: private void setConfigProperty(ConfigPropertySettings[] configs) { // can only be changed by adding a new DDBean
111: ConfigPropertySettings[] old = getConfigProperty();
112: this .configs = configs;
113: pcs.firePropertyChange("configProperty", old, configs);
114: }
115:
116: public String getName() {
117: return getConnectiondefinitionInstance().getName();
118: }
119:
120: public void setName(String name) {
121: String old = getName();
122: getConnectiondefinitionInstance().setName(name);
123: pcs.firePropertyChange("name", old, name);
124: }
125:
126: // public String getGlobalJNDIName() {
127: // return getConnectiondefinitionInstance().getGlobalJndiName();
128: // }
129: //
130: // public void setGlobalJNDIName(String globalJNDIName) {
131: // String old = getGlobalJNDIName();
132: // getConnectiondefinitionInstance().setGlobalJndiName(globalJNDIName);
133: // pcs.firePropertyChange("globalJNDIName", old, globalJNDIName);
134: // }
135:
136: // public boolean isUseConnectionRequestInfo() {
137: // return getConnectionManager().getUseConnectionRequestInfo();
138: // }
139: //
140: // public void setUseConnectionRequestInfo(boolean useConnectionRequestInfo) {
141: // boolean old = isUseConnectionRequestInfo();
142: // getConnectionManager().setUseConnectionRequestInfo(useConnectionRequestInfo);
143: // pcs.firePropertyChange("useConnectionRequestInfo", old, useConnectionRequestInfo);
144: // }
145: //
146: // public boolean isUseSubject() {
147: // return getConnectionManager().getUseSubject();
148: // }
149: //
150: // public void setUseSubject(boolean useSubject) {
151: // boolean old = isUseSubject();
152: // getConnectionManager().setUseSubject(useSubject);
153: // pcs.firePropertyChange("useSubject", old, useSubject);
154: // }
155: //
156: // public boolean isUseTransactionCaching() {
157: // return getConnectionManager().getUseTransactionCaching();
158: // }
159: //
160: // public void setUseTransactionCaching(boolean useTransactionCaching) {
161: // boolean old = isUseTransactionCaching();
162: // getConnectionManager().setUseTransactionCaching(useTransactionCaching);
163: // pcs.firePropertyChange("useTransactionCaching", old, useTransactionCaching);
164: // }
165: //
166: // public boolean isUseLocalTransactions() {
167: // return getConnectionManager().getUseLocalTransactions();
168: // }
169: //
170: // public void setUseLocalTransactions(boolean useLocalTransactions) {
171: // boolean old = isUseLocalTransactions();
172: // getConnectionManager().setUseLocalTransactions(useLocalTransactions);
173: // pcs.firePropertyChange("useLocalTransactions", old, useLocalTransactions);
174: // }
175: //
176: // public boolean isUseTransactions() {
177: // return getConnectionManager().getUseTransactions();
178: // }
179: //
180: // public void setUseTransactions(boolean useTransactions) {
181: // boolean old = isUseTransactions();
182: // getConnectionManager().setUseTransactions(useTransactions);
183: // pcs.firePropertyChange("useTransactions", old, useTransactions);
184: // }
185: //
186: // public int getMaxSize() {
187: // BigInteger test = getConnectionManager().getMaxSize();
188: // return test == null ? 0 : test.intValue();
189: // }
190: //
191: // public void setMaxSize(int maxSize) {
192: // int old = getMaxSize();
193: // getConnectionManager().setMaxSize(BigInteger.valueOf(maxSize));
194: // pcs.firePropertyChange("maxSize", old, maxSize);
195: // }
196: //
197: // public int getBlockingTimeout() {
198: // BigInteger test = getConnectionManager().getBlockingTimeout();
199: // return test == null ? 0 : test.intValue();
200: // }
201: //
202: // public void setBlockingTimeout(int blockingTimeout) {
203: // int old = getBlockingTimeout();
204: // getConnectionManager().setBlockingTimeout(BigInteger.valueOf(blockingTimeout));
205: // pcs.firePropertyChange("blockingTimeout", old, blockingTimeout);
206: // }
207:
208: public boolean isContainerManagedSecurity() {
209: return getConnectionManager().isSetContainerManagedSecurity();
210: }
211:
212: public void setContainerManagedSecurity(
213: boolean containerManagedSecurity) {
214: boolean old = isContainerManagedSecurity();
215: if (old && !containerManagedSecurity) {
216: getConnectionManager().setContainerManagedSecurity(null);
217: } else if (!old && containerManagedSecurity) {
218: getConnectionManager().addNewContainerManagedSecurity();
219: }
220: pcs.firePropertyChange("containerManagedSecurity", old,
221: containerManagedSecurity);
222: }
223:
224: public String toString() {
225: return "Connection " + getName();
226: }
227: }
|