users@jersey.java.net

Re: [Jersey] Injecting Application object

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 05 May 2010 18:44:34 +0200

Hi,

This is a bug in Jersey, can you log an issue?

If you have defined your own instance of Application it should be
possible to inject this instance even if a DI framework like CDI or
Guice is not used to managed the Application instance i.e.

  @Context MyApplication app;

FWIW you can do:

  @Context ResourceConfig rc;

to obtain the list of root resource and provider classes/singletons,
and properties (servlet init params are copied across).

ResourceConfig is Jersey's extension of Application. Jersey will copy
the state of the user-defined application into it's own instance of
ResourceConfig.

Paul.

On May 5, 2010, at 6:27 PM, Jarosław Lewandowski wrote:

> Hi,
>
> I was trying to access javax.ws.rs.core.Application object by
> injecting it into my provider classes using @Context annotations,
> but it seems not to be working. It doesn't work even if there is a
> custom implementation of such class. Is there any known issue with
> it? Should be such class accessible if there is no custom
> implementation?
> I'm using jersey v. 1.1.5.
>
> Best regards
> JL