Package javax.transaction

Examples of javax.transaction.Synchronization


        return resources.remove(key);
    }

    public void registerSynchronization(final TransactionSynchronization synchronization) {
        if (isTransactionActive()) {
            synchronizationRegistry.registerInterposedSynchronization(new Synchronization() {
                public void beforeCompletion() {
                    synchronization.beforeCompletion();
                }

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


            //noinspection unchecked
            Set<EntityBean> registeredEntities = (LinkedHashSet<EntityBean>) synchronizationRegistry.getResource(ENTITIES_TO_STORE);
            if (registeredEntities == null) {
                registeredEntities = new LinkedHashSet<EntityBean>();
                synchronizationRegistry.putResource(ENTITIES_TO_STORE, registeredEntities);
                synchronizationRegistry.registerInterposedSynchronization(new Synchronization() {
                    public void beforeCompletion() {
                        //noinspection unchecked
                        Set<EntityBean> registeredEntities = (LinkedHashSet<EntityBean>) synchronizationRegistry.getResource(ENTITIES_TO_STORE);
                        if (registeredEntities == null) {
                            return;
View Full Code Here

    }

    private void beforeCompletion(List syncs) {
        int i = 0;
        while (true) {
            Synchronization synch;
            synchronized (this) {
                if (i == syncs.size()) {
                    return;
                } else {
                    synch = (Synchronization) syncs.get(i++);
                }
            }
            try {
                synch.beforeCompletion();
            } catch (Exception e) {
                log.warn("Unexpected exception from beforeCompletion; transaction will roll back", e);
                synchronized (this) {
                    status = Status.STATUS_MARKED_ROLLBACK;
                }
View Full Code Here

        }
    }

    private void afterCompletion(List syncs) {
        for (Iterator i = syncs.iterator(); i.hasNext();) {
            Synchronization synch = (Synchronization) i.next();
            try {
                synch.afterCompletion(status);
            } catch (Exception e) {
                log.warn("Unexpected exception from afterCompletion; continuing", e);
            }
        }
    }
View Full Code Here

  }

  private void notifyLocalSynchsBeforeTransactionCompletion() {
    if (synchronizations!=null) {
      for ( int i=0; i<synchronizations.size(); i++ ) {
        Synchronization sync = (Synchronization) synchronizations.get(i);
        try {
          sync.beforeCompletion();
        }
        catch (Throwable t) {
          log.error("exception calling user Synchronization", t);
        }
      }
View Full Code Here

  private void notifyLocalSynchsAfterTransactionCompletion(int status) {
    begun = false;
    if (synchronizations!=null) {
      for ( int i=0; i<synchronizations.size(); i++ ) {
        Synchronization sync = (Synchronization) synchronizations.get(i);
        try {
          sync.afterCompletion(status);
        }
        catch (Throwable t) {
          log.error("exception calling user Synchronization", t);
        }
      }
View Full Code Here

  }

  private void notifyLocalSynchsBeforeTransactionCompletion() {
    if (synchronizations!=null) {
      for ( int i=0; i<synchronizations.size(); i++ ) {
        Synchronization sync = (Synchronization) synchronizations.get(i);
        try {
          sync.beforeCompletion();
        }
        catch (Throwable t) {
          log.error("exception calling user Synchronization", t);
        }
      }
View Full Code Here

  private void notifyLocalSynchsAfterTransactionCompletion(int status) {
    begun = false;
    if (synchronizations!=null) {
      for ( int i=0; i<synchronizations.size(); i++ ) {
        Synchronization sync = (Synchronization) synchronizations.get(i);
        try {
          sync.afterCompletion(status);
        }
        catch (Throwable t) {
          log.error("exception calling user Synchronization", t);
        }
      }
View Full Code Here

      }
      else if (mode == ConnectionMode.WITH_TRANSACTION_MANAGER)
      {
         try
         {
            transactionManager.getTransaction().registerSynchronization(new Synchronization()
            {

               public void beforeCompletion()
               {
               }
View Full Code Here

         // Since between 2 TM implementations the afterCompletion can be called in the same
         // order as the synchronization order or in the reverse order, so we add a second synchronization
         // such that the afterCompletion method will be called in the second call
         try
         {
            tm.getTransaction().registerSynchronization(new Synchronization()
            {

               public void beforeCompletion()
               {
               }
View Full Code Here

TOP

Related Classes of javax.transaction.Synchronization

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.