Managed beans in CDI

There are several ways to declare a Java class as a managed bean. For example, if we annotate a class with @ManageBean, it is defined as a managed bean. However, the CDI specification insists that a class has to be considered as a managed bean according to certain criteria. These criteria are as follows:

  • It is not a nonstatic inner class
  • It is a concrete class or it is annotated with @Decorator
  • It is not an EJB component
  • It does not implement javax.enterprise.inject.spi.Extension
  • It either has a no-argument constructor, or declares a constructor annotated with @Inject

Get Java EE 8 Design Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.