java - What is the best way to call a method(with parameters) right after a class is instantiated using a bean? -
i have read on @postconstruct , init-method don't allow args passed bean.
something along line of this question. args-to-be-passed class instantiates bean.
to simplify: invoker class instantiates invoked class , calls invoked.method(args) args invoker.args.
the question can in beans? help.
imo code below should work, assuming args created part of invoker class or autowired it:
@component class invoker { private string[] args = new string[]("1","2","3") @autowired private invoked invoked; @postconstruct private void init() { invoked.method(args); } }
Comments
Post a Comment