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