============== config class in place of beans.
xml
package [Link];
import [Link];
import [Link];
import [Link];
@Configuration
public class SpringConfig {
@Bean
//@Scope("prototype")
public Customer customer() {
return new Customer();
//return new Customer("ram","ram@[Link]");
}
}
=====================bean
package [Link];
import [Link];
import [Link];
public class Customer implements InitializingBean,DisposableBean{
public String name;
public String email;
public Customer(){
}
public Customer(String name, String email) {
[Link] = name;
[Link] = email;
}
@Override
public String toString() {
return "Customer [name=" + name + ", email=" + email + "]";
}
public void afterPropertiesSet() {
[Link](" initialization of bean done");
}
public void destroy() {
[Link](" destroying bean");
}
}
========================Test
package [Link];
import [Link];
import [Link];
public class AppTest {
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new
AnnotationConfigApplicationContext([Link]);
Customer c=(Customer)[Link]([Link]);
[Link](c +" "+[Link]());
Customer c1=(Customer)[Link]([Link]);
[Link](c1 +" "+[Link]());
[Link]();
}
}