[jboss-cvs] JBossAS SVN: r60205 - in projects/microcontainer/trunk/aop-mc-int: src/main/org/jboss/aop/microcontainer/beans and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 2 14:26:00 EST 2007
Author: kabir.khan at jboss.com
Date: 2007-02-02 14:26:00 -0500 (Fri, 02 Feb 2007)
New Revision: 60205
Removed:
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
Modified:
projects/microcontainer/trunk/aop-mc-int/build.xml
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBinding.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
Log:
Don't split aop-mc-int into boot and deployer jars
Modified: projects/microcontainer/trunk/aop-mc-int/build.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/build.xml 2007-02-02 19:23:26 UTC (rev 60204)
+++ projects/microcontainer/trunk/aop-mc-int/build.xml 2007-02-02 19:26:00 UTC (rev 60205)
@@ -167,32 +167,6 @@
<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/beans/LifecycleBeanMetaDataFactory.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/beans/LifecycleBeanMetaDataFactory.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 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/AspectBinding.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBinding.java 2007-02-02 19:23:26 UTC (rev 60204)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBinding.java 2007-02-02 19:26:00 UTC (rev 60205)
@@ -139,6 +139,7 @@
AdviceBinding binding = new AdviceBinding(name, pointcut, null);
binding.addInterceptorFactory(new AdviceFactory(aspect, method));
manager.addBinding(binding);
+// System.out.println("----> Added binding " + pointcut);
log.debug("Bound binding " + name);
}
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 2007-02-02 19:23:26 UTC (rev 60204)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java 2007-02-02 19:26:00 UTC (rev 60205)
@@ -21,61 +21,321 @@
*/
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.DependencyBuilder;
+import org.jboss.classadapter.spi.Dependency;
import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.signature.MethodSignature;
+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;
/**
- * 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
-
+ * 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>
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
public class AOPDependencyBuilder extends AbstractDependencyBuilder
{
- DependencyBuilder delegate;
-
+ 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();
+
+ static int i = 0;
public List<Object> getDependencies(ClassAdapter classAdapter, MetaData metaData)
{
- DependencyBuilder builder = getDependencyBuilderDelegate(classAdapter);
- if (builder == null)
+ AspectManager manager = AspectManager.instance();
+ try
{
- return super.getDependencies(classAdapter, metaData);
+ ClassInfo classInfo = classAdapter.getClassInfo();
+ String className = classInfo.getName();
+ if (className != null)
+ {
+ if (manager.isNonAdvisableClassName(className))
+ {
+ return super.getDependencies(classAdapter, metaData);
+ }
+
+ 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, metaData, true);
+ 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, metaData);
+ depends.addAll(annotationDependencies);
+ return depends;
+ }
+ return null;
+
}
- return delegate.getDependencies(classAdapter, metaData);
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
}
- private synchronized DependencyBuilder getDependencyBuilderDelegate(ClassAdapter classAdapter)
+ private HashSet<Object> getAnnotationDependencies(ClassInfo classInfo, MetaData metaData)
{
- if (delegate != null)
+ try
{
- return delegate;
+ HashSet<Object> dependencies = new HashSet<Object>();
+ getClassAnnotationDependencies(classInfo, metaData, dependencies);
+ getMethodAnnotationDependencies(classInfo, metaData, dependencies);
+ return dependencies;
}
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void getClassAnnotationDependencies(ClassInfo classInfo, MetaData metaData, 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>>();
+ getMetaDataClassAnnotationDependencies(metaData, metaMap);
+ addAllDependenciesToSet(dependencies, realMap, metaMap);
+ }
+
+ private void getRealClassAnnotationDependencies(ClassInfo classInfo, HashMap<String, ArrayList<String>> dependencies) throws Exception
+ {
+ AnnotationValue[] annotations = classInfo.getAnnotations();
- Class clazz = AOPDeployedChecker.getClassIfExists(
- classAdapter.getClassLoader(),
- "org.jboss.aop.microcontainer.integration.AOPDependencyBuilderDelegate");
-
- if (clazz == null)
+ for (int i = 0 ; i < annotations.length ; i++)
{
- return null;
+ getDependenciesForAnnotation(annotations[i].getType().getName(), annotations[i], dependencies);
}
-
+ }
+
+ private void getMetaDataClassAnnotationDependencies(MetaData metaData, HashMap<String, ArrayList<String>> dependencies) throws Exception
+ {
+ if (metaData != null)
+ {
+ for (Object annotation : metaData.getAnnotations())
+ {
+ getDependenciesForMetaDataAnnotation(annotation, dependencies);
+ }
+ }
+ }
+
+ private void getMethodAnnotationDependencies(ClassInfo classInfo, MetaData metaData, 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>>();
+ getMetaDataMethodAnnotationDependencies(method, metaData, 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 getMetaDataMethodAnnotationDependencies(MethodInfo method, MetaData metaData, HashMap<String, ArrayList<String>> dependencies) throws Exception
+ {
+ if (metaData != null)
+ {
+ TypeInfo[] typeInfos = method.getParameterTypes();
+ Class[] params = new Class[typeInfos.length];
+ for (int i = 0; i < typeInfos.length; ++i)
+ params[i] = typeInfos[i].getType();
+ MetaData methodMetaData = metaData.getComponentMetaData(new MethodSignature(method.getName(), params));
+ if (methodMetaData != null)
+ {
+ for (Object annotation : methodMetaData.getAnnotations())
+ {
+ getDependenciesForMetaDataAnnotation(annotation, dependencies);
+ }
+ }
+ }
+ }
+
+ private void getDependenciesForMetaDataAnnotation(Object annotation, HashMap<String, ArrayList<String>> dependencies) throws Exception
+ {
+ AnnotationInfo info;
+ Class clazz = annotation.getClass().getInterfaces()[0];
try
{
- delegate = (DependencyBuilder)clazz.newInstance();
+ info = (AnnotationInfo)typeInfoFactory.getTypeInfo(clazz);
}
- catch (Exception e)
+ catch (RuntimeException e)
{
- throw new RuntimeException("Error instantiating AOPDependencyBuilderDelegate", 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);
+ }
- return delegate;
+ 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;
+ }
}
Deleted: 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 2007-02-02 19:23:26 UTC (rev 60204)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilderDelegate.java 2007-02-02 19:26:00 UTC (rev 60205)
@@ -1,340 +0,0 @@
-/*
-* 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.metadata.spi.MetaData;
-import org.jboss.metadata.spi.signature.MethodSignature;
-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;
-
-/**
- * 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<Object> getDependencies(ClassAdapter classAdapter, MetaData metaData)
- {
- AspectManager manager = AspectManager.instance();
- try
- {
- ClassInfo classInfo = classAdapter.getClassInfo();
- String className = classInfo.getName();
- if (className != null)
- {
- if (manager.isNonAdvisableClassName(className))
- {
- return super.getDependencies(classAdapter, metaData);
- }
-
- 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, metaData, true);
- 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, metaData);
- depends.addAll(annotationDependencies);
-
- return depends;
- }
- return null;
-
- }
- catch (ClassNotFoundException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- private HashSet<Object> getAnnotationDependencies(ClassInfo classInfo, MetaData metaData)
- {
- try
- {
- HashSet<Object> dependencies = new HashSet<Object>();
- getClassAnnotationDependencies(classInfo, metaData, dependencies);
- getMethodAnnotationDependencies(classInfo, metaData, dependencies);
- return dependencies;
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- private void getClassAnnotationDependencies(ClassInfo classInfo, MetaData metaData, 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>>();
- getMetaDataClassAnnotationDependencies(metaData, 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 getMetaDataClassAnnotationDependencies(MetaData metaData, HashMap<String, ArrayList<String>> dependencies) throws Exception
- {
- if (metaData != null)
- {
- for (Object annotation : metaData.getAnnotations())
- {
- getDependenciesForMetaDataAnnotation(annotation, dependencies);
- }
- }
- }
-
- private void getMethodAnnotationDependencies(ClassInfo classInfo, MetaData metaData, 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>>();
- getMetaDataMethodAnnotationDependencies(method, metaData, 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 getMetaDataMethodAnnotationDependencies(MethodInfo method, MetaData metaData, HashMap<String, ArrayList<String>> dependencies) throws Exception
- {
- if (metaData != null)
- {
- TypeInfo[] typeInfos = method.getParameterTypes();
- Class[] params = new Class[typeInfos.length];
- for (int i = 0; i < typeInfos.length; ++i)
- params[i] = typeInfos[i].getType();
- MetaData methodMetaData = metaData.getComponentMetaData(new MethodSignature(method.getName(), params));
- if (methodMetaData != null)
- {
- for (Object annotation : methodMetaData.getAnnotations())
- {
- 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;
- }
-}
Deleted: 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 2007-02-02 19:23:26 UTC (rev 60204)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDeployedChecker.java 2007-02-02 19:26:00 UTC (rev 60205)
@@ -1,59 +0,0 @@
-/*
-* 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 2007-02-02 19:23:26 UTC (rev 60204)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactory.java 2007-02-02 19:26:00 UTC (rev 60205)
@@ -21,14 +21,11 @@
*/
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;
/**
* The existence of this class is the signal to the kernel that we want to use the aop-mc integration.
@@ -41,7 +38,6 @@
*/
public class AOPJoinpointFactory extends BasicJoinpointFactory
{
- private ConstructorInfo ctorInfo;
/**
* Create a new AOPJoinpointFactory.
*
@@ -54,68 +50,6 @@
public ConstructorJoinpoint getConstructorJoinpoint(ConstructorInfo constructorInfo) throws JoinpointException
{
- ConstructorInfo info = getAOPJoinpointConstructorInfo(constructorInfo);
-
- if (info != null)
- {
- return createAOPConstructorJoinpoint(info, constructorInfo);
- }
- else
- {
- return super.getConstructorJoinpoint(constructorInfo);
- }
+ return new AOPConstructorJoinpoint(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 == 1)
- {
- if (ctors[i].getParameterTypes()[0].getName().equals(ConstructorInfo.class.getName()) == false)
- {
- continue;
- }
- ctorInfo = ctors[i];
- break;
- }
- }
-
- if (ctorInfo == null)
- {
- throw new JoinpointException("No constructor found with the reqiured signature AOPConstructorJoinpoint(ConstructorInfo)");
- }
- return ctorInfo;
- }
-
- private ConstructorJoinpoint createAOPConstructorJoinpoint(ConstructorInfo info, ConstructorInfo aopCtorInfo) throws JoinpointException
- {
- ConstructorJoinpoint jp = new BasicConstructorJoinPoint(info);
- jp.setArguments(new Object[] {aopCtorInfo});
- try
- {
- return (ConstructorJoinpoint)jp.dispatch();
- }
- catch (Throwable e)
- {
- throw new JoinpointException("Error calling AOPConstructorJoinpoint constructor", e);
- }
- }
}
More information about the jboss-cvs-commits
mailing list