Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.TransactionSynchronizationAdapter


      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCompletion(int status) {
              assertTrue("Correct completion status", status == TransactionSynchronization.STATUS_UNKNOWN);
            }
          });
View Full Code Here


      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCompletion(int status) {
              assertTrue("Correct completion status", status == TransactionSynchronization.STATUS_UNKNOWN);
            }
          });
View Full Code Here

      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCompletion(int status) {
              assertTrue("Correct completion status", status == TransactionSynchronization.STATUS_UNKNOWN);
            }
          });
View Full Code Here

      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          status.setRollbackOnly();
          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCompletion(int status) {
              assertTrue("Correct completion status", status == TransactionSynchronization.STATUS_UNKNOWN);
            }
          });
View Full Code Here

    tt.execute(new TransactionCallback() {
      @Override
      public Object doInTransaction(TransactionStatus status) {
        EntityManagerFactoryUtils.getTransactionalEntityManager(factory).flush();
        TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
          @Override
          public void afterCompletion(int status) {
            tt.execute(new TransactionCallback() {
              @Override
              public Object doInTransaction(TransactionStatus status) {
View Full Code Here

  }

  @Override
  public void put(final Object key, final Object value) {
    if (TransactionSynchronizationManager.isSynchronizationActive()) {
      TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
        @Override
        public void afterCommit() {
          targetCache.put(key, value);
        }
      });
View Full Code Here

  }

  @Override
  public void evict(final Object key) {
    if (TransactionSynchronizationManager.isSynchronizationActive()) {
      TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
        @Override
        public void afterCommit() {
          targetCache.evict(key);
        }
      });
View Full Code Here

  @SuppressWarnings("unchecked")
  private List<T> getCurrentBuffer() {
    if(!TransactionSynchronizationManager.hasResource(bufferKey)) {
      TransactionSynchronizationManager.bindResource(bufferKey, new ArrayList<T>());

      TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
        @Override
        public void beforeCommit(boolean readOnly) {
          List<T> items = (List<T>) TransactionSynchronizationManager.getResource(bufferKey);

          if(!CollectionUtils.isEmpty(items)) {
View Full Code Here

    step.setTasklet(new TestingChunkOrientedTasklet<String>(getReader(new String[] { "a", "b", "c" }),
        new ItemWriter<String>() {
      @Override
      public void write(List<? extends String> data) throws Exception {
        TransactionSynchronizationManager
        .registerSynchronization(new TransactionSynchronizationAdapter() {
          @Override
          public void beforeCommit(boolean readOnly) {
            throw new RuntimeException("Simulate commit failure");
          }
        });
View Full Code Here

    if (!TransactionSynchronizationManager.hasResource(bufferKey)) {

      TransactionSynchronizationManager.bindResource(bufferKey, new StringBuffer());

      TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
        @Override
        public void afterCompletion(int status) {
          clear();
        }
View Full Code Here

TOP

Related Classes of org.springframework.transaction.support.TransactionSynchronizationAdapter

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.