use of org.glassfish.jersey.internal.inject.Binding in project jersey by jersey.
the class Hk2Helper method bind.
/**
* Bind descriptors to Hk2-like {@link Binder}.
*
* @param locator HK2 locator.
* @param descriptors collection of descriptors.
*/
static void bind(ServiceLocator locator, Iterable<Binding> descriptors) {
DynamicConfiguration dc = getDynamicConfiguration(locator);
for (Binding binding : descriptors) {
bindBinding(locator, dc, binding);
}
dc.commit();
}
use of org.glassfish.jersey.internal.inject.Binding in project jersey by jersey.
the class AbstractBinderTest method testFirstLayer.
@Test
public void testFirstLayer() {
AbstractBinder binder = new AbstractBinder() {
@Override
protected void configure() {
bind(CacheControlProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(CookieProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(DateProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(EntityTagProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(LinkProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
}
};
List<Binding> bindings = new ArrayList<>(binder.getBindings());
assertEquals(5, bindings.size());
// Keep ordering.
assertEquals(CacheControlProvider.class, ((ClassBinding) bindings.get(0)).getService());
assertEquals(CookieProvider.class, ((ClassBinding) bindings.get(1)).getService());
assertEquals(DateProvider.class, ((ClassBinding) bindings.get(2)).getService());
assertEquals(EntityTagProvider.class, ((ClassBinding) bindings.get(3)).getService());
assertEquals(LinkProvider.class, ((ClassBinding) bindings.get(4)).getService());
}
use of org.glassfish.jersey.internal.inject.Binding in project jersey by jersey.
the class CdiValidationResultBinder method done.
@Override
@SuppressWarnings("unchecked")
public void done() {
if (beanManager != null) {
// in CDI environment
Binding binding = Bindings.supplier(new GenericCdiBeanSupplier(CdiValidationResult.class, injectionManager, beanManager, true)).to(CdiValidationResult.class).to(ValidationResult.class);
injectionManager.register(binding);
}
}
Aggregations