users@jersey.java.net

[Jersey] Injection into custom injectable providers

From: Franck Mangin <franck102_at_yahoo.com>
Date: Mon, 18 Mar 2013 06:28:11 -0700 (PDT)

I am struggling with the rules for injection into my custom injectable (singleton) providers:

1. Is it ok to inject ServletContext into my providers, or is this working (currently) just because I am lucky that the ServletProvider has been laoded before my custom provider:

public class CustomInjectableProvider implements InjectableProvider<Context, Type>, Injectable<T>
{
    private @Context ServletContext _servletContext;
    ...

If this isn't the right pattern, how can a custom injectable provider access servlet parameters?


2. Is there a reliable way to have one custom provider rely on another custom provider:

public class CustomInjectableProvider1 implements InjectableProvider<Context, Type>, Injectable<T>
{
    private @Context CustomInjectableProvider2 _someService;
    ...

Thanks!
Franck Mangin