Package com.caucho.transaction

Examples of com.caucho.transaction.TransactionImpl


  }

  @Override
  protected ContextContainer getContextContainer()
  {
    TransactionImpl xa = _xaManager.getCurrent();
   
    if (xa == null || ! xa.isActive()) {
      return null;
    }
   
    return (ContextContainer) xa.getResource("caucho.xa.scope");
  }
View Full Code Here


  }

  @Override
  protected ContextContainer createContextContainer()
  {
    TransactionImpl xa = _xaManager.getCurrent();
   
    if (xa == null || ! xa.isActive()) {
      return null;
    }
   
    XAContextContainer context
      = (XAContextContainer) xa.getResource("caucho.xa.scope");
   
    if (context == null) {
      context = new XAContextContainer();
      xa.setAttribute("caucho.xa.scope", context);
      xa.registerSynchronization(context);
    }
   
    return context;
  }
View Full Code Here

  @Override
  public <T> T get(Contextual<T> bean,
                   CreationalContext<T> creationalContext)
  {
    TransactionImpl xa = _xaManager.getCurrent();

    if (xa == null || ! xa.isActive()) {
      throw new ContextNotActiveException(L.l("'{0}' cannot be created because @TransactionScoped requires an active transaction.",
                                              bean));
    }
   
    ScopeContext cxt = (ScopeContext) xa.getResource("caucho.xa.scope");
   
    if (cxt == null) {
      cxt = new ScopeContext();
      xa.putResource("caucho.xa.scope", cxt);
      xa.registerSynchronization(cxt);
    }
   
    T result = cxt.get(bean);

    if (result != null || creationalContext == null)
View Full Code Here

   * @return the current transaction if it exists
   */
  public void endRequiresNew(Transaction parent)
  {
    try {
      TransactionImpl xa = getTransaction();
     
      if (xa != null && xa.isRollbackOnly())
        _ut.rollback();
      else
        _ut.commit();
    } catch (RuntimeException e) {
      throw e;
View Full Code Here

  public void beginSupports()
  {
    try {
      TransactionManagerImpl tm = TransactionManagerImpl.getLocal();

      TransactionImpl xa = tm.getTransaction();
     
      if (xa != null)
        xa.setAttribute("allowRollback", Boolean.FALSE);
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new EJBException(e);
    }
View Full Code Here

    }
  }

  public boolean systemException(Throwable e)
  {
    TransactionImpl xa = getTransaction();
   
    AppExceptionItem appExn = null;
   
    if (_ejbManager != null)
      appExn = _ejbManager.getSystemException(e.getClass());

    if (appExn == null || appExn.isRollback()) {
      if (xa != null)
        xa.setRollbackOnly(e);
     
      return appExn == null || appExn.isSystemException();
    }
    else
      return false;
View Full Code Here

      return false;
  }

  public void applicationException(Throwable e)
  {
    TransactionImpl xa = getTransaction();
   
    if (xa == null)
      return;
   
    AppExceptionItem appExn = null;
   
    if (_ejbManager != null)
      appExn = _ejbManager.getApplicationException(e.getClass());
   
    if (appExn != null && appExn.isRollback()) {
      xa.setRollbackOnly(e);
    }
  }
View Full Code Here

   * Commits transaction.
   */
  public void commit()
  {
    try {
      TransactionImpl xa = getTransaction();
     
      if (xa != null && xa.isRollbackOnly())
        _ut.rollback();
      else
        _ut.commit();
    } catch (RuntimeException e) {
      throw e;
View Full Code Here

   * Commits transaction.
   */
  public void rollback()
  {
    try {
      TransactionImpl xa = getTransaction();
     
      if (xa != null)
        _ut.rollback();
    } catch (RuntimeException e) {
      throw e;
View Full Code Here

    if (! getServer().isContainerTransaction()) {
      throw new IllegalStateException(L.l("setRollbackOnly() is only allowed with container-managed transaction"));
    }

    try {
      TransactionImpl xa = TransactionManagerImpl.getLocal().getCurrent();

      if (xa == null || xa.getStatus() == Status.STATUS_NO_TRANSACTION)
        throw new IllegalStateException(L.l("setRollbackOnly() called with no active transaction."));
     
      if (Boolean.FALSE.equals(xa.getAttribute("allowRollback")))
        throw new IllegalStateException(L.l("setRollbackOnly() called in forbidden context"));
     
      xa.setRollbackOnly();
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new IllegalStateException(e);
    }
View Full Code Here

TOP

Related Classes of com.caucho.transaction.TransactionImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.