Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] flow of execution in different threads



>If I'm not mistaken, this works because the threads share the same aspect
>instance
If you mean that 2 threads share the same aspect the answer is no: that is
the reason for the get/putState() logic. The output from a modified example
shows this:

? [main] leaf()
? [main] Aspect.<init>() this=test.Aspect@10385c1
? [main] root()
? [main] void test.Main.leaf() state=Main[One]
? [main] leaf()
> [main] create()
? [Thread-1] Aspect.<init>() this=test.Aspect@f72617
? [Thread-1] run()
? [Thread-1] void test.Main.leaf() state=Main[One]
? [Thread-1] leaf()
< [main] create()
? [main] leaf()
? [main] Aspect.<init>() this=test.Aspect@1e5e2c3
? [main] root()
? [main] void test.Main.leaf() state=Main[Two]
? [main] leaf()
> [main] create()
? [Thread-2] Aspect.<init>() this=test.Aspect@4f1d0d
? [Thread-2] run()
? [Thread-2] void test.Main.leaf() state=Main[Two]
? [Thread-2] leaf()
< [main] create()

WRT classloaders the "problem" is a Java one not an AspectJ one. In order
to share anything between namespaces there has to be a common definition:
the aspect will need to be defined by a classloader that is an ancestor of
the 2 communicating class loaders. To flow context between VMs this is a
question of changing the implementation of the put/getState logic and
augmenting whatever communications protocol (Socket, RMI, WS, ...) you
already have to carry the state. Again this is not specifically an AOP
problem although the VM-VM problem could be cast as a variation of the
wormhole pattern. I believe work has been done in this area.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/

"Serge Beaumont" <serge.beaumont@xxxxxxxxx>@eclipse.org on 18/03/2005
21:12:24

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:    aspectj-users-admin@xxxxxxxxxxx


To:    <aspectj-users@xxxxxxxxxxx>
cc:
Subject:    RE: [aspectj-users] flow of execution in different threads


If I'm not mistaken, this works because the threads share the same aspect
instance: it's basically a singleton-ish thing (MyAspect.aspectOf()...).
This will work as long as you stay within certain borders. Does your
solution work across classloader, maybe even VM borders? That's usually the
big problem in J2EE environments...

> -----Oorspronkelijk bericht-----
> Van: aspectj-users-admin@xxxxxxxxxxx
> [mailto:aspectj-users-admin@xxxxxxxxxxx] Namens Conway.
> Fintan (IT Solutions)
> Verzonden: vrijdag 18 maart 2005 12:58
> Aan: 'aspectj-users@xxxxxxxxxxx'
> Onderwerp: RE: [aspectj-users] flow of execution in different threads
>
>
> For those of you who are interested - here is the output of a
> sample run done on my PC.
>
>
> ?          [main] leaf()
> ?          [main] Aspect.<init>()
> ?          [main] root()
> ?          [main] void Main.leaf() state=Main[One]
> ?          [main] leaf()
> ---> [main] create()
> ?          [Thread-0] Aspect.<init>()
> ?          [Thread-0] run()
> ?          [Thread-0] void Main.leaf() state=Main[One]
> ?          [Thread-0] leaf()
> <--- [main] create()
> ?          [main] leaf()
> ?          [main] Aspect.<init>()
> ?          [main] root()
> ?          [main] void Main.leaf() state=Main[Two]
> ?          [main] leaf()
> ---> [main] create()
> ?          [Thread-1] Aspect.<init>()
> ?          [Thread-1] run()
> ?          [Thread-1] void Main.leaf() state=Main[Two]
> ?          [Thread-1] leaf()
> <--- [main] create()
>
>
>
>
> -----Original Message-----
> From: aspectj-users-admin@xxxxxxxxxxx
> [mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of > Matthew Webster
> Sent: 18 March 2005 11:32
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] flow of execution in different threads
>
>
> There have been a number of questions about determining cflow
> across threads e.g. is a join point one thread in the control
> flow of a join point on the thread that created me and can I
> pass context. Here is an example of how to do it with
> read-only state. The Main class has 2 methods leaf() and
> root(). The "root()" method executes "leaf()" on another
> thread. We want to obtain state in "leaf()" from earlier in
> the control flow, in this case an instance of the Main class,
> which is done using a percflow aspect and a Hashmap. The
> root, lead, create and run pointcuts could be customized or
> made abstract. Comments welcomed:
>
>
> * ** *** ** * ** *** ** * ** *** ** *
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed.
> Any views or opinions presented are solely those of the
> author, and do not necessarily
> represent those of ESB.
> If you have received this email in error please notify the sender.
>
> Although ESB scans e-mail and attachments for viruses, it
> does not guarantee
> that either are virus-free and accepts no liability for any
> damage sustained
> as a result of viruses.
>
> * ** *** ** * ** *** ** * ** *** ** *
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
>



Disclaimer:
This message contains information that may be privileged or confidential
and is the property of Sogeti Nederland B.V. or its Group members. It is
intended only for the person to whom it is addressed. If you are not the
intended recipient, you are not authorized to read, print, retain, copy,
disseminate, distribute, or use this message or any part thereof. If you
receive this message in error, please notify the sender immediately and
delete all copies of this message.

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




Back to the top