binder.bind(supplierBuilder); ServiceBindingBuilder<?> builder = binder.bindFactory(new InstanceSupplierFactoryBridge<>(supplier, disposable)); setupSupplierFactoryBridge(binding, builder); };
@Override protected void configure() { super.bind(metricsRegistry).to(StormMetricsRegistry.class); } })
if (hkManaged) { optionalSingleton( binder.bind(type).to(type).to(bindingType), singleton); } else { binder.bindFactory(new GuiceComponentFactory<>(injector, type)).to(type), singleton); optionalSingleton( binder.bindAsContract(type).to(bindingType), singleton); } else { optionalSingleton( binder.bindFactory(new GuiceComponentFactory<>(injector, type)).to(type).to(bindingType), singleton);
@Override public <T> ActiveDescriptor<T> bind(Descriptor descriptor, boolean requiresDeepCopy) { setLoader(descriptor); return configuration().bind(descriptor, requiresDeepCopy); }
private void complete() { try { resetBuilder(null); } finally { this.configuration = null; } }
/** * {@inheritDoc} * <p> * This method can be called only in the execution context of the {@link #configure()} * method. * </p> */ @Override public <T> FactoryDescriptors addActiveFactoryDescriptor(Class<? extends Factory<T>> rawFactoryClass) throws MultiException, IllegalArgumentException { return configuration().addActiveFactoryDescriptor(rawFactoryClass); }
private <T> AbstractBindingBuilder<T> resetBuilder(AbstractBindingBuilder<T> newBuilder) { if (currentBuilder != null) { currentBuilder.complete(configuration(), getDefaultBinderLoader()); } currentBuilder = newBuilder; return newBuilder; }
@Override public void bind(DynamicConfiguration configuration) { if (this.configuration != null) { throw new IllegalArgumentException("Recursive configuration call detected."); } if (configuration == null) { throw new NullPointerException("configuration"); } this.configuration = configuration; try { configure(); } finally { complete(); } }
/** * 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); } }
private void setLoader(Descriptor descriptor) { if (descriptor.getLoader() == null && descriptor instanceof DescriptorImpl) { ((DescriptorImpl) descriptor).setLoader(getDefaultBinderLoader()); } // else who knows? }
/** * {@inheritDoc} * <p> * This method can be called only in the execution context of the {@link #configure()} * method. * </p> */ @Override public <T> ActiveDescriptor<T> addActiveDescriptor(ActiveDescriptor<T> activeDescriptor) throws IllegalArgumentException { return addActiveDescriptor(activeDescriptor, true); }
if (hkManaged) { optionalSingleton(singleton ? binder.bindFactory((Class<Factory<T>>) type, Singleton.class).to(type).to(res) : binder.bindFactory((Class<Factory<T>>) type).to(type).to(res), singleton); } else { binder.bindFactory(new LazyGuiceFactory(injector, type)).to(res); optionalSingleton(binder.bindFactory(new GuiceComponentFactory<>(injector, type)).to(type), singleton);
/** * {@inheritDoc} * <p> * This method can be called only in the execution context of the {@link #configure()} * method. * </p> */ @Override public <T> ActiveDescriptor<T> bind(Descriptor descriptor) { return bind(descriptor, true); }
if (hkManaged) { optionalSingleton( binder.bind(type).to(type).to(bindingType), singleton); } else { binder.bindFactory(new GuiceComponentFactory<>(injector, type)).to(type), singleton); optionalSingleton( binder.bindAsContract(type).to(bindingType), singleton); } else { optionalSingleton( binder.bindFactory(new GuiceComponentFactory<>(injector, type)).to(type).to(bindingType), singleton);
@Override public <T> ActiveDescriptor<T> bind(Descriptor descriptor, boolean requiresDeepCopy) { setLoader(descriptor); return configuration().bind(descriptor, requiresDeepCopy); }
private void complete() { try { resetBuilder(null); } finally { this.configuration = null; } }
/** * {@inheritDoc} * <p> * This method can be called only in the execution context of the {@link #configure()} * method. * </p> */ @Override public void addUnbindFilter(Filter unbindFilter) throws IllegalArgumentException { configuration().addUnbindFilter(unbindFilter); }
private <T> AbstractBindingBuilder<T> resetBuilder(AbstractBindingBuilder<T> newBuilder) { if (currentBuilder != null) { currentBuilder.complete(configuration(), getDefaultBinderLoader()); } currentBuilder = newBuilder; return newBuilder; }
@Override public void bind(DynamicConfiguration configuration) { if (this.configuration != null) { throw new IllegalArgumentException("Recursive configuration call detected."); } if (configuration == null) { throw new NullPointerException("configuration"); } this.configuration = configuration; try { configure(); } finally { complete(); } }
/** * 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); } }