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>, Prototype.ConfiguredBuilder<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.ConfiguredBuilder<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 outside of service described services. This will create a "virtual" service descriptor that will not be valid for metadata operations.
      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 outside of service described services. This will create a "virtual" service descriptor that will not be valid for metadata operations.
      Parameters:
      contract - contract to add a specific instance for
      instance - instance of the contract
      Returns:
      updated builder instance
    • config

      public BUILDER config(Config config)
      Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.
      Specified by:
      config in interface Prototype.ConfiguredBuilder<BUILDER extends ServiceRegistryConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ServiceRegistryConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      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:
    • serviceDescriptors

      public BUILDER serviceDescriptors(List<GeneratedService.Descriptor<?>> 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<GeneratedService.Descriptor<?>> 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(GeneratedService.Descriptor<?> 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<GeneratedService.Descriptor<?>,?> 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<GeneratedService.Descriptor<?>,?> 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(GeneratedService.Descriptor<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:
    • 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
    • serviceDescriptors

      public List<GeneratedService.Descriptor<?>> 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<GeneratedService.Descriptor<?>,Object> serviceInstances()
      Manually register initial bindings for some of the services in the registry.
      Returns:
      the service instances
    • config

      public Optional<Config> config()
      If this instance was configured, this would be the config instance used.
      Returns:
      config node used to configure this builder, or empty if not configured
    • toString

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

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

      protected void validatePrototype()
      Validates required properties.