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

It would help us to better answer your question if you sent what I like
to call a "realistic example".

By that I mean an example in which all the class, method, variable,
and aspect names are realistic, and connote as part of their name
what you are trying to do.

Examples with names like method1, method2, A, B, C can help explain
the actual semantics of the language, but they are a lot less useful
for giving advice about how to best use the language.  I generally
don't consider them to be realistic examples.

The problem with examples like the one below is that all we can do
is tell you how to do exactly what you are asking for. We can't see
around the exact thing you are asking for to suggest a better approach
to the real underlying problem.

The AspectJ FAQ entry 15.5 talks some more about this as well.



> -----Original Message-----
> From: aspectj-users-admin@xxxxxxxxxxx 
> [mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Charles Zhang
> Sent: Tuesday, July 01, 2003 7:14 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: 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
> > 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 




Back to the top