Coverage Report - org.mule.impl.internal.notifications.TransactionNotification
 
Classes in this File Line Coverage Branch Coverage Complexity
TransactionNotification
70%
7/10
50%
1/2
1.5
 
 1  
 /*
 2  
  * $Id: TransactionNotification.java 8037 2007-08-24 07:59:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.impl.internal.notifications;
 12  
 
 13  
 import org.mule.umo.UMOTransaction;
 14  
 import org.mule.umo.manager.UMOServerNotification;
 15  
 
 16  
 public class TransactionNotification extends UMOServerNotification implements BlockingServerEvent
 17  
 {
 18  
     /**
 19  
      * Serial version
 20  
      */
 21  
     private static final long serialVersionUID = -3245036187011582121L;
 22  
     public static final int TRANSACTION_BEGAN = TRANSACTION_EVENT_ACTION_START_RANGE + 1;
 23  
     public static final int TRANSACTION_COMMITTED = TRANSACTION_EVENT_ACTION_START_RANGE + 2;
 24  
     public static final int TRANSACTION_ROLLEDBACK = TRANSACTION_EVENT_ACTION_START_RANGE + 3;
 25  
 
 26  2
     private static final transient String[] ACTIONS = new String[] {"begin", "commit", "rollback"};
 27  
 
 28  
     /**
 29  
      * Ideally, that should've been a transaction's XID, but we'd need to resort to all kinds of reflection
 30  
      * tricks to get it. Still, toString() typically outputs a class name followed by the
 31  
      * XID, so that's good enough.
 32  
      */
 33  
     private String transactionStringId;
 34  
 
 35  
     public TransactionNotification(UMOTransaction transaction, int action)
 36  
     {
 37  6
         super(transaction, action);
 38  6
         this.transactionStringId = transaction.toString();
 39  6
     }
 40  
 
 41  
     public String getTransactionStringId()
 42  
     {
 43  0
         return this.transactionStringId;
 44  
     }
 45  
 
 46  
     protected String getActionName(int action)
 47  
     {
 48  6
         int i = action - TRANSACTION_EVENT_ACTION_START_RANGE;
 49  6
         if (i - 1 > ACTIONS.length)
 50  
         {
 51  0
             return String.valueOf(action);
 52  
         }
 53  6
         return ACTIONS[i - 1];
 54  
     }
 55  
 
 56  
     public String toString()
 57  
     {
 58  0
         return EVENT_NAME + "{" + "action=" + getActionName(action) + ", transactionStringId=" + transactionStringId
 59  
                + ", timestamp=" + timestamp + "}";
 60  
     }
 61  
 
 62  
 }