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 import org.kuali.rice.krms.api.repository.type.KrmsTypeRepositoryService;
22 import org.kuali.rice.krms.impl.authorization.AgendaAuthorizationService;
23 import org.kuali.rice.krms.impl.provider.repository.RepositoryToEngineTranslator;
24
25 import javax.xml.namespace.QName;
26
27
28
29
30
31
32
33 public final class KrmsRepositoryServiceLocator {
34
35 private KrmsRepositoryServiceLocator() {
36
37 }
38
39 private static final Logger LOG = Logger.getLogger(KrmsRepositoryServiceLocator.class);
40
41 public static final String KRMS_ATTRIBUTE_DEFINITION_SERVICE = "krmsAttributeDefinitionService";
42 public static final String KRMS_TYPE_REPOSITORY_SERVICE = "krmsTypeRepositoryService";
43 public static final String CRITERIA_LOOKUP_SERVICE = "criteriaLookupService";
44 public static final String KRMS_CONTEXT_BO_SERVICE = "contextBoService";
45 public static final String KRMS_AGENDA_BO_SERVICE = "agendaBoService";
46 public static final String KRMS_TERM_BO_SERVICE = "termBoService";
47 public static final String KRMS_RULE_BO_SERVICE = "ruleBoService";
48 public static final String KRMS_AGENDA_AUTHORIZATION_SERVICE = "agendaAuthorizationService";
49 public static final String KRMS_REPOSITORY_TO_ENGINE_TRANSLATOR = "repositoryToEngineTranslator";
50
51 private static KrmsAttributeDefinitionService krmsAttributeDefinitionService;
52 private static ContextBoService contextBoService;
53 private static TermBoService termBoService;
54 private static AgendaBoService agendaBoService;
55 private static RuleBoService ruleBoService;
56 private static AgendaAuthorizationService agendaAuthorizationService;
57 private static KrmsTypeRepositoryService krmsTypeRepositoryService;
58 private static RepositoryToEngineTranslator krmsRepositoryToEngineTranslator;
59
60 public static <T extends Object> T getService(String serviceName) {
61 return KrmsRepositoryServiceLocator.<T>getBean(serviceName);
62 }
63
64 public static <T extends Object> T getBean(String serviceName) {
65 if ( LOG.isDebugEnabled() ) {
66 LOG.debug("Fetching service " + serviceName);
67 }
68 return GlobalResourceLoader.<T>getService(QName.valueOf(serviceName));
69 }
70
71 public static KrmsAttributeDefinitionService getKrmsAttributeDefinitionService() {
72 if ( krmsAttributeDefinitionService == null ) {
73 krmsAttributeDefinitionService = getService(KRMS_ATTRIBUTE_DEFINITION_SERVICE);
74 }
75 return krmsAttributeDefinitionService;
76 }
77
78 public static CriteriaLookupService getCriteriaLookupService() {
79 return getService(CRITERIA_LOOKUP_SERVICE);
80 }
81
82 public static void setKrmsAttributeDefinitionService(final KrmsAttributeDefinitionService service) {
83 krmsAttributeDefinitionService = service;
84 }
85
86 public static ContextBoService getContextBoService() {
87 if (contextBoService == null) {
88 contextBoService = getService(KRMS_CONTEXT_BO_SERVICE);
89 }
90 return contextBoService;
91 }
92
93 public static TermBoService getTermBoService() {
94 if (termBoService == null) {
95 termBoService = getService(KRMS_TERM_BO_SERVICE);
96 }
97 return termBoService;
98 }
99
100 public static AgendaBoService getAgendaBoService() {
101 if (agendaBoService == null) {
102 agendaBoService = getService(KRMS_AGENDA_BO_SERVICE);
103 }
104 return agendaBoService;
105 }
106
107 public static RuleBoService getRuleBoService() {
108 if (ruleBoService == null) {
109 ruleBoService = getService(KRMS_RULE_BO_SERVICE);
110 }
111 return ruleBoService;
112 }
113
114 public static AgendaAuthorizationService getAgendaAuthorizationService() {
115 if (agendaAuthorizationService == null) {
116 agendaAuthorizationService = getService(KRMS_AGENDA_AUTHORIZATION_SERVICE);
117 }
118 return agendaAuthorizationService;
119 }
120
121 public static KrmsTypeRepositoryService getKrmsTypeRepositoryService() {
122 if (krmsTypeRepositoryService == null) {
123 krmsTypeRepositoryService = getService(KRMS_TYPE_REPOSITORY_SERVICE);
124 }
125 return krmsTypeRepositoryService;
126 }
127
128 public static RepositoryToEngineTranslator getKrmsRepositoryToEngineTranslator() {
129 if (krmsRepositoryToEngineTranslator == null) {
130 krmsRepositoryToEngineTranslator = getService(KRMS_REPOSITORY_TO_ENGINE_TRANSLATOR);
131 }
132 return krmsRepositoryToEngineTranslator;
133 }
134 }