Package com.caucho.transaction

Examples of com.caucho.transaction.TransactionImpl


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

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

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


   * Returns the current EntityManager.
   */
  private EntityManager getCurrent()
  {
    try {
      TransactionImpl xa = (TransactionImpl) _ut.getTransaction();
     
      if (xa == null)
        return null;
     
      EntityManagerItem item;
     
      item = (EntityManagerItem) xa.getAttribute("resin.env.jpa.EntityManagerItem");
     
      if (item != null) {
        return item.getEntityManager();
      }

      if (_emf == null) {
        _emf = _persistenceUnit.getEntityManagerFactoryDelegate();
       
        if (_emf == null)
          throw new IllegalStateException(L.l("{0}: EntityManagerFactory cannot be found from {1}",
                                              this, _persistenceUnit));
      }

      EntityManager em;
     
      if (xa != null && xa.getStatus() == Status.STATUS_ACTIVE) {
        em = _emf.createEntityManager(_persistenceUnit.getProperties());

        item = new EntityManagerItem(item, em, xa);

        xa.setAttribute("resin.env.jpa.EntityManagerItem", item);
       
        // _threadEntityManager.set(item);

        xa.registerSynchronization(item);

        return em;
      }

      /*
 
View Full Code Here

      if (request instanceof AbstractHttpRequest)
        ((AbstractHttpRequest) request).finishInvocation();

      if (_tm != null) {
        try {
          TransactionImpl transaction = _tm.getCurrent();
          if (transaction.getStatus() != Status.STATUS_NO_TRANSACTION) {
            log.warning("Transaction not properly closed for " + ((HttpServletRequest) request).getRequestURL());
          }
          transaction.close();
        } catch (Throwable e) {
          log.log(Level.WARNING, e.getMessage(), e);
        }
      }
     
View Full Code Here

  }

  @Override
  public <T> T get(Contextual<T> bean)
  {
    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)
      return cxt.get(bean);
    else
      return null;
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

    throws SystemException, RollbackException
  {
    if (_resources.contains(resource))
      return;
   
    TransactionImpl xa = _transactionManager.getTransaction();
    if (xa != null && xa.isActive()) {
      ManagedPoolItem poolItem = resource.getXAPoolItem();

      enlistPoolItem(xa, poolItem);
    }
   
View Full Code Here

      return;
 
    poolItem.setTransaction(this);

    if (xa instanceof TransactionImpl) {
      TransactionImpl xaImpl = (TransactionImpl) xa;
     
      // server/164l
      if (xaImpl.allowLocalTransactionOptimization())
  poolItem.enableLocalTransactionOptimization(true);
    }

    if (poolItem.getXid() == null)
      xa.enlistResource(poolItem);
View Full Code Here

   * Returns the XID.
   */
  public Xid getXid()
    throws SystemException, RollbackException
  {
    TransactionImpl xa = (TransactionImpl) _transactionManager.getTransaction();

    if (xa != null)
      return xa.getXid();
    else
      return null;
  }
View Full Code Here

   * Returns the XID.
   */
  public int getEnlistedResourceCount()
    throws SystemException, RollbackException
  {
    TransactionImpl xa = (TransactionImpl) _transactionManager.getTransaction();

    if (xa != null)
      return xa.getEnlistedResourceCount();
    else
      return 0;
  }
View Full Code Here

      if (request instanceof AbstractHttpRequest)
        ((AbstractHttpRequest) request).finishInvocation();

      if (_tm != null) {
        try {
          TransactionImpl transaction = _tm.getCurrent();
          if (transaction.getStatus() != Status.STATUS_NO_TRANSACTION) {
            log.warning("Transaction not properly closed for " + ((HttpServletRequest) request).getRequestURL());
          }
          transaction.close();
        } catch (Throwable e) {
          log.log(Level.WARNING, e.getMessage(), 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.