Actually, after taking a closer look, that file's not going to help you at
all. I'd forgotten what we did exactly. I asked the same question awhile
back and now I'm remembering that I never found a solution and gave up on
it, so I'd love to know if you figure it out.
On Thu, Feb 10, 2011 at 12:
Let me put the whole thing a bit differently...
Does anyone know of a way to get a reference to the Container (or
ConfigurationManager or Configuration) from within -
ServletContextListener.contextInitialized(ServletContextEvent sce)
Or, maybe I could refactor some stuff and do it within -
Serv
This isn't a request thread... It is spawned from a ServletContextListener.
I am still playing around, I have a ServletContext object right now
(in the debugger) and I'm seeing if I can get the container from
there.
I'll check out Ben's solution and see if that helps.
-Wes
On Thu, Feb 10, 2011
register ConfigurableListableBeanFactory, ServletContext and ServletConfig
objects with
org.springframework.web.context.support.WebApplicationContextUtils.registerEnvironmentBeans(bf,sc,config)
once inside registerEnvironmentBeans method bith the servletContext and
servletConfig parameters
The simplest solution - if it's possible - is to make the spawned thread a
parent of the request thread, and then grab what you need from the parent
thread as soon as the child thread starts.
Does Struts2 use InheritableThreadLocal? If it did, this would be even easier.
John
On 2/10/11 11:02
If I'm understanding correctly, I had the same problem writing the Guice
plugin. Our solution was probably a bit ugly, but it was the only way I
could find of making it work, so maybe it will help you:
http://code.google.com/p/google-guice/source/browse/trunk/extensions/struts2/src/com/google/inje
Because, I'm not in a request-processing thread...
In this app, I have a ServletContextListener that launches threads for
managing some housekeeping stuff (in this case, looking for specific
xml files in jars). I need the configured packages (PackageConfigs)
within one of these threads.
I did try
Wes,
to be frankly I didn't get what you said.
Dispatcher.getInstance().getContainer() should be yield a container
reference (among the other things it's the better way a know in order
to do that).
What's the problem with the threadlocal stuff?
On 10 February 2011 17:43, Wes Wannemacher wrote:
Guys,
I am in a non-struts environment (spring class, loaded by a customer
ServletContextListener), and I am trying to get my hands on the Struts
2 configuration. I first tried to do -
Dispatcher.getInstance().getContainer()
But, the dispatcher instance is a threadlocal. I don't really care
abou