Search in sources :

Example 1 with SupplierInstanceBinding

use of org.glassfish.jersey.internal.inject.SupplierInstanceBinding in project jersey by jersey.

the class Hk2Helper method bindBinding.

/**
     * Binds the single descriptor using an external {@link DynamicConfiguration}.
     *
     * @param locator HK2 injection manager.
     * @param dc      HK2 Dynamic configuration to bind the object.
     * @param binding Jersey descriptor as a holder of information about an injection point.
     */
private static void bindBinding(ServiceLocator locator, DynamicConfiguration dc, Binding<?, ?> binding) {
    if (ClassBinding.class.isAssignableFrom(binding.getClass())) {
        ActiveDescriptor<?> activeDescriptor = translateToActiveDescriptor((ClassBinding<?>) binding);
        bindBinding(locator, dc, activeDescriptor, binding.getAliases());
    } else if (InstanceBinding.class.isAssignableFrom(binding.getClass())) {
        ActiveDescriptor<?> activeDescriptor = translateToActiveDescriptor((InstanceBinding<?>) binding);
        bindBinding(locator, dc, activeDescriptor, binding.getAliases());
    } else if (InjectionResolverBinding.class.isAssignableFrom(binding.getClass())) {
        InjectionResolverBinding resolverDescriptor = (InjectionResolverBinding) binding;
        bindBinding(locator, dc, wrapInjectionResolver(resolverDescriptor), binding.getAliases());
        bindBinding(locator, dc, translateToActiveDescriptor(resolverDescriptor), binding.getAliases());
    } else if (SupplierClassBinding.class.isAssignableFrom(binding.getClass())) {
        bindSupplierClassBinding(locator, (SupplierClassBinding<?>) binding);
    } else if (SupplierInstanceBinding.class.isAssignableFrom(binding.getClass())) {
        bindSupplierInstanceBinding(locator, (SupplierInstanceBinding<?>) binding);
    } else {
        throw new RuntimeException(LocalizationMessages.UNKNOWN_DESCRIPTOR_TYPE(binding.getClass().getSimpleName()));
    }
}
Also used : InstanceBinding(org.glassfish.jersey.internal.inject.InstanceBinding) SupplierInstanceBinding(org.glassfish.jersey.internal.inject.SupplierInstanceBinding) InjectionResolverBinding(org.glassfish.jersey.internal.inject.InjectionResolverBinding) ActiveDescriptor(org.glassfish.hk2.api.ActiveDescriptor) AbstractActiveDescriptor(org.glassfish.hk2.utilities.AbstractActiveDescriptor) SupplierClassBinding(org.glassfish.jersey.internal.inject.SupplierClassBinding)

Aggregations

ActiveDescriptor (org.glassfish.hk2.api.ActiveDescriptor)1 AbstractActiveDescriptor (org.glassfish.hk2.utilities.AbstractActiveDescriptor)1 InjectionResolverBinding (org.glassfish.jersey.internal.inject.InjectionResolverBinding)1 InstanceBinding (org.glassfish.jersey.internal.inject.InstanceBinding)1 SupplierClassBinding (org.glassfish.jersey.internal.inject.SupplierClassBinding)1 SupplierInstanceBinding (org.glassfish.jersey.internal.inject.SupplierInstanceBinding)1