View Javadoc
1   /**
2    * Copyright 2005-2015 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.kew.framework;
17  
18  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
19  import org.kuali.rice.kew.api.KewApiConstants;
20  import org.kuali.rice.kew.framework.actionlist.ActionListCustomizationHandlerService;
21  import org.kuali.rice.kew.framework.actionlist.ActionListCustomizationMediator;
22  import org.kuali.rice.kew.framework.document.search.DocumentSearchCustomizationHandlerService;
23  import org.kuali.rice.kew.framework.document.security.DocumentSecurityHandlerService;
24  import org.kuali.rice.kew.framework.rule.attribute.WorkflowRuleAttributeHandlerService;
25  import org.kuali.rice.kew.framework.validation.RuleValidationAttributeExporterService;
26  import org.kuali.rice.ksb.api.KsbApiServiceLocator;
27  
28  import javax.xml.namespace.QName;
29  
30  /**
31   * A static service locator which aids in locating the various KEW framework services.
32   */
33  public class KewFrameworkServiceLocator {
34  
35      public static final String DOCUMENT_SEARCH_CUSTOMIZATION_HANDLER_SERVICE = "documentSearchCustomizationHandlerService";
36      public static final String DOCUMENT_SECURITY_HANDLER_SERVICE = "documentSecurityHandlerService";
37      public static final String RULE_VALIDATION_ATTRIBUTE_EXPORTER_SERVICE = "ruleValidationAttributeExporterService";
38      public static final String ACTION_LIST_CUSTOMIZATION_MEDIATOR = "rice.kew.actionListCustomizationMediator";
39      public static final String ACTION_LIST_CUSTOMIZATION_HANDLER_SERVICE = "actionListCustomizationHandlerService";
40      public static final String WORKFLOW_RULE_ATTRIBUTE_HANDLER_SERVICE = "workflowRuleAttributeHandlerService";
41  
42  
43      static <T> T getService(String serviceName) {
44          return GlobalResourceLoader.<T>getService(serviceName);
45      }
46  
47      static <T> T getServiceOnBus(String serviceName, String applicationId) {
48          return (T)KsbApiServiceLocator.getServiceBus().getService(new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, serviceName), applicationId);
49      }
50  
51      public static DocumentSearchCustomizationHandlerService getDocumentSearchCustomizationHandlerService(
52              String applicationId) {
53          return getServiceOnBus(DOCUMENT_SEARCH_CUSTOMIZATION_HANDLER_SERVICE, applicationId);
54      }
55  
56      public static DocumentSecurityHandlerService getDocumentSecurityHandlerService(
57              String applicationId) {
58          return getServiceOnBus(DOCUMENT_SECURITY_HANDLER_SERVICE, applicationId);
59      }
60  
61      public static RuleValidationAttributeExporterService getRuleValidationAttributeExporterService(String applicationId) {
62          return getServiceOnBus(RULE_VALIDATION_ATTRIBUTE_EXPORTER_SERVICE, applicationId);
63      }
64  
65      public static WorkflowRuleAttributeHandlerService getWorkflowRuleAttributeHandlerService(String applicationId) {
66          return getServiceOnBus(WORKFLOW_RULE_ATTRIBUTE_HANDLER_SERVICE, applicationId);
67      }
68  
69      public static ActionListCustomizationMediator getActionListCustomizationMediator() {
70          return getService(ACTION_LIST_CUSTOMIZATION_MEDIATOR);
71      }
72      
73      public static ActionListCustomizationHandlerService getActionListCustomizationHandlerService(
74              String applicationId) {
75          return getServiceOnBus(ACTION_LIST_CUSTOMIZATION_HANDLER_SERVICE, applicationId);
76      }
77  }