    001// Copyright 2007, 2008, 2009, 2011 The Apache Software Foundation
    002//
    003// Licensed under the Apache License, Version 2.0 (the "License");
    004// you may not use this file except in compliance with the License.
    005// You may obtain a copy of the License at
    006//
    007//     http://www.apache.org/licenses/LICENSE-2.0
    008//
    009// Unless required by applicable law or agreed to in writing, software
    010// distributed under the License is distributed on an "AS IS" BASIS,
    011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012// See the License for the specific language governing permissions and
    013// limitations under the License.
    014
    015package org.apache.tapestry5.ioc.annotations;
    016
    017import java.lang.annotation.Documented;
    018import java.lang.annotation.Retention;
    019import java.lang.annotation.Target;
    020
    021import static java.lang.annotation.ElementType.FIELD;
    022import static java.lang.annotation.ElementType.PARAMETER;
    023import static java.lang.annotation.RetentionPolicy.RUNTIME;
    024import static org.apache.tapestry5.ioc.annotations.AnnotationUseContext.*;
    025
    026/**
    027 * Used to inject a symbol value, via a symbol name. This is used much like {@link
    028 * org.apache.tapestry5.ioc.annotations.Value} annotation, except that symbols are not expanded ... the entire value is
    029 * a symbol name. This allows the annotation to reference a public constant variable.
    030 * <p/>
    031 * <p/>
    032 * The injected value may be coerced from string to an alternate type (defined by the field or parameter to which
    033 * the @Symbol annotation is attached). For better control, use the {@link IntermediateType} annotation as well, which
    034 * allows the string to be coerced to an alternate type before being coerced a second time to the field or parameter type.
    035 */
    036@Target(
    037        {PARAMETER, FIELD})
    038@Retention(RUNTIME)
    039@Documented
    040@UseWith({COMPONENT, MIXIN, PAGE, SERVICE})
    041public @interface Symbol
    042{
    043    /**
    044     * The name of the symbol to inject.
    045     */
    046    String value();
    047}