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