Coverage Report - org.kuali.rice.kns.util.spring.KualiTransactionInterceptor
 
Classes in this File Line Coverage Branch Coverage Complexity
KualiTransactionInterceptor
0%
0/38
0%
0/36
7
 
 1  
 /*
 2  
  * Copyright 2006-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.kns.util.spring;
 17  
 
 18  
 import java.lang.reflect.Method;
 19  
 
 20  
 import org.apache.log4j.Logger;
 21  
 import org.springframework.transaction.TransactionStatus;
 22  
 import org.springframework.transaction.support.DefaultTransactionStatus;
 23  
 
 24  0
 public class KualiTransactionInterceptor extends org.springframework.transaction.interceptor.TransactionInterceptor {
 25  0
     private static final Logger LOG = Logger.getLogger(KualiTransactionInterceptor.class);
 26  
 
 27  
 
 28  
     /**
 29  
      * @see org.springframework.transaction.interceptor.TransactionAspectSupport#createTransactionIfNecessary(java.lang.reflect.Method,
 30  
      *      java.lang.Class)
 31  
      */
 32  
     protected TransactionInfo createTransactionIfNecessary(Method method, Class targetClass) {
 33  0
         TransactionInfo txInfo = super.createTransactionIfNecessary(method, targetClass);
 34  
 
 35  
         // using INFO level since DEBUG level turns on the (somewhat misleading) log statements of the superclass
 36  0
         if (logger.isInfoEnabled()) {
 37  0
             if (txInfo != null) {
 38  0
                 TransactionStatus txStatus = txInfo.getTransactionStatus();
 39  0
                 if (txStatus != null) {
 40  0
                     if (txStatus.isNewTransaction()) {
 41  0
                         LOG.info("creating explicit transaction for " + txInfo.getJoinpointIdentification());
 42  
                     }
 43  
                     else {
 44  0
                         if (txStatus instanceof DefaultTransactionStatus) {
 45  0
                             DefaultTransactionStatus dtxStatus = (DefaultTransactionStatus) txStatus;
 46  
 
 47  0
                             if (dtxStatus.isNewSynchronization()) {
 48  0
                                 LOG.info("creating implicit transaction for " + txInfo.getJoinpointIdentification());
 49  
                             }
 50  
                         }
 51  
                     }
 52  
                 }
 53  
             }
 54  
         }
 55  
 
 56  0
         return txInfo;
 57  
     }
 58  
 
 59  
     /**
 60  
      * @see org.springframework.transaction.interceptor.TransactionAspectSupport#doCloseTransactionAfterThrowing(org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo,
 61  
      *      java.lang.Throwable)
 62  
      */
 63  
     protected void doCloseTransactionAfterThrowing(TransactionInfo txInfo, Throwable ex) {
 64  
         // using INFO level since DEBUG level turns on the (somewhat misleading) log statements of the superclass
 65  0
         if (logger.isInfoEnabled()) {
 66  0
             if (txInfo != null) {
 67  0
                 TransactionStatus txStatus = txInfo.getTransactionStatus();
 68  0
                 if (txStatus != null) {
 69  0
                     if (txStatus.isNewTransaction()) {
 70  0
                         LOG.info("closing explicit transaction for " + txInfo.getJoinpointIdentification());
 71  
                     }
 72  
                     else {
 73  0
                         if (txStatus instanceof DefaultTransactionStatus) {
 74  0
                             DefaultTransactionStatus dtxStatus = (DefaultTransactionStatus) txStatus;
 75  
 
 76  0
                             if (dtxStatus.isNewSynchronization()) {
 77  0
                                 LOG.info("closing implicit transaction for " + txInfo.getJoinpointIdentification());
 78  
                             }
 79  
                         }
 80  
                     }
 81  
                 }
 82  
             }
 83  
         }
 84  
 
 85  0
         super.completeTransactionAfterThrowing(txInfo, ex);
 86  0
     }
 87  
 
 88  
     /**
 89  
      * @see org.springframework.transaction.interceptor.TransactionAspectSupport#doCommitTransactionAfterReturning(org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo)
 90  
      */
 91  
     protected void doCommitTransactionAfterReturning(TransactionInfo txInfo) {
 92  
         // using INFO level since DEBUG level turns on the (somewhat misleading) log statements of the superclass
 93  0
         if (logger.isInfoEnabled()) {
 94  0
             if (txInfo != null) {
 95  0
                 TransactionStatus txStatus = txInfo.getTransactionStatus();
 96  0
                 if (txStatus != null) {
 97  0
                     if (txStatus.isNewTransaction()) {
 98  0
                         LOG.info("committing explicit transaction for " + txInfo.getJoinpointIdentification());
 99  
                     }
 100  
                     else {
 101  0
                         if (txStatus instanceof DefaultTransactionStatus) {
 102  0
                             DefaultTransactionStatus dtxStatus = (DefaultTransactionStatus) txStatus;
 103  
 
 104  0
                             if (dtxStatus.isNewSynchronization()) {
 105  0
                                 LOG.info("committing implicit transaction for " + txInfo.getJoinpointIdentification());
 106  
                             }
 107  
                         }
 108  
                     }
 109  
                 }
 110  
             }
 111  
         }
 112  
 
 113  0
         super.commitTransactionAfterReturning(txInfo);
 114  0
     }
 115  
 }