Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] how do you write a pointcut in aop.xml for an inner class?

Hi Andy,

Are there any issues with having multiple aop.xml files, and with one per jar? Any things to avoid in terms of classpath order or overloading or hiding?

The old problem is back again. I am adding in this to help diagnose but wanted to post a quick followup to see if there are considerations I just am not making.

 options="-showWeaveInfo"

But that the problem is intermittent bothers me a bit. This is with 1.6.4 and I am running under Jboss 4.0.3.SP1.

Bob 

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
Sent: Monday, April 13, 2009 6:27 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] how do you write a pointcut in aop.xml for an inner class?

Your initial pointcut just worked for me.

--- ListenerService.java ---
package p;

public class ListenerService {
  public void doit() {
    new ServiceContext().run();
  }

    private class ServiceContext implements Runnable {
        public void run() {
            System.out.println("hello world");
        }
    }
}
---

--- Abstract.java ---
abstract aspect Abstract {
  abstract pointcut scope();
  before(): scope() {
    System.out.println(thisJoinPoint);
  }
}
---

--- Foo.java ---
import p.*;

public class Foo {
  public static void main(String []argv) {
    new ListenerService().doit();
  }
}
---

--- META-INF\aop.xml ---
<aspectj>
  <aspects>
    <concrete-aspect name="wibble" extends="Abstract">
      <pointcut name="scope" expression="execution(* p.ListenerService.ServiceContext.run(..))"/>
    </concrete-aspect>
  </aspects>
  <weaver options="-showWeaveInfo"/>
</aspectj>
---

C:\aspectj164-dev\bin>java -javaagent:..\lib\aspectjweaver.jar Foo [AppClassLoader@9fbe93] weaveinfo Join point 'method-execution(void p.ListenerService$ServiceContext.run())' in Type 'p.ListenerService$ServiceContext' (ListenerService.java:10) advised by before advice from 'wibble' (Abstract.java:4) execution(void p.ListenerService.ServiceContext.run())
hello world

what is different in your setup to mine?

Andy.

2009/4/13 Buck, Robert <rbuck@xxxxxxxxxxxx>:
> Hello,
>
> Given the following:
>
> public class ListenerService {
>     private class ServiceContext implements Runnable {
>         public void run() {
>             System.out.println("hello world");
>         }
>     }
> }
>
> How do I write an pointcut in an aop.xml file for the inner class that 
> is a Runnable and only for this Runnable?
>
> I have tried several times and I cannot get this to work at all. For 
> example here are two of the many tries I made:
>
> <pointcut name="scope" expression="execution(* 
> com.verisign.smq.spi.ListenerService.ServiceContext.run())"/>
> <pointcut name="scope" expression="execution(* *.run()) AND 
> within(com.verisign.smq.spi.ListenerService)"/>
> Help would be greatly appreciated. This is a road-blocker for an issue 
> I have.
>
> Thanks
>
> Bob
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top