Hi Alex,
You need to declare the generic type:
private ContextResolver<CleanupService> cleanupService;
public PositionRecord(@Context ContextResolver<CleanupService>
cleanupService) {
this.cleanupService = cleanupService;
}
ContextResolver is not a way to provide generic injection support as
is the case with InjectableProvider. It is designed to provide some
contextual object for a given Java type e.g. for a JAXB type return a
JAXB context.
Instead it is better to define an InjectableProvider for the
CleanupService and then you can support what you require.
I can write some example code to help you in this respect. I could
even write some injectable provider code for the injection of JDO
objects on singleton and per-request resources.
Paul.
On Feb 17, 2009, at 6:03 AM, Roytman, Alex wrote:
> Hello Paul,
>
> I created a custom service which I want to inject using @Context
> annotation. It gets loaded and registered fine.
>
> I can get it using
> @Context Providers providers;
> providers.getContextResolver(CleanupService.class, null);
>
> but any field or constructor parameter defined as @Context
> CleanupService cleanupService in Resource or another Provider is not
> injected. My resolver's getContext() method is never called.
>
>
> I will try to debug it but if you could give me some hints or if you
> think it is a bug, I would appreciate
>
> Thank you,
> Alex
>
>
> @Path("position")
> public class PositionRecord extends JdoResource {
> private CleanupService cleanupService;
>
> public PositionRecord(@Context CleanupService cleanupService) {
> this.cleanupService = cleanupService;
> }
>
> ....
>
>
> Context resolver is attached
>
>
> <
> CleanupServiceContextResolver
> .java
> >---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net