Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] cflow below problem

You appear to have a rogue '!' in your pointcut.

pointcut updateStatus() :
     execution(* com.beanX.updateStatus(..));
"execution of the updateStatus method"


public pointcut getObject() :
        execution (MyObject com.MyComponent.*(..))
        && !(cflow(updateStatus()));
"execution of a method in the MyComponent type that returns a MyObject
instance unless in the control flow of an updateStatus method"

when your description says:

what i want do do is to intercept the call to component.getOBject() OLNLY
when is in the workflow of the call (or the execution)
of updateStatus

so your second pointcut should be:

public pointcut getObject() :
        execution (MyObject com.MyComponent.*(..))
        && cflow(updateStatus());
"execution of a method in the MyComponent type that returns a MyObject
instance when in the control flow of an updateStatus method"

Here is a program
======8<========
class BeanX {

 MyComponent component = new MyComponent();

 public void updateStatus() {
   getChildrens();
 }

 public void getChildrens() {
   MyObject objs = component.getObject();
 }
}


class MyObject {}
class MyComponent { public MyObject getObject() { return new MyObject(); }}


public aspect X {

 pointcut updateStatus(): execution(* BeanX.updateStatus(..));

 public pointcut getObject() :
       execution (MyObject MyComponent.*(..))
       && (cflow(updateStatus()));

 before(): getObject() {
   System.err.println("getObject running in the control flow of updateStatus");
 }

 public static void main(String[]argv) {
   BeanX bx = new BeanX();
   bx.getChildrens(); // advice doesnt run
   bx.updateStatus(); // advice runs
 }
}
======8<========

In the main() method there is a call directly to getChildrens() which
doesnt get advised (the getObject() won't be in the control flow of
updateStatus()) and then there is a call to updateStatus() which will
cause getObject() to be called in the control flow you are looking
for.

Andy.


On 24/05/06, Marco Mistroni <mmistroni@xxxxxxxxx> wrote:
hi all,
 i have following problem

i have following bean

beanX {

   public void updateStatus() {
         getChildrens();
   }


   public void getChildrens() {
         MyObject objs = component.getObject();
  }
}


what i want do do is to intercept the call to component.getOBject() OLNLY
when is in the workflow of the call (or the execution)
of updateStatus

i have written the following pointcut (which obviously is not working.)...
what am i missing?


pointcut updateStatus() :
     execution(* com.beanX.updateStatus(..));


public pointcut getObject() :
        execution (MyObject com.MyComponent.*(..))
        && !(cflow(updateStatus()));


is there something that i am missing?

thanks and regards
   marco




_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users





Back to the top