A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Frameworks
»
Spring
Author
Problem calling destroy method
Hemant Thard
Ranch Hand
Joined: Dec 23, 2008
Posts: 119
posted
Feb 06, 2011 08:04:47
0
Hi Guys,
i am having difficulty understanding why destroy method is not called in my
java
standalone application.
i have tried using both : defining destroy-method property in my bean element and using DisposableBean bean. But this doesn't seems to work
can any one provide an explanation for this behavior.
Regards,
Hemant
dileep keely
Ranch Hand
Joined: Jun 28, 2010
Posts: 91
posted
Feb 07, 2011 19:46:38
0
i am having difficulty understanding why destroy method is not called
It means that implementation is holding some resources.
close the application context.
Example: package com.amex.example1; import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Test { private String message; public void setMessage(String message) { this.message = message; } public void init(){ System.out.println("init()"+message); } public void destroy() { System.out.println("Calling the destroy method"); } public static void main(String[] args) { ConfigurableApplicationContext context= new ClassPathXmlApplicationContext("beans.xml"); Test test = (Test)context.getBean("test"); context.close(); } } <bean id="test" class="com.amex.example1.Test" init-method="init" destroy-method="destroy"> <property name="message" value="Welcome to spring lifecycle"/> </bean>
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
11
I like...
posted
Feb 07, 2011 19:53:22
0
I recently replied to this kind of question at Manning's forum.
Check it out
.
[My Blog]
All roads lead to JavaRanch
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: Problem calling destroy method
Similar Threads
destroy() for Servlet
DefaultMessageListenerContainer not getting started
Disposable bean's destroy method is not being called ???
manually call unsetEntityContext?
Spring - Connection Problem in some Unit Tests
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter