public final class ContextManager extends Object
Context
manager to register and retrieve ContextScope
s.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)
|
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. current ClassLoader and all it's parents) must be scanned when
looking for available context scopes.
|
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. current ClassLoader and all it's parents) must be scanned when
looking for available context scopes.
|
static boolean |
unregisterScope(ClassLoader classLoader,
String name)
Unregister the
ContextScope bound to given classLoader , if any. |
public static boolean isUseClassLoaderHierarchy()
true
if the ClassLoader hierarchy must be scanned when looking for available context scopes,
false
if only the current ClassLoader must be taken into accountpublic static void setUseClassLoaderHierarchy(boolean useClassLoaderHierarchy)
useClassLoaderHierarchy
- true
to scan the ClassLoader hierarchy when looking for available
context scopes, false
if only the current ClassLoader must be taken into accountpublic static ClassLoader getDefaultClassLoader()
ClassLoader
.ClassLoader
. If null
, ClassUtils.getDefaultClassLoader()
will be
usedpublic static void setDefaultClassLoader(ClassLoader classLoader)
ClassLoader
to use when a ClassLoader is not directly specified.classLoader
- the default ClassLoader
public static boolean isScopeRegistered(ClassLoader classLoader, String scopeName)
classLoader
.classLoader
- ClassLoader. If null
, getDefaultClassLoader()
will be usedscopeName
- Scope name (not null)true
if scope is registeredpublic static void registerScope(ClassLoader classLoader, ContextScope scope)
ContextScope
bound to given classLoader
.classLoader
- ClassLoader. If null
, getDefaultClassLoader()
will be usedscope
- Scope to register (not null)public static boolean unregisterScope(ClassLoader classLoader, String name)
ContextScope
bound to given classLoader
, if any.classLoader
- ClassLoader. If null
, getDefaultClassLoader()
will be usedname
- Scope name (not null)true
if the scope was unregisteredpublic static Iterable<ContextScope> getScopes()
ContextScope
s for default ClassLoaderContextScope.getOrder()
getDefaultClassLoader()
public static Iterable<ContextScope> getScopes(ClassLoader classLoader)
ContextScope
s for given classLoader
classLoader
- ClassLoader. If null
, getDefaultClassLoader()
will be usedContextScope.getOrder()
public static ContextScope getScope(String name)
ContextScope
with given name
bound to default ClassLoadername
- Scope name (not null)null
if not registeredpublic static ContextScope getScope(String name, ClassLoader classLoader)
name
- Scope name (not null)classLoader
- ClassLoader. If null
, getDefaultClassLoader()
will be usednull
if not registeredCopyright © 2019 The Holon Platform. All rights reserved.