/** * Binds component into HK2 context. If component is annotated with {@link HK2Managed}, then registers type, * otherwise register guice "bridge" factory around component. * * @param binder HK2 binder * @param injector guice injector * @param type component type * @param hkManaged true if bean must be managed by HK2, false to bind guice managed instance * @param singleton true to force singleton scope * @see ru.vyarus.dropwizard.guice.module.jersey.support.GuiceComponentFactory */ public static void bindComponent(final AbstractBinder binder, final Injector injector, final Class<?> type, final boolean hkManaged, final boolean singleton) { if (hkManaged) { optionalSingleton( binder.bindAsContract(type), singleton); } else { // default case: simple service registered directly (including resource) optionalSingleton( binder.bindFactory(new GuiceComponentFactory<>(injector, type)).to(type), singleton); } }
/** * Binds component into HK2 context. If component is annotated with {@link HK2Managed}, then registers type, * otherwise register guice "bridge" factory around component. * * @param binder HK2 binder * @param injector guice injector * @param type component type * @param hkManaged true if bean must be managed by HK2, false to bind guice managed instance * @param singleton true to force singleton scope * @see ru.vyarus.dropwizard.guice.module.jersey.support.GuiceComponentFactory */ public static void bindComponent(final AbstractBinder binder, final Injector injector, final Class<?> type, final boolean hkManaged, final boolean singleton) { if (hkManaged) { optionalSingleton( binder.bindAsContract(type), singleton); } else { // default case: simple service registered directly (including resource) optionalSingleton( binder.bindFactory(new GuiceComponentFactory<>(injector, type)).to(type), singleton); } }
singleton); optionalSingleton( binder.bindAsContract(type).to(bindingType), singleton); } else {
singleton); optionalSingleton( binder.bindAsContract(type).to(bindingType), singleton); } else {