Class ForwardingServiceRegistry

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

public abstract class ForwardingServiceRegistry extends Object implements ServiceRegistry
An implementation of ServiceRegistry which forwards all its method calls to another ServiceRegistry Subclasses should override one or more methods to modify the behavior of the backing ServiceRegistry as desired per the decorator pattern.
  • Constructor Details

    • ForwardingServiceRegistry

      public ForwardingServiceRegistry()
  • Method Details

    • delegate

      protected abstract ServiceRegistry delegate()
      Returns the delegate
      Returns:
      delegate
    • 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:
    • 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
    • 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
    • iterator

      public Iterator<Service> iterator()
      Specified by:
      iterator in interface Iterable<Service>
    • 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
    • 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
    • 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.