Reputation: 577
I've a spring question which may be general to spring, but it's more specifically for a Spring Integration Poller.
Basically, when I start the application I want all the spring config to be loaded up - so I can get any errors/failures quickly rather than when someone tries to make the first call to a specific bean etc. Part of this is so that my spring Integration poller's begin to poll immediatly when the application is started and not just after a message is published etc (as there could be old messages being re-tried etc)
I've searched around and seen mentions of using "BeanFactory" vs "ApplicationContext" - but these examples seem to always be code-driven around the initialisation however my application is defined within the xml configuration of web.xml as far as I know.
Am I missing something really obvious here? or can anyone guide me in the right direction please?
My servlet is defined as below in case this helps any:
<servlet>
<servlet-name>myservletname</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/context.xml</param-value>
</init-param>
</servlet>
Thanks In Advance
Upvotes: 0
Views: 53
Reputation: 54
You may also use ServletContextListener. You can implement this interface and if you have few tasks to run you can then divide tasks per implementations of listeners interface and then you will be able to turn on/off those listeners you actually need.
Upvotes: 1
Reputation: 577
I think I've worked this out.
It seems that by providing the following within my servlet element - it seems to behave as I expected
<load-on-startup>1</load-on-startup>
Now it is like this:
<servlet>
<servlet-name>myservletname</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
Upvotes: 1