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.GerConnectionmanagerType;
021: import org.apache.xmlbeans.SchemaTypeLoader;
022:
023: /**
024: * Represents connectiondefinition-instance/connectionmanager in the Geronimo
025: * Connector deployment plan.
026: *
027: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
028: */
029: public class ConnectionManager extends XmlBeanSupport {
030: private DDBean outboundRA;
031: private SinglePool singlePool;
032: private PartitionedPool partitionedPool;
033:
034: public ConnectionManager() {
035: super (null);
036: }
037:
038: public ConnectionManager(DDBean outboundRA,
039: GerConnectionmanagerType manager) {
040: super (null);
041: configure(outboundRA, manager);
042: }
043:
044: void configure(DDBean outboundRA, GerConnectionmanagerType manager) {
045: this .outboundRA = outboundRA;
046: setXmlObject(manager);
047: if (!manager.isSetNoTransaction()
048: && !manager.isSetLocalTransaction()
049: && !manager.isSetXaTransaction()) {
050: String[] test = outboundRA.getText("transaction-support");
051: if (test.length > 0) {
052: String tx = test[0];
053: if (tx.equalsIgnoreCase("NoTransaction")) {
054: manager.addNewNoTransaction();
055: } else if (tx.equalsIgnoreCase("LocalTransaction")) {
056: manager.addNewLocalTransaction();
057: } else if (tx.equalsIgnoreCase("XATransaction")) {
058: manager.addNewXaTransaction();
059: manager.getXaTransaction()
060: .addNewTransactionCaching();
061: }
062: }
063: }
064: if (manager.isSetSinglePool()) {
065: singlePool = new SinglePool(manager.getSinglePool());
066: } else if (manager.isSetPartitionedPool()) {
067: partitionedPool = new PartitionedPool(manager
068: .getPartitionedPool());
069: } else if (!manager.isSetNoPool()) {
070: singlePool = new SinglePool(manager.addNewSinglePool());
071: }
072: }
073:
074: protected GerConnectionmanagerType getManager() {
075: return (GerConnectionmanagerType) getXmlObject();
076: }
077:
078: // ----------------------- JavaBean Properties for connection-manager ----------------------
079:
080: public boolean isContainerManagedSecurity() {
081: return getManager().isSetContainerManagedSecurity();
082: }
083:
084: public void setContainerManagedSecurity(boolean set) {
085: if (set) {
086: if (!isContainerManagedSecurity()) {
087: getManager().addNewContainerManagedSecurity();
088: pcs.firePropertyChange("containerManagedSecurity",
089: !set, set);
090: }
091: } else {
092: if (isContainerManagedSecurity()) {
093: getManager().unsetContainerManagedSecurity();
094: pcs.firePropertyChange("containerManagedSecurity",
095: !set, set);
096: }
097: }
098: }
099:
100: public boolean isTransactionNone() {
101: return getManager().isSetNoTransaction();
102: }
103:
104: public void setTransactionNone(boolean set) {
105: if (set) {
106: if (!isTransactionNone()) {
107: getManager().addNewNoTransaction();
108: pcs.firePropertyChange("transactionNone", !set, set);
109: }
110: if (isTransactionLocal())
111: setTransactionLocal(false);
112: if (isTransactionXA())
113: setTransactionXA(false);
114: if (isTransactionLog())
115: setTransactionLog(false);
116: } else {
117: if (isTransactionNone()) {
118: getManager().unsetNoTransaction();
119: pcs.firePropertyChange("transactionNone", !set, set);
120: }
121: }
122: }
123:
124: public boolean isTransactionLocal() {
125: return getManager().isSetLocalTransaction();
126: }
127:
128: public void setTransactionLocal(boolean set) {
129: if (set) {
130: if (!isTransactionLocal()) {
131: getManager().addNewLocalTransaction();
132: pcs.firePropertyChange("transactionLocal", !set, set);
133: }
134: if (isTransactionNone())
135: setTransactionNone(false);
136: if (isTransactionXA())
137: setTransactionXA(false);
138: if (isTransactionLog())
139: setTransactionLog(false);
140: } else {
141: if (isTransactionLocal()) {
142: getManager().unsetLocalTransaction();
143: pcs.firePropertyChange("transactionLocal", !set, set);
144: }
145: }
146: }
147:
148: public boolean isTransactionLog() {
149: return getManager().isSetTransactionLog();
150: }
151:
152: public void setTransactionLog(boolean set) {
153: if (set) {
154: if (!isTransactionLog()) {
155: getManager().addNewTransactionLog();
156: pcs.firePropertyChange("transactionLog", !set, set);
157: }
158: if (isTransactionNone())
159: setTransactionNone(false);
160: if (isTransactionXA())
161: setTransactionXA(false);
162: if (isTransactionLocal())
163: setTransactionLocal(false);
164: } else {
165: if (isTransactionLog()) {
166: getManager().unsetTransactionLog();
167: pcs.firePropertyChange("transactionLog", !set, set);
168: }
169: }
170: }
171:
172: public boolean isTransactionXA() {
173: return getManager().isSetXaTransaction();
174: }
175:
176: public void setTransactionXA(boolean set) {
177: if (set) {
178: if (!isTransactionXA()) {
179: getManager().addNewXaTransaction();
180: pcs.firePropertyChange("transactionXA", !set, set);
181: }
182: if (isTransactionNone())
183: setTransactionNone(false);
184: if (isTransactionLog())
185: setTransactionLog(false);
186: if (isTransactionLocal())
187: setTransactionLocal(false);
188: } else {
189: if (isTransactionXA()) {
190: boolean oldTX = isTransactionXACachingTransaction();
191: boolean oldThread = isTransactionXACachingThread();
192: getManager().unsetXaTransaction();
193: pcs.firePropertyChange("transactionXA", !set, set);
194: if (oldTX) {
195: pcs.firePropertyChange(
196: "transactionXACachingTransaction", true,
197: false);
198: }
199: if (oldThread) {
200: pcs.firePropertyChange(
201: "transactionXACachingThread", true, false);
202: }
203: }
204: }
205: }
206:
207: public boolean isTransactionXACachingTransaction() {
208: return isTransactionXA()
209: && getManager().getXaTransaction()
210: .isSetTransactionCaching();
211: }
212:
213: public void setTransactionXACachingTransaction(boolean set) {
214: if (set) {
215: setTransactionXA(true);
216: if (!getManager().getXaTransaction()
217: .isSetTransactionCaching()) {
218: getManager().getXaTransaction()
219: .addNewTransactionCaching();
220: pcs.firePropertyChange(
221: "transactionXACachingTransaction", !set, set);
222: }
223: } else {
224: if (isTransactionXA()
225: && getManager().getXaTransaction()
226: .isSetTransactionCaching()) {
227: getManager().getXaTransaction()
228: .unsetTransactionCaching();
229: pcs.firePropertyChange(
230: "transactionXACachingTransaction", !set, set);
231: }
232: }
233: }
234:
235: public boolean isTransactionXACachingThread() {
236: return isTransactionXA()
237: && getManager().getXaTransaction().isSetThreadCaching();
238: }
239:
240: public void setTransactionXACachingThread(boolean set) {
241: if (set) {
242: setTransactionXA(true);
243: if (!getManager().getXaTransaction().isSetThreadCaching()) {
244: getManager().getXaTransaction().addNewThreadCaching();
245: pcs.firePropertyChange("transactionXACachingThread",
246: !set, set);
247: }
248: } else {
249: if (isTransactionXA()
250: && getManager().getXaTransaction()
251: .isSetThreadCaching()) {
252: getManager().getXaTransaction().unsetThreadCaching();
253: pcs.firePropertyChange("transactionXACachingThread",
254: !set, set);
255: }
256: }
257: }
258:
259: public boolean isPoolNone() {
260: return getManager().isSetNoPool();
261: }
262:
263: public void setPoolNone(boolean set) {
264: if (set) {
265: if (!getManager().isSetNoPool()) {
266: getManager().addNewNoPool();
267: pcs.firePropertyChange("poolNone", !set, set);
268: }
269: if (getPoolSingle() != null)
270: setPoolSingle(null);
271: if (getPoolPartitioned() != null)
272: setPoolPartitioned(null);
273: } else {
274: if (getManager().isSetNoPool()) {
275: getManager().unsetNoPool();
276: pcs.firePropertyChange("poolNone", !set, set);
277: }
278: if (getPoolSingle() == null && getPoolPartitioned() == null) {
279: setPoolSingle(new SinglePool());
280: }
281: }
282: }
283:
284: public SinglePool getPoolSingle() {
285: return singlePool;
286: }
287:
288: public void setPoolSingle(SinglePool pool) {
289: SinglePool old = getPoolSingle();
290: if (pool != null) {
291: singlePool = pool;
292: if (!getManager().isSetSinglePool()) {
293: getManager().addNewSinglePool();
294: }
295: singlePool.configure(getManager().getSinglePool());
296: pcs.firePropertyChange("poolSingle", old, pool);
297: if (isPoolNone())
298: setPoolNone(false);
299: if (getPoolPartitioned() != null)
300: setPoolPartitioned(null);
301: } else {
302: if (getManager().isSetSinglePool()) {
303: getManager().unsetSinglePool();
304: pcs.firePropertyChange("poolSingle", old, pool);
305: }
306: }
307: }
308:
309: public PartitionedPool getPoolPartitioned() {
310: return partitionedPool;
311: }
312:
313: public void setPoolPartitioned(PartitionedPool pool) {
314: PartitionedPool old = getPoolPartitioned();
315: if (pool != null) {
316: partitionedPool = pool;
317: if (!getManager().isSetPartitionedPool()) {
318: getManager().addNewPartitionedPool();
319: }
320: partitionedPool
321: .configure(getManager().getPartitionedPool());
322: pcs.firePropertyChange("poolPartitioned", old, pool);
323: if (isPoolNone())
324: setPoolNone(false);
325: if (getPoolSingle() != null)
326: setPoolSingle(null);
327: } else {
328: if (getManager().isSetPartitionedPool()) {
329: getManager().unsetPartitionedPool();
330: pcs.firePropertyChange("poolPartitioned", old, pool);
331: }
332: }
333: }
334:
335: // ----------------------- End of JavaBean Properties ----------------------
336:
337: protected SchemaTypeLoader getSchemaTypeLoader() {
338: return Connector15DCBRoot.SCHEMA_TYPE_LOADER;
339: }
340: }
|