javax.resource.spi.LocalTransactionException Java Examples

The following examples show how to use javax.resource.spi.LocalTransactionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JCALocalTransaction.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void commit() throws ResourceException
{
  if (DEBUG) {
    try {
      throw new NullPointerException("Asif:JCALocalTransaction:commit");
    }
    catch (NullPointerException npe) {
      npe.printStackTrace();
    }
  }
  LogWriter logger = cache.getLogger();
  if (logger.fineEnabled()) {
    logger.fine("JCALocalTransaction:invoked commit");
  }
  TXStateInterface tsp = this.gfTxMgr.getTXState();
  if (tsp != null && this.tid != tsp.getTransactionId()) {
    throw new IllegalStateException(
        "Local Transaction associated with Tid = " + this.tid
            + " attempting to commit a different transaction");
  }
  try {
    this.gfTxMgr.commit();
    this.tid = null;
  }
  catch (Exception e) {
    throw new LocalTransactionException(e.toString());
  }
  // Iterator<ConnectionEventListener> itr = this.listeners.iterator();
  // ConnectionEvent ce = new
  // ConnectionEvent(this,ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
  // while( itr.hasNext()) {
  // itr.next().localTransactionCommitted(ce);
  // }

}
 
Example #2
Source File: JCALocalTransaction.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void commit() throws ResourceException
{
  if (DEBUG) {
    try {
      throw new NullPointerException("Asif:JCALocalTransaction:commit");
    }
    catch (NullPointerException npe) {
      npe.printStackTrace();
    }
  }
  LogWriter logger = cache.getLogger();
  if (logger.fineEnabled()) {
    logger.fine("JCALocalTransaction:invoked commit");
  }
  TXStateInterface tsp = this.gfTxMgr.getTXState();
  if (tsp != null && this.tid != tsp.getTransactionId()) {
    throw new IllegalStateException(
        "Local Transaction associated with Tid = " + this.tid
            + " attempting to commit a different transaction");
  }
  try {
    this.gfTxMgr.commit();
    this.tid = null;
  }
  catch (Exception e) {
    throw new LocalTransactionException(e.toString());
  }
  // Iterator<ConnectionEventListener> itr = this.listeners.iterator();
  // ConnectionEvent ce = new
  // ConnectionEvent(this,ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
  // while( itr.hasNext()) {
  // itr.next().localTransactionCommitted(ce);
  // }

}
 
Example #3
Source File: JCALocalTransaction.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void begin() throws ResourceException
{
  if (DEBUG) {
    try {
      throw new NullPointerException("Asif:JCALocalTransaction:begin");
    }
    catch (NullPointerException npe) {
      npe.printStackTrace();
    }
  }
  try {
    if (!initDone || this.cache.isClosed()) {
      this.init();
    }
    // System.out.println("JCALocalTransaction:Asif: cache is ="+cache +
    // " for tx ="+this);
    LogWriter logger = cache.getLogger();
    if (logger.fineEnabled()) {
      logger.fine("JCALocalTransaction::begin:");
    }
    TransactionManager tm = cache.getJTATransactionManager();
    if (this.tid != null) {
      throw new LocalTransactionException(
          " A transaction is already in progress");
    }
    if (tm != null && tm.getTransaction() != null) {
      if (logger.fineEnabled()) {
        logger.fine("JCAManagedConnection: JTA transaction is on");
      }
      // This is having a JTA transaction. Assuming ignore jta flag is true,
      // explicitly being a gemfire transaction.
      TXStateInterface tsp = this.gfTxMgr.getTXState();
      if (tsp == null) {
        this.gfTxMgr.begin();
        tsp = this.gfTxMgr.getTXState();
        tsp.getProxy().setJCA(true);
        this.tid = tsp.getTransactionId();
        if (logger.fineEnabled()) {
          logger.fine("JCALocalTransaction:begun GFE transaction");
        }
      }
      else {
        throw new LocalTransactionException(
            "GemFire is already associated with a transaction");
      }
    }
    else {
      if (logger.fineEnabled()) {
        logger.fine("JCAManagedConnection: JTA Transaction does not exist.");
      }
    }
  }
  catch (SystemException e) {
    // this.onError();
    throw new ResourceException(e);
  }
  // Not to be invoked for local transactions managed by the container
  // Iterator<ConnectionEventListener> itr = this.listeners.iterator();
  // ConnectionEvent ce = new ConnectionEvent(this,
  // ConnectionEvent.LOCAL_TRANSACTION_STARTED);
  // while (itr.hasNext()) {
  // itr.next().localTransactionStarted(ce);
  // }

}
 
Example #4
Source File: JCALocalTransaction.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void begin() throws ResourceException
{
  if (DEBUG) {
    try {
      throw new NullPointerException("Asif:JCALocalTransaction:begin");
    }
    catch (NullPointerException npe) {
      npe.printStackTrace();
    }
  }
  try {
    if (!initDone || this.cache.isClosed()) {
      this.init();
    }
    // System.out.println("JCALocalTransaction:Asif: cache is ="+cache +
    // " for tx ="+this);
    LogWriter logger = cache.getLogger();
    if (logger.fineEnabled()) {
      logger.fine("JCALocalTransaction::begin:");
    }
    TransactionManager tm = cache.getJTATransactionManager();
    if (this.tid != null) {
      throw new LocalTransactionException(
          " A transaction is already in progress");
    }
    if (tm != null && tm.getTransaction() != null) {
      if (logger.fineEnabled()) {
        logger.fine("JCAManagedConnection: JTA transaction is on");
      }
      // This is having a JTA transaction. Assuming ignore jta flag is true,
      // explicitly being a gemfire transaction.
      TXStateInterface tsp = this.gfTxMgr.getTXState();
      if (tsp == null) {
        this.gfTxMgr.begin();
        tsp = this.gfTxMgr.getTXState();
        tsp.getProxy().setJCA(true);
        this.tid = tsp.getTransactionId();
        if (logger.fineEnabled()) {
          logger.fine("JCALocalTransaction:begun GFE transaction");
        }
      }
      else {
        throw new LocalTransactionException(
            "GemFire is already associated with a transaction");
      }
    }
    else {
      if (logger.fineEnabled()) {
        logger.fine("JCAManagedConnection: JTA Transaction does not exist.");
      }
    }
  }
  catch (SystemException e) {
    // this.onError();
    throw new ResourceException(e);
  }
  // Not to be invoked for local transactions managed by the container
  // Iterator<ConnectionEventListener> itr = this.listeners.iterator();
  // ConnectionEvent ce = new ConnectionEvent(this,
  // ConnectionEvent.LOCAL_TRANSACTION_STARTED);
  // while (itr.hasNext()) {
  // itr.next().localTransactionStarted(ce);
  // }

}