Interface TransformerRegistry<K>

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

    public interface TransformerRegistry<K>
    extends Map<K,​Transformer>, StaticService
    Registry to cache transformers in memory.

    The registry contains two caches:

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

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

    • Method Detail

      • resolveTransformer

        Transformer resolveTransformer​(K key)
        Lookup a Transformer in the registry which supports the transformation for the data types represented by the key.
        Parameters:
        key - a key represents the from/to data types to transform
        Returns:
        Transformer if matched, otherwise null
      • staticSize

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

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

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

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

        boolean isStatic​(String scheme)
        Whether the given transformer is stored in the static cache
        Parameters:
        scheme - the scheme supported by this transformer
        Returns:
        true if in static cache, false if not
      • isStatic

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

        boolean isDynamic​(String scheme)
        Whether the given transformer is stored in the dynamic cache
        Parameters:
        scheme - the scheme supported by this transformer
        Returns:
        true if in dynamic cache, false if not
      • isDynamic

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

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