dev@jsr311.java.net

Re: JSR311: JAX-RS and EJB

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 24 Nov 2008 14:55:46 -0500

On Nov 24, 2008, at 1:56 PM, Stephan Koops wrote:
>
> do we mix software layers here?

Not necessarily but, like many things, it could be used unwisely.
>
> Otherwise I prefer option 3. Why do we need a new JNDI namespace for
> it?
>
Without the new context a JAX-RS runtime would have no way to work out
the JNDI name given only the class name - see problem (i) below.

> To option 1: If the idea is to have the EJB on in one class and the
> JAX-RS annotations in another interface, than we could use just
> implements. Otherwise we get a case like EJB 1 and 2, where an
> implementing class should not implement its interface. So that's not
> good IMO.
>
In option 1 the idea was to use the EJB annotation to declare the JNDI
name and interface for EJBs that should be exposed as JAX-RS
resources. An equivalent alternative would be to add a method to
Application like:

Map<String, Class> getEJBs();

Marc.

>
>> Experts,
>>
>> Its time to start discussing the work we want to do for the first
>> maintenance release of JAX-RS. For 1.1 we'll be concentrating on
>> alignment with EE 6 and fixing any bugs that may have come to light
>> since 1.0 was finalized.
>>
>> One significant issue that we've only briefly touched on before is
>> how
>> to combine JAX-RS and EJB in a portable way to expose an EJB directly
>> as a JAX-RS resource. There are a couple of technical issues that
>> prevent that today:
>>
>> (i) Given an EJB class name there's no portable way to work out the
>> JNDI name to use to obtain an instance.
>> (ii) Given a JNDI name one can lookup an instance but, at least for
>> the no-interface variant, the JAX-RS annotations will not be present
>> on the returned proxy.
>>
>> We discussed this with the EJB and EE spec leads and came up with the
>> following three potential solutions:
>>
>> (1) Declare a dependency on a resource EJB somewhere. E.g.:
>>
>> @EJB(name="OrdersResourceRef",
>> beanInterface=com.acme.OrdersResource.class)
>>
>> is placed on the Application class. The JAX-RS runtime will use the
>> following lookup to obtain an instance:
>>
>> OrdersResource o = (OrdersResource)
>> new InitialContext().lookup("java:comp/env/OrdersResourceRef");
>>
>> and will reflect on the com.acme.OrdersResource.class to determine
>> the
>> JAX-RS annotations.
>>
>> (2) Declare the JNDI name on the resource class. E.g.:
>>
>> @Stateless
>> @Path("somepath")
>> @JNDIName("OrdersResourceRef")
>> public class OrdersResource { ... }
>>
>> Assuming the name is added to the global namespace, the lookup to
>> obtain an instance is:
>>
>> OrdersResource o = (OrdersResource)
>> new InitialContext().lookup("java:global/OrdersResourceRef");
>>
>> The JAX-RS runtime will reflect on the resource class as normal.
>>
>> (3) Introduce a new java:module/... context that contains all
>> components in the current module. Given:
>>
>> @Stateless
>> @Path("somepath")
>> public class OrdersResource { ... }
>>
>> The JAX-RS runtime would use the following lookup to obtain an
>> instance:
>>
>> OrdersResource o = (OrdersResource)
>> new InitialContext().lookup("java:module/OrdersResource");
>>
>> and will reflect on the resource class as normal.
>>
>> Thoughts, comments, preferences ?
>>
>> Thanks,
>> Marc.
> _________________________________________________________________________
> Sensationsangebot nur bis 30.11: WEB.DE FreeDSL - Telefonanschluss +
> DSL
> für nur 16,37 Euro/mtl.!* http://dsl.web.de/?
> ac=OM.AD.AD008K13805B7069a
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.