Package javax.transaction

Examples of javax.transaction.Synchronization


    }

    private void beforeCompletion() {
        int i = 0;
        while (true) {
            Synchronization synch;
            synchronized (this) {
                if (i == syncList.size()) {
                    return;
                }
                synch = (Synchronization) syncList.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() {
        // this does not synchronize because nothing can modify our state at this time
        for (Iterator i = syncList.iterator(); i.hasNext();) {
            Synchronization synch = (Synchronization) i.next();
            try {
                synch.afterCompletion(status);
            } catch (Exception e) {
                log.warn("Unexpected exception from afterCompletion; continuing", e);
                continue;
            }
        }
View Full Code Here

          }
          //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

    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

  public void transition() {
    registerNotification(Event.EVENTTYPE_TRANSITION);
  }

  private static void registerNotification(final String event) {
    Synchronization notification = new Synchronization() {

      public void beforeCompletion() {
      }

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

          }
          //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

            BitronixTransaction bt = ((BitronixTransactionManager) ut).getCurrentTransaction();
            // Ensure that all actions have occurred so that we get what is _really_ commited to the db
            // (This code is straight from bitronix)
            Iterator<?> iter = bt.getSynchronizationScheduler().reverseIterator();
            while (iter.hasNext()) {
                Synchronization synchronization = (Synchronization) iter.next();
                try {
                    synchronization.beforeCompletion();
                } catch (RuntimeException ex) {
                    bt.setStatus(Status.STATUS_MARKED_ROLLBACK);
                    throw ex;
                }
            }
View Full Code Here

      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

         // 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

      }
      else if (mode == ConnectionMode.WITH_TRANSACTION_MANAGER)
      {
         try
         {
            transactionManager.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.