001/*
002 * Copyright 2002-2019 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.beans.factory.annotation;
018
019import java.lang.annotation.Documented;
020import java.lang.annotation.ElementType;
021import java.lang.annotation.Retention;
022import java.lang.annotation.RetentionPolicy;
023import java.lang.annotation.Target;
024
025/**
026 * Annotation at the field or method/constructor parameter level
027 * that indicates a default value expression for the affected argument.
028 *
029 * <p>Typically used for expression-driven dependency injection. Also supported
030 * for dynamic resolution of handler method parameters, e.g. in Spring MVC.
031 *
032 * <p>A common use case is to assign default field values using
033 * {@code #{systemProperties.myProp}} style expressions.
034 *
035 * <p>Note that actual processing of the {@code @Value} annotation is performed
036 * by a {@link org.springframework.beans.factory.config.BeanPostProcessor
037 * BeanPostProcessor} which in turn means that you <em>cannot</em> use
038 * {@code @Value} within
039 * {@link org.springframework.beans.factory.config.BeanPostProcessor
040 * BeanPostProcessor} or
041 * {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor BeanFactoryPostProcessor}
042 * types. Please consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor}
043 * class (which, by default, checks for the presence of this annotation).
044 *
045 * @author Juergen Hoeller
046 * @since 3.0
047 * @see AutowiredAnnotationBeanPostProcessor
048 * @see Autowired
049 * @see org.springframework.beans.factory.config.BeanExpressionResolver
050 * @see org.springframework.beans.factory.support.AutowireCandidateResolver#getSuggestedValue
051 */
052@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
053@Retention(RetentionPolicy.RUNTIME)
054@Documented
055public @interface Value {
056
057        /**
058         * The actual value expression: for example {@code #{systemProperties.myProp}}.
059         */
060        String value();
061
062}