public enum DefaultContext extends Enum<DefaultContext> implements Context
Context implementation, using ContextManager to access context scopes and resources.| Enum Constant and Description |
|---|
INSTANCE |
CLASSLOADER_SCOPE_NAME, THREAD_SCOPE_NAME| Modifier and Type | Method and Description |
|---|---|
<T> Optional<T> |
resource(String resourceKey,
Class<T> resourceType,
ClassLoader classLoader)
Lookup a context resource of
resourceType class using given resourceKey. |
Optional<ContextScope> |
scope(String name,
ClassLoader classLoader)
|
static DefaultContext |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static DefaultContext[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOfclassLoaderScope, classLoaderScope, executeThreadBound, executeThreadBound, get, resource, resource, resource, scope, threadScope, threadScopepublic static final DefaultContext INSTANCE
public static DefaultContext[] values()
for (DefaultContext c : DefaultContext.values()) System.out.println(c);
public static DefaultContext valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic Optional<ContextScope> scope(String name, ClassLoader classLoader)
Contextscope in interface Contextname - Scope name (not null)classLoader - ClassLoader, if null, the default ClassLoader is usedContextScope with given name, or an empty Optional if a scope with such name is
not registered in contextpublic <T> Optional<T> resource(String resourceKey, Class<T> resourceType, ClassLoader classLoader)
ContextresourceType class using given resourceKey.
All registered context scopes are invoked, in the order defined by ContextScope.getOrder() precedence
value. The first not null resource instance obtained from a scope is the one returned to caller, if
any.
resource in interface ContextT - Resource typeresourceKey - Resource key (not null)resourceType - Required resource type (not null)classLoader - ClassLoader to use. If null, the default ClassLoader is used.Copyright © 2019 The Holon Platform. All rights reserved.