[jboss-cvs] JBossAS SVN: r84504 - in projects/aop/branches/createspi/aop/src: main/java/org/jboss/aop/plugins and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 20 06:49:31 EST 2009


Author: kabir.khan at jboss.com
Date: 2009-02-20 06:49:30 -0500 (Fri, 20 Feb 2009)
New Revision: 84504

Added:
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/AbstractManager.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPSystem.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultConfiguration.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultManager.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultWeaver.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/LoadInterceptedClassesStrategy.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/metadata/
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/metadata/DefaultMetaDataFactory.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPSystem.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AbstractAOPSystem.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Configuration.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/ConfigurationProperties.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Manager.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Weaver.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/metadata/
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/metadata/MetaDataFactory.java
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/util/CollectionConvert.java
   projects/aop/branches/createspi/aop/src/test/java/org/jboss/test/aop/unit/spi/
   projects/aop/branches/createspi/aop/src/test/java/org/jboss/test/aop/unit/spi/AOPSystemUnitTestCase.java
   projects/aop/branches/createspi/aop/src/test/java/org/jboss/test/aop/unit/spi/ConfigurationUnitTestCase.java
Removed:
   projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/LoadInterceptedClassesStrategy.java
Log:
Add Weaver, Configuration and Manager interfaces

