public final class EnvironmentProvider
extends java.lang.Object
The EnvironmentProvider
is a singleton object to store and provide
Environment
instances. It provides the possibility to register and
retrieve Environment
instances on a per object or per class base.
Since an Environment
is designed as a substitute for some features
of the JDK System
class, the retrieval of the Environment
associated with a class should be possible without additional information about
the context. Class-based Environment
objects are also associated with
the thread, that actually registered the instance.
Constructor and Description |
---|
EnvironmentProvider() |
Modifier and Type | Method and Description |
---|---|
static Environment |
getEnvironment(java.lang.Object obj)
This method returns an
Environment instance that has been registered
for the given object. |
static void |
removeEnvironment(java.lang.Object obj)
Removing a registered
Environment . |
static void |
setEnvironment(java.lang.Object obj,
Environment env)
Registering an
Environment for the given object. |
public static Environment getEnvironment(java.lang.Object obj)
Environment
instance that has been registered
for the given object.
Environment
instance available for the
object then its class name is used to find a more general Environment
instance.
Environment
could be found a default Environment
is returned, usually a DefaultEnvironment
instance.
Environment
instance except
for runtime exceptions.obj
- the object thats environment should be retrievedEnvironment
instance for the callerEnvironment
,
DefaultEnvironment
public static void setEnvironment(java.lang.Object obj, Environment env) throws java.lang.NullPointerException
Environment
for the given object. If this object
is a Class
instance, the Environment
is
common for all instances of this class and its subclasses.obj
- the object the given Environment
is forenv
- the Environment
to storejava.lang.NullPointerException
- if one of the parameters is null
public static void removeEnvironment(java.lang.Object obj)
Environment
. If the given object is not known
to the EnvironmentProvider
the method does nothing.obj
- the object thats Environment
should be removed