struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: How to Initialize additional components when the Struts 2 Engine starts
Date Thu, 04 Sep 2008 17:56:38 GMT
Why? Spring provides facilities for using managed beans as context 
listeners. Instead of trying to make your listener aware of Spring by 
hand, just use Springs facilities to register/manage your listener.

L.

Carlos Luis Zúñiga 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 would
> have to instantiate it by myself, right?
> 
> Carlos Luis Zúñiga Sibaja
> __________________________
> carlosluiszuniga@gmail.com
> 
> divide et impera...
> 
> 
> On Thu, Sep 4, 2008 at 11:30 AM, Gabriel Belingueres
> <belingueres@gmail.com>wrote:
> 
>> Use a ServletContextListener [1].
>>
>> [1]
>> http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContextListener.html
>>
>> 2008/9/4, Carlos Luis Zúñiga Sibaja <carlosluiszuniga@gmail.com>:
>>> Hi All,
>>>
>>> I'm starting a Struts 2 project and there are some tasks (check for the
>> DB
>>> version, correctness of the schema, etc.) I'd like to perform when the
>>> 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 and
>>> registering the listener on a static block, using
>>> Dispatcher.addDispatcherListener, but is does not seem to run. This is
>>> 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úñiga Sibaja
>>> __________________________
>>> carlosluiszuniga@gmail.com
>>>
>>> divide et impera...
>>>
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message