Class 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
    • Field Detail

      • CONFIG_MUST_NOT_BE_NULL

        protected static final java.lang.String CONFIG_MUST_NOT_BE_NULL
        See Also:
        Constant Field Values
      • CONSUMER_MUST_NOT_BE_NULL

        protected static final java.lang.String CONSUMER_MUST_NOT_BE_NULL
        See Also:
        Constant Field Values
      • SUPPLIER_MUST_NOT_BE_NULL

        protected static final java.lang.String SUPPLIER_MUST_NOT_BE_NULL
        See Also:
        Constant Field Values
      • TAGS_MUST_NOT_BE_NULL

        protected static final java.lang.String TAGS_MUST_NOT_BE_NULL
        See Also:
        Constant Field Values
      • configurations

        protected final java.util.concurrent.ConcurrentMap<java.lang.String,​C> configurations
      • registryTags

        protected final io.vavr.collection.Map<java.lang.String,​java.lang.String> registryTags
        Global tags which must be added to each instance created by this registry.
    • Constructor Detail

      • AbstractRegistry

        public AbstractRegistry​(C defaultConfig)
      • AbstractRegistry

        public AbstractRegistry​(C defaultConfig,
                                io.vavr.collection.Map<java.lang.String,​java.lang.String> registryTags)
      • AbstractRegistry

        public AbstractRegistry​(C defaultConfig,
                                RegistryEventConsumer<E> registryEventConsumer,
                                io.vavr.collection.Map<java.lang.String,​java.lang.String> tags)
      • AbstractRegistry

        public AbstractRegistry​(C defaultConfig,
                                java.util.List<RegistryEventConsumer<E>> registryEventConsumers)
      • AbstractRegistry

        public AbstractRegistry​(C defaultConfig,
                                java.util.List<RegistryEventConsumer<E>> registryEventConsumers,
                                io.vavr.collection.Map<java.lang.String,​java.lang.String> tags)
      • AbstractRegistry

        public AbstractRegistry​(C defaultConfig,
                                java.util.List<RegistryEventConsumer<E>> registryEventConsumers,
                                io.vavr.collection.Map<java.lang.String,​java.lang.String> tags,
                                RegistryStore<E> registryStore)
    • Method Detail

      • 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
      • 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