1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.util;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.rice.core.api.config.module.RunMode;
20 import org.kuali.rice.core.api.config.property.ConfigContext;
21 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
22
23 import javax.xml.namespace.QName;
24
25
26
27
28
29
30 public class KRMSServiceLocatorInternal {
31
32 public static final String KRMS_RUN_MODE_PROPERTY = "krms.mode";
33 public static final String KRMS_MODULE_NAMESPACE = "KRMS";
34
35 private static final Logger LOG = Logger.getLogger(KRMSServiceLocatorInternal.class);
36
37
38 @SuppressWarnings("unchecked")
39 public static <A> A getService(String serviceName) {
40 return (A)getBean(serviceName);
41 }
42
43 public static Object getBean(String serviceName) {
44 if ( LOG.isDebugEnabled() ) {
45 LOG.debug("Fetching service " + serviceName);
46 }
47 QName name = new QName(serviceName);
48 RunMode krmsRunMode = RunMode.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KRMS_RUN_MODE_PROPERTY));
49 if (krmsRunMode == RunMode.REMOTE || krmsRunMode == RunMode.THIN) {
50 name = new QName(KRMS_MODULE_NAMESPACE, serviceName);
51 }
52 return GlobalResourceLoader.getResourceLoader().getService(name);
53 }
54
55
56
57
58
59 }