001 /**
002 * Copyright 2005-2011 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 */
016 package org.kuali.rice.edl.impl.service;
017
018 import javax.xml.namespace.QName;
019
020 import org.apache.log4j.Logger;
021 import org.kuali.rice.core.api.config.module.RunMode;
022 import org.kuali.rice.core.api.config.property.ConfigContext;
023 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
024 import org.kuali.rice.kew.service.KEWServiceLocator;
025 import org.kuali.rice.kew.api.KewApiConstants;
026
027 public class EdlServiceLocator {
028
029 private static final Logger LOG = Logger.getLogger(EdlServiceLocator.class);
030
031 public static final String EDL_RUN_MODE_PROPERTY = "edl.mode";
032 public static final String EDOCLITE_SERVICE = "enEDocLiteService";
033
034
035 static <T> T getService(String serviceName) {
036 return GlobalResourceLoader.<T>getService(serviceName);
037 }
038
039 public static EDocLiteService getEDocLiteService() {
040 return getService(EDOCLITE_SERVICE);
041 }
042
043 public static Object getBean(String serviceName) {
044 if ( LOG.isDebugEnabled() ) {
045 LOG.debug("Fetching service " + serviceName);
046 }
047 return GlobalResourceLoader.getResourceLoader().getService(
048 (RunMode.REMOTE.equals(RunMode.valueOf(ConfigContext.getCurrentContextConfig().getProperty(EDL_RUN_MODE_PROPERTY)))) ?
049 new QName(KewApiConstants.KEW_MODULE_NAMESPACE, serviceName) : new QName(serviceName));
050 }
051
052 }