KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > deployment > dconfigbean > ConnectionDefinitionInstance


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
18 package org.apache.geronimo.connector.deployment.dconfigbean;
19
20 import javax.enterprise.deploy.model.DDBean JavaDoc;
21 import javax.enterprise.deploy.model.XpathListener JavaDoc;
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 /**
31  * @version $Revision 1.0$ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
32  */

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 JavaDoc 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 JavaDoc 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 // JavaBean properties for this object (with a couple helper methods)
91

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) { // can only be changed by adding a new DDBean
105
ConfigPropertySettings[] old = getConfigProperty();
106         this.configs = configs;
107         pcs.firePropertyChange("configProperty", old, configs);
108     }
109
110     public String JavaDoc getName() {
111         return getConnectiondefinitionInstance().getName();
112     }
113
114     public void setName(String JavaDoc name) {
115         String JavaDoc old = getName();
116         getConnectiondefinitionInstance().setName(name);
117         pcs.firePropertyChange("name", old, name);
118     }
119
120 // public String getGlobalJNDIName() {
121
// return getConnectiondefinitionInstance().getGlobalJndiName();
122
// }
123
//
124
// public void setGlobalJNDIName(String globalJNDIName) {
125
// String old = getGlobalJNDIName();
126
// getConnectiondefinitionInstance().setGlobalJndiName(globalJNDIName);
127
// pcs.firePropertyChange("globalJNDIName", old, globalJNDIName);
128
// }
129

130 // public boolean isUseConnectionRequestInfo() {
131
// return getConnectionManager().getUseConnectionRequestInfo();
132
// }
133
//
134
// public void setUseConnectionRequestInfo(boolean useConnectionRequestInfo) {
135
// boolean old = isUseConnectionRequestInfo();
136
// getConnectionManager().setUseConnectionRequestInfo(useConnectionRequestInfo);
137
// pcs.firePropertyChange("useConnectionRequestInfo", old, useConnectionRequestInfo);
138
// }
139
//
140
// public boolean isUseSubject() {
141
// return getConnectionManager().getUseSubject();
142
// }
143
//
144
// public void setUseSubject(boolean useSubject) {
145
// boolean old = isUseSubject();
146
// getConnectionManager().setUseSubject(useSubject);
147
// pcs.firePropertyChange("useSubject", old, useSubject);
148
// }
149
//
150
// public boolean isUseTransactionCaching() {
151
// return getConnectionManager().getUseTransactionCaching();
152
// }
153
//
154
// public void setUseTransactionCaching(boolean useTransactionCaching) {
155
// boolean old = isUseTransactionCaching();
156
// getConnectionManager().setUseTransactionCaching(useTransactionCaching);
157
// pcs.firePropertyChange("useTransactionCaching", old, useTransactionCaching);
158
// }
159
//
160
// public boolean isUseLocalTransactions() {
161
// return getConnectionManager().getUseLocalTransactions();
162
// }
163
//
164
// public void setUseLocalTransactions(boolean useLocalTransactions) {
165
// boolean old = isUseLocalTransactions();
166
// getConnectionManager().setUseLocalTransactions(useLocalTransactions);
167
// pcs.firePropertyChange("useLocalTransactions", old, useLocalTransactions);
168
// }
169
//
170
// public boolean isUseTransactions() {
171
// return getConnectionManager().getUseTransactions();
172
// }
173
//
174
// public void setUseTransactions(boolean useTransactions) {
175
// boolean old = isUseTransactions();
176
// getConnectionManager().setUseTransactions(useTransactions);
177
// pcs.firePropertyChange("useTransactions", old, useTransactions);
178
// }
179
//
180
// public int getMaxSize() {
181
// BigInteger test = getConnectionManager().getMaxSize();
182
// return test == null ? 0 : test.intValue();
183
// }
184
//
185
// public void setMaxSize(int maxSize) {
186
// int old = getMaxSize();
187
// getConnectionManager().setMaxSize(BigInteger.valueOf(maxSize));
188
// pcs.firePropertyChange("maxSize", old, maxSize);
189
// }
190
//
191
// public int getBlockingTimeout() {
192
// BigInteger test = getConnectionManager().getBlockingTimeout();
193
// return test == null ? 0 : test.intValue();
194
// }
195
//
196
// public void setBlockingTimeout(int blockingTimeout) {
197
// int old = getBlockingTimeout();
198
// getConnectionManager().setBlockingTimeout(BigInteger.valueOf(blockingTimeout));
199
// pcs.firePropertyChange("blockingTimeout", old, blockingTimeout);
200
// }
201

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 JavaDoc toString() {
217         return "Connection "+getName();
218     }
219 }
220
Popular Tags