Class Bindings

java.lang.Object
org.glassfish.jersey.internal.inject.Bindings

public final class Bindings extends Object
Utility class to create a new injection binding descriptions for arbitrary Java beans.
Author:
Petr Bouda
  • Method Details

    • getBindings

      public static Collection<Binding> getBindings(InjectionManager injectionManager, Binder binder)
    • service

      public static <T> ClassBinding<T> service(Class<T> serviceType)
      Start building a new class-based service binding.

      Does NOT service the service type itself as a contract type.

      Type Parameters:
      T - service type.
      Parameters:
      serviceType - service class.
      Returns:
      initialized binding builder.
    • serviceAsContract

      public static <T> ClassBinding<T> serviceAsContract(Class<T> serviceType)
      Start building a new class-based service binding.

      Binds the service type itself as a contract type.

      Type Parameters:
      T - service type.
      Parameters:
      serviceType - service class.
      Returns:
      initialized binding builder.
    • service

      public static <T> ClassBinding<T> service(GenericType<T> serviceType)
      Start building a new generic type-based service binding.

      Binds the generic service type itself as a contract type.

      Type Parameters:
      T - service type.
      Parameters:
      serviceType - generic service type information.
      Returns:
      initialized binding builder.
    • serviceAsContract

      public static <T> ClassBinding<T> serviceAsContract(GenericType<T> serviceType)
      Start building a new generic type-based service binding.

      Binds the generic service type itself as a contract type.

      Type Parameters:
      T - service type.
      Parameters:
      serviceType - generic service type information.
      Returns:
      initialized binding builder.
    • serviceAsContract

      public static <T> ClassBinding<T> serviceAsContract(Type serviceType)
      Start building a new generic type-based service binding.

      Binds the generic service type itself as a contract type.

      Type Parameters:
      T - service type.
      Parameters:
      serviceType - generic service type information.
      Returns:
      initialized binding builder.
    • service

      public static <T> InstanceBinding<T> service(T service)
      Start building a new instance-based service binding. The binding is naturally considered to be a singleton-scoped.

      Does NOT service the service type itself as a contract type.

      Type Parameters:
      T - service type.
      Parameters:
      service - service instance.
      Returns:
      initialized binding builder.
    • serviceAsContract

      public static <T> InstanceBinding<T> serviceAsContract(T service)
      Start building a new instance-based service binding. The binding is naturally considered to be a singleton-scoped.

      Binds the generic service type itself as a contract type.

      Type Parameters:
      T - service type.
      Parameters:
      service - service instance.
      Returns:
      initialized binding builder.
    • supplier

      public static <T> SupplierClassBinding<T> supplier(Class<? extends Supplier<T>> supplierType, Class<? extends Annotation> supplierScope)
      Start building a new supplier class-based service binding.
      Type Parameters:
      T - service type.
      Parameters:
      supplierType - service supplier class.
      supplierScope - factory scope.
      Returns:
      initialized binding builder.
    • supplier

      public static <T> SupplierClassBinding<T> supplier(Class<? extends Supplier<T>> supplierType)
      Start building a new supplier class-based service binding.

      The supplier itself is bound in a per-lookup scope.

      Type Parameters:
      T - service type.
      Parameters:
      supplierType - service supplier class.
      Returns:
      initialized binding builder.
    • supplier

      public static <T> SupplierInstanceBinding<T> supplier(Supplier<T> supplier)
      Start building a new supplier instance-based service binding.
      Type Parameters:
      T - service type.
      Parameters:
      supplier - service instance.
      Returns:
      initialized binding builder.
    • injectionResolver

      public static <T extends InjectionResolver> InjectionResolverBinding<T> injectionResolver(T resolver)
      Start building a new injection resolver binding. The injection resolver is naturally considered to be a singleton-scoped.

      There is no need to provide any additional information. Other method on Binding will be ignored.

      Type Parameters:
      T - type of the injection resolver.
      Parameters:
      resolver - injection resolver instance.
      Returns:
      initialized binding builder.