Interface Service.InjectionPointFactory<T>

Type Parameters:
T - the type that the factory produces
All Known Implementing Classes:
GeneratedService.IpFactoryInterceptionWrapper
Enclosing class:
Service

public static interface Service.InjectionPointFactory<T>
Provides ability to contextualize the injected service by the target receiver of the injection point dynamically at runtime. This API will provide service instances of type T.

The ordering of services, and the preferred service itself, is determined by the service registry implementation.

The service registry does not make any assumptions about qualifiers of the instances being created, though they should be either the same as the injection point factory itself, or a subset of it, so the service can be discovered through one of the lookup methods (i.e. the injection point factory may be annotated with a Service.Named with Service.Named.WILDCARD_NAME value, and each instance provided may use a more specific name qualifier).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final TypeName
    Type name of this interface.
  • Method Summary

    Modifier and Type
    Method
    Description
    first(Lookup lookup)
    Get (or create) an instance of this service type for the given injection point context.
    list(Lookup lookup)
    Get (or create) a list of instances matching the criteria for the given injection point context.
  • Field Details

    • TYPE

      static final TypeName TYPE
      Type name of this interface.
  • Method Details

    • first

      Get (or create) an instance of this service type for the given injection point context. This is logically the same as using the first element of the result from calling list(Lookup).
      Parameters:
      lookup - the service query
      Returns:
      the best service instance matching the criteria, if any matched, with qualifiers (if any)
    • list

      default List<Service.QualifiedInstance<T>> list(Lookup lookup)
      Get (or create) a list of instances matching the criteria for the given injection point context.
      Parameters:
      lookup - the service query
      Returns:
      the service instances matching criteria for the lookup in order of weight, or empty if none matching