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