01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.beans.factory.annotation;
18:
19: import java.lang.annotation.ElementType;
20: import java.lang.annotation.Retention;
21: import java.lang.annotation.RetentionPolicy;
22: import java.lang.annotation.Target;
23:
24: /**
25: * Marks a constructor, field, setter method or config method as to be
26: * autowired by Spring's dependency injection facilities.
27: *
28: * <p>Only one constructor (at max) of any given bean class may carry this
29: * annotation, indicating the constructor to autowire when used as a Spring
30: * bean. Such a constructor does not have to be public.
31: *
32: * <p>Fields are injected right after construction of a bean, before any
33: * config methods are invoked. Such a config field does not have to be public.
34: *
35: * <p>Config methods may have an arbitrary name and any number of arguments;
36: * each of those arguments will be autowired with a matching bean in the
37: * Spring container. Bean property setter methods are effectively just
38: * a special case of such a general config method. Such config methods
39: * do not have to be public.
40: *
41: * <p>In the case of multiple argument methods, the 'required' parameter is
42: * applicable for all arguments.
43: *
44: * <p>Please do consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor}
45: * class (which, by default, checks for the presence of this annotation).
46: *
47: * @author Juergen Hoeller
48: * @author Mark Fisher
49: * @since 2.5
50: * @see AutowiredAnnotationBeanPostProcessor
51: */
52: @Retention(RetentionPolicy.RUNTIME)
53: @Target({ElementType.CONSTRUCTOR,ElementType.FIELD,ElementType.METHOD})
54: public @interface Autowired {
55:
56: /**
57: * <code>true</code> if the dependency is required.
58: * <p>Defaults to <code>true</code>.
59: */
60: boolean required() default true;
61:
62: }
|