1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.service;
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 import org.kuali.rice.kim.api.KimConstants;
23 import org.kuali.rice.kim.impl.group.GroupInternalService;
24 import org.kuali.rice.kim.service.dao.UiDocumentServiceDAO;
25
26 import javax.xml.namespace.QName;
27
28
29
30
31
32
33
34 public final class KIMServiceLocatorInternal {
35
36 private static final Logger LOG = Logger.getLogger(KIMServiceLocatorInternal.class);
37
38 public static final String KIM_RUN_MODE_PROPERTY = "kim.mode";
39
40 public static final String KIM_UI_DOCUMENT_SERVICE = "kimUiDocumentService";
41 public static final String GROUP_INTERNAL_SERVICE = "groupInternalService";
42 public static final String UI_DOCUMENT_SERVICE_DAO = "uiDocumentServiceDAO";
43
44 public static Object getService(String serviceName) {
45 return getBean(serviceName);
46 }
47
48 public static Object getBean(String serviceName) {
49 if ( LOG.isDebugEnabled() ) {
50 LOG.debug("Fetching service " + serviceName);
51 }
52 QName name = new QName(serviceName);
53 RunMode kimRunMode = RunMode.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KIM_RUN_MODE_PROPERTY));
54 if (kimRunMode == RunMode.REMOTE || kimRunMode == RunMode.THIN) {
55 name = new QName(KimConstants.KIM_MODULE_NAMESPACE, serviceName);
56 }
57 return GlobalResourceLoader.getResourceLoader().getService(name);
58 }
59
60 public static UiDocumentService getUiDocumentService() {
61 return (UiDocumentService)getService(KIM_UI_DOCUMENT_SERVICE);
62 }
63
64 public static GroupInternalService getGroupInternalService() {
65 return (GroupInternalService)getService(GROUP_INTERNAL_SERVICE);
66 }
67
68 public static UiDocumentServiceDAO getUiDocumentServiceDAO() {
69 return (UiDocumentServiceDAO) getBean(UI_DOCUMENT_SERVICE_DAO);
70 }
71 }