Class LocalRegistryAndDiscoveryProvider

java.lang.Object
org.wildfly.discovery.impl.LocalRegistryAndDiscoveryProvider
All Implemented Interfaces:
DiscoveryProvider, RegistryProvider

public final class LocalRegistryAndDiscoveryProvider extends Object implements RegistryProvider, DiscoveryProvider
A local in-memory service registry and discovery provider. Services registered with this provider can be subsequently discovered. Since all operations happen in-memory, the discovery provider always completes immediately.
Author:
David M. Lloyd
  • Constructor Details

    • LocalRegistryAndDiscoveryProvider

      public LocalRegistryAndDiscoveryProvider()
  • Method Details

    • registerService

      public ServiceRegistration registerService(ServiceURL serviceURL)
      Description copied from interface: RegistryProvider
      Register a service with this provider. Service URLs which are unsupported must be ignored; in this case, the empty registration handle must be returned.
      Specified by:
      registerService in interface RegistryProvider
      Parameters:
      serviceURL - the service to register (not null)
      Returns:
      the service registration handle (must not be null)
    • registerServices

      public ServiceRegistration registerServices(ServiceURL... serviceURLs)
      Description copied from interface: RegistryProvider
      Register multiple services with this provider at once. Service URLs which are unsupported must be ignored. If none of the service URLs are supported, then the empty registration handle must be returned.

      The default implementation calls RegistryProvider.registerService(ServiceURL) for each service in the array and returns an aggregated handle.

      Specified by:
      registerServices in interface RegistryProvider
      Parameters:
      serviceURLs - the services to register (not null, will not contain null elements)
      Returns:
      the service registration handle (must not be null)
    • discover

      public DiscoveryRequest discover(ServiceType serviceType, FilterSpec filterSpec, DiscoveryResult result)
      Description copied from interface: DiscoveryProvider
      Attempt to discover implementations of a service. Matches must be written to the DiscoveryResult.addMatch(ServiceURL) method on the result parameter as they are found. The DiscoveryResult.complete() method must be called when the discovery process is complete or has timed out or failed for any other reason, otherwise discovery clients may hang indefinitely.

      The discovery process should be asynchronous if possible. In this case, this method should return as soon as possible in order to unblock the calling thread quickly and allow other discovery mechanisms to proceed. The discovery process will not be considered complete until the result's completion method is called, even if such a call comes from a different thread.

      Specified by:
      discover in interface DiscoveryProvider
      Parameters:
      serviceType - the service type to match
      filterSpec - the service attribute filter expression, or null to return all matches
      result - the discovery result