• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Bean initialise on start up  RSS feed

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Just a quick Spring Framework Bean question. I want to configure the application context to initialise a bean on start up.

Bean extends SimpleJdbcDaoSupport, it has a connect method defined which is called from the beans constructor.
The connect method basically does some sql querys, then perfroms some function based on results.

Scenario is:
Deploy the web app;
On start up application context see's the bean should be initialised,
Initialised the bean, which then perfroms the connect method.

This is my application context which points to the bean:

<bean id = "sessionManager" class = "com.example.beans.SessionManager">
<property name = "dataSource" ref = "dataSource"/>
</bean>

I have tried addind auto-wireing tags and init-methods to make it work, but so far i have not successfully made the bean call the connect method on start up. The app will basically deploy and then that would be it.
Any help, im sure its prob something small and easy.

best
Mark
 
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Mark,

I kept a SOP in nullary constructor in one of my beans. When I start the server, I see that SOP in console. So I would ask, does your constructor gets called? Do you see any error? http://faq.javaranch.com/java/ItDoesntWorkIsUseless
 
Mark Hughes
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishal,

I found this online, http://static.springframework.org/spring/docs/1.2.x/reference/beans.html

About half way down in section 3.4.1. Lifecycle interfaces, i found what i was after in the form of the init-method and implements InitializingBean. I got it working then. I also found a prob with my logging which was not working so that why i thought other areas were not working.

Best
Mark
 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!