View Javadoc
1   /**
2    * Copyright 2005-2014 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.api;
17  
18  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
19  import org.kuali.rice.krms.api.engine.Engine;
20  import org.kuali.rice.krms.api.engine.expression.ComparisonOperatorService;
21  import org.kuali.rice.krms.api.repository.RuleRepositoryService;
22  import org.kuali.rice.krms.api.repository.type.KrmsTypeRepositoryService;
23  
24  import javax.xml.namespace.QName;
25  
26  /**
27   * A static service locator which aids in locating the various remotable services that form the Kuali Rule Management System API.
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class KrmsApiServiceLocator {
32  
33  	public static final String ENGINE = "rice.krms.engine";
34  	public static final QName RULE_REPOSITORY_SERVICE = new QName(KrmsConstants.Namespaces.KRMS_NAMESPACE_2_0, "ruleRepositoryService");
35      public static final QName KRMS_TYPE_REPOSITORY_SERVICE = new QName(KrmsConstants.Namespaces.KRMS_NAMESPACE_2_0, "krmsTypeRepositoryService");
36      public static final String COMPARISON_SERVICE = "comparisonOperatorService";
37  
38      /**
39       * Get the named service
40       * @param serviceName
41       * @param <T>
42       * @return  <T> T
43       */
44      static <T> T getService(String serviceName) {
45          return GlobalResourceLoader.<T>getService(QName.valueOf(serviceName));
46      }
47  
48      /**
49       * Get the qnamed service
50       * @param serviceName
51       * @param <T>
52       * @return <T> T
53       */
54      static <T> T getService(QName serviceName) {
55          return GlobalResourceLoader.<T>getService(serviceName);
56      }
57  
58      /**
59       * Return the {@link Engine}
60       * @return {@link Engine}
61       */
62      public static Engine getEngine() {
63          return getService(ENGINE);
64      }
65  
66      /**
67       * Return the {@link RuleRepositoryService}
68       * @return {@link RuleRepositoryService}
69       */
70      public static RuleRepositoryService getRuleRepositoryService() {
71      	return getService(RULE_REPOSITORY_SERVICE);
72      }
73  
74      /**
75       * Return the {@link KrmsTypeRepositoryService}
76       * @return {@link KrmsTypeRepositoryService}
77       */
78      public static KrmsTypeRepositoryService getKrmsTypeRepositoryService() {
79          return getService(KRMS_TYPE_REPOSITORY_SERVICE);
80      }
81  
82      /**
83       * Return the {@link ComparisonOperatorService}
84       * @return {@link ComparisonOperatorService}
85       */
86      public static ComparisonOperatorService getComparisonOperatorService() {
87          return getService(COMPARISON_SERVICE);
88      }
89  }