1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.test; |
17 | |
|
18 | |
import javax.sql.DataSource; |
19 | |
import javax.transaction.UserTransaction; |
20 | |
|
21 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
22 | |
import org.kuali.rice.core.framework.resourceloader.SpringResourceLoader; |
23 | |
import org.springframework.context.ConfigurableApplicationContext; |
24 | |
import org.springframework.transaction.jta.JtaTransactionManager; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 0 | public class TestHarnessServiceLocator { |
38 | |
|
39 | |
private static ConfigurableApplicationContext context; |
40 | |
|
41 | |
public static final String USER_TRANSACTION = "userTransaction"; |
42 | |
public static final String TRANSACTON_MANAGER = "transactionManager"; |
43 | |
public static final String DATA_SOURCE = "dataSource"; |
44 | |
|
45 | |
public static Object getService(String serviceName) { |
46 | 0 | return getContext().getBean(serviceName); |
47 | |
} |
48 | |
|
49 | |
public static DataSource getDataSource() { |
50 | 0 | return (DataSource)getService(DATA_SOURCE); |
51 | |
} |
52 | |
|
53 | |
public static JtaTransactionManager getJtaTransactionManager() { |
54 | 0 | return (JtaTransactionManager)getService(TRANSACTON_MANAGER); |
55 | |
} |
56 | |
|
57 | |
public static UserTransaction getUserTransaction() { |
58 | 0 | return (UserTransaction)getService(USER_TRANSACTION); |
59 | |
} |
60 | |
|
61 | |
public static ConfigurableApplicationContext getContext() { |
62 | 0 | return context; |
63 | |
} |
64 | |
|
65 | |
public static void setContext(ConfigurableApplicationContext context) { |
66 | 0 | TestHarnessServiceLocator.context = context; |
67 | 0 | } |
68 | |
} |