com.holonplatform.core.internal

## Class ContextManager

- java.lang.Object
- - com.holonplatform.core.internal.ContextManager

-     public final class ContextManager
      extends Object

  `Context` manager to register and retrieve `ContextScope`s.
  Since:
    5.0.0

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static ClassLoader` | `getDefaultClassLoader()` Gets the default `ClassLoader`.
    `static ContextScope` | `getScope(String name)` Gets the `ContextScope` with given `name` bound to default ClassLoader
    `static ContextScope` | `getScope(String name, ClassLoader classLoader)` Gets the `ContextScope` with given `name` bound to given `classLoader`
    `static Iterable<ContextScope>` | `getScopes()` Gets all available `ContextScope`s for default ClassLoader
    `static Iterable<ContextScope>` | `getScopes(ClassLoader classLoader)` Gets all available `ContextScope`s for given `classLoader`
    `static boolean` | `isScopeRegistered(ClassLoader classLoader, String scopeName)` Gets whether the given scope name is registered for given `classLoader`.
    `static boolean` | `isUseClassLoaderHierarchy()` Get whether the ClassLoader hierarchy (i.e.
    `static void` | `registerScope(ClassLoader classLoader, ContextScope scope)` Register a `ContextScope` bound to given `classLoader`.
    `static void` | `setDefaultClassLoader(ClassLoader classLoader)` Sets the default `ClassLoader` to use when a ClassLoader is not directly specified.
    `static void` | `setUseClassLoaderHierarchy(boolean useClassLoaderHierarchy)` Set whether the ClassLoader hierarchy (i.e.
    `static boolean` | `unregisterScope(ClassLoader classLoader, String name)` Unregister the `ContextScope` bound to given `classLoader`, if any.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### isUseClassLoaderHierarchy

          public static boolean isUseClassLoaderHierarchy()

      Get whether the ClassLoader hierarchy (i.e. current ClassLoader and all it's parents) must be scanned when looking for available context scopes.
      Returns:
        `true` if the ClassLoader hierarchy must be scanned when looking for available context scopes, `false` if only the current ClassLoader must be taken into account

    - #### setUseClassLoaderHierarchy

          public static void setUseClassLoaderHierarchy(boolean useClassLoaderHierarchy)

      Set whether the ClassLoader hierarchy (i.e. current ClassLoader and all it's parents) must be scanned when looking for available context scopes.
      Parameters:
        `useClassLoaderHierarchy` - `true` to scan the ClassLoader hierarchy when looking for available context scopes, `false` if only the current ClassLoader must be taken into account

    - #### getDefaultClassLoader

          public static ClassLoader getDefaultClassLoader()

      Gets the default `ClassLoader`.
      Returns:
        the default `ClassLoader`. If `null`, `ClassUtils.getDefaultClassLoader()` will be used

    - #### setDefaultClassLoader

          public static void setDefaultClassLoader(ClassLoader classLoader)

      Sets the default `ClassLoader` to use when a ClassLoader is not directly specified.
      Parameters:
        `classLoader` - the default `ClassLoader`

    - #### isScopeRegistered

          public static boolean isScopeRegistered(ClassLoader classLoader,
                                                  String scopeName)

      Gets whether the given scope name is registered for given `classLoader`.
      Parameters:
        `classLoader` - ClassLoader. If `null`, `getDefaultClassLoader()` will be used
        `scopeName` - Scope name (not null)
      Returns:
        `true` if scope is registered

    - #### registerScope

          public static void registerScope(ClassLoader classLoader,
                                           ContextScope scope)

      Register a `ContextScope` bound to given `classLoader`.
      Parameters:
        `classLoader` - ClassLoader. If `null`, `getDefaultClassLoader()` will be used
        `scope` - Scope to register (not null)

    - #### unregisterScope

          public static boolean unregisterScope(ClassLoader classLoader,
                                                String name)

      Unregister the `ContextScope` bound to given `classLoader`, if any.
      Parameters:
        `classLoader` - ClassLoader. If `null`, `getDefaultClassLoader()` will be used
        `name` - Scope name (not null)
      Returns:
        `true` if the scope was unregistered

    - #### getScopes

          public static Iterable<ContextScope> getScopes()

      Gets all available `ContextScope`s for default ClassLoader
      Returns:
        ContextScopes iterator, preserving the order defined using `ContextScope.getOrder()`
      See Also:
        `getDefaultClassLoader()`

    - #### getScopes

          public static Iterable<ContextScope> getScopes(ClassLoader classLoader)

      Gets all available `ContextScope`s for given `classLoader`
      Parameters:
        `classLoader` - ClassLoader. If `null`, `getDefaultClassLoader()` will be used
      Returns:
        ContextScopes iterator, preserving the order defined using `ContextScope.getOrder()`

    - #### getScope

          public static ContextScope getScope(String name)

      Gets the `ContextScope` with given `name` bound to default ClassLoader
      Parameters:
        `name` - Scope name (not null)
      Returns:
        ContextScope with given name, or `null` if not registered

    - #### getScope

          public static ContextScope getScope(String name,
                                              ClassLoader classLoader)

      Gets the `ContextScope` with given `name` bound to given `classLoader`
      Parameters:
        `name` - Scope name (not null)
        `classLoader` - ClassLoader. If `null`, `getDefaultClassLoader()` will be used
      Returns:
        ContextScope with given name, or `null` if not registered

Copyright © 2019 The Holon Platform. All rights reserved.