Class ServiceRegistryConfig.BuilderBase<BUILDER extends ServiceRegistryConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ServiceRegistryConfig>

java.lang.Object
io.helidon.service.registry.ServiceRegistryConfig.BuilderBase<BUILDER,PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER,PROTOTYPE>
Direct Known Subclasses:
ServiceRegistryConfig.Builder
Enclosing interface:
ServiceRegistryConfig

public abstract static class ServiceRegistryConfig.BuilderBase<BUILDER extends ServiceRegistryConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ServiceRegistryConfig> extends Object implements Prototype.Builder<BUILDER,PROTOTYPE>
Fluent API builder base for ServiceRegistryConfig.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(ServiceRegistryConfig prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(ServiceRegistryConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • putContractInstance

      public BUILDER putContractInstance(TypeName contract, Object instance)
      Put an instance of a contract. In case there is a descriptor that matches the contract (i.e. the service type is the provided contract), the instance will be assigned that descriptor. The instance would be outside of service described services otherwise, creating a "virtual" service descriptor that will not be valid for metadata operations.

      If there is no descriptor for the contract, you will not be able to use our Maven plugin to code generate bindings and main classes.

      Parameters:
      contract - contract to add a specific instance for
      instance - instance of the contract
      Returns:
      updated builder instance
    • putContractInstance

      public BUILDER putContractInstance(Class<?> contract, Object instance)
      Put an instance of a contract. In case there is a descriptor that matches the contract (i.e. the service type is the provided contract), the instance will be assigned that descriptor. The instance would be outside of service described services otherwise, creating a "virtual" service descriptor that will not be valid for metadata operations.

      If there is no descriptor for the contract, you will not be able to use our Maven plugin to code generate bindings and main classes.

      Parameters:
      contract - contract to add a specific instance for
      instance - instance of the contract
      Returns:
      updated builder instance
    • discoverServices

      public BUILDER discoverServices(boolean discoverServices)
      Whether to discover services from the class path. When set to false, only services added through serviceDescriptors() and/or serviceInstances() would be available.
      Parameters:
      discoverServices - whether to discover services from classpath, defaults to true
      Returns:
      updated builder instance
      See Also:
    • discoverServicesFromServiceLoader

      public BUILDER discoverServicesFromServiceLoader(boolean discoverServicesFromServiceLoader)
      Whether to discover services from Java service loader. See ServiceDiscovery.SERVICES_LOADER_RESOURCE.
      Parameters:
      discoverServicesFromServiceLoader - whether to discover Java ServiceLoader services from classpath (a curated list only), defaults to true
      Returns:
      updated builder instance
      See Also:
    • allowLateBinding

      public BUILDER allowLateBinding(boolean allowLateBinding)
      Whether to allow binding via methods, such as Services.set(Class, Object[]). When disabled, attempts at late binding will throw an exception.
      Parameters:
      allowLateBinding - whether late binding is enabled, defaults to true
      Returns:
      updated builder instance
      See Also:
    • serviceDescriptors

      public BUILDER serviceDescriptors(List<ServiceDescriptor<?>> serviceDescriptors)
      Manually registered service descriptors to add to the registry. This is useful when discoverServices() is set to false, to register only hand-picked services into the registry.

      Even when service discovery is used, this can be used to add service descriptors that are not part of a service discovery mechanism (such as testing services).

      Parameters:
      serviceDescriptors - services to register
      Returns:
      updated builder instance
      See Also:
    • addServiceDescriptors

      public BUILDER addServiceDescriptors(List<ServiceDescriptor<?>> serviceDescriptors)
      Manually registered service descriptors to add to the registry. This is useful when discoverServices() is set to false, to register only hand-picked services into the registry.

      Even when service discovery is used, this can be used to add service descriptors that are not part of a service discovery mechanism (such as testing services).

      Parameters:
      serviceDescriptors - services to register
      Returns:
      updated builder instance
      See Also:
    • addServiceDescriptor

      public BUILDER addServiceDescriptor(ServiceDescriptor<?> serviceDescriptor)
      Manually registered service descriptors to add to the registry. This is useful when discoverServices() is set to false, to register only hand-picked services into the registry.

      Even when service discovery is used, this can be used to add service descriptors that are not part of a service discovery mechanism (such as testing services).

      Parameters:
      serviceDescriptor - services to register
      Returns:
      updated builder instance
      See Also:
    • serviceInstances

      public BUILDER serviceInstances(Map<ServiceDescriptor<?>,?> serviceInstances)
      This method replaces all values with the new ones.
      Parameters:
      serviceInstances - service instances to register
      Returns:
      updated builder instance
      See Also:
    • addServiceInstances

      public BUILDER addServiceInstances(Map<ServiceDescriptor<?>,?> serviceInstances)
      This method keeps existing values, then puts all new values into the map.
      Parameters:
      serviceInstances - service instances to register
      Returns:
      updated builder instance
      See Also:
    • putServiceInstance

      public <TYPE> BUILDER putServiceInstance(ServiceDescriptor<TYPE> key, TYPE serviceInstance)
      This method adds a new value to the map, or replaces it if the key already exists.
      Type Parameters:
      TYPE - Type to correctly map key and value
      Parameters:
      key - key to add or replace
      serviceInstance - new value for the key
      Returns:
      updated builder instance
      See Also:
    • lookupCacheEnabled

      public BUILDER lookupCacheEnabled(boolean lookupCacheEnabled)
      Flag indicating whether service lookups (i.e., via ServiceRegistry.first(io.helidon.service.registry.Lookup)) are cached.
      Parameters:
      lookupCacheEnabled - the flag indicating whether service lookups are cached, defaults to false
      Returns:
      updated builder instance
      See Also:
    • lookupCacheSize

      public BUILDER lookupCacheSize(int lookupCacheSize)
      Size of the lookup cache when ServiceRegistryConfigBlueprint.lookupCacheEnabled() is set to true.
      Parameters:
      lookupCacheSize - cache size
      Returns:
      updated builder instance
      See Also:
    • interceptionEnabled

      public BUILDER interceptionEnabled(boolean interceptionEnabled)
      Flag indicating whether runtime interception is enabled. If set to false, methods will be invoked without any interceptors, even if interceptors are available.
      Parameters:
      interceptionEnabled - whether to intercept calls at runtime, defaults to true
      Returns:
      updated builder instance
      See Also:
    • limitActivationPhase

      public BUILDER limitActivationPhase(ActivationPhase limitActivationPhase)
      In certain conditions Injection services should be initialized but not started (i.e., avoiding calls to PostConstruct etc.). This can be used in special cases where the normal Injection startup should limit lifecycle up to a given phase.
      Parameters:
      limitActivationPhase - the phase to stop at during lifecycle
      Returns:
      updated builder instance
      See Also:
    • useBinding

      public BUILDER useBinding(boolean useBinding)
      Flag indicating whether compile-time generated Binding's should be used at initialization when starting the registry using ServiceRegistryManager.start(Binding).

      This option is ignored when starting the service registry in any other way.

      Parameters:
      useBinding - the flag indicating whether the provider is permitted to use binding generated code from compile-time, defaults to true
      Returns:
      updated builder instance
      See Also:
    • maxRunLevel

      public BUILDER maxRunLevel(double maxRunLevel)
      Maximal run level to handle when starting from ServiceRegistryManager.start(Binding). This setting is ignored when starting registry using other means, as run levels are not handled by default.
      Parameters:
      maxRunLevel - maximal run level to lookup during application startup when using generated binding
      Returns:
      updated builder instance
      See Also:
    • runLevels

      public BUILDER runLevels(List<Double> runLevels)
      Run levels that should be initialized at startup. Generated Binding will configure all declared run levels of services in the application.

      Note that the result WILL be ordered before use, so initialization will always be handled from the smallest run level to the highest.

      Parameters:
      runLevels - run levels to initialize, up to maxRunLevel(), only used when starting the registry through ServiceRegistryManager.start(Binding) or ServiceRegistryManager.start(Binding, ServiceRegistryConfig)
      Returns:
      updated builder instance
      See Also:
    • addRunLevels

      public BUILDER addRunLevels(List<Double> runLevels)
      Run levels that should be initialized at startup. Generated Binding will configure all declared run levels of services in the application.

      Note that the result WILL be ordered before use, so initialization will always be handled from the smallest run level to the highest.

      Parameters:
      runLevels - run levels to initialize, up to maxRunLevel(), only used when starting the registry through ServiceRegistryManager.start(Binding) or ServiceRegistryManager.start(Binding, ServiceRegistryConfig)
      Returns:
      updated builder instance
      See Also:
    • addRunLevel

      public BUILDER addRunLevel(Double runLevel)
      Run levels that should be initialized at startup. Generated Binding will configure all declared run levels of services in the application.

      Note that the result WILL be ordered before use, so initialization will always be handled from the smallest run level to the highest.

      Parameters:
      runLevel - run levels to initialize, up to maxRunLevel(), only used when starting the registry through ServiceRegistryManager.start(Binding) or ServiceRegistryManager.start(Binding, ServiceRegistryConfig)
      Returns:
      updated builder instance
      See Also:
    • discoverServices

      public boolean discoverServices()
      Whether to discover services from the class path. When set to false, only services added through serviceDescriptors() and/or serviceInstances() would be available.
      Returns:
      the discover services
    • discoverServicesFromServiceLoader

      public boolean discoverServicesFromServiceLoader()
      Whether to discover services from Java service loader. See ServiceDiscovery.SERVICES_LOADER_RESOURCE.
      Returns:
      the discover services from service loader
    • allowLateBinding

      public boolean allowLateBinding()
      Whether to allow binding via methods, such as Services.set(Class, Object[]). When disabled, attempts at late binding will throw an exception.
      Returns:
      the allow late binding
    • serviceDescriptors

      public List<ServiceDescriptor<?>> serviceDescriptors()
      Manually registered service descriptors to add to the registry. This is useful when discoverServices() is set to false, to register only hand-picked services into the registry.

      Even when service discovery is used, this can be used to add service descriptors that are not part of a service discovery mechanism (such as testing services).

      Returns:
      the service descriptors
    • serviceInstances

      public Map<ServiceDescriptor<?>,Object> serviceInstances()
      Manually register initial bindings for some of the services in the registry.
      Returns:
      the service instances
    • lookupCacheEnabled

      public boolean lookupCacheEnabled()
      Flag indicating whether service lookups (i.e., via ServiceRegistry.first(io.helidon.service.registry.Lookup)) are cached.
      Returns:
      the lookup cache enabled
    • lookupCacheSize

      public int lookupCacheSize()
      Size of the lookup cache when ServiceRegistryConfigBlueprint.lookupCacheEnabled() is set to true.
      Returns:
      the lookup cache size
    • interceptionEnabled

      public boolean interceptionEnabled()
      Flag indicating whether runtime interception is enabled. If set to false, methods will be invoked without any interceptors, even if interceptors are available.
      Returns:
      the interception enabled
    • limitActivationPhase

      public ActivationPhase limitActivationPhase()
      In certain conditions Injection services should be initialized but not started (i.e., avoiding calls to PostConstruct etc.). This can be used in special cases where the normal Injection startup should limit lifecycle up to a given phase.
      Returns:
      the limit activation phase
    • useBinding

      public boolean useBinding()
      Flag indicating whether compile-time generated Binding's should be used at initialization when starting the registry using ServiceRegistryManager.start(Binding).

      This option is ignored when starting the service registry in any other way.

      Returns:
      the use binding
      See Also:
    • maxRunLevel

      public double maxRunLevel()
      Maximal run level to handle when starting from ServiceRegistryManager.start(Binding). This setting is ignored when starting registry using other means, as run levels are not handled by default.
      Returns:
      the max run level
    • runLevels

      public List<Double> runLevels()
      Run levels that should be initialized at startup. Generated Binding will configure all declared run levels of services in the application.

      Note that the result WILL be ordered before use, so initialization will always be handled from the smallest run level to the highest.

      Returns:
      the run levels
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.