001    // Copyright 2006, 2007 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    
015    package org.apache.tapestry.ioc.annotations;
016    
017    import org.apache.tapestry.ioc.ObjectProvider;
018    
019    import java.lang.annotation.Documented;
020    import static java.lang.annotation.ElementType.FIELD;
021    import static java.lang.annotation.ElementType.PARAMETER;
022    import java.lang.annotation.Retention;
023    import static java.lang.annotation.RetentionPolicy.RUNTIME;
024    import java.lang.annotation.Target;
025    
026    /**
027     * This annotation serves two similar purposes: it marks parameters that should be injected in the
028     * IoC container, and it marks fields that should be injected inside Tapestry components.
029     * <p/>
030     * In terms of the IoC container; normally, resources take precedence over annotations when
031     * injecting. The Inject annotation overrides this default, forcing the resolution of the parameters
032     * value via the master {@link ObjectProvider}, even when the parameter's type matches a type that
033     * is normally a resource. This is most often used in conjunction with {@link Value} annotation when
034     * injecting a string, as normally, the String would be matched as the service id.
035     * <p/>
036     * In terms of the IoC container, the Inject annotation is only used on parameters to service
037     * builder methods and constructors. However, inside Tapestry components (<em>and only inside components</em>),
038     * it may be applied to fields. On fields that require injection, the Inject annotation is
039     * <em>required</em>.
040     *
041     * @see ObjectProvider
042     */
043    @Target(
044            {PARAMETER, FIELD})
045    @Retention(RUNTIME)
046    @Documented
047    public @interface Inject
048    {
049    
050    }