Class ServiceFinderBinder<T>

java.lang.Object
org.glassfish.jersey.internal.ServiceFinderBinder<T>
Type Parameters:
T - contract type.
All Implemented Interfaces:
Binder

public class ServiceFinderBinder<T> extends Object
Simple ServiceFinder injection binder. Looks for all implementations of a given contract using ServiceFinder and registers found instances to InjectionManager.
Author:
Pavel Bucek, Libor Kramolis
  • Constructor Summary

    Constructors
    Constructor
    Description
    ServiceFinderBinder(Class<T> contract, Map<String,Object> applicationProperties, RuntimeType runtimeType)
    Create a new service finder injection binder.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> org.glassfish.jersey.innate.inject.ClassBinding<T>
    bind(Class<T> serviceType)
    Start building a new class-based service binding.
    bind(Binding binding)
    Binds the provided binding and return the same instance.
    <T> org.glassfish.jersey.innate.inject.InstanceBinding<T>
    bind(T service)
    Start building a new instance-based service binding.
    <T extends InjectionResolver>
    org.glassfish.jersey.innate.inject.InjectionResolverBinding<T>
    bind(T resolver)
    Start building a new injection resolver binding.
    <T> org.glassfish.jersey.innate.inject.ClassBinding<T>
    bindAsContract(GenericType<T> serviceType)
    Start building a new generic type-based service binding.
    <T> org.glassfish.jersey.innate.inject.ClassBinding<T>
    bindAsContract(Class<T> serviceType)
    Start building a new class-based service binding.
    org.glassfish.jersey.innate.inject.ClassBinding<Object>
    bindAsContract(Type serviceType)
    Start building a new generic type-based service binding.
    <T> org.glassfish.jersey.innate.inject.SupplierClassBinding<T>
    bindFactory(Class<? extends Supplier<T>> supplierType)
    Start building a new supplier class-based service binding.
    <T> org.glassfish.jersey.innate.inject.SupplierClassBinding<T>
    bindFactory(Class<? extends Supplier<T>> supplierType, Class<? extends Annotation> supplierScope)
    Start building a new supplier class-based service binding.
    <T> org.glassfish.jersey.innate.inject.SupplierInstanceBinding<T>
    bindFactory(Supplier<T> factory)
    Start building a new supplier instance-based service binding.
    protected void
    Implement to provide binding definitions using the exposed binding methods.
    protected <T> jakarta.inject.Provider<T>
    Creates a new instance of Provider which is able to retrieve a managed instance registered in InjectionManager.
    Gets a collection of descriptors registered in this jersey binder.
    final void
    install(Binder... binders)
    Adds all binding definitions from the binders to the binding configuration.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ServiceFinderBinder

      public ServiceFinderBinder(Class<T> contract, Map<String,Object> applicationProperties, RuntimeType runtimeType)
      Create a new service finder injection binder.
      Parameters:
      contract - contract of the service providers bound by this binder.
      applicationProperties - map containing application properties. May be null.
      runtimeType - runtime (client or server) where the service finder binder is used.
  • Method Details

    • configure

      protected void configure()
      Implement to provide binding definitions using the exposed binding methods.
    • bind

      public <T> org.glassfish.jersey.innate.inject.ClassBinding<T> bind(Class<T> serviceType)
      Start building a new class-based service binding.

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

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

      public <T> org.glassfish.jersey.innate.inject.ClassBinding<T> bindAsContract(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.
    • bindAsContract

      public <T> org.glassfish.jersey.innate.inject.ClassBinding<T> bindAsContract(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.
    • bindAsContract

      public org.glassfish.jersey.innate.inject.ClassBinding<Object> bindAsContract(Type serviceType)
      Start building a new generic type-based service binding.

      Binds the generic service type itself as a contract type.

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

      public <T> org.glassfish.jersey.innate.inject.InstanceBinding<T> bind(T service)
      Start building a new instance-based service binding. 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.
    • bindFactory

      public <T> org.glassfish.jersey.innate.inject.SupplierClassBinding<T> bindFactory(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.
    • bindFactory

      public <T> org.glassfish.jersey.innate.inject.SupplierClassBinding<T> bindFactory(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.
    • bindFactory

      public <T> org.glassfish.jersey.innate.inject.SupplierInstanceBinding<T> bindFactory(Supplier<T> factory)
      Start building a new supplier instance-based service binding.
      Type Parameters:
      T - service type.
      Parameters:
      factory - service instance.
      Returns:
      initialized binding builder.
    • bind

      public <T extends InjectionResolver> org.glassfish.jersey.innate.inject.InjectionResolverBinding<T> bind(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 InternalBinding will be ignored.

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

      protected <T> jakarta.inject.Provider<T> createManagedInstanceProvider(Class<T> clazz)
      Creates a new instance of Provider which is able to retrieve a managed instance registered in InjectionManager. If InjectionManager is null at the time of calling Provider.get() then IllegalStateException is thrown.
      Type Parameters:
      T - type of the managed instance returned using provider.
      Parameters:
      clazz - class of managed instance.
      Returns:
      provider with instance of managed instance.
    • bind

      public Binding bind(Binding binding)
      Binds the provided binding and return the same instance.
      Parameters:
      binding - binding.
      Returns:
      the same provided binding.
    • install

      public final void install(Binder... binders)
      Adds all binding definitions from the binders to the binding configuration.
      Parameters:
      binders - binders whose binding definitions should be configured.
    • getBindings

      public Collection<Binding> getBindings()
      Description copied from interface: Binder
      Gets a collection of descriptors registered in this jersey binder.
      Specified by:
      getBindings in interface Binder
      Returns:
      collection of descriptors.