If you guys like my MethodInterceptor and MethodProxy approach, I could contribute some code. I still need to figure out how to get my configuration rules to start setting properties on the actual instance that's created, but other than that it works just fine. Anyone have any objections to the API or suggestions on how I could name it differently so that we don't look like we're ripping off from CGLIB? :-)
-----Original Message----- From: Howard Lewis Ship [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 2:25 PM To: [email protected] Subject: Re: JDK Proxy Example... It would be nice to scrap the current interceptors guide (which is not only heavy on Javassist, but completely out of date) and replace it with a similar example that used JDK proxies and discussed more powerful techniques. Any volunteers? I'm maxxed out. On Wed, 30 Jun 2004 14:07:04 -0400, James Carman <[EMAIL PROTECTED]> wrote: > I wasn't suggesting USING CGLIB (but I can see where a new > CglibServiceInterceptorFactory could be useful for those who are familiar > with it) or any of the classes in it, but just to borrow some ideas from it. > We could re-use the InvocationDecorator classes that I presented in my > JavaWorld article > (http://www.javaworld.com/javaworld/jw-07-2003/jw-0718-factory.html). It > does essentially the same thing. I REALLY think if you want HiveMind to be > accepted by the general java developer that this interceptor process needs > to be simplified. That's not to say that we get rid of the Javassist stuff, > but it shouldn't be the only mechanism supported by HiveMind > "out-of-the-box", nor should it (IMHO) be the only approach demonstrated in > the documentation. I would think that a pure Java approach should be given > in the documentation and put the Javassist/CGLIB like approaches in an > "Advanced Concepts" section or something. My $0.02, the pure Java approach > should be just as much of the core framework as the Javassist one. > > > > > -----Original Message----- > From: Howard Lewis Ship [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 30, 2004 12:10 PM > To: [email protected] > Subject: Re: JDK Proxy Example... > > It's all accoding to taste and HiveMind doesn't care. I believe the > Javassist approach is more performant, but you have to wrap your mind > around meta- (and meta-meta-) coding. > > Perhaps we should create an "examples" library (hivemind.examples) to > contain these types of things? I'd also like to get a "contributions" > library (hivemind.contrib) to contain useful stuff. However, there's > the issue of getting a CLA for any contribution, and the necessity of > avoiding dependencies on GPL/LGPL code (BSD, MPL, etc. are ok). > > ----- Original Message ----- > From: Pablo Lalloni <[EMAIL PROTECTED]> > Date: Wed, 30 Jun 2004 12:42:13 -0300 > Subject: RE: JDK Proxy Example... > To: [email protected] > > I fully agree with James here, I've been writing some intercetpor > stuff and it has been quite annoying compared with previous work I've > done using Nanning and/or AspectWerkz... > > 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] > > > > > > -- > Howard M. Lewis Ship > Independent J2EE / Open-Source Java Consultant > Creator, Jakarta Tapestry > Creator, Jakarta HiveMind > http://howardlewisship.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Howard M. Lewis Ship Independent J2EE / Open-Source Java Consultant Creator, Jakarta Tapestry Creator, Jakarta HiveMind http://howardlewisship.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
