Thanks, that let me in the right direction.  I ended up writing my own
class and method matchers that both accepted the same list of
subpackage names as the method matcher can't simply grab the package
names from the class matcher.

In case anyone else is trying to do class matching at runtime, i.e.
inside the interceptor itself, take note that classes touched by Guice
AOP will have "$$EnhancerByGuice$$" added to the class name, can't do
a straight equals() comparison.

On Jun 13, 11:25 am, Alen Vrecko <alen_vre...@yahoo.com> wrote:
> Notice the first Matcher takes a <? super Class> and it decides if the
> class is eligible for AOP. The second Matcher takes a <? super Method>
> and it decides if it should intercept the method or not.
>
> Nothing is stopping you from inspecting the method e.g.
>
> new AbstractMatcher<Method>() {
>                     public boolean matches(Method method) {
>                         return method.getDeclaringClass().getPackage
> () .... // decide if you like this method or not
>                     }
>                 }
>
> Cheers
> Alen
>
> On Jun 13, 3:02 pm, tchan <tks...@gmail.com> wrote:
>
>
>
> > Hi;
>
> > Has anyone worked with the AOP interceptors in Guice much?  I'm used
> > to using full blown AspectJ in my other projects and am having
> > difficulty reproducing some mix-in behaviour using plain AOP.
>
> > I want to introduce a tracer on instance methods in certain packages.
> > The catch is that I only want the logic applied to methods declared in
> > those packages.  That is, skip methods defined in parent classes that
> > reside outside of the target packages.
>
> > So say class A resides in org.library and class B that extends A
> > resides in my.project.  I want to only intercept methods defined in
> > my.project.B and not any inherited method from org.library.A.
>
> > Right now, I am using subpackageOf() as my class matcher and any() as
> > my method matcher in my bind interceptor declaration.  This doesn't do
> > what I want, it will apply to all methods in the subpackage, even
> > inherited methods from classes outside the packages I state.
>
> > Does anyone have any ideas on how to do this with a custom method
> > matcher?  And if it can't be done statically, what about during
> > runtime in the actual interceptor?
>
> > Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to