BeanPostProcessor Interface

Spring BeanPostProcessor interface have two methods postProcessBeforeInitialization() and postProcessAfterInitialization().

These methods will get called on every bean initialization.

Create Car.java class with init and destroy method. 

Type.java class implements BeanPostProcessor interface. Override postProcessBeforeInitialization() and postProcessAfterInitialization()methods.

Define init() and destroy() method for Type.java class.

Declaring the default-init-method and default-destroy-method attribute values as true in the beans tag will call the init() and destroy() methods of every bean class.

OUTPUT:
Type init() method called
Before Initialization = car
Car init() method called
After Initialization = car
Name = Honda
Car destroy() method called
Type destroy() method called

Imran Khan

Specialist Master (Architect) with a passion for cutting-edge technologies like AEM (Adobe Experience Manager) and a proven track record of delivering high-quality software solutions.

  • Languages: Java, Python
  • Frameworks: J2EE, Spring, Struts 2.0, Hibernate
  • Web Technologies: React, HTML, CSS
  • Analytics: Adobe Analytics
  • Tools & Technologies: IntelliJ, JIRA

🌐 LinkedIn

📝 Blogs

📧 Imran Khan