FileDocCategorySizeDatePackage
JBITransactionHandler.javaAPI DocGlassfish v2 API4259Fri May 04 22:30:28 BST 2007com.sun.enterprise.jbi.serviceengine.handlers

JBITransactionHandler

public class JBITransactionHandler extends Object implements JBIHandler
Transaction handling for JBI message exchanges is done in this class. It has a singleton instance.
author
Vikas Awasthi

Fields Summary
private String
tx_enable
Constructors Summary
Methods Summary
private javax.transaction.TransactionManagergetTM()

        return Switch.getSwitch().getTransactionManager();
    
public voidhandleInbound(com.sun.enterprise.jbi.serviceengine.comm.MessageExchangeTransport meTransport)

        MessageExchange me = meTransport.getMessageExchange();
        if(!isTxEnabled(me))
            return;

        suspendTx(me);
    
public voidhandleOutbound(com.sun.enterprise.jbi.serviceengine.comm.MessageExchangeTransport meTransport)

        MessageExchange me = meTransport.getMessageExchange();
        if(!isTxEnabled(me))
            return;

        resumeTx(me);
    
protected booleanisTxEnabled(javax.jbi.messaging.MessageExchange me)

        return ((tx_enable==null || tx_enable.equalsIgnoreCase("true")));
    
private voidresumeTx(javax.jbi.messaging.MessageExchange me)


        TransactionManager tm = getTM();
        Transaction tx = (Transaction)me.getProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME);

        if(tx != null) {
            if(me.getStatus().equals(ExchangeStatus.ERROR))
                tx.setRollbackOnly();
            tm.resume(tx);
        }
    
private voidsuspendTx(javax.jbi.messaging.MessageExchange me)


        TransactionManager tm = getTM();
        Transaction tx = tm.getTransaction();

        if (tx != null) {
            if(me.getStatus().equals(ExchangeStatus.ERROR))
                tx.setRollbackOnly();
            tx = tm.suspend();
            me.setProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME, tx);
        }