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.resourceloader.GlobalResourceLoader;
19 import org.springframework.context.ConfigurableApplicationContext;
20 import org.springframework.transaction.jta.JtaTransactionManager;
21
22 import javax.sql.DataSource;
23 import javax.transaction.UserTransaction;
24
25
26
27
28
29
30
31
32
33
34
35
36 public class TestHarnessServiceLocator {
37
38 private static ConfigurableApplicationContext context;
39
40 public static final String USER_TRANSACTION = "userTransaction";
41 public static final String TRANSACTON_MANAGER = "transactionManager";
42 public static final String DATA_SOURCE = "dataSource";
43
44 public static Object getService(String serviceName) {
45 return getContext().getBean(serviceName);
46 }
47
48 public static DataSource getDataSource() {
49 return (DataSource)getService(DATA_SOURCE);
50 }
51
52 public static JtaTransactionManager getJtaTransactionManager() {
53 return (JtaTransactionManager)getService(TRANSACTON_MANAGER);
54 }
55
56 public static UserTransaction getUserTransaction() {
57 return (UserTransaction)getService(USER_TRANSACTION);
58 }
59
60 public static ConfigurableApplicationContext getContext() {
61 return context;
62 }
63
64 public static void setContext(ConfigurableApplicationContext context) {
65 TestHarnessServiceLocator.context = context;
66 }
67 }