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 REMOVE_REPLACE_DOCUMENT_SERVICE = "enRemoveReplaceDocumentService";
195
196 public static final String EXTRACT_SERVICE = "enExtractService";
197
198 public static final String IDENTITY_HELPER_SERVICE = "kewIdentityHelperService";
199
200 public static final String ENTITY_MANAGER_FACTORY = "kewEntityManagerFactory";
201
202 public static final String MAILER = "mailer";
203
204 public static final String WORKFLOW_DOCUMENT_PROTOTYPE = "rice.kew.workflowDocumentPrototype";
205
206 public static final String DOCUMENT_SEARCH_CUSTOMIZATION_MEDIATOR = "rice.kew.documentSearchCustomizationMediator";
207
208 public static final String RULE_VALIDATION_ATTRIBUTE_RESOLVER = "rice.kew.ruleValidationAttributeResolver";
209
210 public static final String WORKFLOW_RULE_ATTRIBUTE_MEDIATOR = "rice.kew.workflowRuleAttributeMediator";
211
212 public static final String LOCAL_CACHE_MANAGER = "kewLocalCacheManager";
213
214 public static EntityManagerFactory getEntityManagerFactory() {
215 return (EntityManagerFactory) getService(ENTITY_MANAGER_FACTORY);
216 }
217
218
219
220
221
222
223 public static <T> T getService(String serviceName) {
224 return KEWServiceLocator.<T>getBean(serviceName);
225 }
226
227 public static <T> T getBean(String serviceName) {
228 if ( LOG.isDebugEnabled() ) {
229 LOG.debug("Fetching service " + serviceName);
230 }
231 QName name = new QName(serviceName);
232 RunMode kewRunMode = RunMode.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KEW_RUN_MODE_PROPERTY));
233 if (kewRunMode == RunMode.REMOTE || kewRunMode == RunMode.THIN) {
234 if (!serviceName.equals(WORKFLOW_DOCUMENT_PROTOTYPE)) {
235 name = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, serviceName);
236 } else {
237 name = new QName(serviceName);
238 }
239 }
240 return GlobalResourceLoader.getResourceLoader().<T>getService(name);
241 }
242
243 public static DocumentTypeService getDocumentTypeService() {
244 return (DocumentTypeService) getBean(DOCUMENT_TYPE_SERVICE);
245 }
246
247 public static DocumentTypePermissionService getDocumentTypePermissionService() {
248 return (DocumentTypePermissionService) getBean(DOCUMENT_TYPE_PERMISSION_SERVICE);
249 }
250
251 public static DocumentSecurityService getDocumentSecurityService() {
252 return (DocumentSecurityService) getBean(DOCUMENT_SECURITY_SERVICE);
253 }
254
255
256 public static ActionRequestService getActionRequestService() {
257 return (ActionRequestService) getBean(ACTION_REQUEST_SRV);
258 }
259
260 public static ActionTakenService getActionTakenService() {
261 return (ActionTakenService) getBean(ACTION_TAKEN_SRV);
262 }
263
264 public static ResponsibilityIdService getResponsibilityIdService() {
265 return (ResponsibilityIdService) getBean(RESPONSIBILITY_ID_SERVICE);
266 }
267
268 public static RouteHeaderService getRouteHeaderService() {
269 return (RouteHeaderService) getBean(DOC_ROUTE_HEADER_SRV);
270 }
271
272 public static RuleTemplateService getRuleTemplateService() {
273 return (RuleTemplateService) getBean(RULE_TEMPLATE_SERVICE);
274 }
275
276 public static RuleAttributeService getRuleAttributeService() {
277 return (RuleAttributeService) getBean(RULE_ATTRIBUTE_SERVICE);
278 }
279
280 public static WorkflowDocumentService getWorkflowDocumentService() {
281 return (WorkflowDocumentService) getBean(WORKFLOW_DOCUMENT_SERVICE);
282 }
283
284 public static RouteModuleService getRouteModuleService() {
285 return (RouteModuleService) getBean(ROUTE_MODULE_SERVICE);
286 }
287
288 public static RoleService getRoleService() {
289 return (RoleService) getBean(ROLE_SERVICE);
290 }
291
292 public static RuleServiceInternal getRuleService() {
293 return (RuleServiceInternal) getBean(RULE_SERVICE);
294 }
295
296 public static RuleDelegationService getRuleDelegationService() {
297 return (RuleDelegationService) getBean(RULE_DELEGATION_SERVICE);
298 }
299
300 public static RoutingReportService getRoutingReportService() {
301 return (RoutingReportService) getBean(ROUTING_REPORT_SERVICE);
302 }
303
304 public static XmlPollerService getXmlPollerService() {
305 return (XmlPollerService) getBean(XML_POLLER_SERVICE);
306 }
307
308 public static UserOptionsService getUserOptionsService() {
309 return (UserOptionsService) getBean(USER_OPTIONS_SRV);
310 }
311
312 public static ActionListService getActionListService() {
313 return (ActionListService) getBean(ACTION_LIST_SRV);
314 }
315
316 public static RouteNodeService getRouteNodeService() {
317 return (RouteNodeService) getBean(ROUTE_NODE_SERVICE);
318 }
319
320 public static SimulationWorkflowEngine getSimulationEngine() {
321 return (SimulationWorkflowEngine) getBean(SIMULATION_ENGINE);
322 }
323
324 public static WorkflowEngineFactory getWorkflowEngineFactory() {
325 return (WorkflowEngineFactory) getBean(WORKFLOW_ENGINE_FACTORY);
326 }
327
328 public static WorkflowDocumentExceptionRoutingService getExceptionRoutingService() {
329 return (WorkflowDocumentExceptionRoutingService) getBean(EXCEPTION_ROUTING_SERVICE);
330 }
331
332 public static ActionListEmailService getActionListEmailService() {
333 return (ActionListEmailService) getBean(KEWServiceLocator.ACTION_LIST_EMAIL_SERVICE);
334 }
335
336 public static EmailContentService getEmailContentService() {
337 return (EmailContentService) getBean(KEWServiceLocator.EMAIL_CONTENT_SERVICE);
338 }
339
340 public static NotificationService getNotificationService() {
341 return (NotificationService) getBean(KEWServiceLocator.NOTIFICATION_SERVICE);
342 }
343
344 public static TransactionManager getTransactionManager() {
345 return (TransactionManager) getBean(JTA_TRANSACTION_MANAGER);
346 }
347
348 public static UserTransaction getUserTransaction() {
349 return (UserTransaction) getBean(USER_TRANSACTION);
350 }
351
352 public static NoteService getNoteService() {
353 return (NoteService) getBean(NOTE_SERVICE);
354 }
355
356 public static ActionRegistry getActionRegistry() {
357 return (ActionRegistry) getBean(ACTION_REGISTRY);
358 }
359
360 public static BranchService getBranchService() {
361 return (BranchService) getBean(BRANCH_SERVICE);
362 }
363
364 public static DocumentSearchService getDocumentSearchService() {
365 return (DocumentSearchService) getBean(DOCUMENT_SEARCH_SERVICE);
366 }
367
368 public static ExtractService getExtractService() {
369 return (ExtractService) getBean(EXTRACT_SERVICE);
370 }
371
372 public static IdentityHelperService getIdentityHelperService() {
373 return (IdentityHelperService) getBean(IDENTITY_HELPER_SERVICE);
374 }
375
376 public static DocumentLinkService getDocumentLinkService(){
377 return (DocumentLinkService) getBean(DOCUMENT_LINK_SERVICE);
378 }
379
380
381
382
383
384
385 public static DataSource getDataSource() {
386 return (DataSource) getBean(DATASOURCE);
387 }
388
389 public static PlatformTransactionManager getPlatformTransactionManager() {
390 return (PlatformTransactionManager) getBean(TRANSACTION_MANAGER);
391 }
392
393 public static WorkflowDocumentPrototype getWorkflowDocumentPrototype() {
394 return getBean(WORKFLOW_DOCUMENT_PROTOTYPE);
395 }
396
397 public static DocumentSearchCustomizationMediator getDocumentSearchCustomizationMediator() {
398 return getBean(DOCUMENT_SEARCH_CUSTOMIZATION_MEDIATOR);
399 }
400
401 public static WorkflowRuleAttributeMediator getWorkflowRuleAttributeMediator() {
402 return getBean(WORKFLOW_RULE_ATTRIBUTE_MEDIATOR);
403 }
404
405 public static RuleValidationAttributeResolver getRuleValidationAttributeResolver() {
406 return getBean(RULE_VALIDATION_ATTRIBUTE_RESOLVER);
407 }
408
409 public static CacheManager getLocalCacheManager() {
410 return (CacheManager) getService(LOCAL_CACHE_MANAGER);
411 }
412 }