users@glassfish.java.net

Re: JAX-RS on Glassfish 3.1: _at_EJB injection?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 15 Jun 2010 16:31:49 +0200

On Jun 15, 2010, at 4:22 PM, glassfish_at_javadesktop.org wrote:

>> It is spec compliant. But we still have some work to
>> do to honor some
>> optional requirements.
>
> OK. So the essential gist is that a resource class needs to be a
> managed bean (either in the @ManagedBean sense or the CDI sense).
> Obviously, unannotated, a resource class [i]is[/i] a CDI managed
> bean, but you're saying that the Java EE 6 specification, somewhere,
> says that a resource class must be explicitly marked as a managed
> bean, owing to, among other things, the lateness of the inclusion of
> CDI into the Java EE specification.
>
> Is that all correct?
>

The JAX-RS spec is a little vague on the matter but is implied :-)
meaning we could improve things and make it much clearer!

The vagueness is around CDI. JAX-RS root resource classes are by
default managed in a per-request scope and any JAX-RS implementation,
that is required to support the JAX-RS programming model, will realize
the requirement to explicitly opt in for CDI so as not to break
existing JAX-RS applications. The portable way of doing this is for
the application to explicitly annotate.

The use of @ManagedBean or @Stateless or @Singleton already requires
explicit use.



> My takeaway: as long as I'm not using constructor injection--which
> I'm not--then simply marking my resource class as @RequestScoped or
> @ManagedBean will enable further injections to take place properly.
>
> Right?
>

Correct.

Paul.

> Thanks again,
> Laird
> [Message sent by forum member 'ljnelson']
>
> http://forums.java.net/jive/thread.jspa?messageID=474344
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>