Re: getting the container (or Configuration/ConfigurationManager) in a non-container-instantiated object

2011-02-10 Thread Ben McCann
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:

Re: getting the container (or Configuration/ConfigurationManager) in a non-container-instantiated object

2011-02-10 Thread Wes Wannemacher
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

Re: getting the container (or Configuration/ConfigurationManager) in a non-container-instantiated object

2011-02-10 Thread Wes Wannemacher
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

RE: getting the container (or Configuration/ConfigurationManager) in a non-container-instantiated object

2011-02-10 Thread Martin Gainty
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

Re: getting the container (or Configuration/ConfigurationManager) in a non-container-instantiated object

2011-02-10 Thread John Lindal
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

Re: getting the container (or Configuration/ConfigurationManager) in a non-container-instantiated object

2011-02-10 Thread Ben McCann
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

Re: getting the container (or Configuration/ConfigurationManager) in a non-container-instantiated object

2011-02-10 Thread Wes Wannemacher
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

Re: getting the container (or Configuration/ConfigurationManager) in a non-container-instantiated object

2011-02-10 Thread Maurizio Cucchiara
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:

getting the container (or Configuration/ConfigurationManager) in a non-container-instantiated object

2011-02-10 Thread Wes Wannemacher
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