Interface ContextClassLoaderFactory

  • All Known Implementing Classes:
    DefaultContextClassLoaderFactory

    public interface ContextClassLoaderFactory
    The ContextClassLoaderFactory provides a mechanism for various Accumulo components to use a custom ClassLoader for specific contexts, such as loading table iterators. This factory is initialized at startup and supplies ClassLoaders when provided a context.

    This factory can be configured using the general.context.class.loader.factory property. All implementations of this factory must have a default (no-argument) public constructor.

    A default implementation is provided for Accumulo 2.x to retain existing context class loader behavior based on per-table configuration. However, after Accumulo 2.x, the default is expected to change to a simpler implementation, and users will need to provide their own implementation to support advanced context class loading features. Some implementations may be maintained by the Accumulo developers in a separate package. Check the Accumulo website or contact the developers for more details on the status of these implementations.

    Because this factory is expected to be instantiated early in the application startup process, configuration is expected to be provided within the environment (such as in Java system properties or process environment variables), and is implementation-specific. However, some limited environment is also available so implementations can have access to Accumulo's own system configuration.

    Since:
    2.1.0
    • Method Detail

      • init

        default void init​(ContextClassLoaderEnvironment env)
        Pass the service environment to allow for additional class loader configuration
        Parameters:
        env - the class loader environment
      • getClassLoader

        ClassLoader getClassLoader​(String contextName)
        Get the class loader for the given contextName. Callers should not cache the ClassLoader result as it may change if/when the ClassLoader reloads. Implementations should throw a RuntimeException of some type (such as IllegalArgumentException) if the provided contextName is not supported or fails to be constructed.
        Parameters:
        contextName - the name of the context that represents a class loader that is managed by this factory (can be null)
        Returns:
        the class loader for the given contextName