001/** 002 * Copyright 2005-2016 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.kim.service; 017 018import org.apache.log4j.Logger; 019import org.kuali.rice.core.api.config.module.RunMode; 020import org.kuali.rice.core.api.config.property.ConfigContext; 021import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; 022import org.kuali.rice.kim.api.KimConstants; 023import org.kuali.rice.kim.impl.group.GroupInternalService; 024import org.kuali.rice.kim.service.dao.UiDocumentServiceDAO; 025 026import javax.xml.namespace.QName; 027 028/** 029 * Service locator for KIM. 030 * 031 * @author Kuali Rice Team (rice.collab@kuali.org) 032 * 033 */ 034public final class KIMServiceLocatorInternal { 035 036 private static final Logger LOG = Logger.getLogger(KIMServiceLocatorInternal.class); 037 038 public static final String KIM_RUN_MODE_PROPERTY = "kim.mode"; 039 040 public static final String KIM_UI_DOCUMENT_SERVICE = "kimUiDocumentService"; 041 public static final String GROUP_INTERNAL_SERVICE = "groupInternalService"; 042 public static final String UI_DOCUMENT_SERVICE_DAO = "uiDocumentServiceDAO"; 043 044 public static Object getService(String serviceName) { 045 return getBean(serviceName); 046 } 047 048 public static Object getBean(String serviceName) { 049 if ( LOG.isDebugEnabled() ) { 050 LOG.debug("Fetching service " + serviceName); 051 } 052 QName name = new QName(serviceName); 053 RunMode kimRunMode = RunMode.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KIM_RUN_MODE_PROPERTY)); 054 if (kimRunMode == RunMode.REMOTE || kimRunMode == RunMode.THIN) { 055 name = new QName(KimConstants.KIM_MODULE_NAMESPACE, serviceName); 056 } 057 return GlobalResourceLoader.getResourceLoader().getService(name); 058 } 059 060 public static UiDocumentService getUiDocumentService() { 061 return (UiDocumentService)getService(KIM_UI_DOCUMENT_SERVICE); 062 } 063 064 public static GroupInternalService getGroupInternalService() { 065 return (GroupInternalService)getService(GROUP_INTERNAL_SERVICE); 066 } 067 068 public static UiDocumentServiceDAO getUiDocumentServiceDAO() { 069 return (UiDocumentServiceDAO) getBean(UI_DOCUMENT_SERVICE_DAO); 070 } 071}