users@jersey.java.net

Re: [Jersey] _at_EJB with jersey ?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Sun, 27 Jul 2008 17:34:32 +0200

Julio Faerman wrote:
> The spec reads:
> "An implementation MAY offer other resource class lifecycles,
> mechanisms for specifying these are outside
> the scope of this specification."
>
> Would it be possible to specify a factory for Resources? If so, it
> could lookup and inject the @EJB there, while we wait JEE 6.
> If not, i guess a superclass constructor could also do it.
> Right?
>

Does the approach i referenced meet your requirements? This allows
references to EJBs (or any other EE related artifact) to be injected on
any managed Jersey component and not just resource classes.

Jersey does have a pluggable factory mechanism for resource life-cycle,
take a look at the @PerRequest and @Singleton annotations and look how
those annotations are annotated. However, in Jersey, life-cycle and
injection are two distinct aspects with separate pluggable APIs.

Paul.

> On Fri, Jul 25, 2008 at 1:25 PM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
>> Felipe Gaścho wrote:
>>> I have an EJB and I was wondering if I can make a reference to EJBs in
>>> Jersey annotated classes, something like:
>>>
>>> @UriTemplate("/test")
>>> public class TestService {
>>> @EJB
>>> private PricesFacadeLocal prices;
>>>
>>> @HttpMethod("GET")
>>> @ProduceMime("text/html")
>>> public String getPrice() {
>>> String result = "<html><head><title>Shoes list</title></head><body>";
>>> result += prices.getPrice(1);
>>> result += "</table></body></html>";
>>> return result;
>>> }
>>> }
>>>
>>> * I am considering to run this code on Glassfish...
>>>
>> See here:
>>
>> http://blogs.sun.com/sandoz/entry/ejb_injection
>>
>> Jersey is not compliant with EE yet, we are waiting for JAX-RS alignment to
>> EE6. But in the interim it is possible to have target support for various
>> aspects (or use Spring).
>>
>> Paul.
>>
>> --
>> | ? + ? = To question
>> ----------------\
>> Paul Sandoz
>> x38109
>> +33-4-76188109
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109