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