Class AbstractRegistry<E,​C>

java.lang.Object
io.github.resilience4j.core.registry.AbstractRegistry<E,​C>
All Implemented Interfaces:
Registry<E,​C>

public class AbstractRegistry<E,​C>
extends java.lang.Object
implements Registry<E,​C>
Abstract registry to be shared with all resilience4j registries
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.github.resilience4j.core.Registry

    Registry.EventPublisher<E>
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected static java.lang.String CONFIG_MUST_NOT_BE_NULL  
    protected java.util.concurrent.ConcurrentMap<java.lang.String,​C> configurations  
    protected static java.lang.String CONSUMER_MUST_NOT_BE_NULL  
    protected static java.lang.String DEFAULT_CONFIG  
    protected RegistryStore<E> entryMap  
    protected io.vavr.collection.Map<java.lang.String,​java.lang.String> registryTags
    Global tags which must be added to each instance created by this registry.
    protected static java.lang.String SUPPLIER_MUST_NOT_BE_NULL  
    protected static java.lang.String TAGS_MUST_NOT_BE_NULL  
  • Constructor Summary

    Constructors 
    Constructor Description
    AbstractRegistry​(C defaultConfig)  
    AbstractRegistry​(C defaultConfig, RegistryEventConsumer<E> registryEventConsumer)  
    AbstractRegistry​(C defaultConfig, RegistryEventConsumer<E> registryEventConsumer, io.vavr.collection.Map<java.lang.String,​java.lang.String> tags)  
    AbstractRegistry​(C defaultConfig, io.vavr.collection.Map<java.lang.String,​java.lang.String> registryTags)  
    AbstractRegistry​(C defaultConfig, java.util.List<RegistryEventConsumer<E>> registryEventConsumers)  
    AbstractRegistry​(C defaultConfig, java.util.List<RegistryEventConsumer<E>> registryEventConsumers, io.vavr.collection.Map<java.lang.String,​java.lang.String> tags)  
    AbstractRegistry​(C defaultConfig, java.util.List<RegistryEventConsumer<E>> registryEventConsumers, io.vavr.collection.Map<java.lang.String,​java.lang.String> tags, RegistryStore<E> registryStore)  
  • Method Summary

    Modifier and Type Method Description
    void addConfiguration​(java.lang.String configName, C configuration)
    Adds a configuration to the registry
    protected E computeIfAbsent​(java.lang.String name, java.util.function.Supplier<E> supplier)  
    java.util.Optional<E> find​(java.lang.String name)
    Find a named entry in the Registry
    protected io.vavr.collection.Map<java.lang.String,​java.lang.String> getAllTags​(io.vavr.collection.Map<java.lang.String,​java.lang.String> tags)
    Creates map with all tags (registry and instance).
    java.util.Optional<C> getConfiguration​(java.lang.String configName)
    Get a configuration by name
    C getDefaultConfig()
    Get the default configuration
    Registry.EventPublisher<E> getEventPublisher()
    Returns an EventPublisher which can be used to register event consumers.
    io.vavr.collection.Map<java.lang.String,​java.lang.String> getTags()  
    java.util.Optional<E> remove​(java.lang.String name)
    Remove an entry from the Registry
    java.util.Optional<E> replace​(java.lang.String name, E newEntry)
    Replace an existing entry in the Registry by a new one.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • computeIfAbsent

      protected E computeIfAbsent​(java.lang.String name, java.util.function.Supplier<E> supplier)
    • find

      public java.util.Optional<E> find​(java.lang.String name)
      Description copied from interface: Registry
      Find a named entry in the Registry
      Specified by:
      find in interface Registry<E,​C>
      Parameters:
      name - the name
    • remove

      public java.util.Optional<E> remove​(java.lang.String name)
      Description copied from interface: Registry
      Remove an entry from the Registry
      Specified by:
      remove in interface Registry<E,​C>
      Parameters:
      name - the name
    • replace

      public java.util.Optional<E> replace​(java.lang.String name, E newEntry)
      Description copied from interface: Registry
      Replace an existing entry in the Registry by a new one.
      Specified by:
      replace in interface Registry<E,​C>
      Parameters:
      name - the existing name
      newEntry - a new entry
    • addConfiguration

      public void addConfiguration​(java.lang.String configName, C configuration)
      Description copied from interface: Registry
      Adds a configuration to the registry
      Specified by:
      addConfiguration in interface Registry<E,​C>
      Parameters:
      configName - the configuration name
      configuration - the added configuration
    • getConfiguration

      public java.util.Optional<C> getConfiguration​(java.lang.String configName)
      Description copied from interface: Registry
      Get a configuration by name
      Specified by:
      getConfiguration in interface Registry<E,​C>
      Parameters:
      configName - the configuration name
      Returns:
      the found configuration if any
    • getDefaultConfig

      public C getDefaultConfig()
      Description copied from interface: Registry
      Get the default configuration
      Specified by:
      getDefaultConfig in interface Registry<E,​C>
      Returns:
      the default configuration
    • getTags

      public io.vavr.collection.Map<java.lang.String,​java.lang.String> getTags()
      Specified by:
      getTags in interface Registry<E,​C>
      Returns:
      global configured registry tags
    • getEventPublisher

      public Registry.EventPublisher<E> getEventPublisher()
      Description copied from interface: Registry
      Returns an EventPublisher which can be used to register event consumers.
      Specified by:
      getEventPublisher in interface Registry<E,​C>
      Returns:
      an EventPublisher
    • getAllTags

      protected io.vavr.collection.Map<java.lang.String,​java.lang.String> getAllTags​(io.vavr.collection.Map<java.lang.String,​java.lang.String> tags)
      Creates map with all tags (registry and instance). When tags (keys) of the two collide the tags passed with this method will override the tags of the registry.
      Parameters:
      tags - Tags of the instance.
      Returns:
      Map containing all tags