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.api;
17  
18  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
19  import org.kuali.rice.kew.api.responsibility.ResponsibilityChangeQueue;
20  import org.kuali.rice.kew.api.action.WorkflowDocumentActionsService;
21  import org.kuali.rice.kew.api.actionlist.ActionListService;
22  import org.kuali.rice.kew.api.doctype.DocumentTypeService;
23  import org.kuali.rice.kew.api.document.WorkflowDocumentService;
24  import org.kuali.rice.kew.api.document.attribute.DocumentAttributeIndexingQueue;
25  import org.kuali.rice.kew.api.extension.ExtensionRepositoryService;
26  import org.kuali.rice.kew.api.group.GroupMembershipChangeQueue;
27  import org.kuali.rice.kew.api.mail.ImmediateEmailReminderQueue;
28  import org.kuali.rice.kew.api.note.NoteService;
29  import org.kuali.rice.kew.api.peopleflow.PeopleFlowService;
30  import org.kuali.rice.kew.api.preferences.PreferencesService;
31  import org.kuali.rice.kew.api.repository.type.KewTypeRepositoryService;
32  import org.kuali.rice.kew.api.rule.RuleService;
33  import org.kuali.rice.ksb.api.KsbApiServiceLocator;
34  
35  import javax.xml.namespace.QName;
36  
37  /**
38   * A static service locator which aids in locating the various services that
39   * form the Kuali Service Bus API.
40   */
41  public class KewApiServiceLocator {
42  
43      // Rice 2.0 - TODO - should these be using the QName versions instead?  How else will they be fetched in "remote" mode?
44  	public static final String WORKFLOW_DOCUMENT_ACTIONS_SERVICE = "rice.kew.workflowDocumentActionsService";
45  	public static final String WORKFLOW_DOCUMENT_SERVICE = "rice.kew.workflowDocumentService";
46      public static final String ACTION_LIST_SERVICE = "rice.kew.actionListService";
47  	public static final String DOCUMENT_TYPE_SERVICE = "rice.kew.documentTypeService";
48  	public static final String NOTE_SERVICE = "rice.kew.noteService";
49      public static final String EXTENSION_REPOSITORY_SERVICE = "rice.kew.extensionRepositoryService";
50      public static final String RULE_SERVICE = "rice.kew.ruleService";
51      public static final String KEW_TYPE_REPOSITORY_SERVICE = "rice.kew.kewTypeRepositoryService";
52      public static final String PEOPLE_FLOW_SERVICE = "rice.kew.peopleFlowService";
53      public static final String PREFERENCES_SERVICE = "rice.kew.preferencesService";
54  
55      public static final QName DOCUMENT_ATTRIBUTE_INDEXING_QUEUE_NAME = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "documentAttributeIndexingQueue");
56      public static final QName GROUP_MEMBERSHIP_CHANGE_QUEUE_NAME = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "groupMembershipChangeQueue");
57      public static final QName IMMEDIATE_EMAIL_REMINDER_QUEUE = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "immediateEmailReminderQueue");
58      public static final QName RESPONSIBILITY_CHANGE_QUEUE = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "responsibilityChangeQueue");
59  
60      static <T> T getService(String serviceName) {
61          return GlobalResourceLoader.<T>getService(serviceName);
62      }
63  
64      public static WorkflowDocumentActionsService getWorkflowDocumentActionsService() {
65          return getService(WORKFLOW_DOCUMENT_ACTIONS_SERVICE);
66      }
67      
68      public static WorkflowDocumentService getWorkflowDocumentService() {
69          return getService(WORKFLOW_DOCUMENT_SERVICE);
70      }
71  
72      public static ActionListService getActionListService() {
73          return getService(ACTION_LIST_SERVICE);
74      }
75      
76      public static DocumentTypeService getDocumentTypeService() {
77          return getService(DOCUMENT_TYPE_SERVICE);
78      }
79      
80      public static NoteService getNoteService() {
81      	return getService(NOTE_SERVICE);
82      }
83  
84      public static RuleService getRuleService() {
85      	return getService(RULE_SERVICE);
86      }
87  
88      public static ExtensionRepositoryService getExtensionRepositoryService() {
89          return getService(EXTENSION_REPOSITORY_SERVICE);
90      }
91  
92      public static KewTypeRepositoryService getKewTypeRepositoryService() {
93          return getService(KEW_TYPE_REPOSITORY_SERVICE);
94      }
95  
96      public static PeopleFlowService getPeopleFlowService() {
97          return getService(PEOPLE_FLOW_SERVICE);
98      }
99  
100     public static DocumentAttributeIndexingQueue getDocumentAttributeIndexingQueue() {
101         return getDocumentAttributeIndexingQueue(null);
102     }
103 
104     public static DocumentAttributeIndexingQueue getDocumentAttributeIndexingQueue(String applicationId) {
105         return (DocumentAttributeIndexingQueue)KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(DOCUMENT_ATTRIBUTE_INDEXING_QUEUE_NAME, applicationId);
106     }
107     
108     public static GroupMembershipChangeQueue getGroupMembershipChangeQueue() {
109         return (GroupMembershipChangeQueue)KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(GROUP_MEMBERSHIP_CHANGE_QUEUE_NAME);
110     }
111 
112     public static ResponsibilityChangeQueue getResponsibilityChangeQueue() {
113         return (ResponsibilityChangeQueue)KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(
114                 RESPONSIBILITY_CHANGE_QUEUE);
115     }
116     
117     public static ImmediateEmailReminderQueue getImmediateEmailReminderQueue() {
118         return KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(IMMEDIATE_EMAIL_REMINDER_QUEUE);
119     }
120 
121     public static PreferencesService getPreferencesService() {
122         return getService(PREFERENCES_SERVICE);
123     }
124 }