Package javax.transaction

Examples of javax.transaction.TransactionSynchronizationRegistry


    );
  }

  @Override
  public boolean canRegisterSynchronization() {
    final TransactionSynchronizationRegistry registry = synchronizationRegistryAccess.getSynchronizationRegistry();
    return JtaStatusHelper.isActive( registry.getTransactionStatus() ) && ! registry.getRollbackOnly();
  }
View Full Code Here


        config.facilities.transactionService = serviceInfo;

        // todo find a better place for this

        // TransactionSynchronizationRegistry
        TransactionSynchronizationRegistry synchronizationRegistry;
        if (transactionManager instanceof TransactionSynchronizationRegistry) {
            synchronizationRegistry = (TransactionSynchronizationRegistry) transactionManager;
        } else {
            // todo this should be built
            synchronizationRegistry = new SimpleTransactionSynchronizationRegistry(transactionManager);
View Full Code Here

            // bind TransactionManager
            TransactionManager transactionManager = SystemInstance.get().getComponent(TransactionManager.class);
            safeBind(comp, "TransactionManager", transactionManager);

            // bind TransactionSynchronizationRegistry
            TransactionSynchronizationRegistry synchronizationRegistry = SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class);
            safeBind(comp, "TransactionSynchronizationRegistry", synchronizationRegistry);

            safeBind(comp, "ORB", new SystemComponentReference(ORB.class));
            safeBind(comp, "HandleDelegate", new SystemComponentReference(HandleDelegate.class));
        } catch (NamingException e) {
View Full Code Here

    * Init lock
    * @return The lock
    */
   private synchronized Lock initLock()
   {
      TransactionSynchronizationRegistry tsr = getTransactionSynchronizationRegistry();
      if (tsr != null && tsr.getTransactionKey() != null)
      {
         if (tsr.getResource(LockKey.INSTANCE) == null)
         {
            Lock lock = new ReentrantLock(true);
            tsr.putResource(LockKey.INSTANCE, lock);
            return lock;
         }
         else
         {
            return (Lock)tsr.getResource(LockKey.INSTANCE);
         }
      }

      return null;
   }
View Full Code Here

    * @return The lock
    */
   private Lock getLock()
   {
      Lock result = null;
      TransactionSynchronizationRegistry tsr = getTransactionSynchronizationRegistry();

      if (tsr != null && tsr.getTransactionKey() != null)
      {
         result = (Lock)tsr.getResource(LockKey.INSTANCE);
         if (result == null)
         {
            result = initLock();
         }
      }
View Full Code Here

    * @throws ResourceException Thrown if an error occurs
    */
   ConnectionListener getTransactionOldConnection(Transaction trackByTransaction, ManagedConnectionPool mcp)
      throws ResourceException
   {
      TransactionSynchronizationRegistry tsr = getTransactionSynchronizationRegistry();
      Lock lock = getLock();
     
      try
      {
         lock.lockInterruptibly();
      }
      catch (InterruptedException ie)
      {
         throw new ResourceException(bundle.unableObtainLock(), ie);
      }
      try
      {
         // Already got one
         ConnectionListener cl = (ConnectionListener)tsr.getResource(mcp);
         if (cl != null)
         {
            if (trace)
               log.tracef("Previous connection tracked by transaction=%s tx=%s", cl, trackByTransaction);
            return cl;
View Full Code Here

      // whether another thread beat us to the punch.
      ConnectionListener cl = mcp.getConnection(subject, cri);
      if (trace)
         log.tracef("Got connection from pool tracked by transaction=%s tx=%s", cl, trackByTransaction);

      TransactionSynchronizationRegistry tsr = getTransactionSynchronizationRegistry();
      Lock lock = getLock();
      try
      {
         lock.lockInterruptibly();
      }
      catch (InterruptedException ie)
      {
         throw new ResourceException(bundle.unableObtainLock(), ie);
      }
      try
      {
         // Check we weren't racing with another transaction
         ConnectionListener other =
            (ConnectionListener)tsr.getResource(mcp);

         if (other != null)
         {
            mcp.returnConnection(cl, false);

            if (trace)
               log.tracef("Another thread already got a connection tracked by transaction=%s tx=%s",
                       other, trackByTransaction);

            cl = other;
         }

         // This is the connection for this transaction
         cl.setTrackByTx(true);
         tsr.putResource(mcp, cl);

         if (trace)
            log.tracef("Using connection from pool tracked by transaction=%s tx=%s", cl, trackByTransaction);

         return cl;
View Full Code Here

            if (name == null) {
                // consider the transaction active if we are not able to look up
                // the TransactionSynchronizationRegistry
                return true;
            }
            TransactionSynchronizationRegistry registry = (TransactionSynchronizationRegistry) context.lookup(name);
            return (registry.getTransactionStatus() == Status.STATUS_ACTIVE);
        } catch (NamingException e) {
            IllegalStateException ex = new IllegalStateException("Transaction not active");
            ex.initCause(e);
            ex.setLinkedException(e);
            throw ex;
View Full Code Here

   */
  @Test
  public void testActiveContextsQuiesce() throws InvalidSyntaxException
  {
    TranSyncRegistryMock backingTSR = new TranSyncRegistryMock();
    TransactionSynchronizationRegistry tsr = Skeleton.newMock(backingTSR, TransactionSynchronizationRegistry.class);
   
    context.registerService(TransactionSynchronizationRegistry.class.getName(), tsr, new Hashtable<String, Object>());
   
    assertNoContextRegistered();
   
View Full Code Here

   */
  @Test
  public void testActiveContextsQuiesceAll() throws InvalidSyntaxException
  {
    TranSyncRegistryMock backingTSR = new TranSyncRegistryMock();
    TransactionSynchronizationRegistry tsr = Skeleton.newMock(backingTSR, TransactionSynchronizationRegistry.class);
   
    context.registerService(TransactionSynchronizationRegistry.class.getName(), tsr, new Hashtable<String, Object>());
   
    assertNoContextRegistered();
   
View Full Code Here

TOP

Related Classes of javax.transaction.TransactionSynchronizationRegistry

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.