Interface ContextStore<K,​C>

  • Type Parameters:
    K - key type to do context lookups
    C - context type

    public interface ContextStore<K,​C>
    Interface to represent context storage for instrumentations.

    Context instances are weakly referenced and will be garbage collected when their corresponding key instance is collected.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  ContextStore.Factory<C>
      Factory interface to create context instances.
    • Method Detail

      • get

        C get​(K key)
        Get context given the key.
        Parameters:
        key - the key to looup
        Returns:
        context object
      • put

        void put​(K key,
                 C context)
        Put new context instance for given key.
        Parameters:
        key - key to use
        context - context instance to save
      • putIfAbsent

        C putIfAbsent​(K key,
                      C context)
        Put new context instance if key is absent.
        Parameters:
        key - key to use
        context - new context instance to put
        Returns:
        old instance if it was present, or new instance
      • putIfAbsent

        C putIfAbsent​(K key,
                      ContextStore.Factory<C> contextFactory)
        Put new context instance if key is absent. Uses context factory to avoid creating objects if not needed.
        Parameters:
        key - key to use
        contextFactory - factory instance to produce new context object
        Returns:
        old instance if it was present, or new instance