Deleted: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/LoadInterceptedClassesStrategy.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/LoadInterceptedClassesStrategy.java	2009-02-20 11:48:55 UTC (rev 84503)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/LoadInterceptedClassesStrategy.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -1,97 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt 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 javassist.CodeConverter;
-import javassist.CtClass;
-import javassist.CtField;
-
-import org.jboss.aop.instrument.DynamicTransformationObserver;
-import org.jboss.aop.instrument.JoinpointClassifier;
-import org.jboss.aop.instrument.JoinpointSimpleClassifier;
-
-
-/**
- * Dynamic AOP Strategy that instruments prepared classes code
- * for interception before they get loaded in the system.
- * This way, no change to a class code has to be made during runtime. 
- * @author Flavia Rainone
- */
-class LoadInterceptedClassesStrategy implements DynamicAOPStrategy
-{
-   /**
-    * Dummy DynamicTransformationObserver. No action is need when a dynamic
-    * transformation occurs.
-    */
-   private DynamicTransformationObserver dynamicTransformationObserver = 
-      new DynamicTransformationObserver(){
-      public void fieldReadDynamicalyWrapped(CtField field) {}
-      public void fieldWriteDynamicalyWrapped(CtField field) {}
-      public void constructorDynamicalyWrapped() {}
-      public void transformationFinished(CtClass clazz, CodeConverter converter) {}
-   };
-   
-   /**
-    * Simple classifier to be used during transformation.
-    */
-   JoinpointClassifier joinpointClassifier = new JoinpointSimpleClassifier();
-
-   /**
-    * Returns <code>null</code> because, as long as no runtime action is required
-    * in this strategy, no observer is required.
-    * @see org.jboss.aop.DynamicAOPStrategy#getInterceptorChainObserver(Class)
-    */
-   public InterceptorChainObserver getInterceptorChainObserver(Class<?> clazz)
-   {
-      return null;
-   }
-   
-   /**
-    * Notifies the strategy that one or more interceptor chains in the
-    * system may have been updated.
-    * This method does nothing because no runtime action is required.
-    * @see org.jboss.aop.DynamicAOPStrategy#interceptorChainsUpdated()
-    */
-   public void interceptorChainsUpdated() { }
-   
-   /**
-    * Returns a <code>org.jboss.aop.instrument.JoinpointSimpleClassifier</code>
-    * instance. This classifier assures that prepared classes will be fully instrumented
-    * for interception before they get loaded in the system.
-    * @see org.jboss.aop.DynamicAOPStrategy#getJoinpointClassifier()
-    */
-   public JoinpointClassifier getJoinpointClassifier()
-   {
-      return this.joinpointClassifier;
-   }
-   
-   /**
-    * Returns a dynamic transformation observer to be notified of the dynamic
-    * events during the <code>clazz</code> transformation. This observer does nothing
-    * because no action is required when a dynamic transformation happens.
-    * @see org.jboss.aop.DynamicAOPStrategy#getJoinpointClassifier()
-    */
-   public DynamicTransformationObserver getDynamicTransformationObserver(CtClass clazz)
-   {
-      return this.dynamicTransformationObserver; 
-   }
-}
\ No newline at end of file

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/AbstractManager.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/AbstractManager.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/AbstractManager.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,77 @@
+/*
+* 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.plugins;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.aop.pointcut.CFlowStack;
+import org.jboss.aop.spi.Manager;
+import org.jboss.aop.util.UnmodifiableEmptyCollections;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractManager implements Manager
+{
+   private final Object lazyCollectionLock = new Object();
+   
+   protected volatile ConcurrentHashMap<String, CFlowStack> cflowStacks = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+
+   public void addCFlowStack(CFlowStack stack)
+   {
+      initCflowStacksMap();
+      cflowStacks.put(stack.getName(), stack);
+   }
+
+   public CFlowStack getCFlowStack(String name)
+   {
+      return cflowStacks.get(name);
+   }
+
+   public void removeCFlowStack(String name)
+   {
+      cflowStacks.remove(name);
+   }
+
+   public Map<String, CFlowStack> getCFlowStacks()
+   {
+      return Collections.unmodifiableMap(cflowStacks);
+   }
+
+   protected void initCflowStacksMap()
+   {
+      if (cflowStacks == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
+      {
+         synchronized(lazyCollectionLock)
+         {
+            if (cflowStacks == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
+            {
+               cflowStacks = new ConcurrentHashMap<String, CFlowStack>();
+            }
+         }
+      }
+   }
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPSystem.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPSystem.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPSystem.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,34 @@
+/*
+* 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.plugins;
+
+import org.jboss.aop.spi.AOPSystem;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultAOPSystem extends AOPSystem
+{
+
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultConfiguration.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultConfiguration.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultConfiguration.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,276 @@
+/*
+* 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.plugins;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.aop.AdvisorFactory;
+import org.jboss.aop.Deployment;
+import org.jboss.aop.classpool.AOPClassPoolRepository;
+import org.jboss.aop.instrument.InstrumentorFactory;
+import org.jboss.aop.pointcut.ast.ClassExpression;
+import org.jboss.aop.spi.Configuration;
+import org.jboss.aop.spi.ConfigurationProperties;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultConfiguration implements Configuration, ConfigurationProperties
+{
+   private boolean optimize;
+   private boolean verbose;
+   private List<String> exclude = new CopyOnWriteArrayList<String>();
+   private List<String> include = new CopyOnWriteArrayList<String>();
+   private List<String> ignore = new CopyOnWriteArrayList<String>();
+   private volatile ClassExpression[] ignoreExpressions = new ClassExpression[0];
+   protected List<String> includedInvisibleAnnotations = new CopyOnWriteArrayList<String>();
+   private boolean debugClasses;
+   private boolean maintainAdvisorMethodInterceptors;
+   
+   public DefaultConfiguration()
+   {
+      initialise();
+   }
+
+   public boolean isOptimize()
+   {
+      return optimize;
+   }
+
+   public void setOptimize(boolean optimize)
+   {
+      this.optimize = optimize;
+   }
+
+   public boolean isVerbose()
+   {
+      return verbose;
+   }
+
+   public void setVerbose(boolean verbose)
+   {
+      this.verbose = verbose;
+   }
+
+   public List<String> getIncludedInvisibleAnnotations()
+   {
+      return includedInvisibleAnnotations;
+   }
+
+   public void setIncludedInvisibleAnnotations(List<String> names)
+   {
+      includedInvisibleAnnotations.clear();
+      if (names != null)
+      {
+         includedInvisibleAnnotations.addAll(names);
+      }
+   }
+
+   public List<String> getExclude()
+   {
+      return exclude;
+   }
+
+   public void setExclude(List<String> exclude)
+   {
+      this.exclude.clear();
+      if (exclude != null)
+      {
+         this.exclude.addAll(exclude);
+      }
+   }
+
+   public List<String> getInclude()
+   {
+      return include;
+   }
+
+   public void setInclude(List<String> include)
+   {
+      this.include.clear();
+      if (include != null)
+      {
+         this.include.addAll(include);
+      }
+   }
+
+   public List<String> getIgnore()
+   {
+      return ignore;
+   }
+   
+   public ClassExpression[] getIgnoreExpressions()
+   {
+      return ignoreExpressions;
+   }
+   
+   public void setIgnore(List<String> ignore)
+   {
+      this.ignore.clear();
+      if (ignore != null)
+      {
+         this.ignore.addAll(ignore);
+      }
+      
+      ClassExpression[] ignored = new ClassExpression[ignore != null ? ignore.size() : 0];
+      for (int i = 0 ; i < ignored.length ; i++)
+      {
+        String ex = ignore.get(i);
+        ignored[i] = new ClassExpression(ex);
+      }
+      ignoreExpressions = ignored;
+   }
+
+   public boolean isDebugClasses()
+   {
+      return debugClasses;
+   }
+
+   public void setDebugClasses(boolean debugClasses)
+   {
+      this.debugClasses = debugClasses;
+   }
+
+   public boolean isMaintainAdvisorMethodInterceptors()
+   {
+      return maintainAdvisorMethodInterceptors;
+   }
+
+   public void setMaintainAdvisorMethodInterceptors(boolean maintainMethodInterceptors)
+   {
+      this.maintainAdvisorMethodInterceptors = maintainMethodInterceptors;
+   }
+
+   protected void initialise()
+   {
+      initialiseOptimized();
+      initialisePrune();
+      initialiseVerbose();
+      initialiseExclude();
+      initialiseInclude();
+      initialiseIgnore();
+      initialiseIncludedInvisibleAnnotations();
+      initialiseDebugClasses();
+      initialiseMaintainAdvisorMethodInterceptors();
+      
+      //TODO Make these accessible from AOPFactory?
+      //If not move them into initialiseXXX methods
+      String instrument = System.getProperty(INSTRUMENTOR, null);
+      InstrumentorFactory.initialise(instrument);
+
+      String advisorName = System.getProperty(ADVISOR, null);
+      AdvisorFactory.initialise(advisorName);
+
+      Deployment.deploy();
+   }
+
+   private void initialiseOptimized()
+   {
+      optimize = getBooleanProperty(OPTIMIZED, OPTIMIZED_DEFAULT);
+   }
+   
+   private void initialisePrune()
+   {
+      //TODO somewhere else?
+      Boolean prune = getBooleanProperty(PRUNE);
+      if (prune != null)
+      {
+         AOPClassPoolRepository.getInstance().setPrune(prune);
+      }
+   }
+
+   private void initialiseVerbose()
+   {
+      verbose = getBooleanProperty(VERBOSE, VERBOSE_DEFAULT);
+   }
+
+   private void initialiseExclude()
+   {
+      setExclude(splitString(System.getProperty(EXCLUDE, null), ","));
+   }
+   
+   private void initialiseInclude()
+   {
+      setInclude(splitString(System.getProperty(INCLUDE, null), ","));
+   }
+   
+   private void initialiseIgnore()
+   {
+      setIgnore(splitString(System.getProperty(IGNORE, null), ","));
+   }
+   
+   private void initialiseIncludedInvisibleAnnotations()
+   {
+      setIncludedInvisibleAnnotations(splitString(System.getProperty(INCLUDED_INVISIBLE_ANNOTATIONS, null), ","));
+   }
+   
+   private void initialiseDebugClasses()
+   {
+      debugClasses = getBooleanProperty(DEBUG_CLASSES, DEBUG_CLASSES_DEFAULT);
+   }
+   
+   private void initialiseMaintainAdvisorMethodInterceptors()
+   {
+      maintainAdvisorMethodInterceptors = getBooleanProperty(MAINTAIN_METHOD_INTERCEPTORS, MAINTAIN_METHOD_INTERCEPTORS_DEFAULT);
+   }
+   
+   private static ArrayList<String> splitString(String string, String delim)
+   {
+      if (string != null)
+      {
+         ArrayList<String> list = new ArrayList<String>();
+         for(String token : string.split(delim))
+         {
+            if (token.trim().length() > 0)
+            {
+               list.add(token.trim());
+            }
+         }
+         return list;
+      }
+      return null;
+   }
+
+   private Boolean getBooleanProperty(String name, Boolean defaultValue)
+   {
+      Boolean value = getBooleanProperty(name);
+      if (value == null)
+      {
+         return defaultValue;
+      }
+      return value;
+   }
+   
+   private Boolean getBooleanProperty(String name)
+   {
+      String value = System.getProperty(name);
+      if (value != null)
+      {
+         return Boolean.valueOf(value);
+      }
+      return null;
+   }
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultManager.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultManager.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultManager.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,85 @@
+/*
+* 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.plugins;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.aop.pointcut.CFlowStack;
+import org.jboss.aop.spi.Configuration;
+import org.jboss.aop.spi.Manager;
+import org.jboss.aop.util.UnmodifiableEmptyCollections;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultManager implements Manager
+{
+   private final Configuration configuration;
+   
+   private final Object lazyCollectionLock = new Object();
+   
+   protected volatile ConcurrentHashMap<String, CFlowStack> cflowStacks = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+
+   protected DefaultManager(Configuration configuration)
+   {
+      this.configuration = configuration;
+   }
+   
+   public void addCFlowStack(CFlowStack stack)
+   {
+      initCFlowStacksMap();
+      cflowStacks.put(stack.getName(), stack);
+   }
+
+   public CFlowStack getCFlowStack(String name)
+   {
+      return cflowStacks.get(name);
+   }
+
+   public void removeCFlowStack(String name)
+   {
+      cflowStacks.remove(name);
+   }
+
+   public Map<String, CFlowStack> getCFlowStacks()
+   {
+      return Collections.unmodifiableMap(cflowStacks);
+   }
+
+   protected void initCFlowStacksMap()
+   {
+      if (cflowStacks == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
+      {
+         synchronized(lazyCollectionLock)
+         {
+            if (cflowStacks == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
+            {
+               cflowStacks = new ConcurrentHashMap<String, CFlowStack>();
+            }
+         }
+      }
+   }
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultWeaver.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultWeaver.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultWeaver.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,232 @@
+/*
+* 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.plugins;
+
+import java.security.ProtectionDomain;
+import java.util.List;
+
+import org.jboss.aop.ClassicWeavingStrategy;
+import org.jboss.aop.DynamicAOPStrategy;
+import org.jboss.aop.SuperClassesFirstWeavingStrategy;
+import org.jboss.aop.WeavingStrategy;
+import org.jboss.aop.instrument.GeneratedAdvisorInstrumentor;
+import org.jboss.aop.instrument.InstrumentorFactory;
+import org.jboss.aop.instrument.JoinPointGenerator;
+import org.jboss.aop.instrument.TransformerCommon;
+import org.jboss.aop.pointcut.ast.ClassExpression;
+import org.jboss.aop.spi.AOPSystem;
+import org.jboss.aop.spi.Configuration;
+import org.jboss.aop.spi.Weaver;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultWeaver implements Weaver
+{
+   Configuration configuration;
+   
+   WeavingStrategy weavingStrategy;
+   
+   protected DynamicAOPStrategy dynamicStrategy = new LoadInterceptedClassesStrategy();
+   
+   protected DefaultWeaver(Configuration configuration)
+   {
+      this.configuration = configuration;
+   }
+   
+   private void initWeavingStrategy()
+   {
+      if (weavingStrategy == null)
+      {
+         if (TransformerCommon.isCompileTime())
+         {
+            weavingStrategy = new ClassicWeavingStrategy();
+         }
+         else if(InstrumentorFactory.getInstrumentor(this,dynamicStrategy.getJoinpointClassifier())
+               instanceof GeneratedAdvisorInstrumentor)
+         {
+            weavingStrategy = new SuperClassesFirstWeavingStrategy();
+         }
+         else
+         {
+            weavingStrategy = new ClassicWeavingStrategy();
+         }
+      }
+   }
+
+   /**
+    * Returns the dynamic aop strategy to be used.
+    */
+   public DynamicAOPStrategy getDynamicAOPStrategy()
+   {
+      return this.dynamicStrategy;
+   }
+
+   /**
+    * Sets the dynamic aop strategy to be used.
+    * Should be called only before any class is transformed.
+    * @param strategy the new dynamic aop strategy.
+    */
+   public void setDynamicAOPStrategy(DynamicAOPStrategy strategy)
+   {
+      // avoid users calling this method in run time
+      if (hasTransformationStarted())
+      {
+         throw new RuntimeException("Dynamic AOP Strategy Update not allowed in run time");
+      }
+      this.dynamicStrategy = strategy;
+   }
+
+   public boolean isWeavable(String classname)
+   {
+      if (classname.startsWith("org.jboss.aop.") ||
+              classname.endsWith("$aop") ||
+              classname.startsWith("javassist") ||
+              classname.startsWith("org.jboss.util.") ||
+              classname.startsWith("gnu.trove.") ||
+              classname.startsWith("EDU.oswego.cs.dl.util.concurrent.") ||
+              classname.contains('.' + JoinPointGenerator.JOINPOINT_CLASS_PREFIX) ||
+      // System classes
+              classname.startsWith("org.apache.tools.ant") ||
+              classname.startsWith("org.apache.crimson") ||
+              classname.startsWith("org.apache.xalan") ||
+              classname.startsWith("org.apache.xml") ||
+              classname.startsWith("org.apache.xpath") ||
+              classname.startsWith("org.ietf.") ||
+              classname.startsWith("org.omg.") ||
+              classname.startsWith("org.w3c.") ||
+              classname.startsWith("org.xml.sax.") ||
+              classname.startsWith("sunw.") ||
+              classname.startsWith("sun.") ||
+              classname.startsWith("java.") ||
+              classname.startsWith("javax.") ||
+              classname.startsWith("com.sun.") ||
+              classname.startsWith("junit") ||
+              classname.startsWith("jrockit.") ||
+              classname.startsWith("com.bea.vm.") ||
+              classname.startsWith("$Proxy")
+             )
+      {
+         //Don't weave these system classes
+         return false;
+      }
+      if (ignoreClass(classname)) return false;
+      if (includeClass(classname)) return true;
+      if (excludeClass(classname)) return false;
+      return true;
+   }
+   
+   public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
+         ProtectionDomain protectionDomain, byte[] classfileBuffer) throws Exception
+   {
+      return translate(className, loader, classfileBuffer);
+   }
+
+   public byte[] translate(String className, ClassLoader loader, byte[] classfileBuffer) throws Exception
+   {
+      try
+      {
+         if (!isWeavable(className))
+         {
+            return null;
+         }
+         lock.lockRead();
+         try
+         {
+            synchronized(this){
+               if (weavingStrategy == null)
+               {
+                  if (TransformerCommon.isCompileTime())
+                  {
+                     weavingStrategy = new ClassicWeavingStrategy();
+                  }
+                  else if(InstrumentorFactory.getInstrumentor(this,dynamicStrategy.getJoinpointClassifier())
+                        instanceof GeneratedAdvisorInstrumentor)
+                  {
+                     weavingStrategy = new SuperClassesFirstWeavingStrategy();
+                  }
+                  else
+                  {
+                     weavingStrategy = new ClassicWeavingStrategy();
+                  }
+               }
+      
+               return weavingStrategy.translate(this, className, loader, classfileBuffer);
+            }
+         }
+         finally
+         {
+            lock.unlockRead();
+         }
+      }
+      catch (Exception e)
+      {
+         // AutoGenerated
+         throw new RuntimeException(e);
+      }
+   }
+
+   public void unregisterClassLoader(ClassLoader loader)
+   {
+   }
+
+   private boolean ignoreClass(String classname)
+   {
+      List<String> ignore = AOPSystem.getConfiguration().getIgnore();
+      if (ignore == null) return false;
+      ClassExpression[] ignoreExprs = AOPSystem.getConfiguration().getIgnoreExpressions();
+      for (int i = 0; i < ignoreExprs.length; i++)
+      {
+         if(ignoreExprs[i].matches(classname)) return true;
+      }
+      return false;
+   }
+
+   public boolean includeClass(String classname)
+   {
+      List<String> include = AOPSystem.getConfiguration().getInclude();
+      if (include == null) return false;
+      for (int i = 0; i < include.size(); i++)
+      {
+         String str = include.get(i);
+         if (classname.startsWith(str)) return true;
+      }
+      return false;
+   }
+
+   public boolean excludeClass(String classname)
+   {
+      List<String> exclude = AOPSystem.getConfiguration().getExclude();
+      if (exclude == null) return false;
+      for (int i = 0; i < exclude.size(); i++)
+      {
+         String str = exclude.get(i);
+         if (str.equals("*")) return true;
+         if (classname.startsWith(str)) return true;
+      }
+      return false;
+   }
+
+
+}

