Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Use aspectj to inject control flow

Thanks for the help. However, the around construct requires all of the
methods have the same return type. Although "Object" can be used as the
generic return type, I don't know if it will take care of the primitive
types. And, indeed, my question is general. Suppose I want to have 10
methods included in the conditional block, then it becomes cumbersome to 
list every method signature. Is this something can be done in
AspectJ? 

Thanks again

Charles

On Tue, 1 Jul 2003, Ramnivas Laddad wrote:

> You can do the following (although, I suspect, your real question
> is of more general nature, so this may not help you):
> 
> aspect ConitionalExecution {
>     pointcut inMethodABody() : withincode(String methodA());
> 
>     Object around() : call(* method3()) || call(* method4())) 
>          && inMethodABody() {
>          if(conditionA) {
>               return proceed();
>          }
>     }
> 
>     Object around() : call(* method5()) 
>          && inMethodABody() {
>          if(!conditionA) {
>               return proceed();
>          }
>     }
> }
> 
> -Ramnivas
> 
> --- Charles Zhang <czhang@xxxxxxxxxxxxxxxx> wrote:
> > Hi, I want to write a piece of AspectJ code that adds new control
> > flow to
> > a sequence of execution such that code like the following:
> > public String methodA()
> > {
> >   method1();
> >   method2();
> >   method3();
> >   method4();
> >   method5();
> >   method6();
> > } 
> > will behave like the following:
> > public String methodA()
> > {
> >   method1();
> >   method2();
> >   if(conditionA)
> >   { 
> >     method3();
> >     method4();
> >    }else
> >    {
> >      method5();
> >    }
> >    method6();
> > }
> > 
> > I remember someone asked a similar question sometime ago. But I
> > couldn't
> > dig it out. 
> > 
> > Anyone has any suggestions? Thanks a lot.  
> > 
> > Charles Zhang 		(http://www.eecg.utoronto.ca/~czhang)
> > Dept. of Elec. & Comp. Engineering 
> > U. of Toronto, Ontario, Canada
> > *********************************************************
> > " Yawn!!" (Charles Zhang) 
> > 
> > 
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 



Back to the top