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