Class SimpleServiceRegistry

java.lang.Object
org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry
All Implemented Interfaces:
Iterable<Service>, ServiceRegistry

public class SimpleServiceRegistry extends Object implements ServiceRegistry
A registry for services
Author:
Pete Muir, Matej Novotny
  • Constructor Details

    • SimpleServiceRegistry

      public SimpleServiceRegistry()
      Initialize a new instance of SimpleServiceRegistry
  • Method Details

    • add

      public <S extends Service> void add(Class<S> type, S service)
      Description copied from interface: ServiceRegistry
      Add a service
      Specified by:
      add in interface ServiceRegistry
      Type Parameters:
      S - the service type to add
      Parameters:
      type - the service type to add
      service - the service implementation
      See Also:
    • addAll

      public void addAll(Collection<Map.Entry<Class<? extends Service>,Service>> services)
      Description copied from interface: ServiceRegistry
      Add services
      Specified by:
      addAll in interface ServiceRegistry
      Parameters:
      services - services to be added
    • entrySet

      public Set<Map.Entry<Class<? extends Service>,Service>> entrySet()
      Description copied from interface: ServiceRegistry
      Returns a set of all service entries
      Specified by:
      entrySet in interface ServiceRegistry
      Returns:
      all service entries as a set
    • get

      protected Map<Class<? extends Service>,Service> get()
      Returns a map containing all registered services
      Returns:
      map with all services
    • get

      public <S extends Service> S get(Class<S> type)
      Description copied from interface: ServiceRegistry
      Retrieve a service implementation
      Specified by:
      get in interface ServiceRegistry
      Type Parameters:
      S - the service type
      Parameters:
      type - the service type
      Returns:
      the service implementation, or null if none is registered
    • getOptional

      public <S extends Service> Optional<S> getOptional(Class<S> type)
      Description copied from interface: ServiceRegistry
      Retrieve a service implementation wrapped in Optional.
      Specified by:
      getOptional in interface ServiceRegistry
      Type Parameters:
      S - the service type
      Parameters:
      type - the service type
      Returns:
      the service implementation wrapped within Optional
    • contains

      public <S extends Service> boolean contains(Class<S> type)
      Description copied from interface: ServiceRegistry
      Check if a service is registered
      Specified by:
      contains in interface ServiceRegistry
      Type Parameters:
      S - the service type
      Parameters:
      type - the service type
      Returns:
      true if a service is registered, otherwise false
    • cleanup

      public void cleanup()
      Description copied from interface: ServiceRegistry
      Clear up the services registered, by calling Service.cleanup() on each registered service
      Specified by:
      cleanup in interface ServiceRegistry
    • cleanupAfterBoot

      public void cleanupAfterBoot()
      Description copied from interface: ServiceRegistry
      Specified by:
      cleanupAfterBoot in interface ServiceRegistry
    • toString

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • iterator

      public Iterator<Service> iterator()
      Specified by:
      iterator in interface Iterable<Service>
    • getRequired

      public <S extends Service> S getRequired(Class<S> type)
      Description copied from interface: ServiceRegistry
      Retrieve a required service implementation. Throws an exception if the service is not available
      Specified by:
      getRequired in interface ServiceRegistry
      Type Parameters:
      S - the service type
      Parameters:
      type - the service type
      Returns:
      the service implementation
    • addIfAbsent

      public <S extends Service> S addIfAbsent(Class<S> type, S service)
      Description copied from interface: ServiceRegistry
      Add a service if no implementation of the given service is registered with the registry yet. Returns null if the given service was added. Otherwise, the previous service implementation is returned.
      Specified by:
      addIfAbsent in interface ServiceRegistry
      Type Parameters:
      S - the service type to add
      Parameters:
      type - the service type to add
      service - the service implementation
      Returns:
      null if no service implementation was previously associated with the given service. Otherwise, the previous service implementation is returned.