diff --git a/org.springframework.core/src/test/java/org/springframework/beans/factory/annotation/Autowired.java b/org.springframework.core/src/test/java/org/springframework/beans/factory/annotation/Autowired.java new file mode 100644 index 0000000000..c326508253 --- /dev/null +++ b/org.springframework.core/src/test/java/org/springframework/beans/factory/annotation/Autowired.java @@ -0,0 +1,67 @@ +/* + * Copyright 2002-2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.beans.factory.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marks a constructor, field, setter method or config method as to be + * autowired by Spring's dependency injection facilities. + * + *
Only one constructor (at max) of any given bean class may carry this + * annotation, indicating the constructor to autowire when used as a Spring + * bean. Such a constructor does not have to be public. + * + *
Fields are injected right after construction of a bean, before any + * config methods are invoked. Such a config field does not have to be public. + * + *
Config methods may have an arbitrary name and any number of arguments; + * each of those arguments will be autowired with a matching bean in the + * Spring container. Bean property setter methods are effectively just + * a special case of such a general config method. Such config methods + * do not have to be public. + * + *
In the case of multiple argument methods, the 'required' parameter is + * applicable for all arguments. + * + *
In case of a {@link java.util.Collection} or {@link java.util.Map} + * dependency type, the container will autowire all beans matching the + * declared value type. In case of a Map, the keys must be declared as + * type String and will be resolved to the corresponding bean names. + * + *
Please do consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor} + * class (which, by default, checks for the presence of this annotation). + * + * @author Juergen Hoeller + * @author Mark Fisher + * @since 2.5 + * @see AutowiredAnnotationBeanPostProcessor + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD}) +public @interface Autowired { + + /** + * Declares whether the annotated dependency is required. + *
Defaults to true
.
+ */
+ boolean required() default true;
+
+}
diff --git a/org.springframework.core/src/test/java/org/springframework/beans/factory/annotation/Qualifier.java b/org.springframework.core/src/test/java/org/springframework/beans/factory/annotation/Qualifier.java
new file mode 100644
index 0000000000..cc1584c843
--- /dev/null
+++ b/org.springframework.core/src/test/java/org/springframework/beans/factory/annotation/Qualifier.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2002-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.beans.factory.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation may be used on a field or parameter as a qualifier for
+ * candidate beans when autowiring. It may also be used to annotate other
+ * custom annotations that can then in turn be used as qualifiers.
+ *
+ * @author Mark Fisher
+ * @author Juergen Hoeller
+ * @since 2.5
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE, ElementType.ANNOTATION_TYPE})
+@Inherited
+@Documented
+public @interface Qualifier {
+
+ String value() default "";
+
+}