Examples of Synchronization


Examples of com.atomikos.icatch.Synchronization

        // associated with the tx at beforeCompletion, and the
        // TM is listening as a SubTxAware!
        // NOTE: doing this at the very beginning of commit
        // also makes sure that the tx can still get new Participants
        // from beforeCompletion work being done! This is required.
        Synchronization sync = null;
        Enumeration enumm = synchronizations_.elements ();
        while ( enumm.hasMoreElements () ) {
          sync = (Synchronization) enumm.nextElement ();
          try {
            sync.beforeCompletion ();
          } catch ( RuntimeException error ) {
            //see case 24246: rollback only
            setRollbackOnly();
            Configuration.logWarning ( "Unexpected error in beforeCompletion: " , error );
          }
View Full Code Here

Examples of de.willuhn.jameica.hbci.synchronize.Synchronization

    // Liste der Sync-Jobs hinzufuegen
    BeanService service = Application.getBootLoader().getBootable(BeanService.class);
    List<SynchronizeBackend> backends = service.get(SynchronizeEngine.class).getBackends();
    for (SynchronizeBackend backend:backends)
    {
      Synchronization sync = new Synchronization();
      sync.setBackend(backend);
      List<SynchronizeJob> jobs = backend.getSynchronizeJobs(null); // fuer alle Konten
      if (jobs != null)
      {
        for (SynchronizeJob job:jobs)
        {
          boolean checked = true;
          try
          {
            // nicht markiert, wenn das letzte Mal explizit abgewaehlt
            checked = !uncheckedCache.containsKey(job.getName());
          }
          catch (Exception e)
          {
            Logger.error("unable to determine if job was unchecked",e);
          }
          this.addItem(job,checked);

          sync.getJobs().add(job);
        }
      }
      this.syncList.add(sync);
    }
  }
View Full Code Here

Examples of javax.transaction.Synchronization

      GlobalTransaction gtx = cache.getTransactionTable().get(cache.getTransactionManager().getTransaction());
      OrderedSynchronizationHandler osh = cache.getTransactionTable().get(gtx).getOrderedSynchronizationHandler();

