Hi Tim,
Currently only JAX-RS/Jersey artifacts are injected on spring-managed
beans that are resource or provider classes.
There is an issue open to improve spring integration, by using a bean
post processor, which should resolve the issue you are encountering:
http://java.net/jira/browse/JERSEY-469
Paul.
On Nov 23, 2010, at 6:20 PM, Tim Wood wrote:
> Hi,
>
> I am having trouble understanding how to inject the ResourceContext
> into
> a bean that was created by spring. For example, I have two classes. A
> sub-resource managed by Jersey and a plain request scoped bean managed
> by spring.
>
> @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
> public class SomeResource
> {
> @Inject
> Private MyBean myBean;
>
> [...]
> }
>
> @Component
> @Scope("request")
> public class MyBean implements IMyBean
> {
> @Context
> private ResourceContext resourceContext;
>
> [...]
> }
>
>
> I was expecting the member variable resourceContext to be set with the
> correct ResourceContext. However, it is never injected (always null).
> myBean is injected and any spring auto-wired members in it are filled
> in; but the jersey annotated resourceContext member is not.
>
> I thought that Jersey (1.3) would fill in the @Context and @Inject and
> @PathParam, etc, annotations when satisfying the @Inject. Have I
> misunderstood how this is supposed to work? What is the best way to do
> something like this?
>
> Cheers,
>
> Tim