Return-Path: Delivered-To: apmail-struts-dev-archive@www.apache.org Received: (qmail 81739 invoked from network); 10 Feb 2011 20:57:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Feb 2011 20:57:33 -0000 Received: (qmail 54509 invoked by uid 500); 10 Feb 2011 20:57:33 -0000 Delivered-To: apmail-struts-dev-archive@struts.apache.org Received: (qmail 54451 invoked by uid 500); 10 Feb 2011 20:57:32 -0000 Mailing-List: contact dev-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Developers List" Reply-To: "Struts Developers List" Delivered-To: mailing list dev@struts.apache.org Received: (qmail 54443 invoked by uid 99); 10 Feb 2011 20:57:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Feb 2011 20:57:32 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.216.48] (HELO mail-qw0-f48.google.com) (209.85.216.48) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Feb 2011 20:57:28 +0000 Received: by qwe4 with SMTP id 4so1070756qwe.35 for ; Thu, 10 Feb 2011 12:57:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.224.37.2 with SMTP id v2mr18081996qad.92.1297371426480; Thu, 10 Feb 2011 12:57:06 -0800 (PST) Received: by 10.220.179.65 with HTTP; Thu, 10 Feb 2011 12:57:06 -0800 (PST) In-Reply-To: References: Date: Thu, 10 Feb 2011 15:57:06 -0500 Message-ID: Subject: Re: getting the container (or Configuration/ConfigurationManager) in a non-container-instantiated object From: Wes Wannemacher To: Struts Developers List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 - Servlet.init(ServletConfig config) I was hoping for some way to grab a hold of one of the filters (Prepare or Execute) and yanking the Container out of there, but I can't seem to find a good way to get at it, outside of Struts but within a web-app. -Wes On Thu, Feb 10, 2011 at 3:15 PM, Wes Wannemacher wrote: > This isn't a request thread... It is spawned from a ServletContextListene= r. > > 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 at 2:43 PM, John Lindal wrot= e: >> 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 paren= t thread as soon as the child thread starts. >> >> Does Struts2 use InheritableThreadLocal? =A0If it did, this would be eve= n easier. >> >> John >> >> >> On 2/10/11 11:02 AM, "Wes Wannemacher" wrote: >> >> 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 to get the Dispatcher instance, but it kept coming back >> null, which led me to dig a bit and then I realized that I am not in a >> request processing thread (neither is the ServletContextListener that >> launched the thread). I am going to try to poke around the >> ServletContext to see if I can get the container that way. >> >> -Wes >> >> On Thu, Feb 10, 2011 at 1:29 PM, Maurizio Cucchiara >> wrote: >>> 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 >>>> about the dispatcher, I'd just like to get a ref to the container. >>>> >>>> Any ideas? >>>> >>>> -Wes >>>> >>>> -- >>>> Wes Wannemacher >>>> >>>> Head Engineer, WanTii, Inc. >>>> Need Training? Struts, Spring, Maven, Tomcat... >>>> Ask me for a quote! >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org >>>> For additional commands, e-mail: dev-help@struts.apache.org >>>> >>>> >>> >>> >>> >>> -- >>> Maurizio Cucchiara >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org >>> For additional commands, e-mail: dev-help@struts.apache.org >>> >>> >> >> >> >> -- >> Wes Wannemacher >> >> Head Engineer, WanTii, Inc. >> Need Training? Struts, Spring, Maven, Tomcat... >> Ask me for a quote! >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org >> For additional commands, e-mail: dev-help@struts.apache.org >> >> >> > > > > -- > Wes Wannemacher > > Head Engineer, WanTii, Inc. > Need Training? Struts, Spring, Maven, Tomcat... > Ask me for a quote! > --=20 Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org For additional commands, e-mail: dev-help@struts.apache.org