Hello,
Thanks for this explanation, it will be helpful in future!
My mistake was quite different I think.. I wrote my own method matcher and I
don't know all the rules of reflection in Java. I just add a trick to
"forget" method this "volatile" modifier.
I'd like somebody from Guice Team looked at this and told me if it is ok or
not?
Cheers,
Anthony
/**
* Search for the method signature into all the interface annotated with
a
* given annotation.
*/
public boolean matches(Method method) {
// Hook to avoid twice interceptions of the same method
if (Modifier.isVolatile(method.getModifiers())) {
return false;
}
boolean matches = false;
Class<?> type = method.getDeclaringClass();
Class<?>[] iTypes = ReflectUtils.getInterfaces(type, annClass);
for (Class<?> iType : iTypes) {
Method iMethod = null;
try {
iMethod = iType.getDeclaredMethod(method.getName(), method
.getParameterTypes());
} catch (SecurityException e) {
// Should never happen
} catch (NoSuchMethodException e) {
// Should never happen
}
if (iMethod != null) {
matches = true;
break;
}
}
return matches;
}
2008/9/13 tzwoenn <[EMAIL PROTECTED]>
>
> I had the same problem, but it was caused by myself. Actually I had
> bound the same interceptor during for class level und method level
> interception, like
>
> bindInterceptor(any(), annotatedWith(Interceptors.class),
> javaxInterceptor);
> bindInterceptor(annotatedWith(Interceptors.class), any(),
> javaxInterceptor);
>
> If both - @Interceptors at class and method level - are found, the
> interceptor is called twice. This could be solved by
>
> bindInterceptor(any(), annotatedWith(Interceptors.class),
> javaxInterceptor);
> bindInterceptor(annotatedWith(Interceptors.class),
> not(annotatedWith(Interceptors.class)), javaxInterceptor);
>
> Maybe you made a similar mistake while configuring the interceptor?
>
>
> On Sep 12, 2:06 pm, "Anthony MULLER" <[EMAIL PROTECTED]> wrote:
> > Hmmm... With debugger, when I looked to MethodInvocation instance given
> to
> > invoke() method, I saw something quite strange.
> >
> > in the "proxy" field of "mi" (MethodInvocation instance), there are many
> > "CGLIB$CALLBACK_" fields... Ok...
> >
> > BUT : I found two similars CGLIB$CALLBACK_0 and CGLIB$CALLBACK_1
> >
> > The target methods are respectively :
> >
> > public volatile com.xxx.MyObject
> > com.xxx.MyObjectServiceImpl.createXXX(com.xxx.Session)
> > public com.xxx.MyObject
> > com.xxx.MyObjectServiceImpl.createXXX(com.xxx.Session)
> >
> > So, the same method is present twice, with just "volatile" as
> difference...
> >
> > Why???
> >
> > Another method into the same class doesn't have this behaviour
> (interceptor
> > calling interceptor again calling the real method...)
> >
> > Regards,
> > Anthony MÜLLER
> >
> > 2008/9/12 Anthony MULLER <[EMAIL PROTECTED]>
> >
> > > Hello,
> >
> > > When I use AOP feature, sometimes I have a strange behaviour and I
> don't
> > > know why...
> >
> > > When I call mi.proceed(); into invoke() method of the interceptor, the
> > > interceptor's invoke() method is called again! But the intercepted
> method is
> > > called once has expected...
> >
> > > Why the interceptor is called twice sometimes?
> >
> > > Regards,
> > > Anthony MÜLLER
> >
> >
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---