001/** 002 * Copyright 2005-2017 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krms.impl.repository; 017 018import org.apache.log4j.Logger; 019import org.kuali.rice.core.api.criteria.CriteriaLookupService; 020import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; 021import org.kuali.rice.krms.api.repository.type.KrmsTypeRepositoryService; 022import org.kuali.rice.krms.impl.authorization.AgendaAuthorizationService; 023import org.kuali.rice.krms.impl.provider.repository.RepositoryToEngineTranslator; 024 025import javax.xml.namespace.QName; 026 027/** 028 * This class keeps track of the KRMS Repository Services 029 * 030 * @author Kuali Rice Team (rice.collab@kuali.org) 031 * 032 */ 033public final class KrmsRepositoryServiceLocator { 034 035 private KrmsRepositoryServiceLocator() { 036 // private constructor since this is class is all static utility methods 037 } 038 039 private static final Logger LOG = Logger.getLogger(KrmsRepositoryServiceLocator.class); 040 041 public static final String KRMS_ATTRIBUTE_DEFINITION_SERVICE = "krmsAttributeDefinitionService"; 042 public static final String KRMS_TYPE_REPOSITORY_SERVICE = "krmsTypeRepositoryService"; 043 public static final String CRITERIA_LOOKUP_SERVICE = "criteriaLookupService"; 044 public static final String KRMS_CONTEXT_BO_SERVICE = "contextBoService"; 045 public static final String KRMS_AGENDA_BO_SERVICE = "agendaBoService"; 046 public static final String KRMS_FUNCTION_BO_SERVICE = "functionBoService"; 047 public static final String KRMS_TERM_BO_SERVICE = "termBoService"; 048 public static final String KRMS_RULE_BO_SERVICE = "ruleBoService"; 049 public static final String KRMS_AGENDA_AUTHORIZATION_SERVICE = "agendaAuthorizationService"; 050 public static final String KRMS_REPOSITORY_TO_ENGINE_TRANSLATOR = "repositoryToEngineTranslator"; 051 public static final String TYPE_TYPE_RELATION_BO_SERVICE = "typeTypeRelationBoService"; 052 public static final String KRMS_PROPOSITION_BO_SERVICE = "propositionBoService"; 053 054 private static KrmsAttributeDefinitionService krmsAttributeDefinitionService; 055 private static ContextBoService contextBoService; 056 private static TermBoService termBoService; 057 private static AgendaBoService agendaBoService; 058 private static FunctionBoService functionBoService; 059 private static RuleBoService ruleBoService; 060 private static AgendaAuthorizationService agendaAuthorizationService; 061 private static KrmsTypeRepositoryService krmsTypeRepositoryService; 062 private static RepositoryToEngineTranslator krmsRepositoryToEngineTranslator; 063 private static TypeTypeRelationBoService typeTypeRelationBoService; 064 private static PropositionBoService propositionBoService; 065 066 public static <T extends Object> T getService(String serviceName) { 067 return KrmsRepositoryServiceLocator.<T>getBean(serviceName); 068 } 069 070 public static <T extends Object> T getBean(String serviceName) { 071 if ( LOG.isDebugEnabled() ) { 072 LOG.debug("Fetching service " + serviceName); 073 } 074 return GlobalResourceLoader.<T>getService(QName.valueOf(serviceName)); 075 } 076 077 public static KrmsAttributeDefinitionService getKrmsAttributeDefinitionService() { 078 if ( krmsAttributeDefinitionService == null ) { 079 krmsAttributeDefinitionService = getService(KRMS_ATTRIBUTE_DEFINITION_SERVICE); 080 } 081 return krmsAttributeDefinitionService; 082 } 083 084 public static CriteriaLookupService getCriteriaLookupService() { 085 return getService(CRITERIA_LOOKUP_SERVICE); 086 } 087 088 public static void setKrmsAttributeDefinitionService(final KrmsAttributeDefinitionService service) { 089 krmsAttributeDefinitionService = service; 090 } 091 092 public static ContextBoService getContextBoService() { 093 if (contextBoService == null) { 094 contextBoService = getService(KRMS_CONTEXT_BO_SERVICE); 095 } 096 return contextBoService; 097 } 098 099 public static TermBoService getTermBoService() { 100 if (termBoService == null) { 101 termBoService = getService(KRMS_TERM_BO_SERVICE); 102 } 103 return termBoService; 104 } 105 106 public static AgendaBoService getAgendaBoService() { 107 if (agendaBoService == null) { 108 agendaBoService = getService(KRMS_AGENDA_BO_SERVICE); 109 } 110 return agendaBoService; 111 } 112 113 public static FunctionBoService getFunctionBoService() { 114 if (functionBoService == null) { 115 functionBoService = getService(KRMS_FUNCTION_BO_SERVICE); 116 } 117 return functionBoService; 118 } 119 120 public static RuleBoService getRuleBoService() { 121 if (ruleBoService == null) { 122 ruleBoService = getService(KRMS_RULE_BO_SERVICE); 123 } 124 return ruleBoService; 125 } 126 127 public static AgendaAuthorizationService getAgendaAuthorizationService() { 128 if (agendaAuthorizationService == null) { 129 agendaAuthorizationService = getService(KRMS_AGENDA_AUTHORIZATION_SERVICE); 130 } 131 return agendaAuthorizationService; 132 } 133 134 public static KrmsTypeRepositoryService getKrmsTypeRepositoryService() { 135 if (krmsTypeRepositoryService == null) { 136 krmsTypeRepositoryService = getService(KRMS_TYPE_REPOSITORY_SERVICE); 137 } 138 return krmsTypeRepositoryService; 139 } 140 141 public static RepositoryToEngineTranslator getKrmsRepositoryToEngineTranslator() { 142 if (krmsRepositoryToEngineTranslator == null) { 143 krmsRepositoryToEngineTranslator = getService(KRMS_REPOSITORY_TO_ENGINE_TRANSLATOR); 144 } 145 return krmsRepositoryToEngineTranslator; 146 } 147 148 public static TypeTypeRelationBoService getTypeTypeRelationBoService() { 149 if (typeTypeRelationBoService == null) { 150 typeTypeRelationBoService = getService(TYPE_TYPE_RELATION_BO_SERVICE); 151 } 152 return typeTypeRelationBoService; 153 } 154 155 public static PropositionBoService getPropositionBoService() { 156 if (propositionBoService == null) { 157 propositionBoService = getService(KRMS_PROPOSITION_BO_SERVICE); 158 } 159 return propositionBoService; 160 } 161}