I can do you one better.  I can include the source code for a
MethodInterceptorFactory class that I wrote.  Now, this class is dependent
upon the AOP Alliance (http://sourceforge.net/projects/aopalliance) jar
file, but it makes creating interceptors EASY!  All you have to do is
implement the MethodInterceptor interface (from AOP Alliance).  This class
(or some version similar to it) may make it into the hivemind-lib module in
version 1.1, so make sure you switch over to the "official" one once it
arrives.

Here's an example of how to use it in a hivemodule.xml file...

<service-point 
  id="RollbackOnlyInterceptor"   
  interface="org.aopalliance.intercept.MethodInterceptor">
  <invoke-factory service-id="hivemind.BuilderFactory">
    <construct class="example.interceptor.RollbackOnlyInterceptor" />
  </invoke-factory>
</service-point>

<service-point 
  id="RollbackOnlyInterceptorFactory"   
  interface="org.apache.hivemind.ServiceInterceptorFactory">
  <invoke-factory service-id="hivemind.BuilderFactory">
    <construct   
      class="example.interceptor.factory.MethodInterceptorFactory">
      <set-service 
        service-id="RollbackOnlyInterceptor" 
        property="methodInterceptor"/>
    </construct>
  </invoke-factory>
</service-point>

<implementation service-id="ProjectServices">
  <interceptor service-id="RollbackOnlyInterceptorFactory"/>
</implementation>

Here, we declared the actual interceptor itself as a service and told the
factory which service to call to intercept the methods.

-----Original Message-----
From: Damon Rolfs [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 21, 2004 1:00 AM
To: [email protected]
Subject: Re: Reflection vs. Javassist

Richard, 

Could you please distribute your reflection/proxy - based interceptor?
 (Or at least send me a version?)

Cheers, ~dmr


On Sat, 18 Sep 2004 17:11:30 -0400, James Carman
<[EMAIL PROTECTED]> wrote:
> I wouldn't go so far as to say that there is a performance PROBLEM with
> using JDK proxies.  However, Javassist does provide a slight performance
> gain, but I'm not convinced that it's worth the headache.  I use JDK
proxies
> and it works just fine for all I need.  If you ever do see that
performance
> becomes an issue, then re-implement your interceptor using something like
> Javassist (or CGLIB).
> 
> 
> 
> -----Original Message-----
> From: Hensley, Richard [mailto:[EMAIL PROTECTED]
> Sent: Saturday, September 18, 2004 12:49 PM
> To: '[email protected]'
> Subject: Reflection vs. Javassist
> 
> I've built an interceptor that uses reflection based on the example
logging
> interceptor. At this point, I have no strong desire to learn Javassist
> unless there are known performance problems using reflection vs using
> Javaassist to build out the method implementations.
> 
> My real question, is there any real performance to be gained by using
> Javassist over Java reflection? If there is not, I don't see a good reason
> to put in all the extra engineering effort.
> 
> Richard
> 
> ---------------------------------------------------------------------
> 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]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Attachment: MethodInterceptorFactory.java
Description: Binary data

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to