1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.service;
18
19 import javax.persistence.EntityManagerFactory;
20 import javax.sql.DataSource;
21 import javax.transaction.TransactionManager;
22 import javax.transaction.UserTransaction;
23 import javax.xml.namespace.QName;
24
25 import org.apache.log4j.Logger;
26 import org.kuali.rice.core.api.config.module.RunMode;
27 import org.kuali.rice.core.api.config.property.ConfigContext;
28 import org.kuali.rice.core.api.encryption.EncryptionService;
29 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
30 import org.kuali.rice.core.mail.Mailer;
31 import org.kuali.rice.edl.framework.extract.ExtractService;
32 import org.kuali.rice.kew.actionlist.service.ActionListService;
33 import org.kuali.rice.kew.actionrequest.service.ActionRequestService;
34 import org.kuali.rice.kew.actions.ActionRegistry;
35 import org.kuali.rice.kew.actiontaken.service.ActionTakenService;
36 import org.kuali.rice.kew.batch.XmlPollerService;
37 import org.kuali.rice.kew.docsearch.DocumentLookupCustomizationMediator;
38 import org.kuali.rice.kew.docsearch.service.DocumentSearchService;
39 import org.kuali.rice.kew.doctype.service.DocumentSecurityService;
40 import org.kuali.rice.kew.doctype.service.DocumentTypePermissionService;
41 import org.kuali.rice.kew.doctype.service.DocumentTypeService;
42 import org.kuali.rice.kew.documentlink.service.DocumentLinkService;
43 import org.kuali.rice.kew.engine.WorkflowEngineFactory;
44 import org.kuali.rice.kew.engine.node.service.BranchService;
45 import org.kuali.rice.kew.engine.node.service.RouteNodeService;
46 import org.kuali.rice.kew.engine.simulation.SimulationWorkflowEngine;
47 import org.kuali.rice.kew.exception.WorkflowDocumentExceptionRoutingService;
48 import org.kuali.rice.kew.framework.validation.RuleValidationAttributeExporterService;
49 import org.kuali.rice.kew.identity.service.IdentityHelperService;
50 import org.kuali.rice.kew.impl.document.WorkflowDocumentPrototype;
51 import org.kuali.rice.kew.mail.service.ActionListEmailService;
52 import org.kuali.rice.kew.mail.service.EmailContentService;
53 import org.kuali.rice.kew.notes.service.NoteService;
54 import org.kuali.rice.kew.notification.service.NotificationService;
55 import org.kuali.rice.kew.preferences.service.PreferencesService;
56 import org.kuali.rice.kew.responsibility.service.ResponsibilityIdService;
57 import org.kuali.rice.kew.role.service.RoleService;
58 import org.kuali.rice.kew.routeheader.service.RouteHeaderService;
59 import org.kuali.rice.kew.routeheader.service.WorkflowDocumentService;
60 import org.kuali.rice.kew.routemodule.service.RouteModuleService;
61 import org.kuali.rice.kew.routemodule.service.RoutingReportService;
62 import org.kuali.rice.kew.rule.service.RuleAttributeService;
63 import org.kuali.rice.kew.rule.service.RuleDelegationService;
64 import org.kuali.rice.kew.rule.service.RuleService;
65 import org.kuali.rice.kew.rule.service.RuleTemplateService;
66 import org.kuali.rice.kew.useroptions.UserOptionsService;
67 import org.kuali.rice.kew.util.KEWConstants;
68 import org.kuali.rice.kew.validation.RuleValidationAttributeResolver;
69 import org.springframework.transaction.PlatformTransactionManager;
70
71
72
73
74
75
76
77
78
79
80
81 public final class KEWServiceLocator {
82
83 private static final Logger LOG = Logger.getLogger(KEWServiceLocator.class);
84
85 public static final String KEW_RUN_MODE_PROPERTY = "kew.mode";
86
87 public static final String DATASOURCE = "enWorkflowDataSource";
88
89 public static final String QUICK_LINKS_SERVICE = "enQuickLinksService";
90
91 public static final String DOCUMENT_SEARCH_SERVICE = "enDocumentSearchService";
92
93 public static final String ACTION_TAKEN_SRV = "enActionTakenService";
94
95 public static final String ACTION_REQUEST_SRV = "enActionRequestService";
96
97 public static final String ACTION_LIST_SRV = "enActionListService";
98
99 public static final String DOC_ROUTE_HEADER_SRV = "enDocumentRouteHeaderService";
100
101 public static final String DOCUMENT_TYPE_GROUP_SERVICE = "enDocumentTypeGroupService";
102
103 public static final String DOCUMENT_TYPE_SERVICE = "enDocumentTypeService";
104
105 public static final String DOCUMENT_TYPE_PERMISSION_SERVICE = "enDocumentTypePermissionService";
106
107 public static final String DOCUMENT_SECURITY_SERVICE = "enDocumentSecurityService";
108
109 public static final String USER_OPTIONS_SRV = "enUserOptionsService";
110
111 public static final String DOCUMENT_CHANGE_HISTORY_SRV = "enDocumentChangeHistoryService";
112
113 public static final String DOCUMENT_VALUE_INDEX_SRV = "enDocumentValueIndexService";
114
115 public static final String ROUTE_LEVEL_SERVICE = "enRouteLevelService";
116
117 public static final String CONSTANTS_SERVICE = "enApplicationConstantsService";
118
119 public static final String PREFERENCES_SERVICE = "enPreferencesService";
120
121 public static final String ROUTE_LOG_SERVICE = "enRouteLogService";
122
123 public static final String RULE_TEMPLATE_SERVICE = "enRuleTemplateService";
124
125 public static final String RULE_SERVICE = "enRuleService";
126
127 public static final String RULE_ATTRIBUTE_SERVICE = "enRuleAttributeService";
128
129 public static final String RULE_TEMPLATE_ATTRIBUTE_SERVICE = "enRuleTemplateAttributeService";
130
131 public static final String ROLE_SERVICE = "enRoleService";
132
133 public static final String RESPONSIBILITY_ID_SERVICE = "enResponsibilityIdService";
134
135 public static final String STATS_SERVICE = "enStatsService";
136
137 public static final String ROUTE_MANAGER_QUEUE_SERVICE = "enRouteManagerQueueService";
138
139 public static final String ROUTE_MANAGER_CONTROLLER = "enRouteManagerController";
140
141 public static final String RULE_DELEGATION_SERVICE = "enRuleDelegationService";
142
143 public static final String ROUTE_MANAGER_DRIVER = "enRouteManagerDriver";
144
145 public static final String OPTIMISTIC_LOCK_FAILURE_SERVICE = "enOptimisticLockFailureService";
146
147 public static final String NOTE_SERVICE = "enNoteService";
148
149 public static final String ROUTING_REPORT_SERVICE = "enRoutingReportService";
150
151 public static final String ROUTE_MODULE_SERVICE = "enRouteModuleService";
152
153 public static final String EXCEPTION_ROUTING_SERVICE = "enExceptionRoutingService";
154
155 public static final String ACTION_REGISTRY = "enActionRegistry";
156
157 public static final String BRANCH_SERVICE = "enBranchService";
158
159 public static final String WORKFLOW_MBEAN = "workflowMBean";
160
161 public static final String JTA_TRANSACTION_MANAGER = "jtaTransactionManager";
162
163 public static final String USER_TRANSACTION = "userTransaction";
164
165 public static final String SCHEDULER = "enScheduler";
166
167 public static final String DOCUMENT_LINK_SERVICE = "enDocumentLinkService";
168
169
170
171
172 public static final String XML_POLLER_SERVICE = "enXmlPollerService";
173
174 public static final String DB_TABLES_LOADER = "enDbTablesLoader";
175
176 public static final String ROUTE_NODE_SERVICE = "enRouteNodeService";
177
178 public static final String SIMULATION_ENGINE = "simulationEngine";
179
180 public static final String WORKFLOW_ENGINE_FACTORY = "workflowEngineFactory";
181
182 public static final String ACTION_LIST_EMAIL_SERVICE = "enActionListEmailService";
183
184 public static final String IMMEDIATE_EMAIL_REMINDER_SERVICE = "enImmediateEmailReminderService";
185
186 public static final String EMAIL_CONTENT_SERVICE = "enEmailContentService";
187
188 public static final String NOTIFICATION_SERVICE = "enNotificationService";
189
190 public static final String TRANSACTION_MANAGER = "transactionManager";
191
192 public static final String TRANSACTION_TEMPLATE = "transactionTemplate";
193
194 public static final String WORKFLOW_DOCUMENT_SERVICE = "enWorkflowDocumentService";
195
196 public static final String EXTENSION_SERVICE = "enExtensionService";
197
198 public static final String TRANSFORMATION_SERVICE = "enTransformationService";
199
200 public static final String ENCRYPTION_SERVICE = "enEncryptionService";
201
202 public static final String REMOVE_REPLACE_DOCUMENT_SERVICE = "enRemoveReplaceDocumentService";
203
204 public static final String EXTRACT_SERVICE = "enExtractService";
205
206 public static final String IDENTITY_HELPER_SERVICE = "kewIdentityHelperService";
207
208 public static final String ENTITY_MANAGER_FACTORY = "kewEntityManagerFactory";
209
210 public static final String MAILER = "mailer";
211
212 public static final String WORKFLOW_DOCUMENT_PROTOTYPE = "rice.kew.workflowDocumentPrototype";
213
214 public static final String DOCUMENT_LOOKUP_CUSTOMIZATION_MEDIATOR = "rice.kew.documentLookupCustomizationMediator";
215
216 public static final String RULE_VALIDATION_ATTRIBUTE_RESOLVER = "rice.kew.ruleValidationAttributeResolver";
217
218 public static EntityManagerFactory getEntityManagerFactory() {
219 return (EntityManagerFactory) getService(ENTITY_MANAGER_FACTORY);
220 }
221
222
223
224
225
226
227 public static <T> T getService(String serviceName) {
228 return KEWServiceLocator.<T>getBean(serviceName);
229 }
230
231 public static <T> T getBean(String serviceName) {
232 if ( LOG.isDebugEnabled() ) {
233 LOG.debug("Fetching service " + serviceName);
234 }
235 return GlobalResourceLoader.getResourceLoader().<T>getService(
236 (RunMode.REMOTE.equals(RunMode.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KEW_RUN_MODE_PROPERTY)))) ?
237 new QName(KEWConstants.KEW_MODULE_NAMESPACE, serviceName) : new QName(serviceName));
238 }
239
240 public static WorkflowUtility getWorkflowUtilityService() {
241 if ( LOG.isDebugEnabled() ) {
242 LOG.debug("Fetching service " + KEWConstants.WORKFLOW_UTILITY_SERVICE);
243 }
244 return (WorkflowUtility) GlobalResourceLoader.getResourceLoader().getService(new QName(KEWConstants.WORKFLOW_UTILITY_SERVICE));
245 }
246
247 public static DocumentTypeService getDocumentTypeService() {
248 return (DocumentTypeService) getBean(DOCUMENT_TYPE_SERVICE);
249 }
250
251 public static DocumentTypePermissionService getDocumentTypePermissionService() {
252 return (DocumentTypePermissionService) getBean(DOCUMENT_TYPE_PERMISSION_SERVICE);
253 }
254
255 public static DocumentSecurityService getDocumentSecurityService() {
256 return (DocumentSecurityService) getBean(DOCUMENT_SECURITY_SERVICE);
257 }
258
259
260 public static ActionRequestService getActionRequestService() {
261 return (ActionRequestService) getBean(ACTION_REQUEST_SRV);
262 }
263
264 public static ActionTakenService getActionTakenService() {
265 return (ActionTakenService) getBean(ACTION_TAKEN_SRV);
266 }
267
268 public static ResponsibilityIdService getResponsibilityIdService() {
269 return (ResponsibilityIdService) getBean(RESPONSIBILITY_ID_SERVICE);
270 }
271
272 public static RouteHeaderService getRouteHeaderService() {
273 return (RouteHeaderService) getBean(DOC_ROUTE_HEADER_SRV);
274 }
275
276 public static RuleTemplateService getRuleTemplateService() {
277 return (RuleTemplateService) getBean(RULE_TEMPLATE_SERVICE);
278 }
279
280 public static RuleAttributeService getRuleAttributeService() {
281 return (RuleAttributeService) getBean(RULE_ATTRIBUTE_SERVICE);
282 }
283
284 public static WorkflowDocumentService getWorkflowDocumentService() {
285 return (WorkflowDocumentService) getBean(WORKFLOW_DOCUMENT_SERVICE);
286 }
287
288 public static RouteModuleService getRouteModuleService() {
289 return (RouteModuleService) getBean(ROUTE_MODULE_SERVICE);
290 }
291
292 public static RoleService getRoleService() {
293 return (RoleService) getBean(ROLE_SERVICE);
294 }
295
296 public static RuleService getRuleService() {
297 return (RuleService) getBean(RULE_SERVICE);
298 }
299
300 public static RuleDelegationService getRuleDelegationService() {
301 return (RuleDelegationService) getBean(RULE_DELEGATION_SERVICE);
302 }
303
304 public static RoutingReportService getRoutingReportService() {
305 return (RoutingReportService) getBean(ROUTING_REPORT_SERVICE);
306 }
307
308 public static PreferencesService getPreferencesService() {
309 return (PreferencesService) getBean(PREFERENCES_SERVICE);
310 }
311
312 public static XmlPollerService getXmlPollerService() {
313 return (XmlPollerService) getBean(XML_POLLER_SERVICE);
314 }
315
316 public static UserOptionsService getUserOptionsService() {
317 return (UserOptionsService) getBean(USER_OPTIONS_SRV);
318 }
319
320 public static ActionListService getActionListService() {
321 return (ActionListService) getBean(ACTION_LIST_SRV);
322 }
323
324 public static RouteNodeService getRouteNodeService() {
325 return (RouteNodeService) getBean(ROUTE_NODE_SERVICE);
326 }
327
328 public static SimulationWorkflowEngine getSimulationEngine() {
329 return (SimulationWorkflowEngine) getBean(SIMULATION_ENGINE);
330 }
331
332 public static WorkflowEngineFactory getWorkflowEngineFactory() {
333 return (WorkflowEngineFactory) getBean(WORKFLOW_ENGINE_FACTORY);
334 }
335
336 public static WorkflowDocumentExceptionRoutingService getExceptionRoutingService() {
337 return (WorkflowDocumentExceptionRoutingService) getBean(EXCEPTION_ROUTING_SERVICE);
338 }
339
340 public static ActionListEmailService getActionListEmailService() {
341 return (ActionListEmailService) getBean(KEWServiceLocator.ACTION_LIST_EMAIL_SERVICE);
342 }
343
344 public static EmailContentService getEmailContentService() {
345 return (EmailContentService) getBean(KEWServiceLocator.EMAIL_CONTENT_SERVICE);
346 }
347
348 public static NotificationService getNotificationService() {
349 return (NotificationService) getBean(KEWServiceLocator.NOTIFICATION_SERVICE);
350 }
351
352 public static TransactionManager getTransactionManager() {
353 return (TransactionManager) getBean(JTA_TRANSACTION_MANAGER);
354 }
355
356 public static UserTransaction getUserTransaction() {
357 return (UserTransaction) getBean(USER_TRANSACTION);
358 }
359
360 public static NoteService getNoteService() {
361 return (NoteService) getBean(NOTE_SERVICE);
362 }
363
364 public static ActionRegistry getActionRegistry() {
365 return (ActionRegistry) getBean(ACTION_REGISTRY);
366 }
367
368 public static EncryptionService getEncryptionService() {
369 return (EncryptionService) getBean(ENCRYPTION_SERVICE);
370 }
371
372 public static BranchService getBranchService() {
373 return (BranchService) getBean(BRANCH_SERVICE);
374 }
375
376 public static DocumentSearchService getDocumentSearchService() {
377 return (DocumentSearchService) getBean(DOCUMENT_SEARCH_SERVICE);
378 }
379
380 public static ExtractService getExtractService() {
381 return (ExtractService) getBean(EXTRACT_SERVICE);
382 }
383
384 public static IdentityHelperService getIdentityHelperService() {
385 return (IdentityHelperService) getBean(IDENTITY_HELPER_SERVICE);
386 }
387
388 public static DocumentLinkService getDocumentLinkService(){
389 return (DocumentLinkService) getBean(DOCUMENT_LINK_SERVICE);
390 }
391
392 public static Mailer getMailer(){
393 return (Mailer) getBean(MAILER);
394 }
395
396
397
398
399
400
401 public static DataSource getDataSource() {
402 return (DataSource) getBean(DATASOURCE);
403 }
404
405 public static PlatformTransactionManager getPlatformTransactionManager() {
406 return (PlatformTransactionManager) getBean(TRANSACTION_MANAGER);
407 }
408
409 public static WorkflowDocumentPrototype getWorkflowDocumentPrototype() {
410 return getBean(WORKFLOW_DOCUMENT_PROTOTYPE);
411 }
412
413 public static DocumentLookupCustomizationMediator getDocumentLookupCustomizationMediator() {
414 return getBean(DOCUMENT_LOOKUP_CUSTOMIZATION_MEDIATOR);
415 }
416
417
418 public static RuleValidationAttributeResolver getRuleValidationAttributeResolver() {
419 return getBean(RULE_VALIDATION_ATTRIBUTE_RESOLVER);
420 }
421 }