Hi all,
I was reading through JAX-RS 2.0 edr3 specification and had some questions
about the alignment with other specs. First of all I can see that @Context
is still used to inject UriInfo, HttpHeaders of even servlet resources.
When I read the spec (§3.2) I see the word *Resource* in the
definition : "*_at_Context
Injects an instance of a supported resource*". So why not use the @Resource
annotation ? In the case of JAX-RS @Inject looks more appropriate
(@Resource deals with JNDI names and so on).
For asynchrony (§8) they need to inject an ExecutionContext. Again, this is
done with @Context, which is a real shame as ExecutionContext sounds like
SessionContext (which is injected with a @Resource or @Inject). Asynchrony
in JAX-RS is done with the @Suspend annotation, it has a timeout and a time
unit attributes (@Suspend(timeOut = 15, timeUnit = TimeUnit.SECONDS)) while
we have @Asynchronous in EJB (without any attributes). In the spec there is
even a sample mixing both :
@Stateless
@Path("/")
class EJBResource {
@GET *_at_Suspend @Asynchronous*
public void longRunningOp(@Context ExecutionContext ctx) {
executeLongRunningOp();
ctx.resume("Hello async world!");
}
}
Servlet also has it's own mechanism to deal with asynchronous requests. In
the EJB group we talked about "standardizing" @Asynchronous and giving it
to other specifications. Couldn't it be the case with JAX-RS (and Servlet,
but I think this topic has heavily been debated during Servlet 3.0) ?
And in a more general question, do we really need to push alignment between
specs when it's possible ?
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org> |
Twitter<http://twitter.com/agoncal>|
Blog <http://feeds.feedburner.com/AntonioGoncalves> |
LinkedIn<http://www.linkedin.com/in/agoncal>| Paris
JUG <http://www.parisjug.org>