users@jersey.java.net

Re: [Jersey] EJBs as subresources?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 18 Dec 2009 10:17:20 +0100

On Dec 18, 2009, at 12:00 AM, Moises Lejter wrote:

> Hi!
>
> I was just reading through the spec, and it mentions that EJBs can
> be root resources, Providers, and Application classes - but it does
> not mention subresources.
> Is there a reason why an EJB could not be a subresource?

No.


> Is it just a matter of the specification not mentioning it, thus
> letting implementations go either way?
>

Take a look at ID C002 and the second paragraph:

   https://jsr311.dev.java.net/drafts/changelog.1.1.html

The following additional requirements apply when using Managed Beans,
JSR299-style Managed Beans or EJBs as resource classes, providers or
Application subclasses:

Field and property injection of JAX-RS resources MUST be performed
prior to the container invoking any @PostConstruct annotated method.
Support for constructor injection of JAX-RS resources is OPTIONAL.
Portable applications MUST instead use fields or bean properties in
conjunction with a @PostConstruct annotated method. Implementations
SHOULD warn users about use of non-portable constructor injection.
Implementations MUST NOT require use of @Inject or @Resource to
trigger injection of JAX-RS annotated fields or properties.
Implementations MAY support such usage but SHOULD warn users about non-
portability.

Notice that "resource classes" and not "root resource classes" is
referred to.

Paul.