This is crazy... been using Spring for a while but can't find something like the "init-method" that gets invoked AFTER all the dependencies have been injected.
I saw the BeanPostProcessor thingie but I am looking for something lightweight and non-intrusive that doesn't couple my beans to Spring. Like the init-method!
With Spring 2.5 and above, if an object requires invocation of a callback method upon initialization, that method can be annotated with the @PostConstruct
annotation.
For example:
public class MyClass{
@PostConstruct
public void myMethod() {
...
}
...
}
This is less intrusive than the BeanPostProcessor
approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With