001 /** 002 * Copyright 2005-2013 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.krms.api; 017 018 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; 019 import org.kuali.rice.krms.api.engine.Engine; 020 import org.kuali.rice.krms.api.engine.expression.ComparisonOperatorService; 021 import org.kuali.rice.krms.api.repository.RuleRepositoryService; 022 import org.kuali.rice.krms.api.repository.type.KrmsTypeRepositoryService; 023 024 import javax.xml.namespace.QName; 025 026 /** 027 * A static service locator which aids in locating the various remotable services that form the Kuali Rule Management System API. 028 * 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 */ 031 public class KrmsApiServiceLocator { 032 033 public static final String ENGINE = "rice.krms.engine"; 034 public static final QName RULE_REPOSITORY_SERVICE = new QName(KrmsConstants.Namespaces.KRMS_NAMESPACE_2_0, "ruleRepositoryService"); 035 public static final QName KRMS_TYPE_REPOSITORY_SERVICE = new QName(KrmsConstants.Namespaces.KRMS_NAMESPACE_2_0, "krmsTypeRepositoryService"); 036 public static final String COMPARISON_SERVICE = "comparisonOperatorService"; 037 038 /** 039 * Get the named service 040 * @param serviceName 041 * @param <T> 042 * @return <T> T 043 */ 044 static <T> T getService(String serviceName) { 045 return GlobalResourceLoader.<T>getService(QName.valueOf(serviceName)); 046 } 047 048 /** 049 * Get the qnamed service 050 * @param serviceName 051 * @param <T> 052 * @return <T> T 053 */ 054 static <T> T getService(QName serviceName) { 055 return GlobalResourceLoader.<T>getService(serviceName); 056 } 057 058 /** 059 * Return the {@link Engine} 060 * @return {@link Engine} 061 */ 062 public static Engine getEngine() { 063 return getService(ENGINE); 064 } 065 066 /** 067 * Return the {@link RuleRepositoryService} 068 * @return {@link RuleRepositoryService} 069 */ 070 public static RuleRepositoryService getRuleRepositoryService() { 071 return getService(RULE_REPOSITORY_SERVICE); 072 } 073 074 /** 075 * Return the {@link KrmsTypeRepositoryService} 076 * @return {@link KrmsTypeRepositoryService} 077 */ 078 public static KrmsTypeRepositoryService getKrmsTypeRepositoryService() { 079 return getService(KRMS_TYPE_REPOSITORY_SERVICE); 080 } 081 082 /** 083 * Return the {@link ComparisonOperatorService} 084 * @return {@link ComparisonOperatorService} 085 */ 086 public static ComparisonOperatorService getComparisonOperatorService() { 087 return getService(COMPARISON_SERVICE); 088 } 089 }