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.kew.framework;
017    
018    import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
019    import org.kuali.rice.kew.api.KewApiConstants;
020    import org.kuali.rice.kew.framework.actionlist.ActionListCustomizationHandlerService;
021    import org.kuali.rice.kew.framework.actionlist.ActionListCustomizationMediator;
022    import org.kuali.rice.kew.framework.document.search.DocumentSearchCustomizationHandlerService;
023    import org.kuali.rice.kew.framework.document.security.DocumentSecurityHandlerService;
024    import org.kuali.rice.kew.framework.rule.attribute.WorkflowRuleAttributeHandlerService;
025    import org.kuali.rice.kew.framework.validation.RuleValidationAttributeExporterService;
026    import org.kuali.rice.ksb.api.KsbApiServiceLocator;
027    
028    import javax.xml.namespace.QName;
029    
030    /**
031     * A static service locator which aids in locating the various KEW framework services.
032     */
033    public class KewFrameworkServiceLocator {
034    
035        public static final String DOCUMENT_SEARCH_CUSTOMIZATION_HANDLER_SERVICE = "documentSearchCustomizationHandlerService";
036        public static final String DOCUMENT_SECURITY_HANDLER_SERVICE = "documentSecurityHandlerService";
037        public static final String RULE_VALIDATION_ATTRIBUTE_EXPORTER_SERVICE = "ruleValidationAttributeExporterService";
038        public static final String ACTION_LIST_CUSTOMIZATION_MEDIATOR = "rice.kew.actionListCustomizationMediator";
039        public static final String ACTION_LIST_CUSTOMIZATION_HANDLER_SERVICE = "actionListCustomizationHandlerService";
040        public static final String WORKFLOW_RULE_ATTRIBUTE_HANDLER_SERVICE = "workflowRuleAttributeHandlerService";
041    
042    
043        static <T> T getService(String serviceName) {
044            return GlobalResourceLoader.<T>getService(serviceName);
045        }
046    
047        static <T> T getServiceOnBus(String serviceName, String applicationId) {
048            return (T)KsbApiServiceLocator.getServiceBus().getService(new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, serviceName), applicationId);
049        }
050    
051        public static DocumentSearchCustomizationHandlerService getDocumentSearchCustomizationHandlerService(
052                String applicationId) {
053            return getServiceOnBus(DOCUMENT_SEARCH_CUSTOMIZATION_HANDLER_SERVICE, applicationId);
054        }
055    
056        public static DocumentSecurityHandlerService getDocumentSecurityHandlerService(
057                String applicationId) {
058            return getServiceOnBus(DOCUMENT_SECURITY_HANDLER_SERVICE, applicationId);
059        }
060    
061        public static RuleValidationAttributeExporterService getRuleValidationAttributeExporterService(String applicationId) {
062            return getServiceOnBus(RULE_VALIDATION_ATTRIBUTE_EXPORTER_SERVICE, applicationId);
063        }
064    
065        public static WorkflowRuleAttributeHandlerService getWorkflowRuleAttributeHandlerService(String applicationId) {
066            return getServiceOnBus(WORKFLOW_RULE_ATTRIBUTE_HANDLER_SERVICE, applicationId);
067        }
068    
069        public static ActionListCustomizationMediator getActionListCustomizationMediator() {
070            return getService(ACTION_LIST_CUSTOMIZATION_MEDIATOR);
071        }
072        
073        public static ActionListCustomizationHandlerService getActionListCustomizationHandlerService(
074                String applicationId) {
075            return getServiceOnBus(ACTION_LIST_CUSTOMIZATION_HANDLER_SERVICE, applicationId);
076        }
077    }