parent
7bb4ab6842
commit
74511181de
|
@ -5822,9 +5822,10 @@ you should use the `@Named` annotation as follows:
|
||||||
|
|
||||||
|
|
||||||
[[beans-named]]
|
[[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]
|
[source,java,indent=0]
|
||||||
[subs="verbatim,quotes"]
|
[subs="verbatim,quotes"]
|
||||||
|
@ -5832,7 +5833,7 @@ Instead of `@Component`, `@javax.inject.Named` may be used as follows:
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
@Named("movieListener")
|
@Named("movieListener") // @ManagedBean("movieListener") could be used as well
|
||||||
public class SimpleMovieLister {
|
public class SimpleMovieLister {
|
||||||
|
|
||||||
private MovieFinder movieFinder;
|
private MovieFinder movieFinder;
|
||||||
|
@ -5869,8 +5870,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
|
When using `@Named` or `@ManagedBean`, it is possible to use component scanning in the
|
||||||
as when using Spring annotations:
|
exact same way as when using Spring annotations:
|
||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
[subs="verbatim,quotes"]
|
[subs="verbatim,quotes"]
|
||||||
|
@ -5884,8 +5885,9 @@ as when using Spring annotations:
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
In contrast to `@Component`, the JSR-330 `@Named` annotation is not composable.
|
In contrast to `@Component`, the JSR-330 `@Named` and the JSR-250 `ManagedBean`
|
||||||
Please use Spring's stereotype model for building custom component annotations.
|
annotations are not composable. Please use Spring's stereotype model for building custom
|
||||||
|
component annotations.
|
||||||
====
|
====
|
||||||
|
|
||||||
|
|
||||||
|
@ -5906,7 +5908,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.
|
| `@Inject` has no 'required' attribute; can be used with Java 8's `Optional` instead.
|
||||||
|
|
||||||
| @Component
|
| @Component
|
||||||
| @Named
|
| @Named / @ManagedBean
|
||||||
| JSR-330 does not provide a composable model, just a way to identify named components.
|
| JSR-330 does not provide a composable model, just a way to identify named components.
|
||||||
|
|
||||||
| @Scope("singleton")
|
| @Scope("singleton")
|
||||||
|
|
|
@ -846,6 +846,7 @@ tests and can be used anywhere in the Spring Framework.
|
||||||
* `@Autowired`
|
* `@Autowired`
|
||||||
* `@Qualifier`
|
* `@Qualifier`
|
||||||
* `@Resource` (javax.annotation) _if JSR-250 is present_
|
* `@Resource` (javax.annotation) _if JSR-250 is present_
|
||||||
|
* `@ManagedBean` (javax.annotation) _if JSR-250 is present_
|
||||||
* `@Inject` (javax.inject) _if JSR-330 is present_
|
* `@Inject` (javax.inject) _if JSR-330 is present_
|
||||||
* `@Named` (javax.inject) _if JSR-330 is present_
|
* `@Named` (javax.inject) _if JSR-330 is present_
|
||||||
* `@PersistenceContext` (javax.persistence) _if JPA is present_
|
* `@PersistenceContext` (javax.persistence) _if JPA is present_
|
||||||
|
|
Loading…
Reference in New Issue