Common annotations for the Java platform 1.2
In common annotations, there are three feature sets.
Common annotation
Provided by the javax.annotation
package, it is the basis of dependency injection. ManagedBean
is the base used to make a POJO an injected object. By default, we don’t need to use it because the CDI engine 1.2 automatically makes this annotation to the POJO. So, automatically each bean is injectable. The @priority
annotation was added in this new specification. The @Generated
annotation is very useful to mark autogenerated codes, so you can treat them in a different manner. Here is a sample of PostConstruct
:
@PostConstruct public void reset() { this.minimum = 0; }
It will be executed after the creation of the managed bean that implements it.
@Resources
lets us group a set of @Resource
annotations and call them a second time through the @Resource
annotation. Here's a sample of injection of a BeanManager
:
@Resources({ @Resource(name = "beanManager", lookup = "java:comp/BeanManager...