1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.rice.test; |
17 |
|
|
18 |
|
import org.kuali.rice.core.api.lifecycle.Lifecycle; |
19 |
|
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
20 |
|
import org.springframework.transaction.PlatformTransactionManager; |
21 |
|
import org.springframework.transaction.TransactionStatus; |
22 |
|
import org.springframework.transaction.support.DefaultTransactionDefinition; |
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
@author |
27 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 8 |
Complexity Density: 0.53 |
|
28 |
|
public class TransactionalLifecycle implements Lifecycle { |
29 |
|
|
30 |
|
private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger |
31 |
|
.getLogger(TransactionalLifecycle.class); |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
public static final String DEFAULT_TRANSACTION_MANAGER_NAME = "transactionManager"; |
38 |
|
|
39 |
|
private String transactionManagerName; |
40 |
|
private PlatformTransactionManager transactionManager; |
41 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
0
|
public TransactionalLifecycle(String transactionManagerName) {... |
43 |
0
|
this.transactionManagerName = transactionManagerName; |
44 |
|
} |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
0
|
public TransactionalLifecycle() {... |
47 |
0
|
this(DEFAULT_TRANSACTION_MANAGER_NAME); |
48 |
|
} |
49 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
0
|
public void setTransactionManager(PlatformTransactionManager transactionManager) {... |
51 |
0
|
this.transactionManager = transactionManager; |
52 |
|
} |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
@return |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
59 |
0
|
private PlatformTransactionManager getTransactionManager() {... |
60 |
0
|
if (transactionManager == null) { |
61 |
0
|
transactionManager = (PlatformTransactionManager) GlobalResourceLoader.getService(transactionManagerName); |
62 |
|
} |
63 |
0
|
return transactionManager; |
64 |
|
} |
65 |
|
|
66 |
|
private boolean started; |
67 |
|
private TransactionStatus TRANSACTION_STATUS; |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0
|
public boolean isStarted() {... |
70 |
0
|
return started; |
71 |
|
} |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
73 |
0
|
public void start() throws Exception {... |
74 |
0
|
LOG.info("Starting a transaction from TransactionalLifecycle..."); |
75 |
0
|
DefaultTransactionDefinition defaultTransactionDefinition = new DefaultTransactionDefinition(); |
76 |
0
|
defaultTransactionDefinition.setTimeout(3600); |
77 |
0
|
TRANSACTION_STATUS = getTransactionManager().getTransaction(defaultTransactionDefinition); |
78 |
0
|
started = true; |
79 |
|
} |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
81 |
0
|
public void stop() throws Exception {... |
82 |
0
|
LOG.info("...rolling back transaction from TransactionalLifecycle."); |
83 |
0
|
getTransactionManager().rollback(TRANSACTION_STATUS); |
84 |
0
|
started = false; |
85 |
|
} |
86 |
|
|
87 |
|
} |