Coverage Report - org.apache.commons.messenger.XAMessenger
 
Classes in this File Line Coverage Branch Coverage Complexity
XAMessenger
0%
0/16
0%
0/6
2
 
 1  
 /*
 2  
  * Copyright (C) The Apache Software Foundation. All rights reserved.
 3  
  *
 4  
  * This software is published under the terms of the Apache Software License
 5  
  * version 1.1, a copy of which has been included with this distribution in
 6  
  * the LICENSE file.
 7  
  *
 8  
  * $Id: XAMessenger.java 155459 2005-02-26 13:24:44Z dirkv $
 9  
  */
 10  
 package org.apache.commons.messenger;
 11  
 
 12  
 import javax.jms.Session;
 13  
 import javax.jms.XASession;
 14  
 import javax.transaction.Transaction;
 15  
 import javax.transaction.xa.XAResource;
 16  
 
 17  
 import org.apache.commons.logging.Log;
 18  
 import org.apache.commons.logging.LogFactory;
 19  
 
 20  
 /** <p><code>XAMessenger</code> is a default implementation of
 21  
  * Messenger which can also support XA transactions by enlisting and delisting
 22  
  * XAResources.
 23  
  * This is implemented as a seperate Messenger implementation to avoid the core
 24  
  * Messenger having a dependency on JTA.
 25  
  * .</p>
 26  
  *
 27  
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
 28  
  * @version $Revision: 155459 $
 29  
  */
 30  
 public class XAMessenger extends DefaultMessenger implements XACapable {
 31  
     
 32  
     /** Logger */
 33  0
     private static final Log log = LogFactory.getLog(XAMessenger.class);
 34  
     
 35  0
     public XAMessenger() {
 36  0
     }
 37  
     
 38  
     // XACapable interface
 39  
     //-------------------------------------------------------------------------
 40  
         
 41  
         public void enlistResources(Transaction transaction) throws Exception {
 42  0
                 XAResource resource = getXAResource();
 43  0
                 if (resource != null) {
 44  0
                         transaction.enlistResource(resource);
 45  
                 }
 46  0
         }
 47  
 
 48  
         public void delistResources(Transaction transaction, int flag) throws Exception {
 49  0
                 XAResource resource = getXAResource();
 50  0
                 if (resource != null) {
 51  0
                         transaction.delistResource(resource, flag);
 52  
                 }
 53  0
         }
 54  
 
 55  
     // Implementation methods
 56  
     //-------------------------------------------------------------------------
 57  
     
 58  
     /**
 59  
      * @return the XAResource associated with this Messenger if one exists
 60  
      */
 61  
         protected XAResource getXAResource() throws Exception {
 62  0
                 Session session = getMessengerSession().getSession();
 63  0
                 if (session instanceof XASession) {
 64  0
                         XASession xaSession = (XASession) session;
 65  0
                         return xaSession.getXAResource();
 66  
                 }
 67  0
                 return null;
 68  
         }
 69  
 }