users@jersey.java.net

[Jersey] Re: Injection into custom injectable providers

From: Franck Mangin <franck102_at_yahoo.com>
Date: Thu, 28 Mar 2013 03:31:50 -0700 (PDT)

Anyone?
I could really use some guidance on this... thanks!

Franck




________________________________
 From: Franck Mangin <franck102_at_yahoo.com>
To: "users_at_jersey.java.net" <users_at_jersey.java.net>
Sent: Monday, March 18, 2013 2:28 PM
Subject: Injection into custom injectable providers
 

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