Coverage Report - org.kuali.rice.kew.service.KEWServiceLocator
 
Classes in this File Line Coverage Branch Coverage Complexity
KEWServiceLocator
0%
0/49
0%
0/4
1.044
 
 1  
 /**
 2  
  * Copyright 2005-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  
 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.core.mail.Mailer;
 24  
 import org.kuali.rice.edl.framework.extract.ExtractService;
 25  
 import org.kuali.rice.kew.actionlist.service.ActionListService;
 26  
 import org.kuali.rice.kew.actionrequest.service.ActionRequestService;
 27  
 import org.kuali.rice.kew.actions.ActionRegistry;
 28  
 import org.kuali.rice.kew.actiontaken.service.ActionTakenService;
 29  
 import org.kuali.rice.kew.api.KewApiConstants;
 30  
 import org.kuali.rice.kew.batch.XmlPollerService;
 31  
 import org.kuali.rice.kew.docsearch.DocumentSearchCustomizationMediator;
 32  
 import org.kuali.rice.kew.docsearch.service.DocumentSearchService;
 33  
 import org.kuali.rice.kew.doctype.service.DocumentSecurityService;
 34  
 import org.kuali.rice.kew.doctype.service.DocumentTypePermissionService;
 35  
 import org.kuali.rice.kew.doctype.service.DocumentTypeService;
 36  
 import org.kuali.rice.kew.documentlink.service.DocumentLinkService;
 37  
 import org.kuali.rice.kew.engine.WorkflowEngineFactory;
 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.identity.service.IdentityHelperService;
 43  
 import org.kuali.rice.kew.impl.document.WorkflowDocumentPrototype;
 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.responsibility.service.ResponsibilityIdService;
 49  
 import org.kuali.rice.kew.role.service.RoleService;
 50  
 import org.kuali.rice.kew.routeheader.service.RouteHeaderService;
 51  
 import org.kuali.rice.kew.routeheader.service.WorkflowDocumentService;
 52  
 import org.kuali.rice.kew.routemodule.service.RouteModuleService;
 53  
 import org.kuali.rice.kew.routemodule.service.RoutingReportService;
 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  
  * 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 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  
          * Polls for xml files on disk
 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 LOCAL_CACHE_MANAGER = "kimLocalCacheManager";
 213  
 
 214  
     public static EntityManagerFactory getEntityManagerFactory() {
 215  0
         return (EntityManagerFactory) getService(ENTITY_MANAGER_FACTORY);
 216  
     }
 217  
                 
 218  
         /**
 219  
          * @param serviceName
 220  
          *            the name of the service bean
 221  
          * @return the service
 222  
          */
 223  
         public static <T> T getService(String serviceName) {
 224  0
                 return KEWServiceLocator.<T>getBean(serviceName);
 225  
         }
 226  
         
 227  
         public static <T> T getBean(String serviceName) {
 228  0
                 if ( LOG.isDebugEnabled() ) {
 229  0
                         LOG.debug("Fetching service " + serviceName);
 230  
                 }
 231  0
                 return GlobalResourceLoader.getResourceLoader().<T>getService(
 232  
                                 (RunMode.REMOTE.equals(RunMode.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KEW_RUN_MODE_PROPERTY)))) ?
 233  
                                                 new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, serviceName) : new QName(serviceName));
 234  
         }
 235  
 
 236  
         public static DocumentTypeService getDocumentTypeService() {
 237  0
                 return (DocumentTypeService) getBean(DOCUMENT_TYPE_SERVICE);
 238  
         }
 239  
 
 240  
         public static DocumentTypePermissionService getDocumentTypePermissionService() {
 241  0
                 return (DocumentTypePermissionService) getBean(DOCUMENT_TYPE_PERMISSION_SERVICE);
 242  
         }
 243  
         
 244  
     public static DocumentSecurityService getDocumentSecurityService() {
 245  0
             return (DocumentSecurityService) getBean(DOCUMENT_SECURITY_SERVICE);
 246  
     }
 247  
 
 248  
 
 249  
         public static ActionRequestService getActionRequestService() {
 250  0
                 return (ActionRequestService) getBean(ACTION_REQUEST_SRV);
 251  
         }
 252  
 
 253  
         public static ActionTakenService getActionTakenService() {
 254  0
                 return (ActionTakenService) getBean(ACTION_TAKEN_SRV);
 255  
         }
 256  
 
 257  
         public static ResponsibilityIdService getResponsibilityIdService() {
 258  0
                 return (ResponsibilityIdService) getBean(RESPONSIBILITY_ID_SERVICE);
 259  
         }
 260  
 
 261  
         public static RouteHeaderService getRouteHeaderService() {
 262  0
                 return (RouteHeaderService) getBean(DOC_ROUTE_HEADER_SRV);
 263  
         }
 264  
 
 265  
         public static RuleTemplateService getRuleTemplateService() {
 266  0
                 return (RuleTemplateService) getBean(RULE_TEMPLATE_SERVICE);
 267  
         }
 268  
 
 269  
         public static RuleAttributeService getRuleAttributeService() {
 270  0
                 return (RuleAttributeService) getBean(RULE_ATTRIBUTE_SERVICE);
 271  
         }
 272  
 
 273  
         public static WorkflowDocumentService getWorkflowDocumentService() {
 274  0
                 return (WorkflowDocumentService) getBean(WORKFLOW_DOCUMENT_SERVICE);
 275  
         }
 276  
 
 277  
         public static RouteModuleService getRouteModuleService() {
 278  0
                 return (RouteModuleService) getBean(ROUTE_MODULE_SERVICE);
 279  
         }
 280  
 
 281  
         public static RoleService getRoleService() {
 282  0
                 return (RoleService) getBean(ROLE_SERVICE);
 283  
         }
 284  
 
 285  
         public static RuleServiceInternal getRuleService() {
 286  0
                 return (RuleServiceInternal) getBean(RULE_SERVICE);
 287  
         }
 288  
 
 289  
         public static RuleDelegationService getRuleDelegationService() {
 290  0
                 return (RuleDelegationService) getBean(RULE_DELEGATION_SERVICE);
 291  
         }
 292  
 
 293  
         public static RoutingReportService getRoutingReportService() {
 294  0
                 return (RoutingReportService) getBean(ROUTING_REPORT_SERVICE);
 295  
         }
 296  
 
 297  
         public static XmlPollerService getXmlPollerService() {
 298  0
                 return (XmlPollerService) getBean(XML_POLLER_SERVICE);
 299  
         }
 300  
 
 301  
         public static UserOptionsService getUserOptionsService() {
 302  0
                 return (UserOptionsService) getBean(USER_OPTIONS_SRV);
 303  
         }
 304  
 
 305  
         public static ActionListService getActionListService() {
 306  0
                 return (ActionListService) getBean(ACTION_LIST_SRV);
 307  
         }
 308  
 
 309  
         public static RouteNodeService getRouteNodeService() {
 310  0
                 return (RouteNodeService) getBean(ROUTE_NODE_SERVICE);
 311  
         }
 312  
 
 313  
     public static SimulationWorkflowEngine getSimulationEngine() {
 314  0
                 return (SimulationWorkflowEngine) getBean(SIMULATION_ENGINE);
 315  
         }
 316  
 
 317  
         public static WorkflowEngineFactory getWorkflowEngineFactory() {
 318  0
                 return (WorkflowEngineFactory) getBean(WORKFLOW_ENGINE_FACTORY);
 319  
         }
 320  
 
 321  
         public static WorkflowDocumentExceptionRoutingService getExceptionRoutingService() {
 322  0
                 return (WorkflowDocumentExceptionRoutingService) getBean(EXCEPTION_ROUTING_SERVICE);
 323  
         }
 324  
 
 325  
         public static ActionListEmailService getActionListEmailService() {
 326  0
                 return (ActionListEmailService) getBean(KEWServiceLocator.ACTION_LIST_EMAIL_SERVICE);
 327  
         }
 328  
 
 329  
     public static EmailContentService getEmailContentService() {
 330  0
         return (EmailContentService) getBean(KEWServiceLocator.EMAIL_CONTENT_SERVICE);
 331  
     }
 332  
 
 333  
     public static NotificationService getNotificationService() {
 334  0
                 return (NotificationService) getBean(KEWServiceLocator.NOTIFICATION_SERVICE);
 335  
         }
 336  
 
 337  
         public static TransactionManager getTransactionManager() {
 338  0
                 return (TransactionManager) getBean(JTA_TRANSACTION_MANAGER);
 339  
         }
 340  
 
 341  
         public static UserTransaction getUserTransaction() {
 342  0
                 return (UserTransaction) getBean(USER_TRANSACTION);
 343  
         }
 344  
 
 345  
         public static NoteService getNoteService() {
 346  0
                 return (NoteService) getBean(NOTE_SERVICE);
 347  
         }
 348  
 
 349  
         public static ActionRegistry getActionRegistry() {
 350  0
                 return (ActionRegistry) getBean(ACTION_REGISTRY);
 351  
         }
 352  
 
 353  
     public static EncryptionService getEncryptionService() {
 354  0
                 return (EncryptionService) getBean(ENCRYPTION_SERVICE);
 355  
         }
 356  
 
 357  
     public static BranchService getBranchService() {
 358  0
         return (BranchService) getBean(BRANCH_SERVICE);
 359  
     }
 360  
 
 361  
     public static DocumentSearchService getDocumentSearchService() {
 362  0
             return (DocumentSearchService) getBean(DOCUMENT_SEARCH_SERVICE);
 363  
     }
 364  
 
 365  
     public static ExtractService getExtractService() {
 366  0
         return (ExtractService) getBean(EXTRACT_SERVICE);
 367  
     }
 368  
 
 369  
     public static IdentityHelperService getIdentityHelperService() {
 370  0
             return (IdentityHelperService) getBean(IDENTITY_HELPER_SERVICE);
 371  
     }
 372  
     
 373  
     public static DocumentLinkService getDocumentLinkService(){
 374  0
             return (DocumentLinkService) getBean(DOCUMENT_LINK_SERVICE);
 375  
     }
 376  
     
 377  
     public static Mailer getMailer(){
 378  0
             return (Mailer) getBean(MAILER);
 379  
     }
 380  
     
 381  
     /**
 382  
      * For the following methods, we go directly to the SpringLoader because we do NOT want them to
 383  
      * be wrapped in any sort of proxy.
 384  
      */
 385  
 
 386  
     public static DataSource getDataSource() {
 387  0
         return (DataSource) getBean(DATASOURCE);
 388  
     }
 389  
 
 390  
     public static PlatformTransactionManager getPlatformTransactionManager() {
 391  0
         return (PlatformTransactionManager) getBean(TRANSACTION_MANAGER);
 392  
     }
 393  
     
 394  
     public static WorkflowDocumentPrototype getWorkflowDocumentPrototype() {
 395  0
             return getBean(WORKFLOW_DOCUMENT_PROTOTYPE);
 396  
     }
 397  
 
 398  
     public static DocumentSearchCustomizationMediator getDocumentSearchCustomizationMediator() {
 399  0
         return getBean(DOCUMENT_SEARCH_CUSTOMIZATION_MEDIATOR);
 400  
     }
 401  
 
 402  
 
 403  
     public static RuleValidationAttributeResolver getRuleValidationAttributeResolver() {
 404  0
         return getBean(RULE_VALIDATION_ATTRIBUTE_RESOLVER);
 405  
     }
 406  
 
 407  
     public static CacheManager getLocalCacheManager() {
 408  0
         return (CacheManager) getService(LOCAL_CACHE_MANAGER);
 409  
     }
 410  
 }