Announcement Announcement Module
No announcement yet.
application initialisation Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • application initialisation

    Are there specific features in Spring for the initialisation of an application? For example creating directories, making sure a lucene index exists. At the moment I have those requirements in my init functions in my services (the init functions are called by spring), but I`m not to happy with it because it doesn`t always make much sense to add that responsibility to the service. And I`m not 'sure' which init function is called first.

    I would rather see a 'startup' section (and a shutdown section would be nice to)

    The startup section is always called first... and the shutdown section always is called last.

  • #2
    You can make your service depend on a initilisation service bean:
    <bean id="myService" class="" depends-on="init-service">
    <bean id="init-service" class="" init-method="" destroy-method="">
    Spring will create init-service bean and call its initMethod before creating myService. When the applicationContext shuts down, Spring will destroy myService then call destroy-method and destroy init-service.