In Spring, you can use init-method and destroy-method as attribute in bean configuration file for bean to perform certain actions upon initialization and destruction. Alternative to InitializingBean and DisposableBean interface.

Example

Here’s an example to show you how to use init-method and destroy-method.
package com.mkyong.customer.services;
 
public class CustomerService
{
 String message;
 
 public String getMessage() {
   return message;
 }
 
 public void setMessage(String message) {
   this.message = message;
 }
 
 public void initIt() throws Exception {
   System.out.println("Init method after properties are set : " + message);
 }
 
 public void cleanUp() throws Exception {
   System.out.println("Spring Container is destroy! Customer clean up");
 }
 
}
File : Spring-Customer.xml, define init-method and destroy-method attribute in your bean.
 xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
 
  id="customerService" class="com.mkyong.customer.services.CustomerService" 
  init-method="initIt" destroy-method="cleanUp">
 
   name="message" value="i'm property message" />