Interface ValidatorRegistry<K>

  • Type Parameters:
    K - validator key
    All Superinterfaces:
    AutoCloseable, Map<K,​Validator>, Service, StaticService

    public interface ValidatorRegistry<K>
    extends Map<K,​Validator>, StaticService
    Registry to cache validators in memory.

    The registry contains two caches:

    • static - which keeps all the validators in the cache for the entire lifecycle
    • dynamic - which keeps the validators in a org.apache.camel.support.LRUCache and may evict validators which hasn't been requested recently
    The static cache stores all the validators that are created as part of setting up and starting routes. The static cache has no upper limit.

    The dynamic cache stores the validators that are created and used ad-hoc, such as from custom Java code that creates new validators etc. The dynamic cache has an upper limit, that by default is 1000 entries.

    • Method Detail

      • resolveValidator

        Validator resolveValidator​(K key)
        Lookup a Validator in the registry which supports the validation for the data type represented by the key.
        Parameters:
        key - a key represents the data type
        Returns:
        Validator if matched, otherwise null
      • staticSize

        int staticSize()
        Number of validators in the static registry.
      • dynamicSize

        int dynamicSize()
        Number of validators in the dynamic registry
      • getMaximumCacheSize

        int getMaximumCacheSize()
        Maximum number of entries to store in the dynamic registry
      • purge

        void purge()
        Purges the cache (removes validators from the dynamic cache)
      • isStatic

        boolean isStatic​(DataType type)
        Whether the given Validator is stored in the static cache
        Parameters:
        type - the data type
        Returns:
        true if in static cache, false if not
      • isDynamic

        boolean isDynamic​(DataType type)
        Whether the given Validator is stored in the dynamic cache
        Parameters:
        type - the data type
        Returns:
        true if in dynamic cache, false if not
      • cleanUp

        void cleanUp()
        Cleanup the cache (purging stale entries)