001/*
002 * Copyright 2013 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 */
016package org.springframework.batch.core.configuration.annotation;
017
018import org.springframework.context.annotation.Scope;
019import org.springframework.context.annotation.ScopedProxyMode;
020
021import java.lang.annotation.Documented;
022import java.lang.annotation.Retention;
023import java.lang.annotation.RetentionPolicy;
024
025/**
026 * <p>
027 * Convenient annotation for step scoped beans that defaults the proxy mode, so that it doesn't have to be specified
028 * explicitly on every bean definition. Use this on any &#64;Bean that needs to inject &#64;Values from the step
029 * context, and any bean that needs to share a lifecycle with a step execution (e.g. an ItemStream). E.g.
030 * </p>
031 *
032 * <pre class="code">
033 * &#064;Bean
034 * &#064;StepScope
035 * protected Callable&lt;String&gt; value(@Value(&quot;#{stepExecution.stepName}&quot;)
036 * final String value) {
037 *      return new SimpleCallable(value);
038 * }
039 * </pre>
040 *
041 * <p>Marking a &#64;Bean as &#64;StepScope is equivalent to marking it as <code>&#64;Scope(value="step", proxyMode=TARGET_CLASS)</code></p>
042 *
043 * @author Dave Syer
044 *
045 * @since 2.2
046 *
047 */
048@Scope(value = "step", proxyMode = ScopedProxyMode.TARGET_CLASS)
049@Retention(RetentionPolicy.RUNTIME)
050@Documented
051public @interface StepScope {
052
053}