Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Can I declare an advice as synchronized

Well, that would not have happened with stratified Aspects as in AspectJ*:
http://www.sable.mcgill.ca/~ebodde/meta/

;-)

Eric

--
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada



-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Ron Bodkin
Sent: Thu 7/20/2006 15:19
To: aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] Can I declare an advice as synchronized
 
Gregor: there's a small bug in your aspect: it will give rise to an infinite
loop. That's why I wrote the synchronization in a different aspect. You
could also use:

aspect Fooing {

  static aspect Synchronization {
      // All the advice are synchronized
      Object around(Fooing ai): this(ai) && adviceexecution() {
         synchronized(ai) {
            return proceed(ai);
         }
      }
  }

  ... other advice ...
}
-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Gregor Kiczales
Sent: Thursday, July 20, 2006 12:05 PM
To: aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] Can I declare an advice as synchronized

Yes, I was just about to suggest that since he said all the advice in the
aspect, it is just one more advice in the aspect. It's a synchronization
strategy that crosscuts the advice in the aspect. 


aspect Fooing {

  // All the advice are synchronized
  Object around(Fooing ai): this(ai) && adviceexecution() {
    synchronized(ai) {
      return proceed(ai);
  }

  ... other advice ...
}

> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx 
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Ron Bodkin
> Sent: Thursday, July 20, 2006 12:01 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: RE: [aspectj-users] Can I declare an advice as synchronized
> 
> One other note: the original requester seemed to want to 
> synchronize the advice as a policy for some class of aspects. 
> If you do want to synchronize all the advice in a given 
> aspect or all of some set of aspects, it is crosscutting and 
> you might use another aspect to do it, e.g.,:
> 
> package com.myco.concurrency;
> 
> aspect AspectSynchronization {
>     Object around(Object current) : adviceexecution() && 
> this(current) &&
> within(com.myco.errorhandling..*) {
>         synchronized(current) {
>             return proceed(current);
>         }
>     }
> }
> 
> ________________________________________
> From: aspectj-users-bounces@xxxxxxxxxxx
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of 
> Ramnivas Laddad
> Sent: Thursday, July 20, 2006 6:00 AM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] Can I declare an advice as synchronized
> 
> An alternative is to use synchronized(this) surrounding the 
> code in the advice.
> 
> before() : myPC() {
>     synchronized(this) {
>          ... advice code ...
>     }
> }
> 
> -Ramnivas
> 
> Matthew Webster wrote: 
> 
> The simple solution is to delegate the logic in you advice to 
> a synchronized instance method in the aspect. If you are 
> using default aspect instantiation it will be a singleton 
> guaranteeing that only one thread will execute the logic at a 
> time. If you need to use thisJoinPoint/thisJoinPointStaticPart
> their values can be passes as arguments to the new method. 
> 
> 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/ 
> 
> "Lorenzo D'Ercole" <lorenzodercole@xxxxxxxxxx> Sent by: 
> aspectj-users-bounces@xxxxxxxxxxx
> 20/07/2006 08:25
> Please respond to
> aspectj-users@xxxxxxxxxxx
> 
> To
> <aspectj-users@xxxxxxxxxxx> 
> cc
> 
> Subject
> Re: [aspectj-users] Can I declare an advice as synchronized
> 
> 
> 
> 
> 
> 
> 
> Well, I tryed to use the synchronized keyword writing:
>    synchronized before ....
> but I have a compile error which says:
>    illegal modifier on advice, only strictfp allowed
> For this reason I'm looking for another solution if it 
> exists. Do you have 
> any idea?
> 
> bye
> lollo82
> 
> ----- Original Message ----- 
> From: "Eric Bodden" <eric.bodden@xxxxxxxxxxxxxx>
> To: <aspectj-users@xxxxxxxxxxx>
> Sent: Wednesday, July 19, 2006 10:09 PM
> Subject: RE: [aspectj-users] Can I declare an advice as synchronized
> 
> 
> Hi.
> 
> 
> >     I'm using aspect in an concurrent application and I'd like to be
> > sure that the advices are synchronized. In fact I don't 
> want that more
> > than one thread per time runs the advice code. Can I acchieve this
> > result? I read that an aspect is a singleton on the aspectJ guide,
> does
> > it imply that only one thread per time is inside it?
> 
> No, that is not implied (as it is not for any other regular 
> singleton).
> But you can just use the synchronized keyword for your advice AFAIK.
> 
> Eric
> 
> --
> Eric Bodden
> Sable Research Group, McGill University
> Montreal, Canada
> 
> 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 
> 
> ________________________________________
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>   
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 


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

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



Back to the top