Coverage Report - org.kuali.rice.ksb.messaging.serviceproxies.MessageSender
 
Classes in this File Line Coverage Branch Coverage Complexity
MessageSender
0%
0/8
0%
0/8
5
 
 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.ksb.messaging.serviceproxies;
 18  
 
 19  
 import org.kuali.rice.core.api.config.property.ConfigContext;
 20  
 import org.kuali.rice.core.util.RiceConstants;
 21  
 import org.kuali.rice.ksb.messaging.MessageServiceInvoker;
 22  
 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
 23  
 import org.kuali.rice.ksb.service.KSBServiceLocator;
 24  
 import org.kuali.rice.ksb.util.KSBConstants;
 25  
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 26  
 
 27  
 
 28  
 /**
 29  
  * Responsible for implementing policy to put message into threadpool for execution appropriately. Could make Spring and
 30  
  * overridable service.
 31  
  * 
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  * 
 34  
  */
 35  0
 public class MessageSender {
 36  
 
 37  
     public static void sendMessage(PersistedMessageBO message) throws Exception {
 38  0
         if (!Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.MESSAGING_OFF))) {
 39  
 
 40  0
             if (ConfigContext.getCurrentContextConfig().getObject(RiceConstants.SPRING_TRANSACTION_MANAGER) != null
 41  
                     || ConfigContext.getCurrentContextConfig().getObject(RiceConstants.TRANSACTION_MANAGER_OBJ) != null) {
 42  0
                 if (TransactionSynchronizationManager.isSynchronizationActive()) {
 43  0
                     TransactionSynchronizationManager.registerSynchronization(new MessageSendingTransactionSynchronization(
 44  
                             message));
 45  
                 } else {
 46  0
                     KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message));
 47  
                 }
 48  
             } else {
 49  0
                 KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message));
 50  
             }
 51  
         }
 52  0
     }
 53  
 
 54  
 }