I think Nanning's way to do things is very pleasant, maybe we can borrow some idioms from there.
I haven't used CGLIB directly but seems to be in the same direction.
El mié, 30-06-2004 a las 11:57, James Carman escribió:
Maybe we could include a factory for creating JDK proxy-like interceptors.
Maybe borrow an idea from CGLIB (MethodInterceptor and MethodProxy for
example). That's how I implemented mine. I got VERY confused when trying
to write that javassist stuff and I'm quite an adept Java
developer/architect. I just don't think it's going to be an easy sell for
people when they see that they have to write that javassist stuff when
writing interceptors. If they could write it in pure Java and let the
compiler/IDE help them along, it'd be much easier, IMHO. Right now, there's
nothing "baked in" that facilitates this. I'll send you my stuff once I get
it working. I'm still trying to get my contribution rules working the way I
want them, so you can set properties on your MethodInterceptor
implementation. Here's kind of what I had in mind so far...
public interface MethodInterceptor
{
public Object intercept( Method method,
Object[] args,
MethodProxy chain ) throws Throwable;
}
public class MethodProxy
{
private final Object target;
MethodProxy( Object target )
{
this.target = target;
}
public Object invoke( Method method, Object[] args ) throws Throwable
{
return method.invoke( target, args );
}
}
I want to be able to create an interceptor by doing...
interceptor (service-id="MethodInterceptor")
{
method-interceptor (class="mypackage.MyInterceptorImplementation")
{
set-property (name="foo" value="bar")
}
}
or something along those lines. How does this sound?
-----Original Message-----
From: Howard Lewis Ship [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 29, 2004 10:55 PM
To: [email protected]
Subject: Re: JDK Proxy Example...
I think some of the unit tests make use of JDK proxy instead of Javassist.
On Tue, 29 Jun 2004 22:21:03 -0400, James Carman
<[EMAIL PROTECTED]> wrote:
>
> Is there a good example of how to use a JDK proxy (or an
InvocationHandler)
> as an interceptor? I couldn't find anything in the download that I have.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
