Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7656655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:49:23+00:00 2026-05-31T12:49:23+00:00

I am reading the Pro Spring 2.5 book and in chapter 4 they talk

  • 0

I am reading the Pro Spring 2.5 book and in chapter 4 they talk about life cycle callbacks. How is Spring able to notify when an instance is destroyed (after what I read it is only available on singletons)? What mechanism is used?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:49:24+00:00Added an answer on May 31, 2026 at 12:49 pm

    No magic here, destroy callbacks are called when the BeanFactory/ApplicationContext is destroyed (close() method is called). In desktop applications this has to be done manually, in servlet environment the same mechanism that was used to start the application context (typically ContextLoaderListener) handled destroying for you.

    Two notes:

    • destroying is important for objects requiring explicit clean-up like database connection pools (DataSource) or threads.

    • Beans are destroyed in the opposite order compared to creation order. This is understandable: when bean A depends on B, B has to be created first. When bean A is destroyed, B has to be destroyed afterwards, otherwise A would not be able to access its dependencies during destroy phase.

    Also Spring allows you to automatically register shutdown hook to handle shutdown automatically. I wouldn’t advice that, but just for the record:

    ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(...)
    ctx.registerShutdownHook();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reading Pro JPA 2. The book talks begins by talking about ORM in
After reading Steven Sanderson's book Pro ASP.NET MVC I am convinced about the benefits
I am reading the Pro Spring 2.5 book and I have a question to
I'm reading a book about C# ( Pro C# and the .NET 4 Platform
I am reading Pro Spring 2.5 and I have a question to chapter 2
I'm currently reading the book Pro Asp.Net MVC Framework. In the book, the author
I was reading Steven Sanderson's book Pro ASP.NET MVC Framework and he suggests using
I have finally finished reading Pro ASP.NET MVC 2 Framework Chapter 3: Pre-requisites but
In the book I'm reading Pro Linq in C# 2010 (APress, Freeman and Ratz)
This is sort of out of curiosity question. Reading through Pro Android 3 book

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.