    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.ioc.annotations.UseWith;
    016import org.apache.tapestry5.services.javascript.JavaScriptSupport;
    017
    018import java.lang.annotation.Documented;
    019import java.lang.annotation.Retention;
    020import java.lang.annotation.Target;
    021
    022import static java.lang.annotation.ElementType.FIELD;
    023import static java.lang.annotation.RetentionPolicy.RUNTIME;
    024import static org.apache.tapestry5.ioc.annotations.AnnotationUseContext.*;
    025
    026/**
    027 * Defines a field of a component class that is replaced at runtime with a read-only value obtained from the
    028 * {@link org.apache.tapestry5.services.Environment} service.
    029 *
    030 * Most commonly, the field will be of type {@link JavaScriptSupport}, {@link org.apache.tapestry5.services.Heartbeat}
    031 * or {@link org.apache.tapestry5.services.FormSupport}, though many other options are possible.
    032 */
    033@Target(FIELD)
    034@Documented
    035@Retention(RUNTIME)
    036@UseWith(
    037{ COMPONENT, MIXIN, PAGE })
    038public @interface Environmental
    039{
    040    /**
    041     * The value determines if the environmental service to be injected is required or not. In most cases, it is, so the
    042     * default is true.
    043     */
    044    boolean value() default true;
    045}