Guys, you might try creating a common superclass called
FilteredMethodInterceptor which takes a method name pattern or something as
a parameter (warning, this code is off the top of my head)...
public abstract class FilteredMethodInterceptor implements MethodInterceptor
{
protected Object invokeImpl( MethodInvocation methodInvocation ) throws
Throwable;
private String methodNamePattern;
public void setMethodNamePattern( String methodNamePattern )
{
this.methodNamePattern = methodNamePattern;
}
public Object invoke( MethodInvocation methodInvocation ) throws Throwable
{
if(methodInvocation.getMethod().getName().matches(methodNamePattern))
{
Return invokeImpl( methodInvocation );
}
else
{
Return methodInvocation.proceed();
}
}
}
-----Original Message-----
From: Vinicius Carvalho [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 28, 2005 9:50 PM
To: [email protected]
Subject: Re: Hivemind + AOP : Which approach to take?
Hum I've tried it here but...
<service-point interface="org.apache.hivemind.ServiceInterceptorFactory"
id="nullInterceptor">
<invoke-factory>
<construct
class="com.cs.interceptor.NullIdentityServiceInterceptor"/>
</invoke-factory>
</service-point>
<service-point interface="com.cs.service.ICRUDService" id="produtoService">
<invoke-factory model="singleton">
<construct class="com.cs.service.CRUDService">
<set-object property="dao"
value="service:produtoDAO"/>
</construct>
</invoke-factory>
<interceptor service-id="hivetranse.core.TransactionInterceptor">
<method pattern="*" demarcation="Required"/>
</interceptor>
<interceptor service-id="nullInterceptor">
<include method="update*"/>
</interceptor>
</service-point>
Problem is that the interceptor is being called for all methods not
only the ones that start with update
Any ideas???
On 7/28/05, Konstantin Ignatyev <[EMAIL PROTECTED]> wrote:
> Thanks for the nice comments :)
>
> About interceptors:
> they get applied to the methods according to
> MethodMatcher:
>
http://jakarta.apache.org/hivemind/hivemind/apidocs/org/apache/hivemind/meth
odmatch/MethodMatcher.html
> By default: all methods.
> See HM LoggingInterceptor example:
> http://jakarta.apache.org/hivemind/hivemind/LoggingInterceptor.html
>
> note inlude and exclude parameters.
>
> --- Vinicius Carvalho <[EMAIL PROTECTED]> wrote:
>
> > Hey Konstantin, your page Rocks dude, I've seen your
> > comparisons
> > before, excellent work, really nice! It was good to
> > see some
> > comparisons between the many AOP approaches around,
> > I really took your
> > advices when choosing one :D
> >
> > Well what I was wondering about interceptors is that
> > after defining an
> > interceptor I can't tell which method to apply it.
> > I've seen you
> > examples : "HiveMindInstrumenter" and also the
> > Interceptor from
> > HiveUtils. I didn't get a chance to see your code,
> > but I guess you
> > must threat the pattern as well.
> >
> > The problem is, my developer team should take care
> > of that all the
> > time, so I'm more error prone than with regular
> > aspects where I could
> > have full control of pointcuts through xml. Of
> > course It's just
> > wondering... I haven't had the time to test it :P
> >
> > Thanks again
> >
> > On 7/28/05, Konstantin Ignatyev
> > <[EMAIL PROTECTED]> wrote:
> > > And what exacly you cannot achieve with HiveMind
> > > interceptors? Why do you need/want a full AOP
> > system?
> > >
> > > Speaking of AspectWerkz - it has merged with
> > AspectJ.
> > > AspectJ - they actually regained sanity after the
> > > merger and now we do not have to use altered Java
> > > syntax (but need JVM 5). See
> > >
> >
> http://www.eclipse.org/aspectj/doc/next/adk15notebook/ataspectj.html
> > >
> > >
> > > I have couple of comparisons between various AOP
> > > frameworks and you can see them here:
> > >
> >
> http://kgionline.com/presentations/aop_test/overview/doc/index.html
> > > - work in progress, some links do no work;
> > > and here:
> > > http://kgionline.com/articles/aop_1/aop_perf.jsp
> > >
> > >
> > > --- linuja <[EMAIL PROTECTED]> wrote:
> > >
> > > > With javassist, you can implement one very easy
> > > > yourself.
> > > > also, you can use the *Fab class of hivemind
> > > > directly.
> > > >
> > > > 2005/7/26, Vinicius Carvalho
> > > > <[EMAIL PROTECTED]>:
> > > > >
> > > > > Well it's me again (I guess ppl may be getting
> > > > tired of my questions)
> > > > >
> > > > > Ok. I probably said this before, but I'm
> > trying to
> > > > create a pure
> > > > > hivemind project (no springs attached :D), I
> > have
> > > > nothing against
> > > > > Spring, on the opposite, I like it pretty
> > much, I
> > > > just don't see why
> > > > > use spring for some pieces that Hivemind +
> > > > HiveUtils could easily get
> > > > > pretty well.
> > > > >
> > > > > Ok, so I get in a real hard decision. Using
> > AOP
> > > > with spring means, all
> > > > > my beans must be managed by it, which they
> > aren't
> > > > anymore :D.
> > > > >
> > > > > I tried Interceptors ... well I really would
> > like
> > > > to have a pattern
> > > > > for my methods, not apply it to all o 'em.
> > I've
> > > > checked out Jean's
> > > > > TransactionInterceptorFactory source code, and
> > > > found that would take a
> > > > > pretty long way to do the same for my
> > > > interceptors.
> > > > >
> > > > > Ok, so we've few choices left:
> > > > >
> > > > > AspectWerkz: I really like it, non intrusive
> > in
> > > > one aspect (uses
> > > > > proxies) but you gotta change your
> > classloader,
> > > > hum.. my tomcat turned
> > > > > just 300% slower with the new classloader. Out
> > of
> > > > question.
> > > > >
> > > > > JBoss AOP: I'm a Tomcat user, I really get as
> > far
> > > > away from JBoss and
> > > > > EJB stuff as I can.
> > > > >
> > > > > AspectJ: Nice, fast, but too intrusive, and
> > you
> > > > can't debug your code
> > > > > anymore.
> > > > >
> > > > > I was wondering if someone who've been using
> > AOP
> > > > with Hivemind in a
> > > > > project would care to share it's experiences /
> > > > opinions ?
> > > > >
> > > > > Regards
> > > > >
> > > > >
> > > >
> > >
> >
> ---------------------------------------------------------------------
> > > > > 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]
> >
> >
>
>
> Konstantin Ignatyev
>
>
>
>
> PS: If this is a typical day on planet earth, humans will add fifteen
million tons of carbon to the atmosphere, destroy 115 square miles of
tropical rainforest, create seventy-two miles of desert, eliminate between
forty to one hundred species, erode seventy-one million tons of topsoil, add
2,700 tons of CFCs to the stratosphere, and increase their population by
263,000
>
> Bowers, C.A. The Culture of Denial: Why the Environmental Movement Needs
a Strategy for Reforming Universities and Public Schools. New York: State
University of New York Press, 1997: (4) (5) (p.206)
>
---------------------------------------------------------------------
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]