@Target(value=TYPE)
@Retention(value=RUNTIME)
public @interface LazyBinding
binder.bind(extType)
.
If extension installer implements
BindingInstaller
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 in Provider
, 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.
BindingInstaller
,
GuiceFeature
,
as alternative for jersey extensions