my dog learned polymorphism*
The moose likes Spring and the fly likes inject into application listener? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "inject into application listener?" Watch "inject into application listener?" New topic
Author

inject into application listener?

vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
Hi. I want to create an application scope variable on startup of my web app. However the variable will contain data from the database. My app interacts with the database via injecting a sessionFactory bean into my daoimpl classes (which extend HibernateDaoSupport). My question is does the application listener execute prior to the spring container load up. I am guessing the answer is yes, in which case how do I go about this issue?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Spring provides a context startup event that can be used to run code after the context is loaded.
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
I'm not sure if this is what you meant, but the following works fine

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No, it isn't; beans can simply implement <tt>ApplicationListener</tt> and pay attention to <tt>ContextRefreshedEvent</tt>s. Context refresh events signal that the context is available, hence all beans etc. are ready to be used. This has the added advantage of handling *all* context refresh events, regardless of why the event too place.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inject into application listener?
 
Similar Threads
Hibernate connection problem with struts2
JBOSS ERROR - "Both MyFaces and the RI are on your classpath."
Listener Query
About Listener
Settings Class