Reputation:
is there any valid reason, all jersey resource classes are marked with @ManagedBean annotation. Already, the resource classes are marked with @Path and @Produces jaxrs annotations. is it not sufficient for the container to consider it as a jax-rs resource class?
Upvotes: 1
Views: 1215
Reputation: 3269
@ManagedBean
annotation is required if you want to inject your EJBs in JAX-RS resources without using @Local annotations and interfaces on your EJBs.
Compare the following Jersey documentation topics:
So you may choose what approach fits your needs well: either to use @Local
interface + @Stateless
EJB or to inject your @Stateless
EJBs without @Local
interface in your @ManagedBean
annotated resource.
Also take a look at the official example: https://github.com/jersey/jersey/tree/master/examples/managed-beans-webapp
Upvotes: 0
Reputation: 1909
javax.annotation.ManagedBean is not a jax-rs annotation, and because of that, the container shouldn't assume anything about jax-rs when reading that annotation, so, yes, @Path
and @Produces
are enough for the container to consider it as a jax-rs resource. You can use @ManagedBean if you want additional services (non-jax-rs related) to be provided to your resources by the container, check the link.
Upvotes: 0