1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.jencks.factory;
18
19 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
20 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions;
21 import org.springframework.beans.factory.FactoryBean;
22 import org.springframework.beans.factory.InitializingBean;
23
24 /***
25 * This FactoryBean creates the xa transaction strategy for the
26 * JCA connection manager used.
27 * <p/>
28 * This class can be injected in the ConnectionManagerFactoryBean to
29 * configure the ConnectionManager instance returned.
30 *
31 * @author Thierry Templier
32 * @see ConnectionManagerFactoryBean#setTransactionSupport(TransactionSupport)
33 */
34 public class XATransactionFactoryBean implements FactoryBean, InitializingBean {
35
36 private boolean useTransactionCaching;
37 private boolean useThreadCaching;
38
39 private TransactionSupport transactionSupport;
40
41 public Object getObject() throws Exception {
42 return transactionSupport;
43 }
44
45 public Class getObjectType() {
46 return TransactionSupport.class;
47 }
48
49 public boolean isSingleton() {
50 return true;
51 }
52
53 /***
54 * Set the useThreadCaching property to allow the ConnectionManager to
55 * cache connections for a thread.
56 */
57 public void setUseThreadCaching(boolean useThreadCaching) {
58 this.useThreadCaching = useThreadCaching;
59 }
60
61 /***
62 * Set the useTransactionCaching property to allow the ConnectionManager to
63 * cache connections for the current transaction.
64 * <p/>
65 * This allows connections to be used several times in the same transaction.
66 * So it prevents the connection to be enlisted several times in the
67 * current transaction.
68 */
69 public void setUseTransactionCaching(boolean useTransactionCaching) {
70 this.useTransactionCaching = useTransactionCaching;
71 }
72
73 /***
74 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
75 */
76 public void afterPropertiesSet() throws Exception {
77 this.transactionSupport = new XATransactions(useTransactionCaching, useThreadCaching);
78 }
79
80 }