1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.core.config.spring; |
17 | |
|
18 | |
import javax.transaction.TransactionManager; |
19 | |
import javax.transaction.UserTransaction; |
20 | |
|
21 | |
import org.kuali.rice.core.config.ConfigContext; |
22 | |
import org.kuali.rice.core.util.RiceConstants; |
23 | |
import org.springframework.beans.factory.FactoryBean; |
24 | |
import org.springframework.transaction.PlatformTransactionManager; |
25 | |
import org.springframework.transaction.jta.JtaTransactionManager; |
26 | |
|
27 | 0 | public class PlatformTransactionManagerFactoryBean implements FactoryBean { |
28 | |
|
29 | |
private UserTransaction userTransaction; |
30 | |
private TransactionManager transactionManager; |
31 | |
|
32 | |
public Object getObject() throws Exception { |
33 | 0 | if (ConfigContext.getCurrentContextConfig().getObject(RiceConstants.SPRING_TRANSACTION_MANAGER) != null) { |
34 | 0 | return ConfigContext.getCurrentContextConfig().getObject(RiceConstants.SPRING_TRANSACTION_MANAGER); |
35 | |
} |
36 | 0 | JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); |
37 | 0 | jtaTransactionManager.setTransactionManager(this.getTransactionManager()); |
38 | 0 | jtaTransactionManager.setUserTransaction(this.getUserTransaction()); |
39 | 0 | jtaTransactionManager.afterPropertiesSet(); |
40 | 0 | return jtaTransactionManager; |
41 | |
} |
42 | |
|
43 | |
public Class getObjectType() { |
44 | 0 | return PlatformTransactionManager.class; |
45 | |
} |
46 | |
|
47 | |
public boolean isSingleton() { |
48 | 0 | return true; |
49 | |
} |
50 | |
|
51 | |
public UserTransaction getUserTransaction() { |
52 | 0 | return userTransaction; |
53 | |
} |
54 | |
|
55 | |
public void setUserTransaction(UserTransaction userTransaction) { |
56 | 0 | this.userTransaction = userTransaction; |
57 | 0 | } |
58 | |
|
59 | |
public TransactionManager getTransactionManager() { |
60 | 0 | return transactionManager; |
61 | |
} |
62 | |
|
63 | |
public void setTransactionManager(TransactionManager transactionManager) { |
64 | 0 | this.transactionManager = transactionManager; |
65 | 0 | } |
66 | |
|
67 | |
} |