[jboss-cvs] JBossAS SVN: r57972 - in projects/aop/trunk/aop/src/main/org/jboss/aop: . instrument

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 1 15:30:23 EST 2006


Author: kabir.khan at jboss.com
Date: 2006-11-01 15:30:18 -0500 (Wed, 01 Nov 2006)
New Revision: 57972

Added:
   projects/aop/trunk/aop/src/main/org/jboss/aop/InterceptionMarkers.java
Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
Log:
Move the interception marker stuff for determining if we shold convert references out of aspect manager so we can handle this differently for domains for scoped classloaders

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java	2006-11-01 20:17:15 UTC (rev 57971)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java	2006-11-01 20:30:18 UTC (rev 57972)
@@ -161,70 +161,16 @@
    protected PrecedenceDefEntry[] sortedPrecedenceDefEntries;
    protected WeavingStrategy weavingStrategy;
 
-   protected final ConcurrentReaderHashMap convertableReference = new ConcurrentReaderHashMap();
-   protected final ConcurrentReaderHashMap hasFieldInterception = new ConcurrentReaderHashMap();
-   protected final ConcurrentReaderHashMap hasConstructorInterception = new ConcurrentReaderHashMap();
-
-   protected final ConcurrentReaderHashMap skipConvertableReference = new ConcurrentReaderHashMap();
-   protected final ConcurrentReaderHashMap skipFieldInterception = new ConcurrentReaderHashMap();
-   protected final ConcurrentReaderHashMap skipConstructorInterception = new ConcurrentReaderHashMap();
-
    protected DynamicAOPStrategy dynamicStrategy = new LoadInterceptedClassesStrategy();
    // indicates that the transformation process has begun
    protected boolean transformationStarted = false;
 
    //This will be set by the AspectManagerService if running in JBoss
    public static AOPScopedClassLoaderHelper scopedCLHelper;
+   
+   //Keeps track of if we need to convert references etc for a given class. Domains for scoped classloaders will have their own version of this
+   protected static InterceptionMarkers interceptionMarkers = new InterceptionMarkers();
 
-   public void addConstructionInterceptionMarker(String classname)
-   {
-      skipConstructorInterception.remove(classname);
-      skipConvertableReference.remove(classname);
-      hasConstructorInterception.put(classname, classname);
-      convertableReference.put(classname, classname);
-   }
-
-   public void addFieldInterceptionMarker(String classname)
-   {
-      skipFieldInterception.remove(classname);
-      skipConvertableReference.remove(classname);
-      hasFieldInterception.put(classname, classname);
-      convertableReference.put(classname, classname);
-   }
-
-   public void skipReference(String classname)
-   {
-      skipConvertableReference.put(classname, classname);
-   }
-
-   public boolean shouldSkipConstruction(String classname)
-   {
-      return !(hasConstructorInterception.containsKey(classname) || !skipConstructorInterception.containsKey(classname));
-      //return false;
-   }
-
-   public boolean shouldSkipFieldAccess(String classname)
-   {
-      return !(hasFieldInterception.containsKey(classname) || !skipFieldInterception.containsKey(classname));
-      //return false;
-   }
-
-   public void skipConstruction(String classname)
-   {
-      skipConstructorInterception.put(classname, classname);
-   }
-
-   public void skipFieldAccess(String classname)
-   {
-      skipFieldInterception.put(classname, classname);
-   }
-
-   public boolean convertReference(String classname)
-   {
-      return !skipConvertableReference.containsKey(classname) || convertableReference.containsKey(classname);
-      //return true;
-   }
-
    // Static -------------------------------------------------------
 
    protected static AspectManager manager;
@@ -366,6 +312,10 @@
       return manager;
    }
 
