001package arez.annotations; 002 003import java.lang.annotation.Documented; 004import java.lang.annotation.ElementType; 005import java.lang.annotation.Target; 006import javax.annotation.Nonnull; 007 008/** 009 * Annotation that marks a method as requiring an existing Arez transaction. 010 * 011 * <p>The method that is annotated with this annotation must comply with the additional constraints:</p> 012 * <ul> 013 * <li>Must not be annotated with any other arez annotation</li> 014 * <li>Must not be private</li> 015 * <li>Must not be static</li> 016 * <li>Must not be final</li> 017 * <li>Must not be abstract</li> 018 * <li>Must be accessible to the class annotated by the {@link ArezComponent} annotation.</li> 019 * </ul> 020 * 021 * <p>This annotation is only supported on methods contained within a type annotated by 022 * {@link ArezComponent} or {@link ArezComponentLike}. Other usages will fail compilation.</p> 023 * 024 * <p>Unlike {@link Action}, this annotation never creates or wraps a transaction and instead verifies 025 * that the caller has already established a transaction with the required characteristics.</p> 026 */ 027@Documented 028@Target( ElementType.METHOD ) 029public @interface RequiresTransaction 030{ 031 /** 032 * Return the required mode of the existing transaction. 033 * 034 * @return the required mode of the existing transaction. 035 */ 036 @Nonnull 037 TransactionMode mode() default TransactionMode.ANY; 038 039 /** 040 * Return the required tracking state of the existing transaction. 041 * 042 * @return the required tracking state of the existing transaction. 043 */ 044 @Nonnull 045 TrackingMode tracking() default TrackingMode.ANY; 046}