0

Use Spring AOP to intercept calls on composer

asked 2009-07-15 07:06:58 +0800

edudant gravatar image edudant
219 1 1 1
zk.datalite.cz

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

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2009-07-20 04:40:26 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

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.

link publish delete flag offensive edit

answered 2012-03-21 08:44:46 +0800

javaenthu gravatar image javaenthu
141 2

Is this issue solved yet?

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-07-15 07:06:58 +0800

Seen: 331 times

Last updated: Mar 21 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More