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 2007 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in
 5  
  * compliance with the License. You may obtain a copy of the License at
 6  
  * 
 7  
  * http://www.opensource.org/licenses/ecl2.php
 8  
  * 
 9  
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
 10  
  * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
 11  
  * language governing permissions and limitations under the License.
 12  
  */
 13  
 package org.kuali.rice.ksb.messaging.serviceproxies;
 14  
 
 15  
 import org.kuali.rice.core.config.Config;
 16  
 import org.kuali.rice.core.config.ConfigContext;
 17  
 import org.kuali.rice.core.util.RiceConstants;
 18  
 import org.kuali.rice.ksb.messaging.MessageServiceInvoker;
 19  
 import org.kuali.rice.ksb.messaging.PersistedMessage;
 20  
 import org.kuali.rice.ksb.service.KSBServiceLocator;
 21  
 import org.kuali.rice.ksb.util.KSBConstants;
 22  
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 23  
 
 24  
 
 25  
 /**
 26  
  * Responsible for implementing policy to put message into threadpool for execution appropriately. Could make Spring and
 27  
  * overridable service.
 28  
  * 
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  * 
 31  
  */
 32  0
 public class MessageSender {
 33  
 
 34  
     public static void sendMessage(PersistedMessage message) throws Exception {
 35  0
         if (!new Boolean(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.MESSAGING_OFF))) {
 36  
 
 37  0
             if (ConfigContext.getCurrentContextConfig().getObject(RiceConstants.SPRING_TRANSACTION_MANAGER) != null
 38  
                     || ConfigContext.getCurrentContextConfig().getObject(RiceConstants.TRANSACTION_MANAGER_OBJ) != null) {
 39  0
                 if (TransactionSynchronizationManager.isSynchronizationActive()) {
 40  0
                     TransactionSynchronizationManager.registerSynchronization(new MessageSendingTransactionSynchronization(
 41  
                             message));
 42  
                 } else {
 43  0
                     KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message));
 44  
                 }
 45  
             } else {
 46  0
                 KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message));
 47  
             }
 48  
         }
 49  0
     }
 50  
 
 51  
 }