This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Confused about Spring's init-method attribute

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my dispatcher-servlet.xml file I have several controller beans defined as below:



In my applicationContext.xml I define bean1 which includes an init-method attribute. There are also various child property elements not listed.


I define no other beans that correspond to the example.Bean1 class and no classes in my app call the example.Bean1.init method.

In my web app the example.Bean1.init method get called multiple times, once per each controller bean that references bean1. Is this the expected behavior? I have come accross a number of articles and postings that discuss bean lifecycles, but none addressed this particular point.

What I was hoping is that the example.Bean1.init method would be called exactly once no matter how many other beans reference it, but that appears to not be the case. Is there a way to get the behavior I am looking for?

I am using Spring Web MVC 2.5 and use Netbeans 6.1 to deploy my web app to Apache Tomcat 6 in case that matters.

TH
 
And inside of my fortune cookie was this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!