[jboss-cvs] JBossAS SVN: r105186 - branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon May 24 17:27:46 EDT 2010


Author: flavia.rainone at jboss.com
Date: 2010-05-24 17:27:46 -0400 (Mon, 24 May 2010)
New Revision: 105186

Modified:
   branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/AspectAnnotationLoader.java
   branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/AspectXmlLoader.java
Log:
[JBAOP-793] Enable write locks during (un)deployment of aspects by AspectXmlLoader and AspectAnnotationLoader

Modified: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/AspectAnnotationLoader.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/AspectAnnotationLoader.java	2010-05-24 21:16:06 UTC (rev 105185)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/AspectAnnotationLoader.java	2010-05-24 21:27:46 UTC (rev 105186)
@@ -105,92 +105,108 @@
 
    public void deployInputStreamIterator(Iterator it) throws Exception
    {
-      while (it.hasNext())
+      AspectManager.lock.lockWrite();
+      try
       {
-         InputStream stream = (InputStream) it.next();
-         DataInputStream dstream = new DataInputStream(stream);
-         ClassFile cf = null;
-         try
+         while (it.hasNext())
          {
-            cf = new ClassFile(dstream);
-         }
-         finally
-         {
-            dstream.close();
-            stream.close();
-         }
-         if (AspectManager.verbose) System.out.println("[debug] Looking for aspects in: " + cf.getName());
-         AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
-         if (visible != null)
-         {
-            AspectDefinition def = deployAspect(visible, cf);
-
-            if (def == null)
+            InputStream stream = (InputStream) it.next();
+            DataInputStream dstream = new DataInputStream(stream);
+            ClassFile cf = null;
+            try
             {
-               def = deployInterceptor(visible, cf);
+               cf = new ClassFile(dstream);
             }
-
-            if (def == null)
+            finally
             {
-               deployDynamicCFlow(visible, cf);
+               dstream.close();
+               stream.close();
             }
-
-            if (def == null)
+            if (AspectManager.verbose) System.out.println("[debug] Looking for aspects in: " + cf.getName());
+            AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
+            if (visible != null)
             {
-               if (!deployPreparedClass(visible, cf))
+               AspectDefinition def = deployAspect(visible, cf);
+   
+               if (def == null)
                {
-                  deployPrecedence(visible, cf);
+                  def = deployInterceptor(visible, cf);
                }
+   
+               if (def == null)
+               {
+                  deployDynamicCFlow(visible, cf);
+               }
+   
+               if (def == null)
+               {
+                  if (!deployPreparedClass(visible, cf))
+                  {
+                     deployPrecedence(visible, cf);
+                  }
+               }
+               else
+               {
+                  deployPointcuts(cf);
+                  deployMixins(cf);
+                  deployIntroductions(cf);
+                  deployTypedefs(cf);
+                  deployCFlowStackDefs(cf);
+                  deployPrepares(cf);
+                  deployAnnotationIntroductions(cf);
+                  deployDeclares(cf);
+               }
             }
-            else
-            {
-               deployPointcuts(cf);
-               deployMixins(cf);
-               deployIntroductions(cf);
-               deployTypedefs(cf);
-               deployCFlowStackDefs(cf);
-               deployPrepares(cf);
-               deployAnnotationIntroductions(cf);
-               deployDeclares(cf);
-            }
          }
       }
+      finally
+      {
+         AspectManager.lock.unlockWrite();
+      }
    }
 
    public void undeployInputStreamIterator(Iterator it) throws Exception
    {
-      while (it.hasNext())
+      AspectManager.lock.lockWrite();
+      try
       {
-         InputStream stream = (InputStream) it.next();
-         DataInputStream dstream = new DataInputStream(stream);
-         ClassFile cf = null;
-         try
+         while (it.hasNext())
          {
-            cf = new ClassFile(dstream);
+            InputStream stream = (InputStream) it.next();
+            DataInputStream dstream = new DataInputStream(stream);
+            ClassFile cf = null;
+            try
+            {
+               cf = new ClassFile(dstream);
+            }
+            finally
+            {
+               dstream.close();
+               stream.close();
+            }
+            if (AspectManager.verbose) System.out.println("[debug] Looking for aspects in: " + cf.getName());
+            AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
+            if (visible != null)
+            {
+               undeployAspect(visible, cf);
+               undeployInterceptor(visible, cf);
+               undeployDynamicCFlow(visible, cf);
+               undeployPreparedClass(visible, cf);
+               undeployPrecedence(visible, cf);
+               undeployPointcuts(cf);
+               undeployMixins(cf);
+               undeployIntroductions(cf);
+               undeployTypedefs(cf);
+               undeployCFlowStackDefs(cf);
+               undeployPrepares(cf);
+               undeployAnnotationIntroductions(cf);
+            }
          }
-         finally
-         {
-            dstream.close();
-            stream.close();
-         }
-         if (AspectManager.verbose) System.out.println("[debug] Looking for aspects in: " + cf.getName());
-         AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
-         if (visible != null)
-         {
-            undeployAspect(visible, cf);
-            undeployInterceptor(visible, cf);
-            undeployDynamicCFlow(visible, cf);
-            undeployPreparedClass(visible, cf);
-            undeployPrecedence(visible, cf);
-            undeployPointcuts(cf);
-            undeployMixins(cf);
-            undeployIntroductions(cf);
-            undeployTypedefs(cf);
-            undeployCFlowStackDefs(cf);
-            undeployPrepares(cf);
-            undeployAnnotationIntroductions(cf);
-         }
       }
+      finally
+      {
+         AspectManager.lock.unlockWrite();
+      }
    }
 
    private AspectDefinition deployAspect(AnnotationsAttribute visible, ClassFile cf) throws Exception

Modified: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/AspectXmlLoader.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/AspectXmlLoader.java	2010-05-24 21:16:06 UTC (rev 105185)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/AspectXmlLoader.java	2010-05-24 21:27:46 UTC (rev 105186)
@@ -881,6 +881,7 @@
    {
       setupDefaultName(url);
       Element top = doc.getDocumentElement();
+      AspectManager.lock.lockWrite();
       try
       {
          deployTopElements(top);
@@ -891,6 +892,10 @@
          if (AspectManager.verbose) e.printStackTrace();
          throw new RuntimeException(e);
       }
+      finally
+      {
+         AspectManager.lock.unlockWrite();
+      }
    }
 
    public void deployDomain(Element element) throws Exception
@@ -1087,13 +1092,21 @@
 
    public void undeployXML(Document doc, URL url) throws Exception
    {
-      //Check for URL here
-      setupDefaultName(url);
-      undeployTopElements(doc.getDocumentElement());
+      AspectManager.lock.lockWrite();
+      try
+      {
+         //Check for URL here
+         setupDefaultName(url);
+         undeployTopElements(doc.getDocumentElement());
+   
+         bulkUndeploy();
+      }
+      finally
+      {
+         AspectManager.lock.unlockWrite();
+      }
 
-      bulkUndeploy();
 
-
    }
 
    private void bulkUndeploy()




More information about the jboss-cvs-commits mailing list