Package org.springframework.transaction.interceptor

Examples of org.springframework.transaction.interceptor.TransactionAttribute


   * @throws NoSuchMethodException
   */
  public void testDoesNotResolveTxAnnotationOnMethodFromClassImplementingAnnotatedInterface() throws SecurityException, NoSuchMethodException {
    AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
    Method m = ImplementsAnnotatedInterface.class.getMethod("echo", Throwable.class);
    TransactionAttribute ta = atas.getTransactionAttribute(m, ImplementsAnnotatedInterface.class);
    assertNull(ta);
  }
View Full Code Here


      final DataSource finalDataSource = dataSource;
      int propagation = newTxRequired ? TransactionDefinition.PROPAGATION_REQUIRES_NEW
          : TransactionDefinition.PROPAGATION_REQUIRED;

      TransactionAttribute transactionAttribute = TestContextTransactionUtils.createDelegatingTransactionAttribute(
        testContext, new DefaultTransactionAttribute(propagation));

      new TransactionTemplate(transactionManager, transactionAttribute).execute(new TransactionCallbackWithoutResult() {

        @Override
View Full Code Here

    if (txContext != null) {
      throw new IllegalStateException("Cannot start a new transaction without ending the existing transaction.");
    }

    PlatformTransactionManager tm = null;
    TransactionAttribute transactionAttribute = this.attributeSource.getTransactionAttribute(testMethod, testClass);

    if (transactionAttribute != null) {
      transactionAttribute = TestContextTransactionUtils.createDelegatingTransactionAttribute(testContext,
        transactionAttribute);

      if (logger.isDebugEnabled()) {
        logger.debug("Explicit transaction definition [" + transactionAttribute + "] found for test context "
            + testContext);
      }

      if (transactionAttribute.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NOT_SUPPORTED) {
        return;
      }

      tm = getTransactionManager(testContext, transactionAttribute.getQualifier());
    }

    if (tm != null) {
      txContext = new TransactionContext(testContext, tm, transactionAttribute, isRollback(testContext));
      runBeforeTransactionMethods(testContext);
View Full Code Here

   * @return TransactionAttribute the configured transaction attribute,
   * or <code>null</code> if none was found
   */
  protected TransactionAttribute determineTransactionAttribute(AnnotatedElement ae) {
    for (TransactionAnnotationParser annotationParser : this.annotationParsers) {
      TransactionAttribute attr = annotationParser.parseTransactionAnnotation(ae);
      if (attr != null) {
        return attr;
      }
    }
    return null;
View Full Code Here

            this.transactionAttributeSource = transactionAttributeSource;
        }

        @Override
        public TransactionAttribute getTransactionAttribute(Method method, Class<?> targetClass) {
            final TransactionAttribute transactionAttribute = transactionAttributeSource.getTransactionAttribute(method, targetClass);
           
            //No dialect ignore support if transactionAttribute is null
            if (transactionAttribute == null) {
                return transactionAttribute;
            }
View Full Code Here

    if (testMethod.isAnnotationPresent(NotTransactional.class)) {
      return;
    }

    TransactionAttribute transactionAttribute =
        this.attributeSource.getTransactionAttribute(testMethod, testContext.getTestClass());
    TransactionDefinition transactionDefinition = null;
    if (transactionAttribute != null) {
      transactionDefinition = new DelegatingTransactionAttribute(transactionAttribute) {
        public String getName() {
          return testMethod.getName();
        }
      };
    }

    if (transactionDefinition != null) {
      if (logger.isDebugEnabled()) {
        logger.debug("Explicit transaction definition [" + transactionDefinition +
            "] found for test context [" + testContext + "]");
      }
      String qualifier = transactionAttribute.getQualifier();
      PlatformTransactionManager tm;
      if (StringUtils.hasLength(qualifier)) {
        // Use autowire-capable factory in order to support extended qualifier matching
        // (only exposed on the internal BeanFactory, not on the ApplicationContext).
        BeanFactory bf = testContext.getApplicationContext().getAutowireCapableBeanFactory();
View Full Code Here

   * @return TransactionAttribute the configured transaction attribute,
   * or <code>null</code> if none was found
   */
  protected TransactionAttribute determineTransactionAttribute(AnnotatedElement ae) {
    for (TransactionAnnotationParser annotationParser : this.annotationParsers) {
      TransactionAttribute attr = annotationParser.parseTransactionAnnotation(ae);
      if (attr != null) {
        return attr;
      }
    }
    return null;
View Full Code Here

  @Test
  public void testOverrideWithoutChangingRollbackRules() throws Exception {
    TransactionAttributeEditor editor = new TransactionAttributeEditor();
    editor.setAsText("-RuntimeException");
    TransactionAttribute attr = (TransactionAttribute) editor.getValue();
    assertTrue(attr.rollbackOn(new RuntimeException("")));
    assertFalse(attr.rollbackOn(new Exception("")));
  }
View Full Code Here

  @Test
  public void testChangeRollbackRules() throws Exception {
    TransactionAttributeEditor editor = new TransactionAttributeEditor();
    editor.setAsText("+RuntimeException");
    TransactionAttribute attr = (TransactionAttribute) editor.getValue();
    assertFalse(attr.rollbackOn(new RuntimeException("")));
    assertFalse(attr.rollbackOn(new Exception("")));
  }
View Full Code Here

TOP

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

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.