[jboss-cvs] JBossAS SVN: r58238 - in projects/microcontainer/trunk: aop-mc-int aop-mc-int/src/main/org/jboss/aop/microcontainer/beans aop-mc-int/src/main/org/jboss/aop/microcontainer/integration container/src/main/org/jboss/repository/plugins/basic container/src/main/org/jboss/repository/spi kernel/src/main/org/jboss/kernel/plugins/dependency

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Nov 9 17:02:56 EST 2006


Author: kabir.khan at jboss.com
Date: 2006-11-09 17:02:35 -0500 (Thu, 09 Nov 2006)
New Revision: 58238

Added:
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilderDelegate.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDeployedChecker.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactoryDelegate.java
Modified:
   projects/microcontainer/trunk/aop-mc-int/build.xml
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataFactory.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactory.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactory.java
   projects/microcontainer/trunk/container/src/main/org/jboss/repository/plugins/basic/BasicMetaDataContextFactory.java
   projects/microcontainer/trunk/container/src/main/org/jboss/repository/spi/MetaDataContextFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java
Log:
Fixes to include the aop/mc integration into jboss 5

Split jboss-aop-mc-int.jar into jboss-aop-mc-int.boot (for jboss/lib/) and jboss-aop-mc-deployer.jar (for jboss/server/xxx/deployers/jboss-aop-jboss5-deployer/). The boot jar contains the hooks (AOPJoinpointFactory, AOPMetaDataContextFactory, AOPDependencyBuilder and the xml stuff) into the mc for AOP, but does not call through to the AOP layer until the classes in the deployer jar become available.

Modify MetaDataContextFactory to take an additional classloader parameter.

Remove hard references to deployer.jar classes from classes in the boot jar.

Only check dependencies and attempt to create proxies for classes that have "advisable names"

Modified: projects/microcontainer/trunk/aop-mc-int/build.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/build.xml	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/aop-mc-int/build.xml	2006-11-09 22:02:35 UTC (rev 58238)
@@ -158,12 +158,36 @@
   <target name="module-jars" depends="init">
 
     <!-- Build jboss-kernel.jar -->
-    <jar jarfile="${build.lib}/${jar.prefix}.jar" manifest="${build.etc}/default.mf">
-      <fileset dir="${build.classes}"/>
-      <fileset dir="${build.resources}">
-         <include name="schema/**"/>
+   <jar jarfile="${build.lib}/${jar.prefix}.jar" manifest="${build.etc}/default.mf">
+     <fileset dir="${build.classes}"/>
+     <fileset dir="${build.resources}">
+        <include name="schema/**"/>
+     </fileset>
+   </jar>
+   <jar jarfile="${build.lib}/${jar.prefix}-boot.jar" manifest="${build.etc}/default.mf">
+     <fileset dir="${build.classes}">
+   	  <include name="org/jboss/aop/microcontainer/beans/xml/*.class"/>
+     	  <include name="org/jboss/aop/microcontainer/beans/AspectBeanMetaDataFactory.class"/>
+        <include name="org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.class"/>
+     	  <include name="org/jboss/aop/microcontainer/integration/AOPDeployedChecker.class"/>
+   	  <include name="org/jboss/aop/microcontainer/integration/AOPJoinpointFactory.class"/>
+        <include name="org/jboss/aop/microcontainer/integration/AOPJoinpointFactoryBuilder.class"/>
+     	 <include name="org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactory.class"/>
+     </fileset>
+     <fileset dir="${build.resources}">
+        <include name="schema/**"/>
+     </fileset>
+   </jar>
+   <jar jarfile="${build.lib}/${jar.prefix}-deployer.jar" manifest="${build.etc}/default.mf">
+      <fileset dir="${build.classes}">
+         <exclude name="org/jboss/aop/microcontainer/beans/xml/*.class"/>
+         <exclude name="org/jboss/aop/microcontainer/beans/AspectBeanMetaDataFactory.class"/>
+         <exclude name="org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.class"/>
+      	<exclude name="org/jboss/aop/microcontainer/integration/AOPDeployedChecker.class"/>
+         <exclude name="org/jboss/aop/microcontainer/integration/AOPJoinpointFactory.class"/>
+         <exclude name="org/jboss/aop/microcontainer/integration/AOPJoinpointFactoryBuilder.class"/>
       </fileset>
-    </jar>
+   </jar>
     <jar jarfile="${build.lib.retro}/${jar.prefix}14.jar" manifest="${build.etc}/default.mf">
       <fileset dir="${build.classes.retro}"/>
       <fileset dir="${build.resources}">

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataFactory.java	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataFactory.java	2006-11-09 22:02:35 UTC (rev 58238)
@@ -84,14 +84,14 @@
       String aspectName = name + "$Aspect";
       AbstractBeanMetaData aspect = new AbstractBeanMetaData();
       aspect.setName(aspectName);
-      aspect.setBean(Aspect.class.getName());
+      aspect.setBean("org.jboss.aop.microcontainer.beans.Aspect");
       aspect.addProperty(new AbstractPropertyMetaData("manager", aspectManager));
       result.add(aspect);
       
       String aspectBindingName = name + "$AspectBinding";
       AbstractBeanMetaData aspectBinding = new AbstractBeanMetaData();
       aspectBinding.setName(aspectBindingName);
