1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.services;
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.framework.role.RoleTypeService;
24 import org.kuali.rice.kim.impl.group.GroupInternalService;
25 import org.kuali.rice.kim.impl.responsibility.ResponsibilityInternalService;
26 import org.kuali.rice.kim.impl.role.RoleDao;
27 import org.kuali.rice.kim.impl.role.RoleInternalService;
28 import org.springframework.cache.CacheManager;
29
30 import javax.xml.namespace.QName;
31
32 public class KimImplServiceLocator {
33 private static final Logger LOG = Logger.getLogger(KimImplServiceLocator.class);
34
35 public static final String KIM_RUN_MODE_PROPERTY = "kim.mode";
36 public static final String RESPONSIBILITY_INTERNAL_SERVICE = "responsibilityInternalService";
37 public static final String GROUP_INTERNAL_SERVICE = "groupInternalService";
38 public static final String ROLE_INTERNAL_SERVICE = "kimRoleInternalService";
39 public static final String LOCAL_CACHE_MANAGER = "kimLocalCacheManager";
40 public static final String DEFAULT_ROLE_TYPE_SERVICE = "kimRoleTypeService";
41
42 public static final String KIM_ROLE_DAO = "kimRoleDao";
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 ResponsibilityInternalService getResponsibilityInternalService() {
61 return (ResponsibilityInternalService) getService(RESPONSIBILITY_INTERNAL_SERVICE);
62 }
63
64 public static GroupInternalService getGroupInternalService() {
65 return (GroupInternalService) getService(GROUP_INTERNAL_SERVICE);
66 }
67
68 public static RoleInternalService getRoleInternalService() {
69 return (RoleInternalService) getService(ROLE_INTERNAL_SERVICE);
70 }
71
72 public static CacheManager getLocalCacheManager() {
73 return (CacheManager) getService(LOCAL_CACHE_MANAGER);
74 }
75
76 public static RoleTypeService getDefaultRoleTypeService() {
77 return (RoleTypeService) getService(DEFAULT_ROLE_TYPE_SERVICE);
78 }
79
80 public static RoleDao getRoleDao() {
81 return (RoleDao) getService(KIM_ROLE_DAO);
82 }
83 }