|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
BaseContext | The Base Context all contexts describing a class's contextual 'inversion-of-control' (dependencies) must extend. |
Class Summary | |
---|---|
ContextWrapper | Utility class to create Proxy wrappers to a single defined context class from a list of context subclasses. |
This package provides a supporting utility, ContextWrapper, for Inversion of Control pattern in schibsted søk code.
This is a pure design pattern that is independant of IoC frameworks.
For more information read
Examining the validity of Inversion of Control
Each class that requires dependencies defines these dependencies in an inner interface named "Context". The class then accepts an implementation of this Context in it's constructor(s) and uses the context to perform those dependencies that it should not take responsibility for.
The major flaw, and hence reason for this package, is that, because the
contextual IoC requires you to implement the Context in the calling code, the
calling code ends up very verbose with lots of anonymous classes inside
constructor calls. In a highly depth-wise IoC implementation many of these Context
anonymous class implementations will just be delegating to the next context(s) up.
This last verbosity explosion can be avoided by using the ContextWrapper utility
to create a java.util.reflect.Proxy class implementing the required Context and
automatically delegating back to the next context(s) up.
One requirement of ContextWrapper is that the returning context and list of contexts
that will be delegated to must all extend the BaseContext interface.
This is solely for type-safety.
|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |