Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] adding synchronization/thread support in code using aspects

You can't change a method signature.  (There's a
FAQ entry on point.)  But you can wrap a join point
using around advice -- e.g.,

   Object around() : execution(* MyClass.*(..)) {
      synchronized(someLock) {
           return proceed();
      }
    }

   // or, for non-static methods
   Object around(MyClass myClass): target(myClass)
         && execution(* MyClass.*(..)) {
      synchronized(myClass.lock) {
           return proceed();
      }
    }

See also the examples in the distribution
(coordination package, spacewar/*Synchronization.java).

Wes

Irum Godil wrote:
Hi, I want to know if someone knows of example code or techniques in order to add synchronization support inside a class, by adding the keyword synchronize in the method signature. The AspectJ FAQ mentions the following, but the shown thread is not available. "For more details, see The AspectJ Programming Guide. In the case of synchronized, we have what we consider a better solution that uses around advice instead of introduction. This solution is described in this thread (no longer available) on the AspectJ users list, with some additional comments (no longer available) . " Any help will be greatly appreciated. Thanks.


		
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!



Back to the top