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.gbean.ReferenceCollection;
20 import org.apache.geronimo.transaction.log.UnrecoverableLog;
21 import org.apache.geronimo.transaction.manager.TransactionLog;
22 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
23 import org.springframework.beans.factory.FactoryBean;
24 import org.springframework.beans.factory.InitializingBean;
25
26 /***
27 * This FactoryBean creates and configures the Geronimo implementation
28 * of the TransactionManager interface.
29 *
30 * @author Thierry Templier
31 * @see UnrecoverableLog
32 * @see org.apache.geronimo.transaction.log.HOWLLog
33 */
34 public class TransactionManagerFactoryBean implements FactoryBean, InitializingBean {
35
36 private int defaultTransactionTimeoutSeconds = 600;
37 private TransactionLog transactionLog;
38 private ReferenceCollection resourceManagers;
39
40 private TransactionManagerImpl transactionManagerImpl;
41
42 public Object getObject() throws Exception {
43 return transactionManagerImpl;
44 }
45
46 public Class getObjectType() {
47 return TransactionManagerImpl.class;
48 }
49
50 public boolean isSingleton() {
51 return true;
52 }
53
54 /***
55 * Set the default transaction timeout in second.
56 */
57 public void setDefaultTransactionTimeoutSeconds(int timeout) {
58 defaultTransactionTimeoutSeconds = timeout;
59 }
60
61 /***
62 * Set the transaction log for the transaction context manager.
63 */
64 public void setTransactionLog(TransactionLog log) {
65 transactionLog = log;
66 }
67
68 public ReferenceCollection getResourceManagers() {
69 return resourceManagers;
70 }
71
72 /***
73 * Set the resource managers
74 */
75 public void setResourceManagers(ReferenceCollection resourceManagers) {
76 this.resourceManagers = resourceManagers;
77 }
78
79 public void afterPropertiesSet() throws Exception {
80 if (transactionLog == null) {
81 transactionLog = new UnrecoverableLog();
82 }
83 this.transactionManagerImpl = new TransactionManagerImpl(defaultTransactionTimeoutSeconds,
84 transactionLog, resourceManagers);
85 }
86
87 }