001package arez.annotations;
002
003import java.lang.annotation.Documented;
004import java.lang.annotation.ElementType;
005import java.lang.annotation.Target;
006
007/**
008 * Annotation to identify method that is invoked before the component is disposed.
009 * This method is the first method invoked during the dispose operation and it occurs within the scope
010 * of the transaction that dispose is occurring within.
011 *
012 * <p>If there are multiple methods annotated with this annotation then the methods declared in parent
013 * classes will be invoked last and multiple methods within a single class will be invoked in reverse declaration
014 * order.</p>
015 *
016 * <p>The method that is annotated with this annotation must comply with the additional constraints:</p>
017 * <ul>
018 * <li>Must not be annotated with any other arez annotation</li>
019 * <li>Must have 0 parameters</li>
020 * <li>Must not return a value</li>
021 * <li>Must not be private</li>
022 * <li>Must not be static</li>
023 * <li>Must not be abstract</li>
024 * <li>Must not throw exceptions</li>
025 * <li>Must be accessible to the class annotated by the {@link ArezComponent} annotation.</li>
026 * <li>
027 *   Should not be public as not expected to be invoked outside the component. A warning will be generated but can
028 *   be suppressed by the {@link SuppressWarnings} or {@link SuppressArezWarnings} annotations with a key
029 *   "Arez:PublicLifecycleMethod". This warning is also suppressed by the annotation processor if it is implementing
030 *   an interface method.
031 * </li>
032 * <li>
033 *   Should not be protected if in the class annotated with the {@link ArezComponent} annotation as the method is not
034 *   expected to be invoked outside the component. A warning will be generated but can be suppressed by the
035 *   {@link SuppressWarnings} or {@link SuppressArezWarnings} annotations with a key "Arez:ProtectedMethod".
036 * </li>
037 * </ul>
038 */
039@Documented
040@Target( ElementType.METHOD )
041public @interface PreDispose
042{
043}