Meaning of bean discovery mode annotated in CDI 1.1

前端 未结 3 830
不知归路
不知归路 2020-11-30 08:52

I am migrating an application to Java EE 7 and would like to CDI 1.1. But I don\'t get the meaning of bean-discovery-mode=\"annotated\". The CDI 1.1 specificat

3条回答
  •  温柔的废话
    2020-11-30 09:07

    When using bean-discovery-mode="annotated" only classes with a bean defining annotation are discovered. All other classes are ignored. Any scope type is a bean defining annotation. If a scope type is declared on a bean class, then the bean class is said to have a bean defining annotation [spec]. The 1.1 spec is not completely clear here. Only classes with a @NormalScope scope or @Dependent pseudo scope are discovered, @javax.inject.Singleton and all other @Scope (pseudo) scopes are ignored.

    Note that the definition of a "bean defining annotation" changed in CDI 1.2 and is now very well defined:

    The set of bean defining annotations contains:

    • @ApplicationScoped, @SessionScoped, @ConversationScoped and @RequestScoped annotations,
    • all other normal scope types,
    • @Interceptor and @Decorator annotations,
    • all stereotype annotations (i.e. annotations annotated with @Stereotype), and the @Dependent scope annotation.

提交回复
热议问题