Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 18927 invoked from network); 4 Sep 2008 18:00:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Sep 2008 18:00:43 -0000 Received: (qmail 6102 invoked by uid 500); 4 Sep 2008 18:00:31 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 6072 invoked by uid 500); 4 Sep 2008 18:00:31 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 6061 invoked by uid 99); 4 Sep 2008 18:00:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Sep 2008 11:00:31 -0700 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jak-struts-user@m.gmane.org designates 80.91.229.2 as permitted sender) Received: from [80.91.229.2] (HELO ciao.gmane.org) (80.91.229.2) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Sep 2008 17:59:33 +0000 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1KbJ7i-0004LY-U8 for user@struts.apache.org; Thu, 04 Sep 2008 18:00:02 +0000 Received: from cpe0016b5ef7ea1-cm0014e88ef4b4.cpe.net.cable.rogers.com ([99.233.20.4]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 04 Sep 2008 18:00:02 +0000 Received: from laurie by cpe0016b5ef7ea1-cm0014e88ef4b4.cpe.net.cable.rogers.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 04 Sep 2008 18:00:02 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: user@struts.apache.org From: Laurie Harper Subject: Re: How to Initialize additional components when the Struts 2 Engine starts Date: Thu, 04 Sep 2008 13:56:38 -0400 Lines: 81 Message-ID: References: <911feef00809041012g7c9194cfhaea120775bb8bbf@mail.gmail.com> <911feef00809041038p2a154f64q1dfc27c2823829e3@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: cpe0016b5ef7ea1-cm0014e88ef4b4.cpe.net.cable.rogers.com User-Agent: Thunderbird 2.0.0.16 (Macintosh/20080707) In-Reply-To: <911feef00809041038p2a154f64q1dfc27c2823829e3@mail.gmail.com> Sender: news X-Virus-Checked: Checked by ClamAV on apache.org Why? Spring provides facilities for using managed beans as context=20 listeners. Instead of trying to make your listener aware of Spring by=20 hand, just use Springs facilities to register/manage your listener. L. Carlos Luis Z=FA=F1iga Sibaja wrote: > This sounds a bit like what I need, my only issue would that here I can= 't > access the Spring context that is associated to the Struts Engine. I wo= uld > have to instantiate it by myself, right? >=20 > Carlos Luis Z=FA=F1iga Sibaja > __________________________ > carlosluiszuniga@gmail.com >=20 > divide et impera... >=20 >=20 > On Thu, Sep 4, 2008 at 11:30 AM, Gabriel Belingueres > wrote: >=20 >> Use a ServletContextListener [1]. >> >> [1] >> http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContextList= ener.html >> >> 2008/9/4, Carlos Luis Z=FA=F1iga Sibaja : >>> Hi All, >>> >>> I'm starting a Struts 2 project and there are some tasks (check for t= he >> DB >>> version, correctness of the schema, etc.) I'd like to perform when th= e >>> webapp inits. I'd like to execute these tasks right when the Struts >> engine >>> starts, because I'd like to get advantage from the Spring IoC context= >> that >>> get's initilize along side the Struts engine. >>> Does anybody have an idea on how can I do this? I looked at the wiki = and >> the >>> DispatcherListener interface is mentioned, I tried implementing it an= d >>> registering the listener on a static block, using >>> Dispatcher.addDispatcherListener, but is does not seem to run. This i= s >>> example code for the class: >>> >>> import org.apache.struts2.dispatcher.DispatcherListener; >>> import org.apache.struts2.dispatcher.Dispatcher; >>> >>> public class StrutsConfigurator { >>> >>> static { >>> Dispatcher.addDispatcherListener(new DispatcherListener() { >>> >>> public void dispatcherInitialized(Dispatcher du) { >>> System.out.println("It's aliveeeeee!!!!!!!!!!!!!"); >>> } >>> >>> public void dispatcherDestroyed(Dispatcher du) { >>> } >>> }); >>> } >>> } >>> >>> Thanks for your help. >>> >>> Carlos Luis Z=FA=F1iga Sibaja >>> __________________________ >>> carlosluiszuniga@gmail.com >>> >>> divide et impera... >>> >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org