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