To build a custom decorator or interceptor, you must construct both a
DecoratorFactory
and the implementation itself. The Factory
is called during component construction according to the component template.
Interceptors are merely an extension of Decorators and are differentiated
purely by their class hierarchy. Decorators implement a method that
returns the set of interfaces that they would like to expose onto a
component's public facade. By implementing these interfaces, the decorator
will be automatically delegated to by the controlling component facade.
Interceptors must provide additional capabilities to become part of a
component's interceptor chain. This chain is constructed according to the
ordering of the interceptors within the ComponentTemplate and each
interceptor is expected to chain the execution along to the next
interceptor as appropriate.
Decorators and interceptors can also have custom configurations that add
additional control capabilities to the deployment of the functionality.
These custom configurations can be any configuration implementation such
that when the decorator is being constructed, it is passed into the factory
method. The decorator can then use this configuration to control its
behavior.