Package javax.transaction

Examples of javax.transaction.Synchronization


        afterCompletion(syncList);
    }

    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


                        final int status = transactionSynchronizationRegistry.getTransactionStatus();
                        // if this SFSB instance is already associated with a different transaction, then it's an error
                        // if the thread is currently associated with a tx, then register a tx synchronization
                        if (currentTransactionKey != null && status != Status.STATUS_COMMITTED) {
                            // register a tx synchronization for this SFSB instance
                            final Synchronization statefulSessionSync = new StatefulSessionSynchronization(instance, lockOwner);
                            transactionSynchronizationRegistry.registerInterposedSynchronization(statefulSessionSync);
                            wasTxSyncRegistered = true;
                            if (ROOT_LOGGER.isTraceEnabled()) {
                                ROOT_LOGGER.trace("Registered tx synchronization: " + statefulSessionSync + " for tx: " + currentTransactionKey +
                                        " associated with stateful component instance: " + instance);
View Full Code Here

                //if a transaction is active we register a sync
                //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

                        // if this entity instance is already associated with a different transaction, then it's an error

                        // if the thread is currently associated with a tx, then register a tx synchronization
                        if (currentTransactionKey != null) {
                            // register a tx synchronization for this entity instance
                            final Synchronization entitySynchronization = new EntityBeanSynchronization(instance, lockOwner);
                            transactionSynchronizationRegistry.registerInterposedSynchronization(entitySynchronization);
                            if (ROOT_LOGGER.isTraceEnabled()) {
                                ROOT_LOGGER.trace("Registered tx synchronization: " + entitySynchronization + " for tx: " + currentTransactionKey +
                                    " associated with stateful component instance: " + instance);
                            }
View Full Code Here

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

            }
View Full Code Here

        //if a transaction is active we register a sync
        //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

                if (transactionStrategy.isActive())
                {
                    final Transaction transaction = (Transaction)transactionStrategy.getTransaction() ;
                    if ((transaction != null) && !SYNCHRONISATIONS.containsKey(transaction))
                    {
                        final Synchronization synch = new JobNotifierSynchronisation(transaction, jobExecutor) ;
                        transaction.registerSynchronization(synch) ;
                        SYNCHRONISATIONS.put(transaction, synch) ;
                    }
                }
            }
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

        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

    _alarm.dequeue();

    if (_interposedSynchronizations != null) {
      // env/06a2
      for (int i = 0; i < _interposedSynchronizations.size(); i++) {
        Synchronization sync = _interposedSynchronizations.get(i);

        try {
          sync.beforeCompletion();
        } catch (RuntimeException e) {
          setRollbackOnly(e);

          RollbackException newException = new RollbackException(e.toString());
          newException.initCause(e);

          throw newException;
        } catch (Throwable e) {
          log.log(Level.FINE, e.toString(), e);
        }
      }
    }

    // server/16h2
    if (_synchronizations != null) {
      // env/06a2
      for (int i = 0; i < _synchronizations.size(); i++) {
      //for (int i = _synchronizations.size() - 1; i >= 0; i--) {
        Synchronization sync = _synchronizations.get(i);

        if (log.isLoggable(Level.FINEST))
          log.finest(this + " beforeCompletion " + sync);

        try {
          sync.beforeCompletion();
        } catch (RuntimeException e) {
          setRollbackOnly(e);

          RollbackException newException = new RollbackException(e.toString());
          newException.initCause(e);
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.