View Javadoc

1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krms.impl.util;
17  
18  import javax.xml.namespace.QName;
19  
20  import org.apache.log4j.Logger;
21  import org.kuali.rice.core.api.config.module.RunMode;
22  import org.kuali.rice.core.api.config.property.ConfigContext;
23  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
24  
25  /**
26   * Like {@link org.kuali.rice.krms.api.KrmsApiServiceLocator} only for non-remotable.
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   *
29   */
30  public class KRMSServiceLocatorInternal {
31  	
32  	public static final String KRMS_RUN_MODE_PROPERTY = "krms.mode";
33  	public static final String KRMS_MODULE_NAMESPACE = "KRMS";
34      public static final String VALIDATION_ACTION_SERVICE = "validationActionService";
35      public static final String VALIDATION_RULE_SERVICE = "validationRuleService";
36  
37  	private static final Logger LOG = Logger.getLogger(KRMSServiceLocatorInternal.class);
38  
39  	
40  	@SuppressWarnings("unchecked")
41  	public static <A> A getService(String serviceName) {
42  		return (A)getBean(serviceName);
43  	}
44  	
45  	public static Object getBean(String serviceName) {
46  		if ( LOG.isDebugEnabled() ) {
47  			LOG.debug("Fetching service " + serviceName);
48  		}
49  		return GlobalResourceLoader.getResourceLoader().getService(
50  				(RunMode.REMOTE.equals(RunMode.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KRMS_RUN_MODE_PROPERTY)))) ?
51  						new QName(KRMS_MODULE_NAMESPACE, serviceName) : new QName(serviceName) );
52  	}
53  	
54  //    public static BusinessObjectService getBusinessObjectService() {
55  //    	return getService(KRMS_BO_SERVICE);
56  //    }
57  	
58  }