Results 1 to 2 of 2

Thread: application initialisation

  1. #1
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    You can make your service depend on a initilisation service bean:
    Code:
    <bean id="myService" class="com.company.MyService" depends-on="init-service">
    ...
    </bean>
    
    <bean id="init-service" class="" init-method="" destroy-method="">
    ...
    </bean>
    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.
    HTH
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

Similar Threads

  1. Replies: 2
    Last Post: Oct 10th, 2005, 05:12 PM
  2. Replies: 6
    Last Post: Sep 29th, 2005, 04:25 AM
  3. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  4. Questioning the core component
    By Martin Kersten in forum Swing
    Replies: 6
    Last Post: Feb 21st, 2005, 03:45 AM
  5. Desktop application, strange behaviour
    By innovate in forum Container
    Replies: 2
    Last Post: Sep 24th, 2004, 04:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •