Interface ObjectFactory.Context
- All Known Implementing Classes:
ExpCompiler.Factory.Context
- Enclosing class:
- ObjectFactory<V>
Context
contain the Factory implementation specific
non-default values and mechanism for overriding the default
instance type returned by the Factory.
Factory implementation can extend the Context
interface
to capture its specific override values.
If, for example, a Factory implementation uses a ThreadLocal
to override the default instance type for unit tests, then the
Context
will hold the current value of the ThreadLocal
.
Getting the Context, clears the ThreadLocal
value.
This allows the tester who wishes to create code that will provide
a wrapper around the default instance type to register their
wrapper class name with the ThreadLocal
, and, within
the wrapper constructor, get the Context
, get
a default instance, and then restore the Context
.