[jboss-cvs] JBossAS SVN: r105185 - in branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop: util and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon May 24 17:16:07 EDT 2010


Author: flavia.rainone at jboss.com
Date: 2010-05-24 17:16:06 -0400 (Mon, 24 May 2010)
New Revision: 105185

Added:
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/util/AOPLock.java
Modified:
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/AspectManager.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassContainer.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/InstanceDomain.java
Log:
[JBAOP-792] Port weaving synchronization from trunk to 1.5.x

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/AspectManager.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/AspectManager.java	2010-05-24 21:10:16 UTC (rev 105184)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/AspectManager.java	2010-05-24 21:16:06 UTC (rev 105185)
@@ -68,6 +68,7 @@
 import org.jboss.aop.pointcut.PointcutStats;
 import org.jboss.aop.pointcut.Typedef;
 import org.jboss.aop.pointcut.ast.ClassExpression;
+import org.jboss.aop.util.AOPLock;
 import org.jboss.util.loading.Translatable;
 import org.jboss.util.loading.Translator;
 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
@@ -144,6 +145,14 @@
    /** ClassExpressions built from ignore. Maintained by top-level AspectManager */
    protected ClassExpression[] ignoreExpressions = new ClassExpression[0];
 
+   /**
+    * This lock synchronizes weaving process with operations that change collections
+    * read during weaving.
+    * For weaving operations, use lock.lockRead(). For operations that change the
+    * collections used during weaving, use lock.lockWrite().
+    */
+   protected static final AOPLock lock = new AOPLock();
+
    protected final LinkedHashMap pointcuts = new LinkedHashMap();
    // contains pointcuts-binding association info
    protected final LinkedHashMap pointcutInfos = new LinkedHashMap();
@@ -240,7 +249,7 @@
 
    public static synchronized AspectManager getTopLevelAspectManager()
    {
-      if (scopedCLHelper == null)
+      if (scopedCLHelper != null)
       {
          //We are not running in jboss
          return instance();
@@ -583,17 +592,30 @@
 
    public synchronized void initialiseClassAdvisor(Class clazz, ClassAdvisor advisor)
    {
-      synchronized (advisors)
+      // avoiding deadlock. Other threads first get the bindignCollection lock
+      // and then the advisors
+      // as we know that the bindingCollection lock will be needed during the 
+      // Advisor.attachClass method execution, we get the lock at this point
+      // making sure we are avoiding the deadlock.
+      lock.lockRead();
+      try
       {
-         advisors.put(clazz, new WeakReference(advisor));
+         synchronized (advisors)
+         {
+            advisors.put(clazz, new WeakReference(advisor));
+            registerClass(clazz);
+            advisor.attachClass(clazz);
+            InterceptorChainObserver observer = dynamicStrategy.getInterceptorChainObserver(clazz);
+            advisor.setInterceptorChainObserver(observer);
+            if (notificationHandler != null)
+            {
+               notificationHandler.attachClass(clazz.getName());
+            }
+         }
       }
-      registerClass(clazz);
-      advisor.attachClass(clazz);
-      InterceptorChainObserver observer = dynamicStrategy.getInterceptorChainObserver(clazz);
-      advisor.setInterceptorChainObserver(observer);
-      if (notificationHandler != null)
+      finally
       {
-         notificationHandler.attachClass(clazz.getName());
+         lock.unlockRead();
       }
    }
 
@@ -801,8 +823,7 @@
               classname.startsWith("com.sun.") ||
               classname.startsWith("junit") ||
               classname.startsWith("jrockit.") ||
-              classname.startsWith("com.bea.vm.") ||
-              classname.startsWith("$Proxy")
+              classname.startsWith("com.bea.vm.")
              );
    }
 
@@ -859,67 +880,75 @@
          {
             return null;
          }
-         AOPClassPool pool = (AOPClassPool) registerClassLoader(loader);
-         CtClass clazz = null;
+         lock.lockRead();
          try
          {
-            clazz = pool.getLocally(className);
-         }
-         catch (NotFoundException e)
-         {
-            // todo Bill Burke: this scares the shit out of me, but it must be done
-            // I think it will screw up hotdeployment at some time.  Then again, maybe not ;)
-            ByteArrayClassPath cp = new ByteArrayClassPath(className, classfileBuffer);
-            pool.insertClassPath(cp);
-            clazz = pool.getLocally(className);
-         }
-         if (clazz.isArray())
-         {
-            if (verbose) System.out.println("[cannot compile] isArray: " + className);
-            pool.flushClass(className);
+            AOPClassPool pool = (AOPClassPool) registerClassLoader(loader);
+            CtClass clazz = null;
+            try
+            {
+               clazz = pool.getLocally(className);
+            }
+            catch (NotFoundException e)
+            {
+               // todo Bill Burke: this scares the shit out of me, but it must be done
+               // I think it will screw up hotdeployment at some time.  Then again, maybe not ;)
+               ByteArrayClassPath cp = new ByteArrayClassPath(className, classfileBuffer);
+               pool.insertClassPath(cp);
+               clazz = pool.getLocally(className);
+            }
+            if (clazz.isArray())
+            {
+               if (verbose) System.out.println("[cannot compile] isArray: " + className);
+               pool.flushClass(className);
+               return null;
+            }
+            if (clazz.isInterface())
+            {
+               if (verbose) System.out.println("[cannot compile] isInterface: " + className);
+               pool.flushClass(className);
+               return null;
+            }
+            if (clazz.isFrozen())
+            {
+               if (verbose) System.out.println("[warning] isFrozen: " + className);
+               clazz.defrost();
+            }
+   
+            ClassAdvisor advisor = new ClassAdvisor(className, this);
+            Instrumentor instrumentor = InstrumentorFactory.getInstrumentor(
+                  pool,
+                  this,
+                  dynamicStrategy.getJoinpointClassifier(),
+                  dynamicStrategy.getDynamicTransformationObserver(clazz));
+   
+            if (!instrumentor.isTransformable(clazz))
+            {
+               if (verbose) System.out.println("[cannot compile] implements Untransformable: " + className);
+               pool.flushClass(className);
+               return null;
+            }
+   
+            attachMetaData(advisor, clazz, true);
+            applyInterfaceIntroductions(advisor, clazz);
+            boolean transformed = instrumentor.transform(clazz, advisor);
+            if (transformed)
+            {
+               pool.lockInCache(clazz);
+               byte[] rtn = clazz.toBytecode();
+               if (AspectManager.getPrune()) clazz.prune();
+               return rtn;
+            }
+            else
+            {
+               pool.soften(clazz);
+            }
             return null;
          }
-         if (clazz.isInterface())
+         finally
          {
-            if (verbose) System.out.println("[cannot compile] isInterface: " + className);
-            pool.flushClass(className);
-            return null;
+            lock.unlockRead();
          }
-         if (clazz.isFrozen())
-         {
-            if (verbose) System.out.println("[warning] isFrozen: " + className);
-            clazz.defrost();
-         }
-
-         ClassAdvisor advisor = new ClassAdvisor(className, this);
-         Instrumentor instrumentor = InstrumentorFactory.getInstrumentor(
-               pool,
-               this,
-               dynamicStrategy.getJoinpointClassifier(),
-               dynamicStrategy.getDynamicTransformationObserver(clazz));
-
-         if (!instrumentor.isTransformable(clazz))
-         {
-            if (verbose) System.out.println("[cannot compile] implements Untransformable: " + className);
-            pool.flushClass(className);
-            return null;
-         }
-
-         attachMetaData(advisor, clazz, true);
-         applyInterfaceIntroductions(advisor, clazz);
-         boolean transformed = instrumentor.transform(clazz, advisor);
-         if (transformed)
-         {
-            pool.lockInCache(clazz);
-            byte[] rtn = clazz.toBytecode();
-            if (AspectManager.getPrune()) clazz.prune();
-            return rtn;
-         }
-         else
-         {
-            pool.soften(clazz);
-         }
-         return null;
       }
       catch (Exception ex)
       {
@@ -1184,11 +1213,16 @@
     */
    public void removePointcut(String name)
    {
-      synchronized (pointcuts)
+      lock.lockWrite();
+      try
       {
          pointcuts.remove(name);
          pointcutInfos.remove(name);
       }
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    /**
@@ -1196,13 +1230,18 @@
     */
    public synchronized void addPointcut(Pointcut pointcut)
    {
-      removePointcut(pointcut.getName());
-      synchronized (pointcuts)
+      lock.lockWrite();
+      try
       {
+         removePointcut(pointcut.getName());
          pointcuts.put(pointcut.getName(), pointcut);
          pointcutInfos.put(pointcut.getName(), new PointcutInfo(pointcut, this.transformationStarted));
+         updatePointcutStats(pointcut);
       }
-      updatePointcutStats(pointcut);
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    /**
@@ -1299,12 +1338,20 @@
     */
    public synchronized void removeBinding(String name)
    {
-      AdviceBinding binding = internalRemoveBinding(name);
-      if (binding != null)
+      lock.lockWrite();
+      try
       {
-         binding.clearAdvisors();
-         dynamicStrategy.interceptorChainsUpdated();
+         AdviceBinding binding = internalRemoveBinding(name);
+         if (binding != null)
+         {
+            binding.clearAdvisors();
+            dynamicStrategy.interceptorChainsUpdated();
+         }
       }
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    public synchronized void removeBindings(ArrayList binds)
@@ -1313,7 +1360,8 @@
 
       HashSet bindingAdvisors = new HashSet();
       ArrayList removedBindings = new ArrayList();
-      synchronized (bindings)
+      lock.lockWrite();
+      try
       {
          int bindSize = binds.size();
 
@@ -1334,6 +1382,10 @@
             removedBindings.add(binding);
          }
       }
+      finally
+      {
+         lock.unlockWrite();
+      }
       Iterator it = bindingAdvisors.iterator();
       while (it.hasNext())
       {
@@ -1363,32 +1415,34 @@
     */
    public synchronized void addBinding(AdviceBinding binding)
    {
-      AdviceBinding removedBinding = internalRemoveBinding(binding.getName());
-      Set affectedAdvisors = removedBinding == null? new HashSet(): new HashSet(removedBinding.getAdvisors());
-      synchronized (bindings)
+      lock.lockWrite();
+      try
       {
+         AdviceBinding removedBinding = internalRemoveBinding(binding.getName());
+         Set affectedAdvisors = removedBinding == null? new HashSet(): new HashSet(removedBinding.getAdvisors());
          bindings.put(binding.getName(), binding);
-      }
-      synchronized (pointcuts)
-      {
          Pointcut pointcut = binding.getPointcut();
          pointcuts.put(pointcut.getName(), pointcut);
          pointcutInfos.put(pointcut.getName(), new PointcutInfo(pointcut, binding, this.transformationStarted));
          updatePointcutStats(pointcut);
-      }
 
-      synchronized (advisors)
-      {
-         updateAdvisorsForAddedBinding(binding);
+         synchronized (advisors)
+         {
+            updateAdvisorsForAddedBinding(binding);
 
-         for (Iterator i = affectedAdvisors.iterator(); i.hasNext(); )
-         {
-            Advisor advisor = (Advisor) i.next();
-            if (isAdvisorRegistered(advisor))
-               advisor.removeAdviceBinding(removedBinding);
+            for (Iterator i = affectedAdvisors.iterator(); i.hasNext(); )
+            {
+               Advisor advisor = (Advisor) i.next();
+               if (isAdvisorRegistered(advisor))
+                  advisor.removeAdviceBinding(removedBinding);
+            }
          }
+         this.dynamicStrategy.interceptorChainsUpdated();
       }
-      this.dynamicStrategy.interceptorChainsUpdated();
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
 
@@ -1532,11 +1586,19 @@
     */
    public synchronized void addInterfaceIntroduction(InterfaceIntroduction pointcut)
    {
-      removeInterfaceIntroduction(pointcut.getName());
-      synchronized (interfaceIntroductions)
+      lock.lockWrite();
+      try
       {
-         interfaceIntroductions.put(pointcut.getName(), pointcut);
+         removeInterfaceIntroduction(pointcut.getName());
+         synchronized (interfaceIntroductions)
+         {
+            interfaceIntroductions.put(pointcut.getName(), pointcut);
+         }
       }
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    /**
@@ -1544,12 +1606,20 @@
     */
    public void removeInterfaceIntroduction(String name)
    {
-      synchronized (interfaceIntroductions)
+      lock.lockWrite();
+      try
       {
-         InterfaceIntroduction pointcut = (InterfaceIntroduction) interfaceIntroductions.remove(name);
-         if (pointcut == null) return;
-         pointcut.clearAdvisors();
+         synchronized (interfaceIntroductions)
+         {
+            InterfaceIntroduction pointcut = (InterfaceIntroduction) interfaceIntroductions.remove(name);
+            if (pointcut == null) return;
+            pointcut.clearAdvisors();
+         }
       }
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    /**
@@ -1557,12 +1627,20 @@
     */
    public synchronized void addAnnotationIntroduction(AnnotationIntroduction pointcut)
    {
-      String name = pointcut.getOriginalAnnotationExpr() + pointcut.getOriginalExpression();
-      removeAnnotationIntroduction(pointcut);
-      synchronized (annotationIntroductions)
+      lock.lockWrite();
+      try
       {
-         annotationIntroductions.put(name, pointcut);
+         String name = pointcut.getOriginalAnnotationExpr() + pointcut.getOriginalExpression();
+         removeAnnotationIntroduction(pointcut);
+         synchronized (annotationIntroductions)
+         {
+            annotationIntroductions.put(name, pointcut);
+         }
       }
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    /**
@@ -1570,11 +1648,15 @@
     */
    public void removeAnnotationIntroduction(AnnotationIntroduction pointcut)
    {
-      String name = pointcut.getOriginalAnnotationExpr() + pointcut.getOriginalExpression();
-      synchronized (annotationIntroductions)
+      lock.lockWrite();
       {
-         annotationIntroductions.remove(name);
+         String name = pointcut.getOriginalAnnotationExpr() + pointcut.getOriginalExpression();
+         synchronized (annotationIntroductions)
+         {
+            annotationIntroductions.remove(name);
+         }
       }
+      lock.unlockWrite();
    }
 
    public List getAnnotationIntroductions()
@@ -1587,26 +1669,42 @@
 
    public synchronized void addDeclare(DeclareDef declare)
    {
-      removeDeclare(declare.getName());
-      synchronized (declares)
+      lock.lockWrite();
+      try
       {
-         declares.put(declare.getName(), declare);
+         removeDeclare(declare.getName());
+         synchronized (declares)
+         {
+            declares.put(declare.getName(), declare);
+         }
+         if (declare.isPointcut())
+         {
+            PointcutStats stats;
+            stats = new PointcutStats(declare.getAst(), manager);
+            stats.matches();
+            updateStats(stats);
+         }
       }
-      if (declare.isPointcut())
+      finally
       {
-         PointcutStats stats;
-         stats = new PointcutStats(declare.getAst(), manager);
-         stats.matches();
-         updateStats(stats);
+         lock.unlockWrite();
       }
    }
 
    public void removeDeclare(String name)
    {
-      synchronized (declares)
+      lock.lockWrite();
+      try
       {
-         declares.remove(name);
+         synchronized (declares)
+         {
+            declares.remove(name);
+         }
       }
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    public Iterator getDeclares()
@@ -1654,12 +1752,20 @@
     */
    public synchronized void addAnnotationOverride(AnnotationIntroduction pointcut)
    {
-      String name = pointcut.getOriginalAnnotationExpr() + pointcut.getOriginalExpression();
-      synchronized (annotationOverrides)
+      lock.lockWrite();
+      try
       {
-         annotationOverrides.put(name, pointcut);
+         String name = pointcut.getOriginalAnnotationExpr() + pointcut.getOriginalExpression();
+         synchronized (annotationOverrides)
+         {
+            annotationOverrides.put(name, pointcut);
+         }
+         updateAdvisorsForAddedAnnotationOverride(pointcut);
       }
-      updateAdvisorsForAddedAnnotationOverride(pointcut);
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    public void updateAdvisorsForAddedAnnotationOverride(AnnotationIntroduction introduction)
@@ -1698,11 +1804,19 @@
     */
    public void removeAnnotationOverride(AnnotationIntroduction pointcut)
    {
-      String name = pointcut.getOriginalAnnotationExpr() + pointcut.getOriginalExpression();
-      synchronized (annotationOverrides)
+      lock.lockWrite();
+      try
       {
-         annotationOverrides.remove(name);
+         String name = pointcut.getOriginalAnnotationExpr() + pointcut.getOriginalExpression();
+         synchronized (annotationOverrides)
+         {
+            annotationOverrides.remove(name);
+         }
       }
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    public List getAnnotationOverrides()
@@ -1795,19 +1909,35 @@
 
    public synchronized void addTypedef(Typedef def) throws Exception
    {
-      removeTypedef(def.getName());
-      synchronized (typedefs)
+      lock.lockWrite();
+      try
       {
-         typedefs.put(def.getName(), def);
+         removeTypedef(def.getName());
+         synchronized (typedefs)
+         {
+            typedefs.put(def.getName(), def);
+         }
       }
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    public void removeTypedef(String name)
    {
-      synchronized (typedefs)
+      lock.lockWrite();
+      try
       {
-         typedefs.remove(name);
+         synchronized (typedefs)
+         {
+            typedefs.remove(name);
+         }
       }
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    public Typedef getTypedef(String name)
@@ -1887,17 +2017,14 @@
     */
    private AdviceBinding internalRemoveBinding(String name)
    {
-      synchronized (bindings)
+      AdviceBinding binding = (AdviceBinding) bindings.remove(name);
+      if (binding == null)
       {
-         AdviceBinding binding = (AdviceBinding) bindings.remove(name);
-         if (binding == null)
-         {
-            return null;
-         }
-         Pointcut pointcut = binding.getPointcut();
-         this.removePointcut(pointcut.getName());
-         return binding;
+         return null;
       }
+      Pointcut pointcut = binding.getPointcut();
+      this.removePointcut(pointcut.getName());
+      return binding;
    }
 
    /**

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassContainer.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassContainer.java	2010-05-24 21:10:16 UTC (rev 105184)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassContainer.java	2010-05-24 21:16:06 UTC (rev 105185)
@@ -232,34 +232,42 @@
    
    protected void createInterceptorChains()
    {
-      TLongObjectHashMap newMethodInfos = initializeMethodChain();
-      ArrayList newConstructorInfos = initializeConstructorChain();
-      
-      LinkedHashMap bindings = manager.getBindings();
-      synchronized (bindings)
+      AspectManager.lock.lockRead();
+      try
       {
-         if (bindings.size() > 0)
+         TLongObjectHashMap newMethodInfos = initializeMethodChain();
+         ArrayList newConstructorInfos = initializeConstructorChain();
+         
+         LinkedHashMap bindings = manager.getBindings();
+         synchronized (bindings)
          {
-            Iterator it = bindings.values().iterator();
-            while (it.hasNext())
+            if (bindings.size() > 0)
             {
-               AdviceBinding binding = (AdviceBinding) it.next();
-               if (AspectManager.verbose) System.out.println("iterate binding " + binding.getName());
-               resolveMethodPointcut(newMethodInfos, binding);
-               resolveConstructorPointcut(newConstructorInfos, binding);
+               Iterator it = bindings.values().iterator();
+               while (it.hasNext())
+               {
+                  AdviceBinding binding = (AdviceBinding) it.next();
+                  if (AspectManager.verbose) System.out.println("iterate binding " + binding.getName());
+                  resolveMethodPointcut(newMethodInfos, binding);
+                  resolveConstructorPointcut(newConstructorInfos, binding);
+               }
             }
          }
+         finalizeConstructorChain(newConstructorInfos);
+         finalizeMethodChain(newMethodInfos);
+         constructorInfos = new ConstructorInfo[newConstructorInfos.size()];
+         if (constructorInfos.length > 0)
+            constructorInfos = (ConstructorInfo[]) newConstructorInfos.toArray(constructorInfos);
+         methodInterceptors = newMethodInfos;
+         
+         populateInterceptorsFromInfos();
+         
+         doesHaveAspects = adviceBindings.size() > 0;
       }
-      finalizeConstructorChain(newConstructorInfos);
-      finalizeMethodChain(newMethodInfos);
-      constructorInfos = new ConstructorInfo[newConstructorInfos.size()];
-      if (constructorInfos.length > 0)
-         constructorInfos = (ConstructorInfo[]) newConstructorInfos.toArray(constructorInfos);
-      methodInterceptors = newMethodInfos;
-      
-      populateInterceptorsFromInfos();
-      
-      doesHaveAspects = adviceBindings.size() > 0;
+      finally
+      {
+         AspectManager.lock.unlockRead();
+      }
    }
    
    /**

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/InstanceDomain.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/InstanceDomain.java	2010-05-24 21:10:16 UTC (rev 105184)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/InstanceDomain.java	2010-05-24 21:16:06 UTC (rev 105185)
@@ -51,12 +51,20 @@
 
    public synchronized void addBinding(AdviceBinding binding)
    {
-      removeBinding(binding.getName());
-      synchronized (bindings)
+      lock.lockWrite();
+      try
       {
-         bindings.put(binding.getName(), binding);
+         removeBinding(binding.getName());
+         synchronized (bindings)
+         {
+            bindings.put(binding.getName(), binding);
+         }
+         if (advisor != null) advisor.newBindingAdded();
       }
-      if (advisor != null) advisor.newBindingAdded();
+      finally
+      {
+         lock.unlockWrite();
+      }
    }
 
    public void addClassMetaData(ClassMetaDataBinding meta)

Added: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/util/AOPLock.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/util/AOPLock.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/util/AOPLock.java	2010-05-24 21:16:06 UTC (rev 105185)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.aop.util;
+
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class AOPLock
+{
+   private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+   
+   /**
+    * Read-lock just this level
+    */
+   public final void lockRead()
+   {
+      lock.readLock().lock();
+   }
+
+   /**
+    * Read-unlock just this level
+    */
+   public final void unlockRead()
+   {
+      lock.readLock().unlock();
+   }
+   
+   /**
+    * Write-lock just this level
+    */
+   public final void lockWrite()
+   {
+      lock.writeLock().lock();
+   }
+   
+   /**
+    * Write-unlock this level
+    */
+   public final void unlockWrite()
+   {
+      lock.writeLock().unlock();
+   }
+}


Property changes on: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/util/AOPLock.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list