Search in sources :

Example 6 with Node

use of org.jboss.cache.Node in project jain-sip.ha by RestComm.

the class JBossSipCache method putClientTransaction.

public void putClientTransaction(SIPClientTransaction clientTransaction) throws SipCacheException {
    UserTransaction tx = null;
    try {
        Properties prop = new Properties();
        prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
        tx = (UserTransaction) new InitialContext(prop).lookup("UserTransaction");
        if (tx != null) {
            tx.begin();
        }
        Node clientTransactionNode = clientTxRootNode.addChild(Fqn.fromString(clientTransaction.getTransactionId()));
        clientTransactionNode.put(clientTransaction.getTransactionId(), clientTransaction);
        if (tx != null) {
            tx.commit();
        }
    } catch (Exception e) {
        if (tx != null) {
            try {
                tx.rollback();
            } catch (Throwable t) {
            }
        }
        throw new SipCacheException("A problem occured while putting the following client transaction " + clientTransaction.getTransactionId() + "  into JBoss Cache", e);
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) Node(org.jboss.cache.Node) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) CacheException(org.jboss.cache.CacheException)

Aggregations

CacheException (org.jboss.cache.CacheException)6 Node (org.jboss.cache.Node)6 ParseException (java.text.ParseException)3 Properties (java.util.Properties)3 InitialContext (javax.naming.InitialContext)3 PeerUnavailableException (javax.sip.PeerUnavailableException)3 RollbackException (javax.transaction.RollbackException)3 TransactionManager (javax.transaction.TransactionManager)3 UserTransaction (javax.transaction.UserTransaction)3 Cache (org.jboss.cache.Cache)3 MobicentsCache (org.mobicents.cache.MobicentsCache)3 IOException (java.io.IOException)2 AbstractHASipDialog (gov.nist.javax.sip.stack.AbstractHASipDialog)1 MobicentsHASIPClientTransaction (gov.nist.javax.sip.stack.MobicentsHASIPClientTransaction)1 MobicentsHASIPServerTransaction (gov.nist.javax.sip.stack.MobicentsHASIPServerTransaction)1 HASipDialog (org.mobicents.ha.javax.sip.HASipDialog)1