[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] weaving code after loops
|
Hey Ron,
the problem I want to manage is a real world problem. To clarify this I
give a more complex example:
void simulate()
{
while(peers.hasNext()) // for all peers
{
Peer p = (Peer)peers.next();
while(!p.finished())
{
// process peer data
// perform actions
}
// at this postion the code should be executed
}
}
This example is derived from our p2p-simulator. The simulate-method loops
overs all peers and performs some actions for each peer. After these
actions I want to include code for sending so called feedback-objects and
logging. We consider this sending-code as optional. Moreover, this code is
called in other methods too. So we decided to implement the
feedback-sending feature as an aspect.
I hope that helps to understand our problem.
best regards
Sven
> Sven, you're right that there is no AspectJ pointcut to pick out any kind
> of loop (or if) statement executing. The reason is that pointcuts that
> picked out specific loops would be brittle in that programmers would
> expect to be able to change how foo is implemented (e.g., to for(;b;) {
> ... } or to while (b&&c) {...}) without changing how aspects work. As
> Rickard said, why do you want to do this?
>
> To use AspectJ with code like this, you could use the extract method
> refactoring, which would let you name a helper method to describe the post
> inner-loop behavior you want to advise.
>
> Ron Bodkin
> Chief Technology Officer
> New Aspects of Software
> o: (415) 824-4690
> m: (415) 509-2895
>
>
>> ------------Original Message------------
>> From: "Sven Apel" <apel@xxxxxxxxxxxxxxxxxxxxxxx>
>> To: aspectj-users@xxxxxxxxxxx
>> Date: Wed, Sep-29-2004 9:09 AM
>> Subject: [aspectj-users] weaving code after loops
>>
>> Hello everybody,
>>
>> I want to weave code into the following example code:
>>
>> void foo()
>> {
>> boolean a = true;
>> boolean b = true;
>>
>> while(a == true)
>> {
>> // do something
>> while(b == true)
>> {
>> // do something
>> }
>> }
>> }
>>
>> I want to weave a call to method bar after the inner while-loop:
>>
>> void foo()
>> {
>> boolean a = true;
>> boolean b = true;
>>
>> while(a == true)
>> {
>> // do something
>> while(b == true)
>> {
>> // do something
>> }
>> bar(); // code to weave
>> }
>> }
>>
>> In current I see no way how I can express this joinpoint using AspectJ.
>> Has
>> anybody an idea?
>>
>> best regards
>> Sven
>>
>> ------------------------------------
>> Dipl.-Inf. Sven Apel
>>
>> Universität Magdeburg:
>> Tel.: +49-(0)-391-67-11899
>> Fax.: +49-(0)-391-67-12020
>> e-mail: apel@xxxxxxxxxxxxxxxxxxxxxxx
>>
>> _______________________________________________
>> 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
>