struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Chan <rc...@i-tao.com>
Subject Re: Struts2 startup service/action
Date Tue, 30 Sep 2008 16:28:48 GMT

but this does not give me access to the Guice injector, which is what I
wanted.  I think the ServletContextListener would work only if using Spring.



Chris Pratt wrote:
> 
> I think the more common way is to use a standard ServletContextListener.
>   (*Chris*)
> 
> On Tue, Sep 30, 2008 at 2:16 AM, Ron Chan <rchan@i-tao.com> wrote:
> 
>>
>> 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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts2-startup-service-action-tp19738655p19745637.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


Mime
View raw message