-      aspectBinding.setBean(AspectBinding.class.getName());
+      aspectBinding.setBean("org.jboss.aop.microcontainer.beans.AspectBinding");
       aspectBinding.addProperty(new AbstractPropertyMetaData("pointcut", pointcut));
       aspectBinding.addProperty(new AbstractPropertyMetaData("aspect", new AbstractDependencyValueMetaData(aspectName, "definition")));
       aspectBinding.addProperty(new AbstractPropertyMetaData("manager", aspectManager));

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java	2006-11-09 22:02:35 UTC (rev 58238)
@@ -64,7 +64,12 @@
    public Object dispatch() throws Throwable
    {
       Class clazz = constructorInfo.getDeclaringClass().getType();
-      ContainerCache cache = ContainerCache.initialise(AspectManager.instance(), clazz, metaDataContext);
+      AspectManager manager = AspectManager.instance();
+      if (manager.isNonAdvisableClassName(clazz.getName()))
+      {
+         return super.dispatch();
+      }
+      ContainerCache cache = ContainerCache.initialise(manager, clazz, metaDataContext);
       Object target = createTarget(cache);
 
       AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java	2006-11-09 22:02:35 UTC (rev 58238)
@@ -21,311 +21,60 @@
 */ 
 package org.jboss.aop.microcontainer.integration;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
-import org.jboss.aop.Advisor;
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.ReflectiveAspectBinder;
-import org.jboss.aop.advice.AspectDefinition;
-import org.jboss.aop.microcontainer.beans.ManagedAspectDefinition;
-import org.jboss.aop.proxy.container.ContainerCache;
-import org.jboss.aop.util.Advisable;
-import org.jboss.aop.util.ClassInfoMethodHashing;
 import org.jboss.classadapter.plugins.dependency.AbstractDependencyBuilder;
 import org.jboss.classadapter.spi.ClassAdapter;
-import org.jboss.classadapter.spi.Dependency;
-import org.jboss.reflect.plugins.AnnotationValueFactory;
-import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl;
-import org.jboss.reflect.spi.AnnotationAttribute;
-import org.jboss.reflect.spi.AnnotationInfo;
-import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.reflect.spi.ArrayInfo;
-import org.jboss.reflect.spi.ArrayValue;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.StringValue;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.reflect.spi.Value;
-import org.jboss.repository.spi.MetaDataContext;
+import org.jboss.classadapter.spi.DependencyBuilder;
 
 /**
- * 
- * @todo document this class
+ * The existence of this class is the signal to the kernel that we want to use the aop-mc integration.
+ * When deployed in jboss the AOPDependencyBuilderDelegate will be deployed as part of the AspectDeployer,
+ * so we use the "normal" dependecy builder until that has been deployed
+
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision$
  */
 public class AOPDependencyBuilder extends AbstractDependencyBuilder
 {
-   private static final String DEPENDENCY_CLASS_NAME = Dependency.class.getName();
-   private static final String DEPENDENCY_NAME_ATTRIBUTE = "name";
-   private static final IntrospectionTypeInfoFactoryImpl typeInfoFactory = new IntrospectionTypeInfoFactoryImpl();
-
+   DependencyBuilder delegate;
+   
    public List getDependencies(ClassAdapter classAdapter)
    {
-      ClassInfo classInfo = classAdapter.getClassInfo();
-      MetaDataContext metaDataContext = classAdapter.getMetaDataContext();
-      try
+      DependencyBuilder builder = getDependencyBuilderDelegate(classAdapter);
+      if (builder == null)
       {
-         if (classInfo.getName() != null)
-         {
-            //FIXME ClassLoader should be in ClassInfo?
-            ClassLoader loader = classInfo.getType().getClassLoader();
-            if (loader == null)
-            {
-               loader = Thread.currentThread().getContextClassLoader();
-            }
-            Class clazz = loader.loadClass(classInfo.getName());
-
-            Advisor advisor;
-            synchronized (ContainerCache.mapLock)
-            {
-               ContainerCache cache = ContainerCache.initialise(AspectManager.instance(), clazz, metaDataContext);
-               advisor = cache.getAdvisor();
-            }
-            
-            ReflectiveAspectBinder binder = new ReflectiveAspectBinder(clazz, advisor);
-            Set aspects = binder.getAspects();
-            
-            ArrayList<Object> depends = new ArrayList<Object>();
-            if (aspects != null && aspects.size() > 0)
-            {
-               Iterator it = aspects.iterator();
-               while (it.hasNext())
-               {
-                  AspectDefinition def = (AspectDefinition) it.next();
-                  if (def instanceof ManagedAspectDefinition)
-                  {
-                     depends.add(def.getName());
-                  }
-               }
-            }
-            
-            HashSet<Object> annotationDependencies = getAnnotationDependencies(classInfo, metaDataContext);
-            depends.addAll(annotationDependencies);
-            
-            return depends;
-         }
-         return null;
-         
+         return super.getDependencies(classAdapter);
       }
-      catch (ClassNotFoundException e)
-      {
-         throw new RuntimeException(e);
-      }
+      return delegate.getDependencies(classAdapter);
    }
    
-   private HashSet<Object> getAnnotationDependencies(ClassInfo classInfo, MetaDataContext metaDataContext)
+   private synchronized DependencyBuilder getDependencyBuilderDelegate(ClassAdapter classAdapter)
    {
-      try
+      if (delegate != null)
       {
-         HashSet<Object> dependencies = new HashSet<Object>();
-         getClassAnnotationDependencies(classInfo, metaDataContext, dependencies);
-         getMethodAnnotationDependencies(classInfo, metaDataContext, dependencies);
-         return dependencies;
+         return delegate;
       }
-      catch (RuntimeException e)
-      {
-         throw e;
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   private void getClassAnnotationDependencies(ClassInfo classInfo, MetaDataContext metaDataContext, HashSet<Object> dependencies) throws Exception
-   {
-      HashMap<String, ArrayList<String>> realMap = new HashMap<String, ArrayList<String>>();
-      getRealClassAnnotationDependencies(classInfo, realMap);
-      HashMap<String, ArrayList<String>> metaMap = new HashMap<String, ArrayList<String>>();
-      getMetaDataContextClassAnnotationDependencies(metaDataContext, metaMap);
-      addAllDependenciesToSet(dependencies, realMap, metaMap);
-   }
-   
-   private void getRealClassAnnotationDependencies(ClassInfo classInfo, HashMap<String, ArrayList<String>> dependencies) throws Exception
-   {
-      AnnotationValue[] annotations = classInfo.getAnnotations();
       
-      for (int i = 0 ; i < annotations.length ; i++)
+      Class clazz = AOPDeployedChecker.getClassIfExists(
+            classAdapter.getClassLoader(), 
+            "org.jboss.aop.microcontainer.integration.AOPDependencyBuilderDelegate");
+      
+      if (clazz == null)
       {
-         getDependenciesForAnnotation(annotations[i].getType().getName(), annotations[i], dependencies);
+         return null;
       }
-   }
-   
-   private void getMetaDataContextClassAnnotationDependencies(MetaDataContext metaDataContext, HashMap<String, ArrayList<String>> dependencies) throws Exception
-   {
-      if (metaDataContext != null)
-      {
-         for (Iterator it = metaDataContext.getAnnotations().iterator() ; it.hasNext() ; )
-         {
-            Object annotation = it.next();
-            getDependenciesForMetaDataAnnotation(annotation, dependencies);
-         }
-      }
-   }
-   
-   private void getMethodAnnotationDependencies(ClassInfo classInfo, MetaDataContext metaDataContext, HashSet<Object> dependencies) throws Exception
-   {
-      Map methodMap = ClassInfoMethodHashing.getMethodMap(classInfo);
-      if (methodMap != null)
-      {
-         for (Iterator it = methodMap.values().iterator() ; it.hasNext() ; )
-         {
-            MethodInfo method = (MethodInfo)it.next();
-            if (Advisable.isAdvisableMethod(method.getModifiers(), method.getName()))
-            {
-               HashMap<String, ArrayList<String>> classMap = new HashMap<String, ArrayList<String>>();
-               getRealMethodAnnotationDependencies(method, classMap);
-               HashMap<String, ArrayList<String>> overrideMap = new HashMap<String, ArrayList<String>>();
-               getMetaDataContextMethodAnnotationDependencies(method, metaDataContext, overrideMap);
-               addAllDependenciesToSet(dependencies, classMap, overrideMap);
-            }
-         }
-      }
-   }
-   
-   private void getRealMethodAnnotationDependencies(MethodInfo methodInfo, HashMap<String, ArrayList<String>> dependencies) throws Exception
-   {
-      AnnotationValue[] annotations = methodInfo.getAnnotations();
-      if (annotations != null)
-      {
-         for (int i = 0 ; i < annotations.length ; i++)
-         {
-            getDependenciesForAnnotation(annotations[i].getType().getName(), annotations[i], dependencies);
-         }
-      }
-   }
-   
-   private void getMetaDataContextMethodAnnotationDependencies(MethodInfo method, MetaDataContext metaDataContext, HashMap<String, ArrayList<String>> dependencies) throws Exception
-   {
-      if (metaDataContext != null)
-      {
-         long hash = ClassInfoMethodHashing.methodHash(method);
-         List methodAnnotations = metaDataContext.getAnnotationsForMethod(hash);
-         for (Iterator it = methodAnnotations.iterator() ; it.hasNext() ; )
-         {
-            Object annotation = it.next();
-            getDependenciesForMetaDataAnnotation(annotation, dependencies);
-         }
-      }
-   }
-   
-   private void getDependenciesForMetaDataAnnotation(Object annotation, HashMap<String, ArrayList<String>> dependencies) throws Exception
-   {
-      AnnotationInfo info;
-      Class clazz = annotation.getClass().getInterfaces()[0];
+      
       try
       {
-         info = (AnnotationInfo)typeInfoFactory.getTypeInfo(clazz);
+         delegate = (DependencyBuilder)clazz.newInstance();
       }
-      catch (RuntimeException e)
+      catch (Exception e)
       {
-         // AutoGenerated
-         throw new RuntimeException("Error creating annotation for " + clazz.getName(), e);
+         throw new RuntimeException("Error instantiating AOPDependencyBuilderDelegate", e);
       }
-      AnnotationValue value = AnnotationValueFactory.createAnnotationValue(typeInfoFactory, typeInfoFactory, info, annotation);
-      getDependenciesForAnnotation(info.getType().getName(), value, dependencies);
-   }
-   
-   private void getDependenciesForAnnotation(String topLevelAnnotationName, AnnotationValue annotation, HashMap<String, ArrayList<String>> dependencies)
-   {
-      if (annotation != null)
-      {
-         addAnnotationAttributeDependencies(topLevelAnnotationName, annotation, dependencies);
-         
-         AnnotationValue[] annotationAnnotations = annotation.getAnnotationType().getAnnotations();
-         for (int i = 0 ; i < annotationAnnotations.length ; i++)
-         {
-            if (annotationAnnotations[i].getAnnotationType().getName().equals(DEPENDENCY_CLASS_NAME))
-            {
-               StringValue value = (StringValue)annotationAnnotations[i].getValue(DEPENDENCY_NAME_ATTRIBUTE);
-               StringValue dependency = (StringValue)annotation.getValue(value.getValue());
-               addDependency(topLevelAnnotationName, dependency, dependencies);
-            }
-         }
-      }
-   }
-   
-   private void addAnnotationAttributeDependencies(String topLevelAnnotationName, AnnotationValue annotation, HashMap<String, ArrayList<String>> dependencies)
-   {
-      MethodInfo[] attributes = annotation.getAnnotationType().getDeclaredMethods();
-      if (attributes != null)
-      {
-         for (int i = 0 ; i < attributes.length ; i++)
-         {
-            Value value = annotation.getValue(attributes[i].getName());
-            
-            if (value instanceof AnnotationValue)
-            {
-               getDependenciesForAnnotation(topLevelAnnotationName, (AnnotationValue)value, dependencies);
-            }
-            else if (value instanceof ArrayValue)
-            {
-               ArrayValue arrVal = (ArrayValue)value;
-               TypeInfo type = ((ArrayInfo)arrVal.getType()).getComponentType();
-               if (type instanceof AnnotationInfo)
-               {
-                  Value[] values = arrVal.getValues();
-                  for (int j = 0 ; j < values.length ; j++)
-                  {
-                     getDependenciesForAnnotation(topLevelAnnotationName, (AnnotationValue)values[j], dependencies);
-                  }
-               }
-            }
-         }
-      }
-   }
-   
-   private void addDependency(String topLevelAnnotationName, StringValue dependency, HashMap<String, ArrayList<String>> dependencies)
-   {
-      ArrayList<String> list = dependencies.get(topLevelAnnotationName);
-      if (list == null)
-      {
-         list = new ArrayList<String>();
-         dependencies.put(topLevelAnnotationName, list);
-      }
       
-      list.add(dependency.getValue());
+      return delegate;
    }
-
-   private void addAllDependenciesToSet(HashSet<Object> dependencies, HashMap<String, ArrayList<String>> classMap, HashMap<String, ArrayList<String>> overrideMap)
-   {
-      HashMap<String, ArrayList<String>> dependencyMap = mergeClassAndOverrideMaps(classMap, overrideMap);
-      if (dependencyMap.size() > 0)
-      {
-         for (ArrayList<String> deps : dependencyMap.values())
-         {
-            dependencies.addAll(deps);
-         }
-      }
-   }
-   
-   private HashMap<String, ArrayList<String>> mergeClassAndOverrideMaps(HashMap<String, ArrayList<String>> classMap, HashMap<String, ArrayList<String>> overrideMap)
-   {
-      if (classMap.size() == 0 && overrideMap.size() == 0)
-      {
-         return classMap;
-      }
-      if (classMap.size() > 0 && overrideMap.size() == 0)
-      {
-         return classMap;
-      }
-      if (classMap.size() == 0 && overrideMap.size() > 0)
-      {
-         return overrideMap;
-      }
-      
-      for (String key : overrideMap.keySet())
-      {
-         classMap.put(key, overrideMap.get(key));
-      }
-      return classMap;
-   }
 }

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilderDelegate.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilderDelegate.java	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilderDelegate.java	2006-11-09 22:02:35 UTC (rev 58238)
@@ -0,0 +1,337 @@
+/*
+* 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.microcontainer.integration;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.ReflectiveAspectBinder;
+import org.jboss.aop.advice.AspectDefinition;
+import org.jboss.aop.microcontainer.beans.ManagedAspectDefinition;
+import org.jboss.aop.proxy.container.ContainerCache;
+import org.jboss.aop.util.Advisable;
+import org.jboss.aop.util.ClassInfoMethodHashing;
+import org.jboss.classadapter.plugins.dependency.AbstractDependencyBuilder;
+import org.jboss.classadapter.spi.ClassAdapter;
+import org.jboss.classadapter.spi.Dependency;
+import org.jboss.reflect.plugins.AnnotationValueFactory;
+import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl;
+import org.jboss.reflect.spi.AnnotationInfo;
+import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.reflect.spi.ArrayInfo;
+import org.jboss.reflect.spi.ArrayValue;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.StringValue;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.Value;
+import org.jboss.repository.spi.MetaDataContext;
+
+/**
+ * Used by the AOPDependencyBuilder once the AspectManager has been installed. Finds all managed aspects that apply 
+ * to the bean and includes their dependencies as dependencies of the bean
+ *  
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AOPDependencyBuilderDelegate extends AbstractDependencyBuilder
+{
+   private static final String DEPENDENCY_CLASS_NAME = Dependency.class.getName();
+   private static final String DEPENDENCY_NAME_ATTRIBUTE = "name";
+   private static final IntrospectionTypeInfoFactoryImpl typeInfoFactory = new IntrospectionTypeInfoFactoryImpl();
+
+   public List getDependencies(ClassAdapter classAdapter)
+   {
+      AspectManager manager = AspectManager.instance();
+      try
+      {
+         ClassInfo classInfo = classAdapter.getClassInfo();
+         String className = classInfo.getName();
+         if (className != null)
+         {
+            if (manager.isNonAdvisableClassName(className))
+            {
+               return super.getDependencies(classAdapter);
+            }
+            
+            MetaDataContext metaDataContext = classAdapter.getMetaDataContext();
+
+            ClassLoader loader = classAdapter.getClassLoader();
+            if (loader == null)
+            {
+               loader = Thread.currentThread().getContextClassLoader();
+            }
+            Class clazz = loader.loadClass(className);
+
+            Advisor advisor;
+            synchronized (ContainerCache.mapLock)
+            {
+               ContainerCache cache = ContainerCache.initialise(manager, clazz, metaDataContext);
+               advisor = cache.getAdvisor();
+            }
+            
+            ReflectiveAspectBinder binder = new ReflectiveAspectBinder(clazz, advisor);
+            Set aspects = binder.getAspects();
+            
+            ArrayList<Object> depends = new ArrayList<Object>();
+            if (aspects != null && aspects.size() > 0)
+            {
+               Iterator it = aspects.iterator();
+               while (it.hasNext())
+               {
+                  AspectDefinition def = (AspectDefinition) it.next();
+                  if (def instanceof ManagedAspectDefinition)
+                  {
+                     depends.add(def.getName());
+                  }
+               }
+            }
+            
+            HashSet<Object> annotationDependencies = getAnnotationDependencies(classInfo, metaDataContext);
+            depends.addAll(annotationDependencies);
+            
+            return depends;
+         }
+         return null;
+         
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   private HashSet<Object> getAnnotationDependencies(ClassInfo classInfo, MetaDataContext metaDataContext)
+   {
+      try
+      {
+         HashSet<Object> dependencies = new HashSet<Object>();
+         getClassAnnotationDependencies(classInfo, metaDataContext, dependencies);
+         getMethodAnnotationDependencies(classInfo, metaDataContext, dependencies);
+         return dependencies;
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   private void getClassAnnotationDependencies(ClassInfo classInfo, MetaDataContext metaDataContext, HashSet<Object> dependencies) throws Exception
+   {
+      HashMap<String, ArrayList<String>> realMap = new HashMap<String, ArrayList<String>>();
+      getRealClassAnnotationDependencies(classInfo, realMap);
+      HashMap<String, ArrayList<String>> metaMap = new HashMap<String, ArrayList<String>>();
+      getMetaDataContextClassAnnotationDependencies(metaDataContext, metaMap);
+      addAllDependenciesToSet(dependencies, realMap, metaMap);
+   }
+   
+   private void getRealClassAnnotationDependencies(ClassInfo classInfo, HashMap<String, ArrayList<String>> dependencies) throws Exception
+   {
+      AnnotationValue[] annotations = classInfo.getAnnotations();
+      
+      for (int i = 0 ; i < annotations.length ; i++)
+      {
+         getDependenciesForAnnotation(annotations[i].getType().getName(), annotations[i], dependencies);
+      }
+   }
+   
+   private void getMetaDataContextClassAnnotationDependencies(MetaDataContext metaDataContext, HashMap<String, ArrayList<String>> dependencies) throws Exception
+   {
+      if (metaDataContext != null)
+      {
+         for (Iterator it = metaDataContext.getAnnotations().iterator() ; it.hasNext() ; )
+         {
+            Object annotation = it.next();
+            getDependenciesForMetaDataAnnotation(annotation, dependencies);
+         }
+      }
+   }
+   
+   private void getMethodAnnotationDependencies(ClassInfo classInfo, MetaDataContext metaDataContext, HashSet<Object> dependencies) throws Exception
+   {
+      Map methodMap = ClassInfoMethodHashing.getMethodMap(classInfo);
+      if (methodMap != null)
+      {
+         for (Iterator it = methodMap.values().iterator() ; it.hasNext() ; )
+         {
+            MethodInfo method = (MethodInfo)it.next();
+            if (Advisable.isAdvisableMethod(method.getModifiers(), method.getName()))
+            {
+               HashMap<String, ArrayList<String>> classMap = new HashMap<String, ArrayList<String>>();
+               getRealMethodAnnotationDependencies(method, classMap);
+               HashMap<String, ArrayList<String>> overrideMap = new HashMap<String, ArrayList<String>>();
+               getMetaDataContextMethodAnnotationDependencies(method, metaDataContext, overrideMap);
+               addAllDependenciesToSet(dependencies, classMap, overrideMap);
+            }
+         }
+      }
+   }
+   
+   private void getRealMethodAnnotationDependencies(MethodInfo methodInfo, HashMap<String, ArrayList<String>> dependencies) throws Exception
+   {
+      AnnotationValue[] annotations = methodInfo.getAnnotations();
+      if (annotations != null)
+      {
+         for (int i = 0 ; i < annotations.length ; i++)
+         {
+            getDependenciesForAnnotation(annotations[i].getType().getName(), annotations[i], dependencies);
+         }
+      }
+   }
+   
+   private void getMetaDataContextMethodAnnotationDependencies(MethodInfo method, MetaDataContext metaDataContext, HashMap<String, ArrayList<String>> dependencies) throws Exception
+   {
+      if (metaDataContext != null)
+      {
+         long hash = ClassInfoMethodHashing.methodHash(method);
+         List methodAnnotations = metaDataContext.getAnnotationsForMethod(hash);
+         for (Iterator it = methodAnnotations.iterator() ; it.hasNext() ; )
+         {
+            Object annotation = it.next();
+            getDependenciesForMetaDataAnnotation(annotation, dependencies);
+         }
+      }
+   }
+   
+   private void getDependenciesForMetaDataAnnotation(Object annotation, HashMap<String, ArrayList<String>> dependencies) throws Exception
+   {
+      AnnotationInfo info;
+      Class clazz = annotation.getClass().getInterfaces()[0];
+      try
+      {
+         info = (AnnotationInfo)typeInfoFactory.getTypeInfo(clazz);
+      }
+      catch (RuntimeException e)
+      {
+         // AutoGenerated
+         throw new RuntimeException("Error creating annotation for " + clazz.getName(), e);
+      }
+      AnnotationValue value = AnnotationValueFactory.createAnnotationValue(typeInfoFactory, typeInfoFactory, info, annotation);
+      getDependenciesForAnnotation(info.getName(), value, dependencies);
+   }
+   
+   private void getDependenciesForAnnotation(String topLevelAnnotationName, AnnotationValue annotation, HashMap<String, ArrayList<String>> dependencies)
+   {
+      if (annotation != null)
+      {
+         addAnnotationAttributeDependencies(topLevelAnnotationName, annotation, dependencies);
+         
+         AnnotationValue[] annotationAnnotations = annotation.getAnnotationType().getAnnotations();
+         for (int i = 0 ; i < annotationAnnotations.length ; i++)
+         {
+            if (annotationAnnotations[i].getAnnotationType().getName().equals(DEPENDENCY_CLASS_NAME))
+            {
+               StringValue value = (StringValue)annotationAnnotations[i].getValue(DEPENDENCY_NAME_ATTRIBUTE);
+               StringValue dependency = (StringValue)annotation.getValue(value.getValue());
+               addDependency(topLevelAnnotationName, dependency, dependencies);
+            }
+         }
+      }
+   }
+   
+   private void addAnnotationAttributeDependencies(String topLevelAnnotationName, AnnotationValue annotation, HashMap<String, ArrayList<String>> dependencies)
+   {
+      MethodInfo[] attributes = annotation.getAnnotationType().getDeclaredMethods();
+      if (attributes != null)
+      {
+         for (int i = 0 ; i < attributes.length ; i++)
+         {
+            Value value = annotation.getValue(attributes[i].getName());
+            
+            if (value instanceof AnnotationValue)
+            {
+               getDependenciesForAnnotation(topLevelAnnotationName, (AnnotationValue)value, dependencies);
+            }
+            else if (value instanceof ArrayValue)
+            {
+               ArrayValue arrVal = (ArrayValue)value;
+               TypeInfo type = ((ArrayInfo)arrVal.getType()).getComponentType();
+               if (type instanceof AnnotationInfo)
+               {
+                  Value[] values = arrVal.getValues();
+                  for (int j = 0 ; j < values.length ; j++)
+                  {
+                     getDependenciesForAnnotation(topLevelAnnotationName, (AnnotationValue)values[j], dependencies);
+                  }
+               }
+            }
+         }
+      }
+   }
+   
+   private void addDependency(String topLevelAnnotationName, StringValue dependency, HashMap<String, ArrayList<String>> dependencies)
+   {
+      ArrayList<String> list = dependencies.get(topLevelAnnotationName);
+      if (list == null)
+      {
+         list = new ArrayList<String>();
+         dependencies.put(topLevelAnnotationName, list);
+      }
+      
+      list.add(dependency.getValue());
+   }
+
+   private void addAllDependenciesToSet(HashSet<Object> dependencies, HashMap<String, ArrayList<String>> classMap, HashMap<String, ArrayList<String>> overrideMap)
+   {
+      HashMap<String, ArrayList<String>> dependencyMap = mergeClassAndOverrideMaps(classMap, overrideMap);
+      if (dependencyMap.size() > 0)
+      {
+         for (ArrayList<String> deps : dependencyMap.values())
+         {
+            dependencies.addAll(deps);
+         }
+      }
+   }
+   
+   private HashMap<String, ArrayList<String>> mergeClassAndOverrideMaps(HashMap<String, ArrayList<String>> classMap, HashMap<String, ArrayList<String>> overrideMap)
+   {
+      if (classMap.size() == 0 && overrideMap.size() == 0)
+      {
+         return classMap;
+      }
+      if (classMap.size() > 0 && overrideMap.size() == 0)
+      {
+         return classMap;
+      }
+      if (classMap.size() == 0 && overrideMap.size() > 0)
+      {
+         return overrideMap;
+      }
+      
+      for (String key : overrideMap.keySet())
+      {
+         classMap.put(key, overrideMap.get(key));
+      }
+      return classMap;
+   }
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDeployedChecker.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDeployedChecker.java	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDeployedChecker.java	2006-11-09 22:02:35 UTC (rev 58238)
@@ -0,0 +1,59 @@
+/*
+* 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.microcontainer.integration;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AOPDeployedChecker
+{
+   public static Class getClassIfExists(ClassLoader beanLoader, String className)
+   {
+      Class clazz = attemptLoadClass(beanLoader, className);
+      if (clazz != null)
+      {
+         return clazz;
+      }
+      
+      //Try the thread context classloader as well
+      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+      return attemptLoadClass(tcl, className);
+   }
+   
+   private static Class attemptLoadClass(ClassLoader loader, String className)
+   {
+      if (loader != null)
+      {
+         try
+         {
+            return loader.loadClass(className);
+         }
+         catch(ClassNotFoundException e)
+         {
+            return null;
+         }
+      }
+      return null;
+   }
+}

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactory.java	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactory.java	2006-11-09 22:02:35 UTC (rev 58238)
@@ -21,15 +21,30 @@
 */
 package org.jboss.aop.microcontainer.integration;
 
+import org.jboss.joinpoint.plugins.BasicConstructorJoinPoint;
 import org.jboss.joinpoint.plugins.BasicJoinpointFactory;
 import org.jboss.joinpoint.spi.ConstructorJoinpoint;
 import org.jboss.joinpoint.spi.JoinpointException;
+import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory;
 import org.jboss.reflect.spi.ClassInfo;
 import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.TypeInfoFactory;
 import org.jboss.repository.spi.MetaDataContext;
 
+/**
+ * The existence of this class is the signal to the kernel that we want to use the aop-mc integration.
+ * When deployed in jboss the AOPConstructorJoinpoint will be deployed as part of the AspectDeployer,
+ * so we use "normal" constructor joinpoints until that has been deployed
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision$
+ */
 public class AOPJoinpointFactory extends BasicJoinpointFactory
 {
+   /** The AOPConstructorJoinpoint constructor one it has been loaded */
+   static volatile ConstructorInfo ctorInfo; 
+   
    /**
     * Create a new AOPJoinpointFactory.
     * 
@@ -42,6 +57,74 @@
 
    public ConstructorJoinpoint getConstructorJoinpoint(ConstructorInfo constructorInfo) throws JoinpointException
    {
-      return new AOPConstructorJoinpoint(constructorInfo, metaDataContext);
+      ConstructorInfo info = getAOPJoinpointConstructorInfo(constructorInfo);
+      
+      if (info != null)
+      {
+         return createAOPConstructorJoinpoint(info, constructorInfo);
+      }
+      else
+      {
+         return super.getConstructorJoinpoint(constructorInfo);
+      }
    }
+   
+   private synchronized ConstructorInfo getAOPJoinpointConstructorInfo(ConstructorInfo currentConstructorInfo) throws JoinpointException
+   {
+      if (ctorInfo != null)
+      {
+         return ctorInfo;
+      }
+      
+      Class clazz = AOPDeployedChecker.getClassIfExists(
+            classInfo.getType().getClassLoader(), 
+            "org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint");
+      
+      if (clazz == null)
+      {
+         return null;
+      }
+      
+      TypeInfoFactory factory = new IntrospectionTypeInfoFactory();
+      ClassInfo info = (ClassInfo)factory.getTypeInfo(clazz);
+      ConstructorInfo[] ctors = info.getDeclaredConstructors();
+      for (int i = 0 ; i < ctors.length ; i++)
+      {
+         if (ctors[i].getParameterTypes().length == 2)
+         {
+            if (ctors[i].getParameterTypes()[0].getName().equals(ConstructorInfo.class.getName()) == false)
+            {
+               continue;
+            }
+            
+            if (ctors[i].getParameterTypes()[1].getName().equals(MetaDataContext.class.getName()) == false)
+            {
+               continue;
+            }
+            ctorInfo = ctors[i];
+            break;
+         }
+      }
+      
+      if (ctorInfo == null)
+      {
+         throw new JoinpointException("No constructor found with the reqiured signature AOPConstructorJoinpoint(ConstructorInfo, MetadataContext)");
+      }
+      return ctorInfo;
+   }
+   
+   private ConstructorJoinpoint createAOPConstructorJoinpoint(ConstructorInfo info, ConstructorInfo aopCtorInfo) throws JoinpointException
+   {
+      ConstructorJoinpoint jp = new BasicConstructorJoinPoint(info);
+      jp.setArguments(new Object[] {aopCtorInfo, metaDataContext});
+      try
+      {
+         return (ConstructorJoinpoint)jp.dispatch();
+      }
+      catch (Throwable e)
+      {
+         throw new JoinpointException("Error calling AOPConstructorJoinpoint constructor", e);
+      }
+      
+   }
 }

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactory.java	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactory.java	2006-11-09 22:02:35 UTC (rev 58238)
@@ -23,6 +23,7 @@
 
 import org.jboss.metadata.spi.repository.MetaDataRepository;
 import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
+import org.jboss.repository.plugins.basic.BasicMetaDataContextFactory;
 import org.jboss.repository.spi.MetaDataContext;
 import org.jboss.repository.spi.MetaDataContextFactory;
 
@@ -31,19 +32,49 @@
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  * @version $Revision$
  */
-public class AOPMetaDataContextFactory implements MetaDataContextFactory
+public class AOPMetaDataContextFactory extends BasicMetaDataContextFactory implements MetaDataContextFactory
 {
-
-   public MetaDataContext getMetaDataContext(MetaDataRepository repository, String beanName)
+   MetaDataContextFactory delegate;
+   public MetaDataContext getMetaDataContext(ClassLoader beanLoader, MetaDataRepository repository, String beanName)
    {
-      if (repository instanceof MutableMetaDataRepository)
+      MetaDataContextFactory factoryDelegate = getMetaDataContextFactoryDelegate(beanLoader);
+      if (factoryDelegate == null)
       {
-         return new AOPMetaDataContext((MutableMetaDataRepository)repository, beanName);
+         return super.getMetaDataContext(beanLoader, repository, beanName);
       }
       else
       {
-         throw new RuntimeException("The passed in repository must be of type org.jboss.metadata.spi.repository.MutableMetaDataRepository");
+         return factoryDelegate.getMetaDataContext(beanLoader, repository, beanName);
       }
    }
    
+   private synchronized MetaDataContextFactory getMetaDataContextFactoryDelegate(ClassLoader beanLoader)
+   {
+      if (delegate != null)
+      {
+         return delegate;
+      }
+      
+      Class clazz = AOPDeployedChecker.getClassIfExists(
+            beanLoader, 
+            "org.jboss.aop.microcontainer.integration.AOPMetaDataContextFactoryDelegate");
+      
+      if (clazz == null)
+      {
+         return null;
+      }
+      
+      try
+      {
+         delegate = (MetaDataContextFactory)clazz.newInstance();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Error instantiating AOPMetaDataContextFactoryDelegate", e);
+      }
+      
+      return delegate;
+   }
+   
+   
 }

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactoryDelegate.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactoryDelegate.java	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactoryDelegate.java	2006-11-09 22:02:35 UTC (rev 58238)
@@ -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.microcontainer.integration;
+
+import org.jboss.metadata.spi.repository.MetaDataRepository;
+import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
+import org.jboss.repository.spi.MetaDataContext;
+import org.jboss.repository.spi.MetaDataContextFactory;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AOPMetaDataContextFactoryDelegate implements MetaDataContextFactory
+{
+
+   public MetaDataContext getMetaDataContext(ClassLoader beanLoader, MetaDataRepository repository, String beanName)
+   {
+      if (repository instanceof MutableMetaDataRepository)
+
+      {
+         return new AOPMetaDataContext((MutableMetaDataRepository)repository, beanName);
+      }
+      else
+      {
+         throw new RuntimeException("The passed in repository must be of type org.jboss.metadata.spi.repository.MutableMetaDataRepository");
+      }
+   }
+}

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/repository/plugins/basic/BasicMetaDataContextFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/repository/plugins/basic/BasicMetaDataContextFactory.java	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/repository/plugins/basic/BasicMetaDataContextFactory.java	2006-11-09 22:02:35 UTC (rev 58238)
@@ -33,7 +33,7 @@
 public class BasicMetaDataContextFactory implements MetaDataContextFactory
 {
 
-   public MetaDataContext getMetaDataContext(MetaDataRepository repository, String beanName)
+   public MetaDataContext getMetaDataContext(ClassLoader beanLoader, MetaDataRepository repository, String beanName)
    {
       return null;
    }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/repository/spi/MetaDataContextFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/repository/spi/MetaDataContextFactory.java	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/repository/spi/MetaDataContextFactory.java	2006-11-09 22:02:35 UTC (rev 58238)
@@ -30,5 +30,5 @@
  */
 public interface MetaDataContextFactory
 {
-   MetaDataContext getMetaDataContext(MetaDataRepository repository, String beanName);
+   MetaDataContext getMetaDataContext(ClassLoader beanLoader, MetaDataRepository repository, String beanName);
 }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java	2006-11-09 20:54:40 UTC (rev 58237)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java	2006-11-09 22:02:35 UTC (rev 58238)
@@ -132,7 +132,6 @@
                }
                if (metaCtx != null)
                {
-                  //metaCtx.addPropertyAnnotations(property.getName(), propertyAnnotations);
                   Set propertyInfos = beanInfo.getProperties();
                   if (propertyInfos != null && propertyInfos.size() > 0)
                   {
@@ -159,7 +158,8 @@
 
       MetaDataRepository repository = (MetaDataRepository)repCtx.getTarget();
       MetaDataContextFactory metaFactory = context.getBeanInfo().getMetaDataContextFactory();
-      MetaDataContext metaCtx = metaFactory.getMetaDataContext(repository, (String)context.getName());
+      ClassLoader beanLoader = context.getBeanInfo().getClassInfo().getType().getClassLoader();
+      MetaDataContext metaCtx = metaFactory.getMetaDataContext(beanLoader, repository, (String)context.getName());
       
       if (metaCtx instanceof MutableMetaDataContext == false)
       {




More information about the jboss-cvs-commits mailing list