0

How can i find the implementations of transactional annotion of springframework? I only found the code below:

This is decompiled.class file.

package org.springframework.transaction.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface Transactional {
    @AliasFor("transactionManager")
    String value() default "";

    @AliasFor("value")
    String transactionManager() default "";

    Propagation propagation() default Propagation.REQUIRED;

    Isolation isolation() default Isolation.DEFAULT;

    int timeout() default -1;

    boolean readOnly() default false;

    Class<? extends Throwable>[] rollbackFor() default {};

    String[] rollbackForClassName() default {};

    Class<? extends Throwable>[] noRollbackFor() default {};

    String[] noRollbackForClassName() default {};
}

Some description but not see how exactly it implemented: You can place the @Transactional annotation before an interface definition, a method on an interface, a class definition, or a public method on a class. However, the mere presence of the @Transactional annotation is not enough to activate the transactional behavior. The @Transactional annotation is simply metadata that can be consumed by some runtime infrastructure that is @Transactional -aware and that can use the metadata to configure the appropriate beans with transactional behavior. In the preceding example, the <tx:annotation-driven/> element switches on the transactional behavior.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224

1 Answers1

1

Behind the scenes reflection is player, You can see the implementation of TransactionAnnotationParser.java interface (Strategy interface for parsing known transaction annotation types. AnnotationTransactionAttributeSource delegates to such parsers for supporting specific annotation types such as Spring's own Transactional, JTA 1.2's Transactional or EJB3's TransactionAttribute.),

Based on implementation SpringTransactionAnnotationParser is one of strategy implementation for parsing Spring's Transactional annotation its parse the transaction. If you need to deep dive into this then you need to go through with spring-tx module

Bhushan Uniyal
  • 5,575
  • 2
  • 22
  • 45