Coverage Report - org.kuali.rice.ksb.messaging.serviceproxies.MessageSendingTransactionSynchronization
 
Classes in this File Line Coverage Branch Coverage Complexity
MessageSendingTransactionSynchronization
0%
0/18
0%
0/2
1.125
 
 1  
 /*
 2  
  * Copyright 2007-2008 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.ksb.messaging.serviceproxies;
 17  
 
 18  
 import org.apache.log4j.Logger;
 19  
 import org.kuali.rice.ksb.messaging.MessageServiceInvoker;
 20  
 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
 21  
 import org.kuali.rice.ksb.service.KSBServiceLocator;
 22  
 import org.springframework.transaction.support.TransactionSynchronization;
 23  
 
 24  
 
 25  
 /**
 26  
  * Sends message when current transaction commits.  
 27  
  * 
 28  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 29  
  *
 30  
  */
 31  
 public class MessageSendingTransactionSynchronization implements TransactionSynchronization {
 32  
     
 33  0
     private static final Logger LOG = Logger.getLogger(MessageSendingTransactionSynchronization.class);
 34  
 
 35  
     //this is to verify this was called without implementing some sort of plugability in this 
 36  
     //layer of the code for the tests.
 37  0
     public static boolean CALLED_TRANS_COMMITTED = false;
 38  0
     public static boolean CALLED_TRANS_ROLLEDBACKED = false;
 39  
     
 40  
     private PersistedMessageBO message;
 41  
     
 42  0
     public MessageSendingTransactionSynchronization(PersistedMessageBO message) {
 43  0
         this.message = message;
 44  0
     }
 45  
 
 46  
     public void afterCommit() {
 47  
 
 48  0
     }
 49  
 
 50  
     public void afterCompletion(int status) {
 51  0
         if (status == STATUS_COMMITTED) {
 52  0
             KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message));
 53  0
             CALLED_TRANS_COMMITTED = true;
 54  
         } else {
 55  0
             LOG.info("Message " + message + " not sent because transaction not committed.");
 56  0
             CALLED_TRANS_ROLLEDBACKED = true;
 57  
         }
 58  0
     }
 59  
 
 60  
     public void beforeCommit(boolean readOnly) {
 61  0
     }
 62  
 
 63  
     public void beforeCompletion() {
 64  0
     }
 65  
 
 66  
     public void resume() {
 67  0
     }
 68  
 
 69  
     public void suspend() {
 70  0
     }
 71  
     
 72  
     public void flush() {
 73  0
     }
 74  
 
 75  
 }