Examples of Synchronization


Examples of javax.transaction.Synchronization

          }
          //flush before completion and
          //register clear on rollback
          log.trace( "Adding flush() and close() synchronization" );
          joinableCMTTransaction.registerSynchronization(
              new Synchronization() {
                public void beforeCompletion() {
                  boolean flush = false;
                  TransactionFactory.Context ctx = null;
                  try {
                    ctx = ( TransactionFactory.Context ) session;
View Full Code Here

Examples of javax.transaction.Synchronization

      throw new IllegalStateException( "EntityManager is closed" );
    }
    if ( !discardOnClose && isTransactionInProgress() ) {
      //delay the closing till the end of the enlisted transaction
      getSession().getTransaction().registerSynchronization(
          new Synchronization() {
            public void beforeCompletion() {
              //nothing to do
            }

            public void afterCompletion(int i) {
View Full Code Here

Examples of javax.transaction.Synchronization

      cache.put("/one/two/three", "key1", "val1");
      numLocks = cache.getNumberOfLocksHeld();
      assertEquals(4, numLocks);

      // we register *second*
      tx.registerSynchronization(new Synchronization()
      {

         public void beforeCompletion()
         {
            try
View Full Code Here

Examples of javax.transaction.Synchronization

      cache.put("/one/two/three", "key1", "val1");
      numLocks = cache.getNumberOfLocksHeld();
      assertEquals(4, numLocks);

      // we register *second*
      tx.registerSynchronization(new Synchronization()
      {

         public void beforeCompletion()
         {
         }
View Full Code Here

Examples of javax.transaction.Synchronization

    if ( !open ) {
      throw new IllegalStateException( "EntityManager is closed" );
    }
    if ( !discardOnClose && isTransactionInProgress() ) {
      //delay the closing till the end of the enlisted transaction
            getSession().getTransaction().registerSynchronization(new Synchronization() {
                public void beforeCompletion() {
                    // nothing to do
                }

        public void afterCompletion( int i ) {
View Full Code Here

Examples of javax.transaction.Synchronization

         OrderedSynchronizationHandler osh = transactionContext.getOrderedSynchronizationHandler();

         final Transaction finalTx = tx;
         System.out.println("Notify called.");
         // add an aborting sync handler.
         Synchronization abort = new Synchronization()
         {

            public void beforeCompletion()
            {
               if (abortBeforeCompletion)
View Full Code Here

Examples of javax.transaction.Synchronization

        when(transactionSynchronizationRegistry.getTransactionKey()).thenReturn("TX1");
        final List<Synchronization> synchronizations = new LinkedList<Synchronization>();
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Synchronization synchronization = (Synchronization) invocation.getArguments()[0];
                synchronizations.add(synchronization);
                return null;
            }
        }).when(transactionSynchronizationRegistry).registerInterposedSynchronization((Synchronization) any());
        final StatefulSessionComponentInstance instance = mock(StatefulSessionComponentInstance.class);
        when(instance.getComponent()).thenReturn(component);
        context.putPrivateData(ComponentInstance.class, instance);

        interceptor.processInvocation(context);

        // commit
        for (Synchronization synchronization : synchronizations) {
            synchronization.beforeCompletion();
        }
        for (Synchronization synchronization : synchronizations) {
            synchronization.afterCompletion(Status.STATUS_COMMITTED);
        }
        synchronizations.clear();

        when(transactionSynchronizationRegistry.getTransactionKey()).thenReturn("TX2");
View Full Code Here

Examples of javax.transaction.Synchronization

        map = Collections.synchronizedMap(new HashMap<Object, CacheEntry>());
        final Map<Object, CacheEntry> existing = cache.putIfAbsent(key, map);
        if (existing != null) {
            map = existing;
        }
        transactionSynchronizationRegistry.registerInterposedSynchronization(new Synchronization() {
            @Override
            public void beforeCompletion() {

            }
View Full Code Here

Examples of javax.transaction.Synchronization

                    //and if the transaction is rolled back we release the instance back into the pool

                    final TransactionSynchronizationRegistry transactionSynchronizationRegistry = entityBeanComponent.getTransactionSynchronizationRegistry();
                    if (transactionSynchronizationRegistry.getTransactionKey() != null) {
                        if(!instanceCachedBefore) {
                            transactionSynchronizationRegistry.registerInterposedSynchronization(new Synchronization() {
                                @Override
                                public void beforeCompletion() {

                                }
View Full Code Here

Examples of javax.transaction.Synchronization

        //and if the transaction is rolled back we release the instance back into the pool

        final TransactionSynchronizationRegistry transactionSynchronizationRegistry = entityBeanComponent.getTransactionSynchronizationRegistry();

        if (transactionSynchronizationRegistry.getTransactionKey() != null) {
            transactionSynchronizationRegistry.registerInterposedSynchronization(new Synchronization() {
                @Override
                public void beforeCompletion() {

                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.