-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I would like to intercept calls on my composer with spring (security, monitor, ...). Typical scenario is GenericForwardComposer and onXXX methods with forward="onClick=onXXXX" atribute for forwarded events.
However, onXXX method is not intercept, because the listener is registered from composer with "this" reference, so the spring proxy object is not invoked.
I solved this with a obscure solution. In some advised method (e.g. doAfterCompose), I got reference to the proxy with AopContext.currentProxy(). Then I rewrote GenericEventListener.onEvent(Event evt) method invocation with:
// mtd.invoke(controller, new Object[] {evt}); Proxy.getInvocationHandler(proxy).invoke(proxy, mtd, new Object[] {evt});
and method calls are then intercepted. But AopContext.currentProxy() is generally considered as bad solution and you should somewhere put autoProxyCreatory.setExposeProxy(true); to make it working. There is some performance penalty as well.
Is there some other way how to get the original composer object that was resolved by spring in apply="${springBean}"?
@ZK: May it be even feature request to send events to the object used in apply instead of "this"? This works for events, but direct calls to composer from zul files are not intercepted as well. Is there some similar soution?
Best Regards,
Jiri Bubnik
Jiri,
It would be difficult. Since the GenericForwardComposer got no information about that it is being "proxied". Application developer has to help on such case. I think overriding doAfterCompose method is the way to go.
As for some new API that user can get the object in "apply", please post to ZK Fetures.
Asked: 2009-07-15 07:06:58 +0800
Seen: 331 times
Last updated: Mar 21 '12