Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 95282 invoked from network); 25 Nov 2003 13:47:07 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 25 Nov 2003 13:47:07 -0000 Received: (qmail 36969 invoked by uid 500); 25 Nov 2003 13:47:00 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 36930 invoked by uid 500); 25 Nov 2003 13:46:59 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 36915 invoked from network); 25 Nov 2003 13:46:59 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 25 Nov 2003 13:46:59 -0000 Received: (qmail 95239 invoked from network); 25 Nov 2003 13:47:01 -0000 Received: from 12-223-65-3.client.insightbb.com (HELO NAMRAC2247) (12.223.65.3) by minotaur-2.apache.org with SMTP; 25 Nov 2003 13:47:01 -0000 Received: from localhost ([127.0.0.1]) by NAMRAC2247 (JAMES SMTP Server 2.1.3) with SMTP ID 606 for ; Tue, 25 Nov 2003 08:44:33 -0500 (EST) From: "James Carman" To: "'Jakarta Commons Developers List'" Subject: RE: [HiveMind] New interceptor support Date: Tue, 25 Nov 2003 08:44:28 -0500 Organization: Carman Consulting, Inc. Message-ID: <000001c3b35a$3fc799a0$6501a8c0@NAMRAC2247> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I like the idea of this hybrid approach! I am NOT a fan of using = javassist to write interceptors. I am writing an article for TheServerSide.com = about HiveMind currently. Is this code available somewhere? I don't plan on demonstrating how to write a purely javassist-based interceptor, as I do = not feel it is very intuitive. However, this simpler approach does seem to = be a nice compromise and I would like to present it. -----Original Message----- From: Christian Essl [mailto:christianessl@yahoo.de]=20 Sent: Tuesday, November 25, 2003 7:38 AM To: commons-dev@jakarta.apache.org Subject: [HiveMind] New interceptor support Javassist is fast and impressingly easy for byte-code generation, = however=20 it is by no way that comfortable (to code, test and debugg) as plain = java.=20 Therefore I've implemented an abstract ServiceInterceptorFactory which=20 allows the user to attach MethodInterceptors to the methods of an=20 interface. (A common pattern used by aopalliance, spring, cglib etc). Ie = a=20 simple tracing interceptor looks like this: public class TracingMethodInterceptor implements MethodInterceptor public Object invoke(Invocation invocation, Object target, Object[] = args)=20 throws Throwable { System.out.println("method: "+invocation.getMethod()+" is called = with=20 args: "+args); Object ret =3D invocation.proceed(target, args); //this invokes the = next=20 method in the interceptor chain System.out.println("method: "+invocation.getMethod()+" returned:=20 "+args); return ret; } } Both the interceptor and the Invocation are created using Javassist,=20 therefore it is in terms of speed (according to my rudimentary testings) = between a plain Javaassist interceptor and a dyna-proxy interceptor. Comparing the existing Hivemind Logging with the same code using the=20 MethodInterceptor and with a DynaProxy for 5.000.000 repetitions the = times=20 (ms) are as follows: (The numbers are not stable but the direction is = quite=20 clear) method: Object getObject() executing MethodLog took: 1000 executing HivemindLog took: 359 executing DynaProxyLog took: 1360 method: void setObject(Object); executing MethodLog took: 968 executing HivemindLog took: 516 executing DynaProxyLog took: 1766 method (9 prim params): int = add(int,int,byte,short,char,double,long,float); executing MethodLog took: 3063 (more primitives and arguments means = bigger=20 args[] and boxing/unboxing) executing HivemindLog took: 594 executing DynaProxyLog took: 4031 As I see interceptors for general use should be created using = javaassist,=20 however other interceptors (which just add some custom AOP for some=20 components) could well be implemented using MethodInterceptors. Here the = higher convinience pays off. --=20 Christian Essl http://jucas.sourceforge.net --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org