Class BindingBuilderFactory

java.lang.Object
org.glassfish.hk2.utilities.binding.BindingBuilderFactory

public class BindingBuilderFactory extends Object
HK2 injection binding utility methods.
  • Constructor Details

    • BindingBuilderFactory

      public BindingBuilderFactory()
  • Method Details

    • addBinding

      public static void addBinding(BindingBuilder<?> builder, DynamicConfiguration configuration)
      Add a binding represented by the binding builder to the HK2 dynamic configuration.
      Parameters:
      builder - binding builder.
      configuration - HK2 dynamic configuration.
    • addBinding

      public static void addBinding(BindingBuilder<?> builder, DynamicConfiguration configuration, HK2Loader defaultLoader)
      Add a binding represented by the binding builder to the HK2 dynamic configuration.
      Parameters:
      builder - binding builder.
      configuration - HK2 dynamic configuration.
      defaultLoader - default HK2 service loader that should be used to load the service class in case a custom loader has not been set.
    • newFactoryBinder

      public static <T> ServiceBindingBuilder<T> newFactoryBinder(Class<? extends Factory<T>> factoryType, Class<? extends Annotation> factoryScope)
      Get a new factory class-based service binding builder.
      Type Parameters:
      T - service type.
      Parameters:
      factoryType - service factory class.
      factoryScope - factory scope.
      Returns:
      initialized binding builder.
    • newFactoryBinder

      public static <T> ServiceBindingBuilder<T> newFactoryBinder(Class<? extends Factory<T>> factoryType)
      Get a new factory class-based service binding builder. The factory itself is bound in a per-lookup scope.
      Type Parameters:
      T - service type.
      Parameters:
      factoryType - service factory class.
      Returns:
      initialized binding builder.
    • newFactoryBinder

      public static <T> ServiceBindingBuilder<T> newFactoryBinder(Factory<T> factory)
      Get a new factory instance-based service binding builder.
      Type Parameters:
      T - service type.
      Parameters:
      factory - service instance.
      Returns:
      initialized binding builder.
    • newBinder

      public static <T> ServiceBindingBuilder<T> newBinder(Class<T> serviceType)
      Get a new class-based service binding builder. Does NOT bind the service type itself as a contract type.
      Type Parameters:
      T - service type.
      Parameters:
      serviceType - service class.
      Returns:
      initialized binding builder.
    • newBinder

      public static <T> ScopedBindingBuilder<T> newBinder(T service)
      Get a new instance-based service binding builder. The binding is naturally considered to be a singleton-scoped. Does NOT bind the service type itself as a contract type.
      Type Parameters:
      T - service type.
      Parameters:
      service - service instance.
      Returns:
      initialized binding builder.