• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confused about Spring's init-method attribute

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic