From 5f68da31538fb01ca2d8d31375a1f1d3c65289ff Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 19 Aug 2016 13:52:39 +0200 Subject: [PATCH] Document support for `@ManagedBean` Issue: SPR-14600 --- src/asciidoc/core-beans.adoc | 18 ++++++++++-------- src/asciidoc/testing.adoc | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/asciidoc/core-beans.adoc b/src/asciidoc/core-beans.adoc index 8af1139edaf..b6f74bd7bd9 100644 --- a/src/asciidoc/core-beans.adoc +++ b/src/asciidoc/core-beans.adoc @@ -5856,9 +5856,10 @@ you should use the `@Named` annotation as follows: [[beans-named]] -=== @Named: a standard equivalent to the @Component annotation +=== @Named and @ManagedBean: standard equivalents to the @Component annotation -Instead of `@Component`, `@javax.inject.Named` may be used as follows: +Instead of `@Component`, `@javax.inject.Named` or `javax.annotation.ManagedBean` may be +used as follows: [source,java,indent=0] [subs="verbatim,quotes"] @@ -5866,7 +5867,7 @@ Instead of `@Component`, `@javax.inject.Named` may be used as follows: import javax.inject.Inject; import javax.inject.Named; - @Named("movieListener") + @Named("movieListener") // @ManagedBean("movieListener") could be used as well public class SimpleMovieLister { private MovieFinder movieFinder; @@ -5903,8 +5904,8 @@ It is very common to use `@Component` without specifying a name for the componen } ---- -When using `@Named`, it is possible to use component scanning in the exact same way -as when using Spring annotations: +When using `@Named` or `@ManagedBean`, it is possible to use component scanning in the +exact same way as when using Spring annotations: [source,java,indent=0] [subs="verbatim,quotes"] @@ -5918,8 +5919,9 @@ as when using Spring annotations: [NOTE] ==== -In contrast to `@Component`, the JSR-330 `@Named` annotation is not composable. -Please use Spring's stereotype model for building custom component annotations. +In contrast to `@Component`, the JSR-330 `@Named` and the JSR-250 `ManagedBean` +annotations are not composable. Please use Spring's stereotype model for building custom +component annotations. ==== @@ -5940,7 +5942,7 @@ features are not available as shown in the table below: | `@Inject` has no 'required' attribute; can be used with Java 8's `Optional` instead. | @Component -| @Named +| @Named / @ManagedBean | JSR-330 does not provide a composable model, just a way to identify named components. | @Scope("singleton") diff --git a/src/asciidoc/testing.adoc b/src/asciidoc/testing.adoc index aa9e7dc81a4..3efed67525b 100644 --- a/src/asciidoc/testing.adoc +++ b/src/asciidoc/testing.adoc @@ -852,6 +852,7 @@ tests and can be used anywhere in the Spring Framework. * `@Autowired` * `@Qualifier` * `@Resource` (javax.annotation) _if JSR-250 is present_ +* `@ManagedBean` (javax.annotation) _if JSR-250 is present_ * `@Inject` (javax.inject) _if JSR-330 is present_ * `@Named` (javax.inject) _if JSR-330 is present_ * `@PersistenceContext` (javax.persistence) _if JPA is present_