Monday, 9 November 2015

Initializing Order in Spring Bean when @PostConstruct,init-method and InitializingBean are all together..

@Component("samsung")
@Scope("prototype")
@Lazy(true)
public class Samsung implements InitializingBean {

private String mid="MB02939";
private String model="GalexyS5";

public void init(){
System.out.println("_@)@)@Kelllll200220__))))");
}


@PostConstruct
public void initiate(){
System.out.println("_@_#)#)#))))))))((((@PostConstruct(((((((((((((((");
}

@Override
public void afterPropertiesSet() throws Exception {
System.out.println(")@)@)___afterPropertiesSet____@)@)");

}

}

<context:component-scan base-package="com.it.annotation"/>
    <bean id="samsung" class="com.it.annotation.Samsung" init-method="init"         autowire="no"/>

</beans>

Order of calling statements are :

_@_#)#)#))))))))((((@PostConstruct((((((((((((((( (@PostConstruct)

)@)@)___afterPropertiesSet____@)@) (InitializingBean )


_@)@)@Kelllll200220__)))) (init-method)




<bean id="samsung" class="com.it.annotation.Samsung" init-method="init" autowire="no"  destroy-method="cleanMethod"/>

No comments:

Post a Comment