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