users@jersey.java.net

Re: [Jersey] EJBs as subresources?

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Fri, 18 Dec 2009 08:45:06 -0500

The spec calls out root resource classes specifically since the implementation is responsible for instance creation. Sub-resource locator methods are responsible for creation of sub-resource instances so they can do whatever they like including returning an EJB instance.

Marc.

On Dec 18, 2009, at 4:17 AM, Paul Sandoz wrote:

>
> 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.