users@jersey.java.net

[Jersey] Please Ignore: Re: Where to put code that should be called at deployment time?

From: Edward Burns <edward.burns_at_oracle.com>
Date: Tue, 14 Jan 2014 14:34:46 -0800

>>>>> On Tue, 14 Jan 2014 14:29:37 -0800, Edward Burns <edward.burns_at_oracle.com> said:

>>>>> On Thu, 9 Jan 2014 14:16:10 -0800, Edward Burns <edward.burns_at_oracle.com> said:
>>>>> On Mon, 6 Jan 2014 16:03:52 +0100, Jakub Podlesak <jakub.podlesak_at_oracle.com> said:
JP> as pointed by Michal, if you register your feature, the application
JP> listener should work just fine. Please see the log attached bellow.

EB> I must have been doing something wrong in the bootstrapping process.

EB> I do see it working now.

EB> Now I come upon another bootstrapping related question. I would like to
EB> have access to the ServletContext instance within my code that handles
EB> the Type.INITIALIZATION_APP_FINISHED event. I tried

EB> @Inject
EB> private Provider<Ref<ServletContext>> servletContextRef;

EB> But I find that at the point in time when
EB> Type.INITIALIZATION_APP_FINISHED is called, servletContextRef.get() is
EB> null.

EB> Is there some other way to obtain a reference to the ServletContext?
EB> I need this because I need to bootstrap JSF, and JSF needs the
EB> ServletContext.

Sorry for the ignorant question. I see now that

@Context
ServletContext servletContext seems to do the trick.

One might reasonably ask why the other approach does not work, though.
Or why I need a jax-rs specific annotation in this case.

Ed

-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/
| 26 Work Days Til DevNexus 2014
| 43 Work Days Til JavaLand 2014