sting-ioc / sting

Home Page:https://sting-ioc.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for @PostConstruct or similar

realityforge opened this issue · comments

The way that the @Injector is constructed and the constraints that are applied to the components (i.e. No invoking Supplier types during construction ala #9) will typically mean that it is impossible for a component to access another component before it is constructed.

The one scenario where this is not true is if the construction of a component creates an asynchronous action that invokes a Suppler dependency before the injector has completed initialization. This is not possible in a web browser but is possible in a JRE environment.

The only real safe way to fix this is to move the asynchronous action until after the injector has created the eager components. To do this we could allow the components to specify this post create action with an annotation like @PostConstruct which would be used to initiate any asynchronous tasks.