//      OrderedSynchronizationHandler.getInstance(cache.getTransactionManager().getTransaction()).registerAtTail(
      osh.registerAtTail(
            new Synchronization()
            {

               public void beforeCompletion()
               {
                  // this will be called after the cache's prepare() phase.  Restart the cache server.
View Full Code Here

Examples of javax.transaction.Synchronization

      if (enlisted != null)
      {
         int i = 0;
         while (i < enlisted.size())
         {
            Synchronization synch = (Synchronization) enlisted.get(i);
            invokeBefore(synch);
            ++i;
         }
      }
     
View Full Code Here

Examples of javax.transaction.Synchronization

      if (enlisted != null)
      {
         int i = 0;
         while (i < enlisted.size())
         {
            Synchronization synch = (Synchronization) enlisted.get(i);
            invokeAfter(synch, status);
            ++i;
         }
      }
     
View Full Code Here

Examples of javax.transaction.Synchronization

      Transaction tx = (Transaction)transactions.get(id);
      if (tx == null)
      {
         throw new IllegalStateException("Tx not found: " + id);
      }
      Synchronization sync = new Synchronization()
      {
         public void beforeCompletion()
         {
            log.info(tid() + " beforeCompletion() called");
         }
View Full Code Here

Examples of javax.transaction.Synchronization

           
            // Synchronization.beforeCompletion
            Iterator syncIterator = synchronization.iterator();
            while (syncIterator.hasNext())
            {
                Synchronization sync = (Synchronization) syncIterator.next();
                sync.beforeCompletion();
            }
           
            List failures = null;
            boolean failed = false;
   
            Iterator branchKeys = branches.keySet().iterator();
   
            if (enlistedResources.size() == 1)
            {
   
                // If we have only one resource, we dont ask to prepare, and we go with one phase commit
                status = Status.STATUS_COMMITTING;
                while (branchKeys.hasNext())
                {
                    Object key = branchKeys.next();
                    XAResource resourceManager = (XAResource) branches.get(key);
                    try
                    {
                        if (!failed)
                        {
                            resourceManager.commit(xid, true);
                        }
                        else
                        {
                            resourceManager.rollback(xid);
                        }
                    }
                    catch (Throwable e)
                    {
                        if( failures == null )
                        {
                            //lazy instantiate this, because we only need on failures
                            failures = new ArrayList();
                        }
                        failures.add(e);
                        failed = true;
                        status = Status.STATUS_MARKED_ROLLBACK;
                        JPOXLogger.TRANSACTION.error(LOCALISER.msg("015038", "commit", resourceManager, getXAErrorCode(e), toString()));                   
                    }
                }
                if (!failed)
                {
                    status = Status.STATUS_COMMITTED;
                }
                else
                {
                    status = Status.STATUS_ROLLEDBACK;
                }
   
            }
            else if (enlistedResources.size() > 0)
            {
   
                // Prepare each enlisted resource
                status = Status.STATUS_PREPARING;
                while ((!failed) && (branchKeys.hasNext()))
                {
                    Object key = branchKeys.next();
                    XAResource resourceManager = (XAResource) branches.get(key);
                    try
                    {
                        // Preparing the resource manager using its branch xid
                        resourceManager.prepare((Xid) key);
                    }
                    catch (Throwable e)
                    {
                        if( failures == null )
                        {
                            //lazy instantiate this, because we only need on failures
                            failures = new ArrayList();
                        }
                        failures.add(e);
                        failed = true;
                        status = Status.STATUS_MARKED_ROLLBACK;
                        JPOXLogger.TRANSACTION.error(LOCALISER.msg("015038", "prepare", resourceManager, getXAErrorCode(e), toString()));
                    }
                }
   
                if (!failed)
                {
                    status = Status.STATUS_PREPARED;
                }
   
                // Starts 2nd commit phase
                // If fail, rollback
                if (failed)
                {
                    status = Status.STATUS_ROLLING_BACK;
                    failed = false;
                    // Rolling back all the prepared (and unprepared) branches
                    branchKeys = branches.keySet().iterator();
                    while (branchKeys.hasNext())
                    {
                        Object key = branchKeys.next();
                        XAResource resourceManager = (XAResource) branches.get(key);
                        try
                        {
                            resourceManager.rollback((Xid) key);
                        }
                        catch (Throwable e)
                        {
                            JPOXLogger.TRANSACTION.error(LOCALISER.msg("015038", "rollback", resourceManager, getXAErrorCode(e), toString()));                       
                            if( failures == null )
                            {
                                //lazy instantiate this, because we only need on failures
                                failures = new ArrayList();
                            }
                            failures.add(e);
                            failed = true;
                        }
                    }
                    status = Status.STATUS_ROLLEDBACK;
                }
                else
                {
                    status = Status.STATUS_COMMITTING;
                    // Commit each enlisted resource
                    branchKeys = branches.keySet().iterator();
                    while (branchKeys.hasNext())
                    {
                        Object key = branchKeys.next();
                        XAResource resourceManager = (XAResource) branches.get(key);
                        try
                        {
                            resourceManager.commit((Xid) key, false);
                        }
                        catch (Throwable e)
                        {
                            JPOXLogger.TRANSACTION.error(LOCALISER.msg("015038", "commit", resourceManager, getXAErrorCode(e), toString()));                    
                            if( failures == null )
                            {
                                //lazy instantiate this, because we only need on failures
                                failures = new ArrayList();
                            }
                            failures.add(e);
                            failed = true;
                        }
                    }
                    status = Status.STATUS_COMMITTED;
                }
            }
   
            // Synchronization.afterCompletion
            syncIterator = synchronization.iterator();
            while (syncIterator.hasNext())
            {
                Synchronization sync = (Synchronization) syncIterator.next();
                sync.afterCompletion(status);
            }
           
            if (status == Status.STATUS_ROLLEDBACK)
            {
                if( failed )
View Full Code Here

Examples of javax.transaction.Synchronization

           
            // Synchronization.afterCompletion
            Iterator syncIterator = synchronization.iterator();
            while (syncIterator.hasNext())
            {
                Synchronization sync = (Synchronization) syncIterator.next();
                sync.afterCompletion(status);
            }
        }
        finally
        {
            completing = false;
View Full Code Here

Examples of javax.transaction.Synchronization

     * @param listener the listener to add
     * @throws SQLException if a problem occurs adding the listener to the transaction
     */
    public void addTransactionContextListener(final TransactionContextListener listener) throws SQLException {
        try {
            getTransaction().registerSynchronization(new Synchronization() {
                public void beforeCompletion() {
                }

                public void afterCompletion(int status) {
                    listener.afterCompletion(TransactionContext.this, status == Status.STATUS_COMMITTED);
View Full Code Here

Examples of javax.transaction.Synchronization

   * avoiding object loading during a flush. Not needed during transactions.
   */
  public void onFlush(FlushEvent event) {
    if ( used ) {
      Session session = event.getSession();
      Synchronization synchronization = flushSynch.get( session );
      if ( synchronization != null ) {
        //first cleanup
        flushSynch.remove( session );
        log.debug( "flush event causing index update out of transaction" );
        synchronization.beforeCompletion();
        synchronization.afterCompletion( Status.STATUS_COMMITTED );
      }
    }
  }
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.