@Target(value={TYPE,METHOD}) @Retention(value=RUNTIME) @Documented public @interface Scope
@Component
,
@Scope
indicates the name of a scope to use for instances of
the annotated type.
When used as a method-level annotation in conjunction with
@Bean
, @Scope
indicates the name of a scope to use
for the instance returned from the method.
In this context, scope means the lifecycle of an instance,
such as singleton
, prototype
, and so forth. Scopes
provided out of the box in Spring may be referred to using the
SCOPE_*
constants available in the ConfigurableBeanFactory
and WebApplicationContext
interfaces.
To register additional custom scopes, see
CustomScopeConfigurer
.
Modifier and Type | Optional Element and Description |
---|---|
ScopedProxyMode |
proxyMode
Specifies whether a component should be configured as a scoped proxy
and if so, whether the proxy should be interface-based or subclass-based.
|
String |
scopeName
Specifies the name of the scope to use for the annotated component/bean.
|
String |
value
Alias for
scopeName() . |
@AliasFor(value="scopeName") public abstract String value
scopeName()
.scopeName()
@AliasFor(value="value") public abstract String scopeName
Defaults to an empty string (""
) which implies
SCOPE_SINGLETON
.
ConfigurableBeanFactory.SCOPE_PROTOTYPE
,
ConfigurableBeanFactory.SCOPE_SINGLETON
,
WebApplicationContext.SCOPE_REQUEST
,
WebApplicationContext.SCOPE_SESSION
,
value()
public abstract ScopedProxyMode proxyMode
Defaults to ScopedProxyMode.DEFAULT
, which typically indicates
that no scoped proxy should be created unless a different default
has been configured at the component-scan instruction level.
Analogous to <aop:scoped-proxy/>
support in Spring XML.
ScopedProxyMode