Reputation: 1429
I have read up on @PostConstruct and init-method but they don't allow args to be passed from the bean.
Something along the line of this question. But the args-to-be-passed are from the class that instantiates the bean.
To simplify: Invoker is the class that instantiates Invoked class and calls Invoked.Method(args) where the args are from Invoker.Args.
The question is can I do all this in Beans? Thanks for your help.
Upvotes: 1
Views: 100
Reputation: 17359
IMO something like the code below should work, assuming that args created as part of Invoker class or autowired into it:
@Component
class Invoker {
private String[] args = new String[]("1","2","3")
@Autowired
private Invoked invoked;
@PostConstruct
private void init() {
invoked.method(args);
}
}
Upvotes: 2