Coverage Report - org.kuali.rice.kew.service.KEWServiceLocator
 
Classes in this File Line Coverage Branch Coverage Complexity
KEWServiceLocator
0%
0/54
0%
0/8
1.087
 
 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.mail.service.ActionListEmailService;
 45  
 import org.kuali.rice.kew.mail.service.EmailContentService;
 46  
 import org.kuali.rice.kew.notes.service.NoteService;
 47  
 import org.kuali.rice.kew.notification.service.NotificationService;
 48  
 import org.kuali.rice.kew.preferences.service.PreferencesService;
 49  
 import org.kuali.rice.kew.responsibility.service.ResponsibilityIdService;
 50  
 import org.kuali.rice.kew.role.service.RoleService;
 51  
 import org.kuali.rice.kew.routeheader.service.RouteHeaderService;
 52  
 import org.kuali.rice.kew.routeheader.service.WorkflowDocumentService;
 53  
 import org.kuali.rice.kew.routemodule.service.RouteModuleService;
 54  
 import org.kuali.rice.kew.routemodule.service.RoutingReportService;
 55  
 import org.kuali.rice.kew.rule.service.RuleAttributeService;
 56  
 import org.kuali.rice.kew.rule.service.RuleDelegationService;
 57  
 import org.kuali.rice.kew.rule.service.RuleService;
 58  
 import org.kuali.rice.kew.rule.service.RuleTemplateService;
 59  
 import org.kuali.rice.kew.useroptions.UserOptionsService;
 60  
 import org.kuali.rice.kew.util.KEWConstants;
 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  
  * Convenience class that holds service names and provide methods to acquire services.  Defaults to
 72  
  * GLR for actual service acquisition.  Used to be responsible for loading and holding spring
 73  
  * application context (when it was SpringServiceLocator) but those responsibilities have been
 74  
  * moved to the SpringLoader.
 75  
  *
 76  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 77  
  *
 78  
  */
 79  0
 public final class KEWServiceLocator {
 80  
 
 81  0
         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 = "enWorkflowDataSource";
 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 PREFERENCES_SERVICE = "enPreferencesService";
 118  
 
 119  
         public static final String ROUTE_LOG_SERVICE = "enRouteLogService";
 120  
 
 121  
         public static final String RULE_TEMPLATE_SERVICE = "enRuleTemplateService";
 122  
 
 123  
         public static final String RULE_SERVICE = "enRuleService";
 124  
 
 125  
         public static final String RULE_ATTRIBUTE_SERVICE = "enRuleAttributeService";
 126  
 
 127  
         public static final String RULE_TEMPLATE_ATTRIBUTE_SERVICE = "enRuleTemplateAttributeService";
 128  
 
 129  
         public static final String ROLE_SERVICE = "enRoleService";
 130  
 
 131  
         public static final String RESPONSIBILITY_ID_SERVICE = "enResponsibilityIdService";
 132  
 
 133  
         public static final String STATS_SERVICE = "enStatsService";
 134  
 
 135  
         public static final String ROUTE_MANAGER_QUEUE_SERVICE = "enRouteManagerQueueService";
 136  
 
 137  
         public static final String ROUTE_MANAGER_CONTROLLER = "enRouteManagerController";
 138  
 
 139  
         public static final String RULE_DELEGATION_SERVICE = "enRuleDelegationService";
 140  
 
 141  
         public static final String ROUTE_MANAGER_DRIVER = "enRouteManagerDriver";
 142  
 
 143  
         public static final String OPTIMISTIC_LOCK_FAILURE_SERVICE = "enOptimisticLockFailureService";
 144  
 
 145  
         public static final String NOTE_SERVICE = "enNoteService";
 146  
 
 147  
         public static final String ROUTING_REPORT_SERVICE = "enRoutingReportService";
 148  
 
 149  
         public static final String ROUTE_MODULE_SERVICE = "enRouteModuleService";
 150  
 
 151  
         public static final String EXCEPTION_ROUTING_SERVICE = "enExceptionRoutingService";
 152  
 
 153  
         public static final String ACTION_REGISTRY = "enActionRegistry";
 154  
 
 155  
         public static final String BRANCH_SERVICE = "enBranchService";
 156  
 
 157  
         public static final String WORKFLOW_MBEAN = "workflowMBean";
 158  
 
 159  
         public static final String APPLICATION_CONSTANTS_CACHE = "applicationConstantsCache";
 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  
          * Polls for xml files on disk
 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 WORKFLOW_ENGINE = "workflowEngine";
 179  
 
 180  
     public static final String SIMULATION_ENGINE = "simulationEngine";
 181  
         
 182  
         public static final String BLANKET_APPROVE_ENGINE_FACTORY = "blanketApproveEngineFactory";
 183  
 
 184  
         public static final String ACTION_LIST_EMAIL_SERVICE = "enActionListEmailService";
 185  
 
 186  
         public static final String IMMEDIATE_EMAIL_REMINDER_SERVICE = "enImmediateEmailReminderService";
 187  
 
 188  
     public static final String EMAIL_CONTENT_SERVICE = "enEmailContentService";
 189  
 
 190  
         public static final String NOTIFICATION_SERVICE = "enNotificationService";
 191  
 
 192  
         public static final String TRANSACTION_MANAGER = "transactionManager";
 193  
 
 194  
         public static final String TRANSACTION_TEMPLATE = "transactionTemplate";
 195  
 
 196  
         public static final String HELP_SERVICE = "enHelpService";
 197  
 
 198  
         public static final String WORKFLOW_DOCUMENT_SERVICE = "enWorkflowDocumentService";
 199  
 
 200  
         public static final String EXTENSION_SERVICE = "enExtensionService";
 201  
 
 202  
         public static final String TRANSFORMATION_SERVICE = "enTransformationService";
 203  
 
 204  
         public static final String ENCRYPTION_SERVICE = "enEncryptionService";
 205  
 
 206  
         public static final String REMOVE_REPLACE_DOCUMENT_SERVICE = "enRemoveReplaceDocumentService";
 207  
 
 208  
         public static final String EXTRACT_SERVICE = "enExtractService";
 209  
         
 210  
         public static final String IDENTITY_HELPER_SERVICE = "kewIdentityHelperService";
 211  
 
 212  
         public static final String ENTITY_MANAGER_FACTORY = "kewEntityManagerFactory";
 213  
         
 214  
         public static final String MAILER = "mailer";
 215  
 
 216  
 
 217  
     public static EntityManagerFactory getEntityManagerFactory() {
 218  0
         return (EntityManagerFactory) getService(ENTITY_MANAGER_FACTORY);
 219  
     }
 220  
         
 221  
         
 222  
         /**
 223  
          * @param serviceName
 224  
          *            the name of the service bean
 225  
          * @return the service
 226  
          */
 227  
         public static Object getService(String serviceName) {
 228  0
                 return getBean(serviceName);
 229  
         }
 230  
         
 231  
         public static Object getBean(String serviceName) {
 232  0
                 if ( LOG.isDebugEnabled() ) {
 233  0
                         LOG.debug("Fetching service " + serviceName);
 234  
                 }
 235  0
                 return GlobalResourceLoader.getResourceLoader().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  0
                 if ( LOG.isDebugEnabled() ) {
 242  0
                         LOG.debug("Fetching service " + KEWConstants.WORKFLOW_UTILITY_SERVICE);
 243  
                 }
 244  0
                 return (WorkflowUtility) GlobalResourceLoader.getResourceLoader().getService(new QName(KEWConstants.WORKFLOW_UTILITY_SERVICE));
 245  
         }
 246  
 
 247  
         public static WorkflowDocumentActions getWorkflowDocumentActionsService() {
 248  0
                 if ( LOG.isDebugEnabled() ) {
 249  0
                         LOG.debug("Fetching service " + KEWConstants.WORKFLOW_DOCUMENT_ACTIONS_SERVICE);
 250  
                 }
 251  0
                 return (WorkflowDocumentActions) GlobalResourceLoader.getResourceLoader().getService(new QName(KEWConstants.WORKFLOW_DOCUMENT_ACTIONS_SERVICE));
 252  
         }
 253  
 
 254  
         public static DocumentTypeService getDocumentTypeService() {
 255  0
                 return (DocumentTypeService) getBean(DOCUMENT_TYPE_SERVICE);
 256  
         }
 257  
 
 258  
         public static DocumentTypePermissionService getDocumentTypePermissionService() {
 259  0
                 return (DocumentTypePermissionService) getBean(DOCUMENT_TYPE_PERMISSION_SERVICE);
 260  
         }
 261  
         
 262  
     public static DocumentSecurityService getDocumentSecurityService() {
 263  0
             return (DocumentSecurityService) getBean(DOCUMENT_SECURITY_SERVICE);
 264  
     }
 265  
 
 266  
 
 267  
         public static ActionRequestService getActionRequestService() {
 268  0
                 return (ActionRequestService) getBean(ACTION_REQUEST_SRV);
 269  
         }
 270  
 
 271  
         public static ActionTakenService getActionTakenService() {
 272  0
                 return (ActionTakenService) getBean(ACTION_TAKEN_SRV);
 273  
         }
 274  
 
 275  
         public static ResponsibilityIdService getResponsibilityIdService() {
 276  0
                 return (ResponsibilityIdService) getBean(RESPONSIBILITY_ID_SERVICE);
 277  
         }
 278  
 
 279  
         public static RouteHeaderService getRouteHeaderService() {
 280  0
                 return (RouteHeaderService) getBean(DOC_ROUTE_HEADER_SRV);
 281  
         }
 282  
 
 283  
         public static RuleTemplateService getRuleTemplateService() {
 284  0
                 return (RuleTemplateService) getBean(RULE_TEMPLATE_SERVICE);
 285  
         }
 286  
 
 287  
         public static RuleAttributeService getRuleAttributeService() {
 288  0
                 return (RuleAttributeService) getBean(RULE_ATTRIBUTE_SERVICE);
 289  
         }
 290  
 
 291  
         public static WorkflowDocumentService getWorkflowDocumentService() {
 292  0
                 return (WorkflowDocumentService) getBean(WORKFLOW_DOCUMENT_SERVICE);
 293  
         }
 294  
 
 295  
         public static RouteModuleService getRouteModuleService() {
 296  0
                 return (RouteModuleService) getBean(ROUTE_MODULE_SERVICE);
 297  
         }
 298  
 
 299  
         public static RoleService getRoleService() {
 300  0
                 return (RoleService) getBean(ROLE_SERVICE);
 301  
         }
 302  
 
 303  
         public static RuleService getRuleService() {
 304  0
                 return (RuleService) getBean(RULE_SERVICE);
 305  
         }
 306  
 
 307  
         public static RuleDelegationService getRuleDelegationService() {
 308  0
                 return (RuleDelegationService) getBean(RULE_DELEGATION_SERVICE);
 309  
         }
 310  
 
 311  
         public static HelpService getHelpService() {
 312  0
                 return (HelpService) getBean(HELP_SERVICE);
 313  
         }
 314  
 
 315  
         public static RoutingReportService getRoutingReportService() {
 316  0
                 return (RoutingReportService) getBean(ROUTING_REPORT_SERVICE);
 317  
         }
 318  
 
 319  
         public static PreferencesService getPreferencesService() {
 320  0
                 return (PreferencesService) getBean(PREFERENCES_SERVICE);
 321  
         }
 322  
 
 323  
         public static XmlPollerService getXmlPollerService() {
 324  0
                 return (XmlPollerService) getBean(XML_POLLER_SERVICE);
 325  
         }
 326  
 
 327  
         public static UserOptionsService getUserOptionsService() {
 328  0
                 return (UserOptionsService) getBean(USER_OPTIONS_SRV);
 329  
         }
 330  
 
 331  
         public static ActionListService getActionListService() {
 332  0
                 return (ActionListService) getBean(ACTION_LIST_SRV);
 333  
         }
 334  
 
 335  
         public static RouteNodeService getRouteNodeService() {
 336  0
                 return (RouteNodeService) getBean(ROUTE_NODE_SERVICE);
 337  
         }
 338  
 
 339  
         public static WorkflowEngine getWorkflowEngine() {
 340  0
                 return (WorkflowEngine) getBean(WORKFLOW_ENGINE);
 341  
         }
 342  
 
 343  
     public static SimulationWorkflowEngine getSimulationEngine() {
 344  0
                 return (SimulationWorkflowEngine) getBean(SIMULATION_ENGINE);
 345  
         }
 346  
 
 347  
         public static BlanketApproveEngineFactory getBlanketApproveEngineFactory() {
 348  0
                 return (BlanketApproveEngineFactory) getBean(BLANKET_APPROVE_ENGINE_FACTORY);
 349  
         }
 350  
 
 351  
         public static WorkflowDocumentExceptionRoutingService getExceptionRoutingService() {
 352  0
                 return (WorkflowDocumentExceptionRoutingService) getBean(EXCEPTION_ROUTING_SERVICE);
 353  
         }
 354  
 
 355  
         public static ActionListEmailService getActionListEmailService() {
 356  0
                 return (ActionListEmailService) getBean(KEWServiceLocator.ACTION_LIST_EMAIL_SERVICE);
 357  
         }
 358  
 
 359  
     public static EmailContentService getEmailContentService() {
 360  0
         return (EmailContentService) getBean(KEWServiceLocator.EMAIL_CONTENT_SERVICE);
 361  
     }
 362  
 
 363  
     public static NotificationService getNotificationService() {
 364  0
                 return (NotificationService) getBean(KEWServiceLocator.NOTIFICATION_SERVICE);
 365  
         }
 366  
 
 367  
         public static TransactionManager getTransactionManager() {
 368  0
                 return (TransactionManager) getBean(JTA_TRANSACTION_MANAGER);
 369  
         }
 370  
 
 371  
         public static UserTransaction getUserTransaction() {
 372  0
                 return (UserTransaction) getBean(USER_TRANSACTION);
 373  
         }
 374  
 
 375  
         public static NoteService getNoteService() {
 376  0
                 return (NoteService) getBean(NOTE_SERVICE);
 377  
         }
 378  
 
 379  
         public static ActionRegistry getActionRegistry() {
 380  0
                 return (ActionRegistry) getBean(ACTION_REGISTRY);
 381  
         }
 382  
 
 383  
     public static EncryptionService getEncryptionService() {
 384  0
                 return (EncryptionService) getBean(ENCRYPTION_SERVICE);
 385  
         }
 386  
 
 387  
     public static BranchService getBranchService() {
 388  0
         return (BranchService) getBean(BRANCH_SERVICE);
 389  
     }
 390  
 
 391  
     public static DocumentSearchService getDocumentSearchService() {
 392  0
             return (DocumentSearchService) getBean(DOCUMENT_SEARCH_SERVICE);
 393  
     }
 394  
 
 395  
     public static ExtractService getExtractService() {
 396  0
         return (ExtractService) getBean(EXTRACT_SERVICE);
 397  
     }
 398  
 
 399  
     public static IdentityHelperService getIdentityHelperService() {
 400  0
             return (IdentityHelperService) getBean(IDENTITY_HELPER_SERVICE);
 401  
     }
 402  
     
 403  
     public static DocumentLinkService getDocumentLinkService(){
 404  0
             return (DocumentLinkService) getBean(DOCUMENT_LINK_SERVICE);
 405  
     }
 406  
     
 407  
     public static Mailer getMailer(){
 408  0
             return (Mailer) getBean(MAILER);
 409  
     }
 410  
     
 411  
     /**
 412  
      * For the following methods, we go directly to the SpringLoader because we do NOT want them to
 413  
      * be wrapped in any sort of proxy.
 414  
      */
 415  
 
 416  
     public static DataSource getDataSource() {
 417  0
         return (DataSource) getBean(DATASOURCE);
 418  
     }
 419  
 
 420  
     public static PlatformTransactionManager getPlatformTransactionManager() {
 421  0
         return (PlatformTransactionManager) getBean(TRANSACTION_MANAGER);
 422  
     }
 423  
 }