Annotation Type LazyBinding
-
@Target(TYPE) @Retention(RUNTIME) public @interface LazyBinding
By default, all resolved extensions are registered in injector bybinder.bind(extType)
. If extension installer implementsBindingInstaller
then installer manually registers extension in context.Registering bean in context means that all singleton services will be instantiated on context start (for production mode)
@LazyBinding
allows omitting registration in simple case and will provide lazy hint for installer with specific binding. Such lazy bean may be useful to defer bean creation: e.g. it is used somewhere as dependency, but wrapped inProvider
, so actual instance is not created immediately.The best example for lazy beans is guice managed jersey extensions: due to the way jersey is integrated, for some time guice context is not aware of HK beans, and the opposite. By making bean lazy, it's creation moved from guice context start to actual usage by HK or jersey, when it can be created.
- Since:
- 21.11.2014
- See Also:
BindingInstaller
,GuiceFeature
,as alternative for jersey extensions