Details
-
New Feature
-
Status: Open
-
Major
-
Resolution: Unresolved
-
5.4
-
None
Description
Often you want to decorate just a method or two of a service interface, and let the rest pass through. Currently, that means implementing the full interface.
it seems that a service with a method like:
<T> createDelegate(Class<T> interfaceType, Object interceptor, T delegate)
could be created. It would match each of the methods of the interfaceType against methods of the interceptor object; if such a method exists, the returned proxy invokes the method on the interceptor. Otherwise, it invokes the corresponding delegate method.
This would make it very easy to decorate just the key methods of an interface.
A requirement could be that every public method of the decorator MUST match a method of the interface. Otherwise, a refactoring of the interface could silently stop invoking methods of the interceptor.