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.ioc.annotations;
014
015import java.lang.annotation.Documented;
016import java.lang.annotation.Retention;
017import java.lang.annotation.Target;
018
019import static java.lang.annotation.ElementType.*;
020import static java.lang.annotation.RetentionPolicy.RUNTIME;
021import static org.apache.tapestry5.ioc.annotations.AnnotationUseContext.*;
022
023/**
024 * This annotation serves is something of the Swiss Army knife for operations related to injection of dependencies into
025 * an arbitrary method of Java Bean.
026 *
027 *
028 * It marks parameters that should be injected in the IoC container, and it marks fields that should be injected inside
029 * Tapestry components.
030 *
031 * In terms of the IoC container; normally, resources take precedence over annotations when injecting. The Inject
032 * annotation overrides this default, forcing the resolution of the parameters value via the master
033 * {@link org.apache.tapestry5.ioc.ObjectProvider}, even when the parameter's type matches a type that is normally a
034 * resource.
035 *
036 * For service implementations, module classes, and other objects constructed via
037 * {@link org.apache.tapestry5.ioc.ObjectLocator#autobuild(Class)}, this annotation indicates that an injection is
038 * desired on the field, as with fields of a Tapestry component.
039 *
040 * In terms of the IoC container, the Inject annotation is only used on parameters to service builder methods (and
041 * contributor and decorator methods) and on module class constructors. constructors. However, inside Tapestry
042 * components (<em>and only inside components</em>), it may be applied to fields. On fields that require injection, the
043 * Inject annotation is <em>required</em>.
044 *
045 * Finally, on a constructor, this is used to indicate <em>which</em> constructor should be used when more than one is
046 * available.
047 * 
048 * @see org.apache.tapestry5.ioc.ObjectProvider
049 */
050@Target(
051{ PARAMETER, FIELD, CONSTRUCTOR })
052@Retention(RUNTIME)
053@Documented
054@UseWith(
055{ COMPONENT, MIXIN, PAGE, SERVICE })
056public @interface Inject
057{
058
059}