+   public InterceptionMarkers getInterceptionMarkers()
+   {
+      return interceptionMarkers;
+   }
 
    public LinkedHashMap getPointcuts()
    {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java	2006-11-01 20:17:15 UTC (rev 57971)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java	2006-11-01 20:30:18 UTC (rev 57972)
@@ -710,7 +710,13 @@
    
    //////////////////////////////////////////////////////////////////////////
    //Methods that should delegate to the top AspectManager
-   
+
+   public InterceptionMarkers getInterceptionMarkers()
+   {
+      return parent.getInterceptionMarkers();
+   }
+
+
    /** Managed by the top-level aspect manager */
    protected Map getScopedClassLoaderDomains()
    {
@@ -723,46 +729,6 @@
       return parent.getSubDomainsPerClass();
    }
 
-   public void addConstructionInterceptionMarker(String classname)
-   {
-      parent.addConstructionInterceptionMarker(classname);
-   }
-
-   public void addFieldInterceptionMarker(String classname)
-   {
-      parent.addFieldInterceptionMarker(classname);
-   }
-
-   public void skipReference(String classname)
-   {
-      parent.skipReference(classname);
-   }
-
-   public boolean shouldSkipConstruction(String classname)
-   {
-      return parent.shouldSkipConstruction(classname);
-   }
-
-   public boolean shouldSkipFieldAccess(String classname)
-   {
-      return parent.shouldSkipFieldAccess(classname);
-   }
-
-   public void skipConstruction(String classname)
-   {
-      parent.skipConstruction(classname);
-   }
-
-   public void skipFieldAccess(String classname)
-   {
-      parent.skipFieldAccess(classname);
-   }
-
-   public boolean convertReference(String classname)
-   {
-      return parent.convertReference(classname);
-   }
-
    /** Only set on a per vm basis */
    public ArrayList getExclude()
    {

Added: projects/aop/trunk/aop/src/main/org/jboss/aop/InterceptionMarkers.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/InterceptionMarkers.java	2006-11-01 20:17:15 UTC (rev 57971)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/InterceptionMarkers.java	2006-11-01 20:30:18 UTC (rev 57972)
@@ -0,0 +1,91 @@
+/*
+* 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;
+
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class InterceptionMarkers
+{
+   protected final ConcurrentReaderHashMap convertableReference = new ConcurrentReaderHashMap();
+   protected final ConcurrentReaderHashMap hasFieldInterception = new ConcurrentReaderHashMap();
+   protected final ConcurrentReaderHashMap hasConstructorInterception = new ConcurrentReaderHashMap();
+
+   protected final ConcurrentReaderHashMap skipConvertableReference = new ConcurrentReaderHashMap();
+   protected final ConcurrentReaderHashMap skipFieldInterception = new ConcurrentReaderHashMap();
+   protected final ConcurrentReaderHashMap skipConstructorInterception = new ConcurrentReaderHashMap();
+
+   public void addConstructionInterceptionMarker(String classname)
+   {
+      skipConstructorInterception.remove(classname);
+      skipConvertableReference.remove(classname);
+      hasConstructorInterception.put(classname, classname);
+      convertableReference.put(classname, classname);
+   }
+
+   public void addFieldInterceptionMarker(String classname)
+   {
+      skipFieldInterception.remove(classname);
+      skipConvertableReference.remove(classname);
+      hasFieldInterception.put(classname, classname);
+      convertableReference.put(classname, classname);
+   }
+
+   public void skipReference(String classname)
+   {
+      skipConvertableReference.put(classname, classname);
+   }
+
+   public boolean shouldSkipConstruction(String classname)
+   {
+      return !(hasConstructorInterception.containsKey(classname) || !skipConstructorInterception.containsKey(classname));
+      //return false;
+   }
+
+   public boolean shouldSkipFieldAccess(String classname)
+   {
+      return !(hasFieldInterception.containsKey(classname) || !skipFieldInterception.containsKey(classname));
+      //return false;
+   }
+
+   public void skipConstruction(String classname)
+   {
+      skipConstructorInterception.put(classname, classname);
+   }
+
+   public void skipFieldAccess(String classname)
+   {
+      skipFieldInterception.put(classname, classname);
+   }
+
+   public boolean convertReference(String classname)
+   {
+      return !skipConvertableReference.containsKey(classname) || convertableReference.containsKey(classname);
+      //return true;
+   }
+
+
+}

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java	2006-11-01 20:17:15 UTC (rev 57971)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java	2006-11-01 20:30:18 UTC (rev 57972)
@@ -102,11 +102,11 @@
       
       if (skipFieldInterception)
       {
-         advisor.getManager().skipFieldAccess(clazz.getName());
+         advisor.getManager().getInterceptionMarkers().skipFieldAccess(clazz.getName());
       }
       else
       {
-         advisor.getManager().addFieldInterceptionMarker(clazz.getName());
+         advisor.getManager().getInterceptionMarkers().addFieldInterceptionMarker(clazz.getName());
       }
          
    }

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java	2006-11-01 20:17:15 UTC (rev 57971)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java	2006-11-01 20:30:18 UTC (rev 57972)
@@ -536,7 +536,7 @@
          for (ReferenceClassIterator it = new ReferenceClassIterator(clazz.getRefClasses()) ; it.hasNext() ; )
          {
             ref = it.next();
-            if (!manager.convertReference(ref)
+            if (!manager.getInterceptionMarkers().convertReference(ref)
                 || manager.isNonAdvisableClassName(ref)
                 || ref.startsWith("java.")
                 || ref.startsWith("javax.")
@@ -570,35 +570,35 @@
             ClassAdvisor advisor = manager.getTempClassAdvisor(ctRef);
             
             
-            if (!manager.shouldSkipFieldAccess(ref) && !ref.equals(clazz.getName()))
+            if (!manager.getInterceptionMarkers().shouldSkipFieldAccess(ref) && !ref.equals(clazz.getName()))
             {
                List fields = getAdvisableFields(ctRef);
                if (fieldAccessTransformer.replaceFieldAccess(fields, ctRef, advisor))
                {
-                  manager.addFieldInterceptionMarker(ref);
+                  manager.getInterceptionMarkers().addFieldInterceptionMarker(ref);
                   converted = true;
                }
                else
                {
-                  manager.skipFieldAccess(ref);
+                  manager.getInterceptionMarkers().skipFieldAccess(ref);
                }
             }
-            if (!manager.shouldSkipConstruction(ref))
+            if (!manager.getInterceptionMarkers().shouldSkipConstruction(ref))
             {
                if (constructorExecutionTransformer.replaceConstructorAccess(advisor, ctRef))
                {
-                  manager.addConstructionInterceptionMarker(ref);
+                  manager.getInterceptionMarkers().addConstructionInterceptionMarker(ref);
                   converted = true;
                }
                else
                {
-                  manager.skipConstruction(ref);
+                  manager.getInterceptionMarkers().skipConstruction(ref);
                }
             }
 
             if (!converted)
             {
-               manager.skipReference(ref);
+               manager.getInterceptionMarkers().skipReference(ref);
             }
             ref = null;
          }
@@ -651,11 +651,11 @@
          String classname = clazz.getName();
          if (constructorAccessConverted)
          {
-            manager.addConstructionInterceptionMarker(classname);
+            manager.getInterceptionMarkers().addConstructionInterceptionMarker(classname);
          }
          else
          {
-            manager.skipConstruction(classname);
+            manager.getInterceptionMarkers().skipConstruction(classname);
          }
          converted = converted || constructorAccessConverted;
 
@@ -679,9 +679,9 @@
          }
          else
          {
-            if (manager.shouldSkipFieldAccess(classname))
+            if (manager.getInterceptionMarkers().shouldSkipFieldAccess(classname))
             {
-               manager.skipReference(classname);
+               manager.getInterceptionMarkers().skipReference(classname);
             }
          }
 




More information about the jboss-cvs-commits mailing list