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