users@jsr311.java.net

Re: Sub-Resource Locators

From: Craig McClanahan <Craig.McClanahan_at_Sun.COM>
Date: Thu, 31 Jul 2008 14:40:22 -0700

Stephan Koops wrote:
> Hi,
>
> what's the problem to inject in @*Param and @Context annotated fields
> and bean setters, also if the object is not instantiated by the runtime?
> If it shouldn't be injected, than IMO the developer mjst not annotate
> field / bean setters.
>
One key issue is that the JAX-RS runtime does not know that the
sub-resource instance got instantiated at all, because it cannot plug
directly into the "new" operator of the JVM. This is the same reason
that, in all the cases where resource injection is defined in Java EE 5,
it only works in container-managed objects.

A second major problem, as Marc and Paul have mentioned, is that the
runtime would have no way to understand the lifecycle of the
instantiated object, and therefore no way to understand when a previous
injection might not be thread safe, or might no longer be valid.
> best regards
> Stephan
>
Craig

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>