    001// Licensed under the Apache License, Version 2.0 (the "License");
    002// you may not use this file except in compliance with the License.
    003// You may obtain a copy of the License at
    004//
    005// http://www.apache.org/licenses/LICENSE-2.0
    006//
    007// Unless required by applicable law or agreed to in writing, software
    008// distributed under the License is distributed on an "AS IS" BASIS,
    009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    010// See the License for the specific language governing permissions and
    011// limitations under the License.
    012
    013package org.apache.tapestry5.annotations;
    014
    015import org.apache.tapestry5.internal.transform.HeartbeatDeferredWorker;
    016import org.apache.tapestry5.ioc.annotations.UseWith;
    017import org.apache.tapestry5.services.Heartbeat;
    018
    019import java.lang.annotation.Documented;
    020import java.lang.annotation.ElementType;
    021import java.lang.annotation.Retention;
    022import java.lang.annotation.Target;
    023
    024import static java.lang.annotation.RetentionPolicy.RUNTIME;
    025import static org.apache.tapestry5.ioc.annotations.AnnotationUseContext.*;
    026
    027/**
    028 * Marks a component method as deferred until the end of the {@link Heartbeat}. This
    029 * is only allowed on void methods that do not throw exceptions. The invocation is captured
    030 * and will execute at the end of the current Heartbeat.
    031 *
    032 * This annotation should be used with care, since deferring the invocation can change its semantics. For example, the
    033 * value stored in instance variables may change between the time the method is invoked and the time it eventually
    034 * executes. Likewise, runtime exceptions thrown by the method can not be caught by the invoking method.
    035 *
    036 * Annotated methods must return void, and not declare any checked exceptions.
    037 *
    038 * @since 5.2.0
    039 * @see HeartbeatDeferredWorker
    040 */
    041@Target(ElementType.METHOD)
    042@Retention(RUNTIME)
    043@Documented
    044@UseWith(
    045{ COMPONENT, MIXIN, PAGE })
    046public @interface HeartbeatDeferred
    047{
    048
    049}