Hello,
I need to intercept method calls to my POJO's.
Therefore:
1. every POJO implements it's Interface which will be used for Interception via JDK Proxies.
2. POJO's can't be instanciated with new/ newInstance, instead one have to use a Factory which returns a JDK Proxy (java.lang.reflect.Proxy) which is bound to an Interceptor
3. the Interceptor (java.lang.reflect.InvocationHandler) handles method calls (via public Object invoke(Object proxy, Method method, Object[] args))
I'll use this for: Tracking/ Audit of method calls and declarative security checking (no I will not use EJB's...!)
This works fine but I have some doubts about this approach with Hibernate (my POJOS should be "Hibernated")
Hibernate has the Interceptor-Interface, but within this Interface I can't intercept (all) Method calls. What I need is something like public Object invoke(Object proxy, Method method, Object[] args)).
Question: Is there a "solution" for my problem? Can I extend the Interceptor for the required method, where to do it?
Regards,
Frank
|