Copied: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/LoadInterceptedClassesStrategy.java (from rev 84503, projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/LoadInterceptedClassesStrategy.java)
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/LoadInterceptedClassesStrategy.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/LoadInterceptedClassesStrategy.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,97 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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 javassist.CodeConverter;
+import javassist.CtClass;
+import javassist.CtField;
+
+import org.jboss.aop.instrument.DynamicTransformationObserver;
+import org.jboss.aop.instrument.JoinpointClassifier;
+import org.jboss.aop.instrument.JoinpointSimpleClassifier;
+
+
+/**
+ * Dynamic AOP Strategy that instruments prepared classes code
+ * for interception before they get loaded in the system.
+ * This way, no change to a class code has to be made during runtime. 
+ * @author Flavia Rainone
+ */
+class LoadInterceptedClassesStrategy implements DynamicAOPStrategy
+{
+   /**
+    * Dummy DynamicTransformationObserver. No action is need when a dynamic
+    * transformation occurs.
+    */
+   private DynamicTransformationObserver dynamicTransformationObserver = 
+      new DynamicTransformationObserver(){
+      public void fieldReadDynamicalyWrapped(CtField field) {}
+      public void fieldWriteDynamicalyWrapped(CtField field) {}
+      public void constructorDynamicalyWrapped() {}
+      public void transformationFinished(CtClass clazz, CodeConverter converter) {}
+   };
+   
+   /**
+    * Simple classifier to be used during transformation.
+    */
+   JoinpointClassifier joinpointClassifier = new JoinpointSimpleClassifier();
+
+   /**
+    * Returns <code>null</code> because, as long as no runtime action is required
+    * in this strategy, no observer is required.
+    * @see org.jboss.aop.DynamicAOPStrategy#getInterceptorChainObserver(Class)
+    */
+   public InterceptorChainObserver getInterceptorChainObserver(Class<?> clazz)
+   {
+      return null;
+   }
+   
+   /**
+    * Notifies the strategy that one or more interceptor chains in the
+    * system may have been updated.
+    * This method does nothing because no runtime action is required.
+    * @see org.jboss.aop.DynamicAOPStrategy#interceptorChainsUpdated()
+    */
+   public void interceptorChainsUpdated() { }
+   
+   /**
+    * Returns a <code>org.jboss.aop.instrument.JoinpointSimpleClassifier</code>
+    * instance. This classifier assures that prepared classes will be fully instrumented
+    * for interception before they get loaded in the system.
+    * @see org.jboss.aop.DynamicAOPStrategy#getJoinpointClassifier()
+    */
+   public JoinpointClassifier getJoinpointClassifier()
+   {
+      return this.joinpointClassifier;
+   }
+   
+   /**
+    * Returns a dynamic transformation observer to be notified of the dynamic
+    * events during the <code>clazz</code> transformation. This observer does nothing
+    * because no action is required when a dynamic transformation happens.
+    * @see org.jboss.aop.DynamicAOPStrategy#getJoinpointClassifier()
+    */
+   public DynamicTransformationObserver getDynamicTransformationObserver(CtClass clazz)
+   {
+      return this.dynamicTransformationObserver; 
+   }
+}
\ No newline at end of file

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/metadata/DefaultMetaDataFactory.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/metadata/DefaultMetaDataFactory.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/metadata/DefaultMetaDataFactory.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,45 @@
+/*
+* 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.plugins.metadata;
+
+import org.jboss.aop.pointcut.CFlow;
+import org.jboss.aop.pointcut.CFlowStack;
+import org.jboss.aop.spi.metadata.MetaDataFactory;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultMetaDataFactory implements MetaDataFactory
+{
+   public CFlowStack createCFlowStack(String name)
+   {
+      return new org.jboss.aop.pointcut.CFlowStack(name);
+   }
+
+   public void addCFlowToCFlowStack(CFlowStack stack, String expr, boolean not)
+   {
+      CFlow cflow = new CFlow(expr, not);
+      stack.addCFlow(cflow);
+   }
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPSystem.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPSystem.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPSystem.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,101 @@
+/*
+* 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.spi;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.jboss.aop.util.logging.AOPLogger;
+import org.jboss.logging.Logger;
+
+/**
+ * Main entry point to the AOP system. Singleton factory to get hold of the other spi entry points
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AOPSystem
+{
+   private static final Logger STATIC_LOGGER = Logger.getLogger(AOPSystem.class);
+   protected final AOPLogger log = AOPLogger.getLogger(this.getClass());
+   
+   protected static final AOPSystem INSTANCE;
+   
+   protected final Configuration CONFIGURATION;
+   static
+   {
+      INSTANCE = initialiseAOPSystem();
+   }
+   
+   protected AOPSystem()
+   {
+      CONFIGURATION = initialiseConfiguration();
+   }
+   
+   public static Configuration getConfiguration()
+   {
+      return INSTANCE.CONFIGURATION;
+   }
+
+   private static AOPSystem initialiseAOPSystem()
+   {
+      String name = AccessController.doPrivileged(new PrivilegedAction<String>() {
+         public String run()
+         {
+            return System.getProperty(ConfigurationProperties.AOP_SYSTEM, ConfigurationProperties.AOP_SYSTEM_DEFAULT);
+         }});
+      STATIC_LOGGER.debug("Initialising AOPFactory to " + name);
+      try
+      {
+         Class<?> clazz = Class.forName(name);
+         return (AOPSystem)clazz.newInstance();
+      }
+      catch (Exception e)
+      {
+         STATIC_LOGGER.error("Could not initialise AOPFactory instance", e);
+         throw new RuntimeException(e);
+      }
+   }
+
+   private static Configuration initialiseConfiguration()
+   {
+      String name = AccessController.doPrivileged(new PrivilegedAction<String>() {
+         public String run()
+         {
+            return System.getProperty(ConfigurationProperties.CONFIGURATION, ConfigurationProperties.CONFIGURATION_DEFAULT);
+         }});
+      STATIC_LOGGER.debug("Initialising Configuration to " + name);
+      try
+      {
+         Class<?> clazz = Class.forName(name);
+         
+         Configuration configuration = (Configuration)clazz.newInstance();
+         return configuration;
+      }
+      catch (Exception e)
+      {
+         STATIC_LOGGER.error("Could not initialise Configuration instance", e);
+         throw new RuntimeException(e);
+      }
+   }
+
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AbstractAOPSystem.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AbstractAOPSystem.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AbstractAOPSystem.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,85 @@
+/*
+* 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.spi;
+
+/**
+ * Internal interface mandating methods an AOPSystem must implement.
+ * It is there for users wishing to create an alternative AOPSystem,
+ * but is not meant for any other use. The only caller should be
+ * {@link AOPSystem}. Implementation classes must provide a public 
+ * constructor with the same signature as {@link AbstractAOPSystem#AbstractAOPSystem(AOPSystem)}
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractAOPSystem
+{
+   /**
+    * Creates the AbstractAOPSystem. Implementing classes must provide a 
+    * public constructor with the same signature as this 
+    */
+   public AbstractAOPSystem(AOPSystem system)
+   {
+      
+   }
+   
+   /**
+    * Initialise the AOP System with a Configuration object
+    * @param system The calling AOPSystem
+    * @param configuration The Configuration object
+    */
+   protected abstract void setConfiguration(AOPSystem system, Configuration configuration);
+
+   /**
+    * Get the Configuration object
+    * @param system The calling AOPSystem
+    * @return The Configuration object
+    */
+   protected abstract Configuration getConfiguration(AOPSystem system);
+   
+   
+   /**
+    * Initialise the root Manager. This method will be called from within a privileged block. 
+    * @param system The calling AOPSystem
+    */
+   protected abstract void initRootManager(AOPSystem system);
+   
+   /**
+    * Get the root manager
+    * @param system The calling AOPSystem
+    * @return The Configuration object
+    */
+   protected abstract Manager getRootManager(AOPSystem system);
+   
+   /**
+    * Initialise the weaver to be used. This method will be called from withing a privileged block
+    * @param system The calling AOPSystem
+    */
+   protected abstract void initWeaver(AOPSystem system);
+   
+   /**
+    * Get the weaver to use
+    * @param system The calling AOPSystem
+    * @return The weaver
+    */
+   protected abstract Weaver getWeaver(AOPSystem system);
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Configuration.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Configuration.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Configuration.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,140 @@
+/*
+* 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.spi;
+
+import java.util.List;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.pointcut.ast.ClassExpression;
+
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Configuration
+{
+   /**
+    * Gets whether invocation classes should be generated to avoid reflection when using classic weaving
+    * @return whether to generate invocation classes
+    */
+   boolean isOptimize();
+
+   /**
+    * Sets whether invocation classes should be generated to avoid reflection when using classic weaving
+    * @param optimize true to generate invocation classes
+    */
+   void setOptimize(boolean optimize);
+
+   /**
+    * Gets whether verbose logging should be used by the AOP system
+    * @return whether verbose logging is used
+    */
+   boolean isVerbose();
+
+   /**
+    * Sets whether verbose logging should be used by the AOP system
+    * @param true to use verbose logging
+    */
+   void setVerbose(boolean verbose);
+
+   /**
+    * Gets a list of annotation type names that should be checked in RuntimeInvisible(Parameter)Annotations
+    * @return the annotation types to be checked 
+    */
+   List<String> getIncludedInvisibleAnnotations();
+
+   /**
+    * Sets a list of annotation type names that should be checked in RuntimeInvisible(Parameter)Annotations
+    * @param annotationNames the annotation types to be checked 
+    */
+   void setIncludedInvisibleAnnotations(List<String> names);
+
+   /**
+    * Gets a list of class name prefixes that should not be woven
+    * @return the class name prefixes
+    */
+   List<String> getExclude();
+
+   /**
+    * Sets a list of class name prefixes that should not be woven
+    * @param exclude the class name prefixes
+    */
+   void setExclude(List<String> exclude);
+
+   /**
+    * Gets a list of class name prefixes that should be woven although excluded by {@link Configuration#getInclude()}
+    * @return the class name prefixes
+    */
+   List<String> getInclude();
+
+   /**
+    * Sets a list of class name prefixes that should be woven although excluded by {@link Configuration#getExclude()}
+    * @param include the class name prefixes
+    */
+   void setInclude(List<String> include);
+
+   /**
+    * Gets a list of class name patterns that should be not be woven although included by {@link Configuration#getInclude()}
+    * @return the class name patterns
+    */
+   List<String> getIgnore();
+   
+   /**
+    * Gets a list of class expressions that should be not be woven representing the patterns set by {@link Configuration#getIgnore()}
+    * @return the class expressions
+    */
+   ClassExpression[] getIgnoreExpressions();
+   
+   /**
+    * Sets a list of class name patterns that should be not be woven although included by {@link Configuration#getInclude()}
+    * @param the class name patterns
+    */
+   void setIgnore(List<String> ignore);
+
+   /**
+    * Gets whether generated and woven classes should be output to the file system
+    * @return whether the classes should be output
+    */
+   boolean isDebugClasses();
+
+   /**
+    * Sets whether generated and woven classes should be output to the file system
+    * @param debugClasses whether the classes should be output
+    */
+   void setDebugClasses(boolean debugClasses);
+
+   /**
+    * Gets whether or not we should maintain the deprecated {@link Advisor#methodInterceptors} field (boolean). This is required 
+    * in jboss 4.x for backwards compatibility with EJB 3. See JBAOP-517 
+    * @return whether Advisor.methodinterceptors should be maintained
+    */
+   boolean isMaintainAdvisorMethodInterceptors();
+
+   /**
+    * Gets whether or not we should maintain the deprecated {@link Advisor#methodInterceptors} field (boolean). This is required 
+    * in jboss 4.x for backwards compatibility with EJB 3. See JBAOP-517 
+    * @param maintainMethodInterceptors whether Advisor.methodinterceptors should be maintained
+    */
+   void setMaintainAdvisorMethodInterceptors(boolean maintainMethodInterceptors);
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/ConfigurationProperties.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/ConfigurationProperties.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/ConfigurationProperties.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,146 @@
+/*
+* 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.spi;
+
+import org.jboss.aop.plugins.DefaultAOPSystem;
+import org.jboss.aop.plugins.DefaultConfiguration;
+
+/**
+ * Available system properties and default values used in initialising the AOPSystem and its Configuration
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ConfigurationProperties
+{
+   /**
+    * The property name <code>jboss.aop.system</code> used to specify the class name of the main aop system class.
+    * Default value is {@link ConfigurationProperties#AOP_SYSTEM_DEFAULT} 
+    */
+   String AOP_SYSTEM = "jboss.aop.system";
+   
+   /**
+    * The default value for the {@link ConfigurationProperties#AOP_SYSTEM} property is {@link DefaultAOPSystem}
+    */
+   String AOP_SYSTEM_DEFAULT = DefaultAOPSystem.class.getName();
+   
+   /**
+    * The property name <code>jboss.aop.configuration</code> used to specify the configuration class name of the aop system.
+    * Default value is {@link ConfigurationProperties#CONFIGURATION_DEFAULT} 
+    */
+   String CONFIGURATION = "jboss.aop.configuration";
+
+   /**
+    * The default value for the {@link ConfigurationProperties#CONFIGURATION} property is {@link DefaultConfiguration}
+    */
+   String CONFIGURATION_DEFAULT = DefaultConfiguration.class.getName();
+   
+   /**
+    * The property name <code>jboss.aop.optimized</code> used to specify if optimized weaving should be used (boolean).
+    * for the classic weaving mode (boolean).
+    * Default value is {@link ConfigurationProperties#OPTIMIZED_DEFAULT} 
+    */
+   String OPTIMIZED = "jboss.aop.optimized";
+   
+   /**
+    * The default value for the {@link ConfigurationProperties#OPTIMIZED} property (true)
+    */
+   boolean OPTIMIZED_DEFAULT = true;
+   
+   /**
+    * The property name <code>jboss.aop.prune</code> used to specify the classpools should prune classes (boolean).
+    * If not set this is handled by the classpools, currently defaulting to false
+    */
+   String PRUNE = "jboss.aop.prune";
+   
+   /**
+    * The property name <code>jboss.aop.verbose</code> used to specify whether the aop system should log verbosely (boolean).
+    * Default value is {@link ConfigurationProperties#VERBOSE_DEFAULT} 
+    */
+   String VERBOSE = "jboss.aop.verbose";
+
+   /**
+    * The default value for the {@link ConfigurationProperties#VERBOSE} property (false)
+    */
+   boolean VERBOSE_DEFAULT = false;
+   
+   /**
+    * The property name <code>jboss.aop.exclude</code> used to specify a comma-separated list of prefixes
+    * for classes that should not be taken into consideration during the weaving process
+    */
+   String EXCLUDE = "jboss.aop.exclude";
+
+   /**
+    * The property name <code>jboss.aop.include</code> used to specify a comma-separated list of prefixes
+    * for classes that should be taken into consideration during the weaving process even if excluded
+    * by {@link ConfigurationProperties#EXCLUDE}
+    */
+   String INCLUDE = "jboss.aop.include";
+
+   /**
+    * The property name <code>jboss.aop.ignore</code> used to specify a comma-separated list of classname
+    * patterns that should not be taken into consideration during the weaving process even if included
+    * by {@link ConfigurationProperties#INCLUDE}
+    */
+   String IGNORE = "jboss.aop.ignore";
+
+   /**
+    * The property name <code>jboss.aop.invisible.annotations</code> used to specify a comma-separated list of 
+    * annotation type names that should be checked for in RuntimeInvisible(Parameter)Annotations.
+    */
+   String INCLUDED_INVISIBLE_ANNOTATIONS = "jboss.aop.invisible.annotations";
+   
+   /**
+    * The property name <code>jboss.aop.instrumentor</code> used to override the instrumentor class used.
+    */
+   String INSTRUMENTOR = "jboss.aop.instrumentor";
+   
+   /**
+    * The property name <code>jboss.aop.advisor</code> used to override the Advisor class used.
+    */
+   String ADVISOR = "jboss.aop.advisor";
+   
+   /**
+    * The property name <code>jboss.aop.debug.classes</code> used to specify whether woven and generated classes
+    * should be dumped to the filesystem (boolean).
+    * Default value is {@link ConfigurationProperties#DEBUG_CLASSES_DEFAULT} 
+    */
+   String DEBUG_CLASSES = "jboss.aop.debug.classes";
+
+   /**
+    * The default value for the {@link ConfigurationProperties#DEBUG_CLASSES} property (false)
+    */
+   boolean DEBUG_CLASSES_DEFAULT = false;
+   
+   /**
+    * The property name <code>jboss.aop.advisor.methodInterceptors</code> used to set whether or not we should maintain 
+    * the deprecated Advisor.methodInterceptors field (boolean). This is required in jboss 4.x for backwards compatibility 
+    * with EJB 3. See JBAOP-517 
+    * Default value is {@link ConfigurationProperties#MAINTAIN_METHOD_INTERCEPTORS_DEFAULT} 
+    */
+   String MAINTAIN_METHOD_INTERCEPTORS = "jboss.aop.advisor.methodInterceptors";
+   
+   /**
+    * The default value for the {@link ConfigurationProperties#MAINTAIN_METHOD_INTERCEPTORS} property (false)
+    */
+   boolean MAINTAIN_METHOD_INTERCEPTORS_DEFAULT = false;
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Manager.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Manager.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Manager.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,300 @@
+/*
+* 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.spi;
+
+import java.util.Map;
+
+import org.jboss.aop.pointcut.CFlowStack;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Manager
+{
+   CFlowStack getCFlowStack(String name);
+   
+   void addCFlowStack(CFlowStack stack);
+   
+   void removeCFlowStack(String name);
+   
+   Map<String, CFlowStack> getCFlowStacks();
+
+   
+//   InterceptionMarkers getInterceptionMarkers(ClassLoader loader);
+//
+//   Map<String, Pointcut> getPointcuts();
+//
+//   Map<String, PointcutInfo> getPointcutInfos();
+//
+//   DynamicCFlow getDynamicCFlow(String name, ClassLoader cl);
+//
+//   void addDynamicCFlow(String name, DynamicCFlowDefinition cflow);
+//
+//   void removeDynamicCFlow(String name);
+//
+//   ClassMetaDataLoader findClassMetaDataLoader(String group);
+//
+//   void addClassMetaDataLoader(String group, ClassMetaDataLoader loader);
+//
+//   void removeClassMetaDataLoader(String group);
+//
+//   Map<Class<?>, WeakReference<Advisor>> getAdvisors();
+//
+//   Advisor getAdvisor(String name);
+//
+//   Map<String, AdviceBinding> getBindings();
+//
+//   ClassifiedBindingAndPointcutCollection getBindingCollection();
+//
+//   Map<Class<?>, WeakReference<Domain>> getSubDomainsPerClass();
+//
+//   Advisor findAdvisor(Class<?> clazz);
+//
+//   AspectManager findManagerByName(String fqn);
+//
+//   AspectManager findManagerByName(String[] nameparts);
+//
+//   String getManagerFQN();
+//
+//   ClassAdvisor getAdvisorIfAdvised(Class<?> clazz);
+//
+//   Advisor getAnyAdvisorIfAdvised(Class<?> clazz);
+//
+//   ClassAdvisor getAdvisor(Class<?> clazz);
+//
+//   void initialiseClassAdvisor(Class<?> clazz, ClassAdvisor advisor);
+//
+//   boolean isAdvisorRegistered(Advisor advisor);
+//
+//   ClassPool findClassPool(ClassLoader cl);
+//   
+//   ClassPool findClassPool(Class<?> clazz);
+//
+//   ClassPool getRegisteredClassPool(ClassLoader cl);
+//
+//   ClassPool registerClassLoader(ClassLoader ucl);
+//
+//   void unregisterClassLoader(ClassLoader cl);
+//
+//   ArrayList<String> getExclude();
+//
+//   void setExclude(ArrayList<String> exclude);
+//
+//   ArrayList<String> getInclude();
+//
+//   void setInclude(ArrayList<String> include);
+//
+//   ArrayList<String> getIgnore();   
+//   
+//   List<String> getIncludedInvisibleAnnotations();
+//   
+//   void setIncludedInvisibleAnnotations(List<String> ia);
+//
+//   ClassExpression[] getIgnoreExpressions();
+//
+//   void setIgnore(ArrayList<String> ignore);
+//
+//   boolean ignoreClass(String classname);
+//
+//   boolean includeClass(String classname);
+//
+//   boolean excludeClass(String classname);
+//
+//   boolean isNonAdvisableClassName(String classname);
+//
+//   byte[] transform(ClassLoader loader,
+//                           String className,
+//                           @SuppressWarnings(value= {"all"}) Class classBeingRedefined,
+//                           ProtectionDomain protectionDomain,
+//                           byte[] classfileBuffer)
+//           throws Exception;
+//
+//   byte[] translate(String className, ClassLoader loader) throws Exception;
+//
+//   byte[] translate(String className, ClassLoader loader, byte[] classfileBuffer) throws Exception;
+//
+//   void addInterceptorFactory(String name, InterceptorFactory factory);
+//
+//   void removeInterceptorFactory(String name);
+//
+//   Map<String, InterceptorFactory> getInterceptorFactories();
+//
+//   InterceptorFactory getInterceptorFactory(String name);
+//
+//   void addPrecedence(PrecedenceDef precedenceDef);
+//
+//   void removePrecedence(String name);
+//
+//   Map<String, PrecedenceDef> getPrecedenceDefs();
+//
+//   PrecedenceDefEntry[] getSortedPrecedenceDefEntries();
+//
+//   void addAdviceStack(AdviceStack stack);
+//
+//   void removeInterceptorStack(String name);
+//
+//   AdviceStack getAdviceStack(String name);
+//
+//   ClassAdvisor getTempClassAdvisor(CtClass clazz) throws Exception;
+//
+//   Advisor getTempClassAdvisorIfNotExist(Class<?> clazz);
+//
+//   DomainDefinition getContainer(String name);
+//
+//   void addContainer(DomainDefinition def);
+//
+//   void removeContainer(String name);
+//
+//   Pointcut getPointcut(String name);
+//
+//   void removePointcut(String name);
+//
+//   void addPointcut(Pointcut pointcut);
+//
+//   boolean isExecution();
+//
+//   boolean isConstruction();
+//
+//   boolean isCall();
+//
+//   boolean isWithin();
+//
+//   boolean isWithincode();
+//
+//   boolean isGet();
+//
+//   boolean isSet();
+//
+//   void removeBinding(String name);
+//
+//   void removeBindings(ArrayList<String> binds);
+//
+//   void addBinding(AdviceBinding binding);
+//
+//   void updateAdvisorsForAddedBinding(AdviceBinding binding, Set<Advisor> handledAdvisors);
+//
+//   void removeClassMetaData(String name);
+//
+//   void internalRemoveClassMetaData(String name);
+//
+//   void addClassMetaData(ClassMetaDataBinding meta);
+//
+//   InterfaceIntroduction getInterfaceIntroduction(String name);
+//
+//   void addInterfaceIntroduction(InterfaceIntroduction pointcut);
+//
+//   void removeInterfaceIntroduction(String name);
+//
+//   ArrayReplacement getArrayReplacement(String name);
+//
+//   void addArrayReplacement(ArrayReplacement pointcut);
+//
+//   void removeArrayReplacement(String name);
+//
+//   ArrayBinding getArrayBinding(String name);
+//
+//   void addArrayBinding(ArrayBinding binding);
+//
+//   void removeArrayBinding(String name);
+//
+//   void addAnnotationIntroduction(AnnotationIntroduction pointcut);
+//
+//   void removeAnnotationIntroduction(AnnotationIntroduction pointcut);
+//
+//   List<AnnotationIntroduction> getAnnotationIntroductions();
+//
+//   void addDeclare(DeclareDef declare);
+//
+//   void removeDeclare(String name);
+//
+//   Iterator<DeclareDef> getDeclares();
+//
+//   void addAnnotationOverride(AnnotationIntroduction pointcut);
+//
+//   void updateAdvisorsForAddedAnnotationOverride(AnnotationIntroduction introduction);
+//
+//   void removeAnnotationOverride(AnnotationIntroduction pointcut);
+//
+//   List<AnnotationIntroduction> getAnnotationOverrides();
+//
+//   Object getPerVMAspect(AspectDefinition def);
+//
+//   Object getPerVMAspect(String def);
+//
+//   Object createPerVmAspect(String def, AspectDefinition adef, ClassLoader scopedClassLoader);
+//
+//   void addAspectDefinition(AspectDefinition def);
+//
+//   void removeAspectDefinition(String name);
+//
+//   Map<String, AspectDefinition> getAspectDefinitions();
+//
+//   AspectDefinition getAspectDefinition(String name);
+//
+//   void addTypedef(Typedef def) throws Exception;
+//
+//   void removeTypedef(String name);
+//
+//   Typedef getTypedef(String name);
+//
+//   Map<String, InterfaceIntroduction> getInterfaceIntroductions();
+//
+//   Map<String, ArrayReplacement> getArrayReplacements();
+//
+//   Map<String, Typedef> getTypedefs();
+//
+//   Map<String, AdviceStack> getInterceptorStacks();
+//
+//   Map<String, ClassMetaDataLoader> getClassMetaDataLoaders();
+//
+//   Map<String, CFlowStack> getCflowStacks();
+//
+//   Map<String, DynamicCFlowDefinition> getDynamicCFlows();
+//
+//   Map<String, Object> getPerVMAspects();
+//
+//   Map<String, ClassMetaDataBinding> getClassMetaData();
+//
+//   DynamicAOPStrategy getDynamicAOPStrategy();
+//
+//   void setDynamicAOPStrategy(DynamicAOPStrategy strategy);
+//
+//   void addSubDomainPerClass(Class<?> clazz, Domain domain);
+//
+//   void subscribeSubDomain(Domain domain);
+//
+//   void unsubscribeSubDomain(Domain domain);
+//
+//   Map<Domain, Object> getSubscribedSubDomains();
+//
+//   void addLifecycleDefinition(AspectDefinition def);
+//   
+//   void removeLifecycleDefinition(String name);
+//
+//   void addLifecycleBinding(LifecycleCallbackBinding lifecycleBinding);
+//
+//   Map<String, LifecycleCallbackBinding> getLifecycleBindings();
+//
+//   void removeLifecycleBinding(String name);
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Weaver.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Weaver.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Weaver.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,67 @@
+/*
+* 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.spi;
+
+import org.jboss.aop.DynamicAOPStrategy;
+import org.jboss.util.loading.Translator;
+
+/**
+ * Interface used as the entry point for weaving and associated taske
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Weaver extends Translator
+{
+   /**
+    * Entry point for weaving a class
+    * @param className The name of the class we are loading
+    * @param loader The classloader used to load the class
+    * @param classfileBuffer The bytes that contain the class
+    * @return null if the class has not changed, or the changed bytes if it has
+    */
+   public byte[] translate(String classname, ClassLoader loader, byte[] classfileBuffer) throws Exception;
+   
+   /**
+    * Checks if the class should be woven
+    * @param classname The name of the class being checked
+    * @return True if the class should be woven
+    */
+   boolean isWeavable(String classname);
+   
+   /**
+    * Sets the dynamic aop strategy to be used.
+    * Should be called only before any class is transformed.
+    * @param strategy the new dynamic aop strategy.
+    */
+   //TODO DynamicAOPStrategy needs an SPI interface
+   public void setDynamicAOPStrategy(DynamicAOPStrategy strategy);
+
+
+   /**
+    * Returns the dynamic aop strategy to be used.
+    * @return the dynamic aop strategy
+    */
+   //TODO DynamicAOPStrategy needs an SPI interface
+   public DynamicAOPStrategy getDynamicAOPStrategy();
+
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/metadata/MetaDataFactory.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/metadata/MetaDataFactory.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/metadata/MetaDataFactory.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,36 @@
+/*
+* 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.spi.metadata;
+
+import org.jboss.aop.pointcut.CFlowStack;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MetaDataFactory
+{
+   CFlowStack createCFlowStack(String name);
+   
+   void addCFlowToCFlowStack(CFlowStack stack, String expr, boolean not);
+}

Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/util/CollectionConvert.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/util/CollectionConvert.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/util/CollectionConvert.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,49 @@
+/*
+* 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.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class CollectionConvert
+{
+   public static <E> ArrayList<E> toArrayList(List<E> list)
+   {
+      if (list instanceof ArrayList)
+      {
+         return (ArrayList<E>)list;
+      }
+      
+      ArrayList<E> converted = new ArrayList<E>(list.size());
+      for (Iterator<E> it = list.iterator() ; it.hasNext() ; )
+      {
+         converted.add(it.next());
+      }
+      return converted;
+   }
+}

Added: projects/aop/branches/createspi/aop/src/test/java/org/jboss/test/aop/unit/spi/AOPSystemUnitTestCase.java
===================================================================
--- projects/aop/branches/createspi/aop/src/test/java/org/jboss/test/aop/unit/spi/AOPSystemUnitTestCase.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/test/java/org/jboss/test/aop/unit/spi/AOPSystemUnitTestCase.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,47 @@
+/*
+* 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.test.aop.unit.spi;
+
+import org.jboss.aop.spi.AOPSystem;
+import org.jboss.aop.spi.Configuration;
+import org.jboss.aop.spi.ConfigurationProperties;
+
+import junit.framework.TestCase;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AOPSystemUnitTestCase extends TestCase
+{
+   protected void setUp() throws Exception
+   {
+      System.setProperty(ConfigurationProperties.VERBOSE, "true");
+   }
+
+   public void testCanGetConfiuration()
+   {
+      Configuration config = AOPSystem.getConfiguration();
+      assertNotNull(config);
+   }
+}

Added: projects/aop/branches/createspi/aop/src/test/java/org/jboss/test/aop/unit/spi/ConfigurationUnitTestCase.java
===================================================================
--- projects/aop/branches/createspi/aop/src/test/java/org/jboss/test/aop/unit/spi/ConfigurationUnitTestCase.java	                        (rev 0)
+++ projects/aop/branches/createspi/aop/src/test/java/org/jboss/test/aop/unit/spi/ConfigurationUnitTestCase.java	2009-02-20 11:49:30 UTC (rev 84504)
@@ -0,0 +1,500 @@
+/*
+* 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.test.aop.unit.spi;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.aop.plugins.DefaultConfiguration;
+import org.jboss.aop.pointcut.ast.ClassExpression;
+import org.jboss.aop.spi.Configuration;
+
+import junit.framework.TestCase;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConfigurationUnitTestCase extends TestCase
+{
+   final static String FIRST_CLASS = "class.one"; 
+   final static String SECOND_CLASS = "class.one"; 
+   final static List<String> oneClassList = new ArrayList<String>();
+   final static List<String> twoClassList = new ArrayList<String>();
+   static
+   {
+      oneClassList.add(FIRST_CLASS);
+      twoClassList.add(FIRST_CLASS);
+      twoClassList.add(SECOND_CLASS);
+   }
+   final static String oneClassString = FIRST_CLASS;
+   final static String twoClassString = FIRST_CLASS + ", " + SECOND_CLASS;
+   
+   
+   public void testOptimizedNotSet()
+   {
+      Configuration conf = createConfiguration();
+      assertTrue(conf.isOptimize());
+      conf.setOptimize(false);
+      assertFalse(conf.isOptimize());
+      conf.setOptimize(true);
+      assertTrue(conf.isOptimize());
+   }
+   
+   public void testOptimizedSetTrue()
+   {
+      System.setProperty("jboss.aop.optimized", "true");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertTrue(conf.isOptimize());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.optimized");
+      }
+   }
+   
+   public void testOptimizedSetFalse()
+   {
+      System.setProperty("jboss.aop.optimized", "false");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertFalse(conf.isOptimize());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.optimized");
+      }
+   }
+   
+   public void testVerboseNotSet()
+   {
+      Configuration conf = createConfiguration();
+      assertFalse(conf.isVerbose());
+      conf.setOptimize(true);
+      assertTrue(conf.isOptimize());
+      conf.setOptimize(false);
+      assertFalse(conf.isVerbose());
+   }
+   
+   public void testVerboseSetTrue()
+   {
+      System.setProperty("jboss.aop.verbose", "true");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertTrue(conf.isVerbose());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.verbose");
+      }
+   }
+   
+   public void testVerboseSetFalse()
+   {
+      System.setProperty("jboss.aop.verbose", "false");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertFalse(conf.isVerbose());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.verbose");
+      }
+   }
+   
+   public void testDebugClassesNotSet()
+   {
+      Configuration conf = createConfiguration();
+      assertFalse(conf.isDebugClasses());
+      conf.setDebugClasses(true);
+      assertTrue(conf.isDebugClasses());
+      conf.setDebugClasses(false);
+      assertFalse(conf.isDebugClasses());
+   }
+   
+   public void testDebugClassesSetTrue()
+   {
+      System.setProperty("jboss.aop.debug.classes", "true");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertTrue(conf.isDebugClasses());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.debug.classes");
+      }
+   }
+   
+   public void testDebugClassesSetFalse()
+   {
+      System.setProperty("jboss.aop.debug.classes", "false");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertFalse(conf.isDebugClasses());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.debug.classes");
+      }
+   }
+   
+   public void testMaintainMethodInterceptorsNotSet()
+   {
+      Configuration conf = createConfiguration();
+      assertFalse(conf.isMaintainAdvisorMethodInterceptors());
+      conf.setMaintainAdvisorMethodInterceptors(true);
+      assertTrue(conf.isMaintainAdvisorMethodInterceptors());
+      conf.setMaintainAdvisorMethodInterceptors(false);
+      assertFalse(conf.isMaintainAdvisorMethodInterceptors());
+   }
+   
+   public void testMaintainMethodInterceptorsSetTrue()
+   {
+      System.setProperty("jboss.aop.advisor.methodInterceptors", "true");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertTrue(conf.isMaintainAdvisorMethodInterceptors());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.advisor.methodInterceptors");
+      }
+   }
+   
+   public void testMaintainMethodInterceptorsSetFalse()
+   {
+      System.setProperty("jboss.aop.advisor.methodInterceptors", "false");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertFalse(conf.isMaintainAdvisorMethodInterceptors());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.advisor.methodInterceptors");
+      }
+   }
+   
+   public void testIncludedInvisibleAnnotationsNotSet()
+   {
+      Configuration conf = createConfiguration();
+      assertEmptyCollection(conf.getIncludedInvisibleAnnotations());
+
+      conf.setIncludedInvisibleAnnotations(null);
+      assertEmptyCollection(conf.getIncludedInvisibleAnnotations());
+
+      conf.setIncludedInvisibleAnnotations(oneClassList);
+      assertCollection(oneClassList, conf.getIncludedInvisibleAnnotations());
+      
+      conf.setIncludedInvisibleAnnotations(null);
+      assertEmptyCollection(conf.getIncludedInvisibleAnnotations());
+
+      conf.setIncludedInvisibleAnnotations(twoClassList);
+      assertCollection(twoClassList, conf.getIncludedInvisibleAnnotations());
+   }
+
+   public void testIncludedInvisibleAnnotationsOneEntryList()
+   {
+      System.setProperty("jboss.aop.invisible.annotations", oneClassString);
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertCollection(oneClassList, conf.getIncludedInvisibleAnnotations());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.invisible.annotations");
+      }
+      
+   }
+   
+   public void testIncludedInvisibleAnnotationsTwoEntryList()
+   {
+      System.setProperty("jboss.aop.invisible.annotations", twoClassString);
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertCollection(twoClassList, conf.getIncludedInvisibleAnnotations());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.invisible.annotations");
+      }
+      
+   }
+   
+   public void testIncludedInvisibleAnnotationsEmptyList()
+   {
+      System.setProperty("jboss.aop.invisible.annotations", "");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertEmptyCollection(conf.getIncludedInvisibleAnnotations());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.invisible.annotations");
+      }
+      
+   }
+   
+   public void testIncludeNotSet()
+   {
+      Configuration conf = createConfiguration();
+      assertEmptyCollection(conf.getInclude());
+
+      conf.setInclude(null);
+      assertEmptyCollection(conf.getInclude());
+
+      conf.setInclude(oneClassList);
+      assertCollection(oneClassList, conf.getInclude());
+      
+      conf.setInclude(null);
+      assertEmptyCollection(conf.getInclude());
+
+      conf.setInclude(twoClassList);
+      assertCollection(twoClassList, conf.getInclude());
+   }
+
+   public void testIncludeOneEntryList()
+   {
+      System.setProperty("jboss.aop.include", oneClassString);
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertCollection(oneClassList, conf.getInclude());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.include");
+      }
+      
+   }
+   
+   public void testIncludeTwoEntryList()
+   {
+      System.setProperty("jboss.aop.include", twoClassString);
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertCollection(twoClassList, conf.getInclude());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.include");
+      }
+      
+   }
+   
+   public void testIncludeEmptyList()
+   {
+      System.setProperty("jboss.aop.include", "");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertEmptyCollection(conf.getInclude());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.include");
+      }
+      
+   }
+
+   public void testExcludeNotSet()
+   {
+      Configuration conf = createConfiguration();
+      assertEmptyCollection(conf.getExclude());
+
+      conf.setExclude(null);
+      assertEmptyCollection(conf.getExclude());
+
+      conf.setExclude(oneClassList);
+      assertCollection(oneClassList, conf.getExclude());
+      
+      conf.setExclude(null);
+      assertEmptyCollection(conf.getExclude());
+
+      conf.setExclude(twoClassList);
+      assertCollection(twoClassList, conf.getExclude());
+   }
+
+   public void testExcludeOneEntryList()
+   {
+      System.setProperty("jboss.aop.exclude", oneClassString);
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertCollection(oneClassList, conf.getExclude());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.exclude");
+      }
+      
+   }
+   
+   public void testExcludeTwoEntryList()
+   {
+      System.setProperty("jboss.aop.exclude", twoClassString);
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertCollection(twoClassList, conf.getExclude());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.exclude");
+      }
+      
+   }
+   
+   public void testExcludeEmptyList()
+   {
+      System.setProperty("jboss.aop.exclude", "");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertEmptyCollection(conf.getExclude());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.exclude");
+      }
+      
+   }
+   
+   public void testIgnoreNotSet()
+   {
+      Configuration conf = createConfiguration();
+      assertEmptyCollection(conf.getIgnore());
+
+      conf.setIgnore(null);
+      assertEmptyCollection(conf.getIgnore());
+      assertEmptyArray(conf.getIgnoreExpressions());
+
+      conf.setIgnore(oneClassList);
+      assertCollection(oneClassList, conf.getIgnore());
+      assertCollection(oneClassList, conf.getIgnoreExpressions());
+      
+      conf.setIgnore(null);
+      assertEmptyCollection(conf.getIgnore());
+      assertEmptyArray(conf.getIgnoreExpressions());
+
+      conf.setIgnore(twoClassList);
+      assertCollection(twoClassList, conf.getIgnore());
+      assertCollection(twoClassList, conf.getIgnoreExpressions());
+   }
+
+   public void testIgnoreOneEntryList()
+   {
+      System.setProperty("jboss.aop.ignore", oneClassString);
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertCollection(oneClassList, conf.getIgnore());
+         assertCollection(oneClassList, conf.getIgnoreExpressions());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.ignore");
+      }
+      
+   }
+   
+   public void testIgnoreTwoEntryList()
+   {
+      System.setProperty("jboss.aop.ignore", twoClassString);
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertCollection(twoClassList, conf.getIgnore());
+         assertCollection(twoClassList, conf.getIgnoreExpressions());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.ignore");
+      }
+      
+   }
+   
+   public void testIgnoreEmptyList()
+   {
+      System.setProperty("jboss.aop.ignore", "");
+      try
+      {
+         Configuration conf = createConfiguration();
+         assertEmptyCollection(conf.getIgnore());
+         assertEmptyArray(conf.getIgnoreExpressions());
+      }
+      finally
+      {
+         System.clearProperty("jboss.aop.ignore");
+      }
+      
+   }
+   
+   private Configuration createConfiguration()
+   {
+      return new DefaultConfiguration();
+   }
+
+   private void assertEmptyCollection(List<String> actual)
+   {
+     assertNotNull(actual);
+     assertEquals(0, actual.size());
+   }
+   
+   private void assertEmptyArray(Object[] actual)
+   {
+     assertNotNull(actual);
+     assertEquals(0, actual.length);
+   }
+   
+   private void assertCollection(List<String> expected, List<String> actual)
+   {
+      assertEquals(expected.size(), actual.size());
+      for (int i = 0 ; i < expected.size() ; i++)
+      {
+         assertEquals(expected.get(i), actual.get(i));
+      }
+   }
+   
+   private void assertCollection(List<String> expected, ClassExpression[] actual)
+   {
+      assertEquals(expected.size(), actual.length);
+      for (int i = 0 ; i < expected.size() ; i++)
+      {
+         if (!actual[i].matches(expected.get(i)));
+      }
+   }
+
+}




More information about the jboss-cvs-commits mailing list