Return-Path: Delivered-To: apmail-jakarta-hivemind-user-archive@www.apache.org Received: (qmail 33840 invoked from network); 21 Sep 2004 15:43:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 21 Sep 2004 15:43:18 -0000 Received: (qmail 80536 invoked by uid 500); 21 Sep 2004 15:43:14 -0000 Delivered-To: apmail-jakarta-hivemind-user-archive@jakarta.apache.org Received: (qmail 80429 invoked by uid 500); 21 Sep 2004 15:43:13 -0000 Mailing-List: contact hivemind-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: hivemind-user@jakarta.apache.org Delivered-To: mailing list hivemind-user@jakarta.apache.org Received: (qmail 80366 invoked by uid 99); 21 Sep 2004 15:43:12 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [208.147.67.98] (HELO mail1.mckhboc.com) (208.147.67.98) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 21 Sep 2004 08:43:11 -0700 Received: from 139.177.6.217 by mail1.mckhboc.com with ESMTP (Outbound Mail1 SMTP Relay (MMS v5.6.1)); Tue, 21 Sep 2004 08:42:08 -0700 X-Server-Uuid: E618535E-AE39-475D-9091-BC1AF22CB2F2 Received: by smtpout.hboc.com with Internet Mail Service (5.5.2657.72) id ; Tue, 21 Sep 2004 11:43:19 -0400 Received: from atlexc91nthub.hboc.com (ims2.mckesson.com [139.177.6.115] ) by atlexcsmtpb.hboc.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id TJ19YAM4; Tue, 21 Sep 2004 11:43:06 -0400 Received: by ims2.mckesson.com with Internet Mail Service (5.5.2657.72) id ; Tue, 21 Sep 2004 11:40:53 -0400 From: "Hensley, Richard" To: "'hivemind-user@jakarta.apache.org'" , "'Damon Rolfs'" Message-ID: Subject: RE: Reflection vs. Javassist Date: Tue, 21 Sep 2004 11:41:42 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2657.72) X-WSS-ID: 6D4E94451SO15813113-01-01 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Damon, Here you go! It's almost a direct rip off from the example logging interceptor on the web site. package com.mckesson.adept.hivemind; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; import java.util.List; import org.apache.hivemind.InterceptorStack; import org.apache.hivemind.ServiceInterceptorFactory; import org.apache.hivemind.internal.Module; public class TimerInterceptorFactory implements ServiceInterceptorFactory { public TimerInterceptorFactory() { super(); } public void createInterceptor(InterceptorStack stack, Module invokingModule, List parameters) { InvocationHandler handler = new TimerInvocationHandler(stack.peek(), stack.getServiceInterface()); Object interceptor = Proxy.newProxyInstance(invokingModule .getClassResolver().getClassLoader(), new Class[]{stack .getServiceInterface()}, handler); stack.push(interceptor); } } package com.mckesson.adept.hivemind; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import com.mckesson.common.util.Timer; public class TimerInvocationHandler implements InvocationHandler { private String className; private Object inner; public TimerInvocationHandler(Object inner, Class intf) { super(); this.inner = inner; this.className = inner.getClass().getName(); if (this.className.startsWith("$")) { this.className = intf.getName(); } this.className += '.'; } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String timer = this.className + method.getName(); Timer.startTimer(timer); try { Object result = method.invoke(this.inner, args); return result; } catch (InvocationTargetException ex) { throw ex.getTargetException(); } finally { Timer.stopTimer(timer); } } } -----Original Message----- From: Damon Rolfs [mailto:drolfs@gmail.com] Sent: Monday, September 20, 2004 10:00 PM To: hivemind-user@jakarta.apache.org Subject: Re: Reflection vs. Javassist Richard, Could you please distribute your reflection/proxy - based interceptor? (Or at least send me a version?) Cheers, ~dmr --------------------------------------------------------------------- To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: hivemind-user-help@jakarta.apache.org