|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.primix.tapestry.util.Decorator
An implementation of the Decorator pattern. The decorator pattern allows new functionality to be assigned to an existing class. As implemented here, the Decorator object is a smart lookup between a particular class (the class to be Decorated, called the subject class) and some object instance that can provide the extra functionality (called the adaptor). The implementation of the adaptor is not relevant to the Decorator class.
Adaptors are registered before they can be used; the registration maps a particular class to an adaptor instance. The adaptor instance will be used when the subject class matches the registered class, or the subject class inherits from the registered class.
This means that a search must be made that walks the inheritance tree (upwards from the subject class) to find a registered mapping.
In addition, adaptors can be registered against interfaces. Searching of interfaces occurs after searching of classes. The exact order is:
The first match terminates the search.
The Decorator caches the results of search; a subsequent search for the same subject class will be resolved immediately.
This class is thread safe.
Constructor Summary | |
Decorator()
|
Method Summary | |
java.lang.Object |
getAdaptor(java.lang.Class subjectClass)
Gets the adaptor for the specified subjectClass. |
void |
register(java.lang.Class registrationClass,
java.lang.Object adaptor)
Registers an adaptor for a registration class. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Decorator()
Method Detail |
public void register(java.lang.Class registrationClass, java.lang.Object adaptor)
java.lang.IllegalArgumentException
- if an adaptor has already
been registered for the given class.public java.lang.Object getAdaptor(java.lang.Class subjectClass)
java.lang.IllegalArgumentException
- if no adaptor could be found.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |