Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 39107 invoked from network); 30 Sep 2008 09:17:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Sep 2008 09:17:10 -0000 Received: (qmail 13328 invoked by uid 500); 30 Sep 2008 09:16:59 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 13317 invoked by uid 500); 30 Sep 2008 09:16:59 -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 13306 invoked by uid 99); 30 Sep 2008 09:16:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Sep 2008 02:16:59 -0700 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Sep 2008 09:15:56 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1KkbLK-0006Mb-Dw for user@struts.apache.org; Tue, 30 Sep 2008 02:16:30 -0700 Message-ID: <19738655.post@talk.nabble.com> Date: Tue, 30 Sep 2008 02:16:30 -0700 (PDT) From: Ron Chan To: user@struts.apache.org Subject: Struts2 startup service/action MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: rchan@i-tao.com X-Virus-Checked: Checked by ClamAV on apache.org There's been a number of messages about this, and I've tried a number of different suggestions. After going round in circles for a few days, I eventually ended up with just a few lines of code that seems to work. I basically extended the FilterDispatcher, added to the init() method and used the new FilterDispatcher in my web.xml instead. This seems to work but I was wondering if it would cause potential problems. I use Guice and it seems to work, have not tested it with anything else. public class ExtendedFilterDispatcher extends FilterDispatcher { @Override public void init(FilterConfig filterConfig) throws ServletException { super.init(filterConfig); try { Container cont = super.dispatcher.getContainer(); ObjectFactory.setObjectFactory(cont.getInstance(ObjectFactory.class)); QuartzService service = (QuartzService) ObjectFactory.getObjectFactory().buildBean(QuartzService.class, null); service.start(); } catch (Exception e) { e.printStackTrace(); } } } QuartzService is an example, it can be any action or service controlled by the struts objectfactory -- View this message in context: http://www.nabble.com/Struts2-startup-service-action-tp19738655p19738655.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org