1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.repository;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.rice.core.api.criteria.CriteriaLookupService;
20 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
21
22
23
24
25
26
27
28 public final class KrmsRepositoryServiceLocator {
29
30 private static final Logger LOG = Logger.getLogger(KrmsRepositoryServiceLocator.class);
31
32 public static final String KRMS_ATTRIBUTE_DEFINITION_SERVICE = "krmsAttributeDefinitionService";
33 public static final String CRITERIA_LOOKUP_SERVICE = "criteriaLookupService";
34
35 private static KrmsAttributeDefinitionService krmsAttributeDefinitionService;
36
37 public static <T extends Object> T getService(String serviceName) {
38 return KrmsRepositoryServiceLocator.<T>getBean(serviceName);
39 }
40
41 public static <T extends Object> T getBean(String serviceName) {
42 if ( LOG.isDebugEnabled() ) {
43 LOG.debug("Fetching service " + serviceName);
44 }
45 return GlobalResourceLoader.<T>getService(serviceName);
46 }
47
48 public static KrmsAttributeDefinitionService getKrmsAttributeDefinitionService() {
49 if ( krmsAttributeDefinitionService == null ) {
50 krmsAttributeDefinitionService = getService(KRMS_ATTRIBUTE_DEFINITION_SERVICE);
51 }
52 return krmsAttributeDefinitionService;
53 }
54
55 public static CriteriaLookupService getCriteriaLookupService() {
56 return getService(CRITERIA_LOOKUP_SERVICE);
57 }
58
59 public static void setKrmsAttributeDefinitionService(final KrmsAttributeDefinitionService service) {
60 krmsAttributeDefinitionService = service;
61 }
62
63 }