Results 1 to 3 of 3

Thread: Bean destruction order

  1. #1
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    1

    Default Bean destruction order

    Will Spring destroy singletons in a specifc order upon exit? This is important in a scenario like this:

    - Bean A has a dependency on Bean B
    - Bean A's destroy-method refers to the instance of Bean B that it holds
    - I want to make sure that Bean B's destroy-method hasn't been called yet

    A realistic use case might be that Bean B is a database connection and Bean A wants to log to the database the fact that it is being destroyed.

    In other words, the order of destruction of beans should be the inverse of the order of creation. Is this the case?

    Thanks in advance.

  2. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    Destruction should happen properly in relation to the dependencies that are expressed via properties and the explicit depends-on attribute. Basically it should be the reverse of the init/construct order.

    Just make sure that you are using Spring 1.1 or newer (preferably 1.1.1) as I know that Juergen fixed or tweaked this area a little while ago, in August if I remember...
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  3. #3
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Quote Originally Posted by Colin Sampaleanu
    Just make sure that you are using Spring 1.1 or newer (preferably 1.1.1) as I know that Juergen fixed or tweaked this area a little while ago, in August if I remember...
    Just a remark:
    As I saw in JIRA, there still has been an issue that destroy-methods weren't invoked correctly for inner beans (SPR-390). The fix is targetet for 1.1.2

    Andreas

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

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