Package org.springframework.transaction.interceptor

Examples of org.springframework.transaction.interceptor.DefaultTransactionAttribute


    LocalContainerEntityManagerFactoryBean cefb = parseValidPersistenceUnit();

    JpaTransactionManager jpatm = new JpaTransactionManager();
    jpatm.setEntityManagerFactory(cefb.getObject());

    TransactionStatus txStatus = jpatm.getTransaction(new DefaultTransactionAttribute());

    EntityManagerFactory emf = cefb.getObject();
    assertSame("EntityManagerFactory reference must be cached after init", emf, cefb.getObject());

    assertNotSame("EMF must be proxied", mockEmf, emf);
View Full Code Here


    LocalContainerEntityManagerFactoryBean cefb = parseValidPersistenceUnit();

    JpaTransactionManager jpatm = new JpaTransactionManager();
    jpatm.setEntityManagerFactory(cefb.getObject());

    TransactionStatus txStatus = jpatm.getTransaction(new DefaultTransactionAttribute());

    EntityManagerFactory emf = cefb.getObject();
    assertSame("EntityManagerFactory reference must be cached after init", emf, cefb.getObject());

    assertNotSame("EMF must be proxied", mockEmf, emf);
View Full Code Here

    pui.setTransactionType(PersistenceUnitTransactionType.JTA);

    JpaTransactionManager jpatm = new JpaTransactionManager();
    jpatm.setEntityManagerFactory(cefb.getObject());

    TransactionStatus txStatus = jpatm.getTransaction(new DefaultTransactionAttribute());

    EntityManagerFactory emf = cefb.getObject();
    assertSame("EntityManagerFactory reference must be cached after init", emf, cefb.getObject());

    assertNotSame("EMF must be proxied", mockEmf, emf);
View Full Code Here

  @Test
  public void putTransactional() {
    Cache target = new ConcurrentMapCache("testCache");
    Cache cache = new TransactionAwareCacheDecorator(target);

    TransactionStatus status = txManager.getTransaction(new DefaultTransactionAttribute(
        TransactionDefinition.PROPAGATION_REQUIRED));

    Object key = new Object();
    cache.put(key, "123");
    assertNull(target.get(key));
View Full Code Here

    Cache cache = new TransactionAwareCacheDecorator(target);
    Object key = new Object();
    cache.put(key, "123");


    TransactionStatus status = txManager.getTransaction(new DefaultTransactionAttribute(
        TransactionDefinition.PROPAGATION_REQUIRED));
    cache.evict(key);
    assertEquals("123", target.get(key, String.class));
    txManager.commit(status);
View Full Code Here

      builder.throttleLimit(throttleLimit);
    }
    builder.transactionManager(transactionManager);
    if (transactionTimeout != null || propagation != null || isolation != null
        || noRollbackExceptionClasses != null) {
      DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
      if (propagation != null) {
        attribute.setPropagationBehavior(propagation.value());
      }
      if (isolation != null) {
        attribute.setIsolationLevel(isolation.value());
      }
      if (transactionTimeout != null) {
        attribute.setTimeout(transactionTimeout);
      }
      Collection<Class<? extends Throwable>> exceptions = noRollbackExceptionClasses == null ? new HashSet<Class<? extends Throwable>>()
          : noRollbackExceptionClasses;
      final BinaryExceptionClassifier classifier = new BinaryExceptionClassifier(exceptions, false);
      builder.transactionAttribute(new DefaultTransactionAttribute(attribute) {
        @Override
        public boolean rollbackOn(Throwable ex) {
          return classifier.classify(ex);
        }
      });
View Full Code Here

    // On Standalone With Tasklet Ref
    validateTransactionAttributesInherited("s8", ctx);
  }

  private void validateTransactionAttributesInherited(String stepName, ApplicationContext ctx) {
    DefaultTransactionAttribute txa = getTransactionAttribute(ctx, stepName);
    assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, txa.getPropagationBehavior());
    assertEquals(TransactionDefinition.ISOLATION_DEFAULT, txa.getIsolationLevel());
    assertEquals(10, txa.getTimeout());
  }
View Full Code Here

   * @return the transactionAttribute
   */
  @SuppressWarnings("serial")
  protected TransactionAttribute getTransactionAttribute() {

    DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
    attribute.setPropagationBehavior(propagation.value());
    attribute.setIsolationLevel(isolation.value());
    attribute.setTimeout(transactionTimeout);
    return new DefaultTransactionAttribute(attribute) {

      /**
       * Ignore the default behaviour and rollback on all exceptions that bubble up to the tasklet level. The
       * tasklet has to deal with the rollback rules internally.
       */
 
View Full Code Here

  @SuppressWarnings("serial")
  private TransactionAttribute getTransactionAttribute(TransactionAttribute attribute) {

    final Classifier<Throwable, Boolean> classifier = getRollbackClassifier();
    return new DefaultTransactionAttribute(attribute) {
      @Override
      public boolean rollbackOn(Throwable ex) {
        return classifier.classify(ex);
      }
View Full Code Here

    });

    JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
    StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);

    @SuppressWarnings("serial")
    DefaultTransactionAttribute transactionAttribute = new DefaultTransactionAttribute() {
      @Override
      public boolean rollbackOn(Throwable ex) {
        return false;
      }
    };
View Full Code Here

TOP

Related Classes of org.springframework.transaction.interceptor.DefaultTransactionAttribute

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.