Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AspectJ Limits

You are right !
This way, it works.

But the problem remain :
I ask aspectJ to print something when method run() is called, but it
will not be always possible, isn'it ?

What I mean is there are case where the pointcut is unusable but there
will be no compilation error. For example,

pointcut whenToString() : execution(void String.toString(..));

Will never be called !


Thanks a lot.

PS: yes, it was around() ... sorry ...

> The problem is in your pointcut . You probably want to use "execution" 
> instead of "call" . Check the prog guide for details.
> 
> hth,
> Edwin
> 
> At 11:44 25/09/2003 +0200, Mike Baroukh wrote:
> 
> >Hi all.
> >
> >I discovered AspectJ this week and I'm very Impressed. I'm asking myself
> >how I have been able to develop without it until today ...
> >
> >althought, there is a point that would be negative for me. Do anybody
> >knows if it's my mistake ou if it's a well known problem or what ever
> >else ?
> >
> >The problem is that AspectJ can only interrupt calls to a class from
> >calls that are made from my classes. I explain :
> >
> >
> >public class Test implements Runnable {
> >         public void run() {
> >                 System.out.println("Hello !");
> >         }
> >
> >         public void main(String args[]) {
> >                 new Test().run();
> >                 new Thread(new Test()).start();
> >         }
> >}
> >
> >public aspect TestAspect {
> >
> >         pointcut whenDoRun() : call(void Test.run(..));
> >
> >         void after() : whenDoRun() {
> >                 System.err.println("BEFORE");
> >                 proceed();
> >                 System.err.println("AFTER");
> >         }
> >}
> >
> >
> >will result of
> >
> >BEFORE
> >Hello !
> >AFTER
> >Hello !
> >
> >i.e. the second call to run() is not wrapped by BEFORE/AFTER because
> >Thread class has not been modified by AspectJ ...
> >
> >This can be the same if I use, for example, a bean whose setMethod()
> >will be called from BeanUtils that use Class.Method.invoke() method ...
> >There are plenty of other case ..
> >
> >This mean that, according to the way methods are called, I can't be sure
> >the call will be intercepted. Then the way the application as been
> >developped must, I think, know if it will or not use AspectJ. This
> >contrary the fact that components must only do what they have to do and
> >no more ...
> >Also, I can't take an old application and modify it with AspectJ without
> >touch the old code ...
> >
> >Thanks in advance.
> >
> >Mike
> >
> >
> >Mike Baroukh
> >
> >Cardiweb  - 31 Rue de Mogador Paris IXeme
> >06 63 57 27 22 - 01 53 21 82 63 - ICQ: 105910677
> >http://www.cardiweb.com
> >--
> >Les féministes travaillent, picolent, conduisent comme des mecs
> >et après elles s'étonnent qu'on les encule.
> >Patrick Timsit
> >--
> >
> >_______________________________________________
> >aspectj-users mailing list
> >aspectj-users@xxxxxxxxxxx
> >http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users

Mike Baroukh

Cardiweb  - 31 Rue de Mogador Paris IXeme
06 63 57 27 22 - 01 53 21 82 63 - ICQ: 105910677
http://www.cardiweb.com
--
Réfléchir, c'est nier ce que l'on croit.
Emile Chartier, dit Alain, Propos sur la religion
--



Back to the top