[jboss-cvs] JBossAS SVN: r67291 - in projects/microcontainer/trunk: container/src/main/org/jboss/metadata/plugins/loader and 17 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 20 08:16:23 EST 2007
Author: adrian at jboss.org
Date: 2007-11-20 08:16:22 -0500 (Tue, 20 Nov 2007)
New Revision: 67291
Added:
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/AbstractMutableComponentMetaDataLoader.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/ClassMetaDataRetrievalFactory.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrievalFactory.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/support/
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/support/TestClass1.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/support/TestMetaDataRetrievalFactory.java
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/AOPDependencyBuilder.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/memory/MemoryMetaDataLoader.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/AnnotatedElementMetaDataLoader.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/repository/basic/BasicMetaDataRepository.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/ComponentMutableMetaData.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/repository/MutableMetaDataRepository.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/Scope.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKey.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/ConstructorSignature.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/FieldSignature.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/MethodParametersSignature.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/MethodSignature.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/Signature.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/AnnotatedElementLoaderScopeUnitTestCase.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/test/BasicMutableMetaDataRepositoryUnitTestCase.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/test/MutableMetaDataRepositoryTest.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/scope/support/TestComponentMetaDataRepositoryPopulator.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/scope/test/PopulateMetaDataRepositoryUnitTestCase.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelScopeInfo.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/metadata/basic/BasicKernelMetaDataRepository.java
Log:
[JBMICROCONT-221] - Allow scopes to use qualifiers other than String. Add the notion of MetaDataRetrievalFactory to avoid having to construct explicitly know types/scopes. Also added convience methods for component/member annotations and signatures
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 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -53,8 +53,6 @@
*/
public class AOPConstructorJoinpoint extends BasicConstructorJoinPoint
{
- private final static String[] EMPTY_PARAM_ARRAY = new String[0];
-
AOPProxyFactory proxyFactory = new GeneratedAOPProxyFactory();
/**
@@ -135,22 +133,7 @@
private boolean methodHasAnnotations(MetaData metaData, MethodInfo mi)
{
- TypeInfo[] types = mi.getParameterTypes();
- String[] typeStrings;
-
- if (types.length == 0)
- {
- typeStrings = EMPTY_PARAM_ARRAY;
- }
- else
- {
- typeStrings = new String[types.length];
- for (int j = 0 ; j < types.length ; j++)
- {
- typeStrings[j] = types[j].getName();
- }
- }
- MethodSignature sig = new MethodSignature(mi.getName(), typeStrings);
+ MethodSignature sig = new MethodSignature(mi);
MetaData methodMD = metaData.getComponentMetaData(sig);
if (methodMD != null)
{
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-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -228,11 +228,7 @@
{
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));
+ MetaData methodMetaData = metaData.getComponentMetaData(new MethodSignature(method));
if (methodMetaData != null)
{
for (Object annotation : methodMetaData.getAnnotations())
Added: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/AbstractMutableComponentMetaDataLoader.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/AbstractMutableComponentMetaDataLoader.java (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/AbstractMutableComponentMetaDataLoader.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -0,0 +1,255 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.metadata.plugins.loader;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.metadata.spi.ComponentMutableMetaData;
+import org.jboss.metadata.spi.MutableMetaData;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.signature.Signature;
+import org.jboss.reflect.spi.MemberInfo;
+
+/**
+ * AbstractMutableComponentMetaDataLoader.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractMutableComponentMetaDataLoader extends AbstractMutableMetaDataLoader implements ComponentMutableMetaData
+{
+ /** The component metadata */
+ private volatile Map<Signature, MetaDataRetrieval> components;
+
+ /**
+ * Create a new AbstractMutableComponentMetaDataLoader.
+ */
+ public AbstractMutableComponentMetaDataLoader()
+ {
+ this(false);
+ }
+
+ /**
+ * Create a new AbstractMutableComponentMetaDataLoader.
+ *
+ * @param restricted whether items are restricted
+ */
+ public AbstractMutableComponentMetaDataLoader(boolean restricted)
+ {
+ super(restricted);
+ }
+
+ /**
+ * Create a new AbstractComponentMutableMetaDataLoader.
+ *
+ * @param key the scope key
+ */
+ public AbstractMutableComponentMetaDataLoader(ScopeKey key)
+ {
+ this(key, false);
+ }
+
+ /**
+ * Create a new AbstractComponentMetaDataLoader.
+ *
+ * @param key the scope key
+ * @param restricted whether the context is restricted
+ */
+ public AbstractMutableComponentMetaDataLoader(ScopeKey key, boolean restricted)
+ {
+ super(key, restricted);
+ }
+
+ public boolean isEmpty()
+ {
+ return isNullOrEmpty(components);
+ }
+
+ /**
+ * Is map null or empty.
+ *
+ * @param map the map
+ * @return is null or empty
+ */
+ @SuppressWarnings("unchecked")
+ protected static boolean isNullOrEmpty(Map map)
+ {
+ return map == null || map.isEmpty();
+ }
+
+ public MetaDataRetrieval addComponentMetaDataRetrieval(Signature signature, MetaDataRetrieval component)
+ {
+ if (signature == null)
+ throw new IllegalArgumentException("Null signature");
+
+ if (components == null)
+ components = new ConcurrentHashMap<Signature, MetaDataRetrieval>();
+
+ return components.put(signature, component);
+ }
+
+ public MetaDataRetrieval removeComponentMetaDataRetrieval(Signature signature)
+ {
+ if (signature == null)
+ throw new IllegalArgumentException("Null signature");
+
+ if (components == null)
+ return null;
+
+ return components.remove(signature);
+ }
+
+ public MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature)
+ {
+ if (components == null)
+ return null;
+
+ return components.get(signature);
+ }
+
+ /**
+ * Initialise the retrieval
+ *
+ * @param signature the signature
+ * @return the result
+ */
+ protected MutableMetaData initRetrieval(Signature signature)
+ {
+ MetaDataRetrieval result = getComponentMetaDataRetrieval(signature);
+ if (result == null)
+ {
+ result = initComponentRetrieval(signature);
+ addComponentMetaDataRetrieval(signature, result);
+ }
+ if (result instanceof MutableMetaData == false)
+ throw new IllegalStateException("Component is not mutable: " + signature);
+ return (MutableMetaData) result;
+ }
+
+ /**
+ * Initialise a component metadata retrieval
+ *
+ * @param signature the signature
+ * @return the result
+ */
+ protected abstract MetaDataRetrieval initComponentRetrieval(Signature signature);
+
+ public <T extends Annotation> T addAnnotation(Signature signature, T annotation)
+ {
+ MutableMetaData component = initRetrieval(signature);
+ return component.addAnnotation(annotation);
+ }
+
+ public <T> T addMetaData(Signature signature, String name, T metaData, Class<T> type)
+ {
+ MutableMetaData component = initRetrieval(signature);
+ return component.addMetaData(name, metaData, type);
+ }
+
+ public <T> T addMetaData(Signature signature, T metaData, Class<T> type)
+ {
+ MutableMetaData component = initRetrieval(signature);
+ return component.addMetaData(metaData, type);
+ }
+
+ public <T extends Annotation> T removeAnnotation(Signature signature, Class<T> annotationType)
+ {
+ MutableMetaData component = initRetrieval(signature);
+ return component.removeAnnotation(annotationType);
+ }
+
+ public <T> T removeMetaData(Signature signature, Class<T> type)
+ {
+ MutableMetaData component = initRetrieval(signature);
+ return component.removeMetaData(type);
+ }
+
+ public <T> T removeMetaData(Signature signature, String name, Class<T> type)
+ {
+ MutableMetaData component = initRetrieval(signature);
+ return component.removeMetaData(name, type);
+ }
+
+ public <T extends Annotation> T addAnnotation(Member member, T annotation)
+ {
+ return addAnnotation(Signature.getSignature(member), annotation);
+ }
+
+ public <T extends Annotation> T addAnnotation(MemberInfo member, T annotation)
+ {
+ return addAnnotation(Signature.getSignature(member), annotation);
+ }
+
+ public <T> T addMetaData(Member member, String name, T metaData, Class<T> type)
+ {
+ return addMetaData(Signature.getSignature(member), name, metaData, type);
+ }
+
+ public <T> T addMetaData(Member member, T metaData, Class<T> type)
+ {
+ return addMetaData(Signature.getSignature(member), metaData, type);
+ }
+
+ public <T> T addMetaData(MemberInfo member, String name, T metaData, Class<T> type)
+ {
+ return addMetaData(Signature.getSignature(member), name, metaData, type);
+ }
+
+ public <T> T addMetaData(MemberInfo member, T metaData, Class<T> type)
+ {
+ return addMetaData(Signature.getSignature(member), metaData, type);
+ }
+
+ public <T extends Annotation> T removeAnnotation(Member member, Class<T> annotationType)
+ {
+ return removeAnnotation(Signature.getSignature(member), annotationType);
+ }
+
+ public <T extends Annotation> T removeAnnotation(MemberInfo member, Class<T> annotationType)
+ {
+ return removeAnnotation(Signature.getSignature(member), annotationType);
+ }
+
+ public <T> T removeMetaData(Member member, Class<T> type)
+ {
+ return removeMetaData(Signature.getSignature(member), type);
+ }
+
+ public <T> T removeMetaData(Member member, String name, Class<T> type)
+ {
+ return removeMetaData(Signature.getSignature(member), name, type);
+ }
+
+ public <T> T removeMetaData(MemberInfo member, Class<T> type)
+ {
+ return removeMetaData(Signature.getSignature(member), type);
+ }
+
+ public <T> T removeMetaData(MemberInfo member, String name, Class<T> type)
+ {
+ return removeMetaData(Signature.getSignature(member), name, type);
+ }
+}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/memory/MemoryMetaDataLoader.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/memory/MemoryMetaDataLoader.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/memory/MemoryMetaDataLoader.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -27,8 +27,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.jboss.metadata.plugins.loader.AbstractMutableMetaDataLoader;
-import org.jboss.metadata.spi.ComponentMutableMetaData;
+import org.jboss.metadata.plugins.loader.AbstractMutableComponentMetaDataLoader;
import org.jboss.metadata.spi.retrieval.AnnotationItem;
import org.jboss.metadata.spi.retrieval.AnnotationsItem;
import org.jboss.metadata.spi.retrieval.Item;
@@ -48,7 +47,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
-public class MemoryMetaDataLoader extends AbstractMutableMetaDataLoader implements ComponentMutableMetaData
+public class MemoryMetaDataLoader extends AbstractMutableComponentMetaDataLoader
{
/** The annotations */
private volatile Map<String, BasicAnnotationItem> annotations;
@@ -56,9 +55,6 @@
/** MetaData by name */
private volatile Map<String, BasicMetaDataItem> metaDataByName;
- /** The component metadata */
- private volatile Map<Signature, MetaDataRetrieval> components;
-
/** All annotations */
private volatile BasicAnnotationsItem cachedAnnotationsItem;
@@ -363,53 +359,12 @@
return result.getValue();
}
- public MetaDataRetrieval addComponentMetaDataRetrieval(Signature signature, MetaDataRetrieval component)
- {
- if (signature == null)
- throw new IllegalArgumentException("Null signature");
-
- if (components == null)
- components = new ConcurrentHashMap<Signature, MetaDataRetrieval>();
-
- return components.put(signature, component);
- }
-
- public MetaDataRetrieval removeComponentMetaDataRetrieval(Signature signature)
- {
- if (signature == null)
- throw new IllegalArgumentException("Null signature");
-
- if (components == null)
- return null;
-
- return components.remove(signature);
- }
-
- public MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature)
- {
- if (components == null)
- return null;
-
- return components.get(signature);
- }
-
public boolean isEmpty()
{
- return isNullOrEmpty(annotations) && isNullOrEmpty(metaDataByName) && isNullOrEmpty(components);
+ return isNullOrEmpty(annotations) && isNullOrEmpty(metaDataByName) && super.isEmpty();
}
/**
- * Is map null or empty.
- *
- * @param map the map
- * @return is null or empty
- */
- protected static boolean isNullOrEmpty(Map map)
- {
- return map == null || map.isEmpty();
- }
-
- /**
* Invalidate the annotations item
*/
protected void invalidateAnnotationsItem()
@@ -458,4 +413,10 @@
cachedMetaDatasItem = result;
return result;
}
+
+ @Override
+ protected MetaDataRetrieval initComponentRetrieval(Signature signature)
+ {
+ return new MemoryMetaDataLoader();
+ }
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/AnnotatedElementMetaDataLoader.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/AnnotatedElementMetaDataLoader.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/AnnotatedElementMetaDataLoader.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -62,13 +62,13 @@
Scope scope;
if (annotated instanceof Class)
{
- Class clazz = (Class) annotated;
- scope = new Scope(CommonLevels.CLASS, clazz.getName());
+ Class<?> clazz = Class.class.cast(annotated);
+ scope = new Scope(CommonLevels.CLASS, clazz);
}
else if (annotated instanceof Member)
{
Member member = (Member) annotated;
- scope = new Scope(CommonLevels.JOINPOINT, member.getName());
+ scope = new Scope(CommonLevels.JOINPOINT, member);
}
else
{
@@ -118,12 +118,12 @@
if (annotated instanceof Class)
{
- Class clazz = (Class) annotated;
+ Class<?> clazz = Class.class.cast(annotated);
if (signature instanceof ConstructorSignature)
{
try
{
- Constructor constructor = clazz.getConstructor(signature.getParametersTypes(clazz));
+ Constructor<?> constructor = clazz.getConstructor(signature.getParametersTypes(clazz));
return new AnnotatedElementMetaDataLoader(constructor);
}
catch (NoSuchMethodException e)
@@ -186,7 +186,7 @@
{
if (signature instanceof MethodParametersSignature)
{
- Constructor constructor = (Constructor)annotated;
+ Constructor<?> constructor = Constructor.class.cast(annotated);
Annotation[][] paramAnnotations = constructor.getParameterAnnotations();
MethodParametersSignature sig = (MethodParametersSignature) signature;
return new SimpleMetaDataLoader(paramAnnotations[sig.getParam()]);
Added: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/ClassMetaDataRetrievalFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/ClassMetaDataRetrievalFactory.java (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/ClassMetaDataRetrievalFactory.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metadata.plugins.loader.reflection;
+
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalFactory;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.Scope;
+
+/**
+ * ClassMetaDataRetrievalFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassMetaDataRetrievalFactory implements MetaDataRetrievalFactory
+{
+ /** The singleton instance */
+ public static final ClassMetaDataRetrievalFactory INSTANCE = new ClassMetaDataRetrievalFactory();
+
+ public MetaDataRetrieval getMetaDataRetrieval(Scope scope)
+ {
+ if (scope == null)
+ throw new IllegalArgumentException("Null scope");
+ if (CommonLevels.CLASS.equals(scope.getScopeLevel()) == false)
+ throw new IllegalArgumentException("Not a class scope: " + scope);
+
+ // Not a class
+ Object qualifier = scope.getQualifier();
+ if (qualifier instanceof Class == false)
+ return null;
+
+ Class<?> clazz = Class.class.cast(qualifier);
+ AnnotatedElementMetaDataLoader result = new AnnotatedElementMetaDataLoader(clazz);
+ return result;
+ }
+}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/repository/basic/BasicMetaDataRepository.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/repository/basic/BasicMetaDataRepository.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/repository/basic/BasicMetaDataRepository.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -21,17 +21,23 @@
*/
package org.jboss.metadata.plugins.repository.basic;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import org.jboss.metadata.plugins.loader.reflection.ClassMetaDataRetrievalFactory;
import org.jboss.metadata.plugins.repository.AbstractMetaDataRepository;
import org.jboss.metadata.plugins.repository.visitor.ChildrenMetaDataRepositoryVisitor;
import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
import org.jboss.metadata.spi.repository.visitor.MetaDataRepositoryVisitor;
import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalFactory;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.Scope;
import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.scope.ScopeLevel;
/**
* BasicMetaDataRepository.
@@ -44,9 +50,38 @@
/** The retrievals */
private Map<ScopeKey, MetaDataRetrieval> retrievals = new ConcurrentHashMap<ScopeKey, MetaDataRetrieval>();
+ /** The retrieval factories by scope level */
+ private Map<ScopeLevel, MetaDataRetrievalFactory> factories = new ConcurrentHashMap<ScopeLevel, MetaDataRetrievalFactory>();
+
+ /**
+ * Create a new BasicMetaDataRepository.
+ */
+ public BasicMetaDataRepository()
+ {
+ // ClassMetaData retrieval by default
+ addMetaDataRetrievalFactory(CommonLevels.CLASS, ClassMetaDataRetrievalFactory.INSTANCE);
+ }
+
public MetaDataRetrieval getMetaDataRetrieval(ScopeKey key)
{
- return retrievals.get(key);
+ MetaDataRetrieval result = retrievals.get(key);
+ if (result != null)
+ return result;
+
+ // Is this a single level?
+ Collection<Scope> scopes = key.getScopes();
+ if (scopes.size() != 1)
+ return null;
+
+ // See if we have a factory
+ Scope scope = scopes.iterator().next();
+ ScopeLevel scopeLevel = scope.getScopeLevel();
+ MetaDataRetrievalFactory factory = getMetaDataRetrievalFactory(scopeLevel);
+ if (factory == null)
+ return null;
+
+ // We have a factory, use it
+ return factory.getMetaDataRetrieval(scope);
}
public Set<ScopeKey> getChildren(ScopeKey key)
@@ -84,4 +119,27 @@
throw new IllegalArgumentException("Null key");
return retrievals.remove(key);
}
+
+ public MetaDataRetrievalFactory addMetaDataRetrievalFactory(ScopeLevel level, MetaDataRetrievalFactory factory)
+ {
+ if (level == null)
+ throw new IllegalArgumentException("Null level");
+ if (factory == null)
+ throw new IllegalArgumentException("Null factory");
+ return factories.put(level,factory);
+ }
+
+ public MetaDataRetrievalFactory getMetaDataRetrievalFactory(ScopeLevel level)
+ {
+ if (level == null)
+ throw new IllegalArgumentException("Null level");
+ return factories.get(level);
+ }
+
+ public MetaDataRetrievalFactory removeMetaDataRetrievalFactory(ScopeLevel level)
+ {
+ if (level == null)
+ throw new IllegalArgumentException("Null level");
+ return factories.remove(level);
+ }
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/ComponentMutableMetaData.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/ComponentMutableMetaData.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/ComponentMutableMetaData.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -21,8 +21,12 @@
*/
package org.jboss.metadata.spi;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+
import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
import org.jboss.metadata.spi.signature.Signature;
+import org.jboss.reflect.spi.MemberInfo;
/**
* ComponentMutableMetaData.
@@ -48,4 +52,196 @@
* @return any previous component at that signature
*/
MetaDataRetrieval removeComponentMetaDataRetrieval(Signature signature);
+
+ /**
+ * Add a component annotation
+ *
+ * @param <T> the annotation type
+ * @param signature the signature
+ * @param annotation the annotation
+ * @return any previous annotation
+ */
+ <T extends Annotation> T addAnnotation(Signature signature, T annotation);
+
+ /**
+ * Remove a member annotation
+ *
+ * @param <T> the annotation type
+ * @param signature the signature
+ * @param annotationType the annotation type
+ * @return any previous annotation
+ */
+ <T extends Annotation> T removeAnnotation(Signature signature, Class<T> annotationType);
+
+ /**
+ * Add member metaData
+ *
+ * @param <T> the metadata type
+ * @param signature the signature
+ * @param metaData the meta data
+ * @param type the expected type
+ * @return any previous meta data
+ */
+ <T> T addMetaData(Signature signature, T metaData, Class<T> type);
+
+ /**
+ * Remove member metaData
+ *
+ * @param <T> the metadata type
+ * @param signature the signature
+ * @param type the meta data type
+ * @return any previous meta data
+ */
+ <T> T removeMetaData(Signature signature, Class<T> type);
+
+ /**
+ * Add member metaData
+ *
+ * @param <T> the metadata type
+ * @param signature the signature
+ * @param name the name
+ * @param metaData the meta data
+ * @param type the expected type
+ * @return any previous meta data
+ */
+ <T> T addMetaData(Signature signature, String name, T metaData, Class<T> type);
+
+ /**
+ * Remove member metadata
+ *
+ * @param <T> the metadata type
+ * @param signature the signature
+ * @param name the name of the meta data
+ * @param type the expected type of the metadata
+ * @return the metadata or null if not present
+ */
+ <T> T removeMetaData(Signature signature, String name, Class<T> type);
+
+ /**
+ * Add a component annotation
+ *
+ * @param <T> the annotation type
+ * @param member member
+ * @param annotation the annotation
+ * @return any previous annotation
+ */
+ <T extends Annotation> T addAnnotation(Member member, T annotation);
+
+ /**
+ * Remove a member annotation
+ *
+ * @param <T> the annotation type
+ * @param member member
+ * @param annotationType the annotation type
+ * @return any previous annotation
+ */
+ <T extends Annotation> T removeAnnotation(Member member, Class<T> annotationType);
+
+ /**
+ * Add member metaData
+ *
+ * @param <T> the metadata type
+ * @param member member
+ * @param metaData the meta data
+ * @param type the expected type
+ * @return any previous meta data
+ */
+ <T> T addMetaData(Member member, T metaData, Class<T> type);
+
+ /**
+ * Remove member metaData
+ *
+ * @param <T> the metadata type
+ * @param member member
+ * @param type the meta data type
+ * @return any previous meta data
+ */
+ <T> T removeMetaData(Member member, Class<T> type);
+
+ /**
+ * Add member metaData
+ *
+ * @param <T> the metadata type
+ * @param member member
+ * @param name the name
+ * @param metaData the meta data
+ * @param type the expected type
+ * @return any previous meta data
+ */
+ <T> T addMetaData(Member member, String name, T metaData, Class<T> type);
+
+ /**
+ * Remove member metadata
+ *
+ * @param <T> the metadata type
+ * @param member member
+ * @param name the name of the meta data
+ * @param type the expected type of the metadata
+ * @return the metadata or null if not present
+ */
+ <T> T removeMetaData(Member member, String name, Class<T> type);
+
+ /**
+ * Add a member annotation
+ *
+ * @param <T> the annotation type
+ * @param member member
+ * @param annotation the annotation
+ * @return any previous annotation
+ */
+ <T extends Annotation> T addAnnotation(MemberInfo member, T annotation);
+
+ /**
+ * Remove a member annotation
+ *
+ * @param <T> the annotation type
+ * @param member member
+ * @param annotationType the annotation type
+ * @return any previous annotation
+ */
+ <T extends Annotation> T removeAnnotation(MemberInfo member, Class<T> annotationType);
+
+ /**
+ * Add member metaData
+ *
+ * @param <T> the metadata type
+ * @param member member
+ * @param metaData the meta data
+ * @param type the expected type
+ * @return any previous meta data
+ */
+ <T> T addMetaData(MemberInfo member, T metaData, Class<T> type);
+
+ /**
+ * Remove member metaData
+ *
+ * @param <T> the metadata type
+ * @param member member
+ * @param type the meta data type
+ * @return any previous meta data
+ */
+ <T> T removeMetaData(MemberInfo member, Class<T> type);
+
+ /**
+ * Add member metaData
+ *
+ * @param <T> the metadata type
+ * @param member member
+ * @param name the name
+ * @param metaData the meta data
+ * @param type the expected type
+ * @return any previous meta data
+ */
+ <T> T addMetaData(MemberInfo member, String name, T metaData, Class<T> type);
+
+ /**
+ * Remove member metadata
+ *
+ * @param <T> the metadata type
+ * @param member member
+ * @param name the name of the meta data
+ * @param type the expected type of the metadata
+ * @return the metadata or null if not present
+ */
+ <T> T removeMetaData(MemberInfo member, String name, Class<T> type);
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/repository/MutableMetaDataRepository.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/repository/MutableMetaDataRepository.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/repository/MutableMetaDataRepository.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -22,7 +22,9 @@
package org.jboss.metadata.spi.repository;
import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalFactory;
import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.scope.ScopeLevel;
/**
* MutableMetaDataRepository.
@@ -47,4 +49,29 @@
* @return any previous retrieval
*/
MetaDataRetrieval removeMetaDataRetrieval(ScopeKey key);
+
+ /**
+ * Get a meta data retrieval factory for the given scope level
+ *
+ * @param level the scope level
+ * @return the factory
+ */
+ MetaDataRetrievalFactory getMetaDataRetrievalFactory(ScopeLevel level);
+
+ /**
+ * Add a meta data retrieval factory to the given scope level
+ *
+ * @param level the scope level
+ * @param factory the factory
+ * @return any previous factory
+ */
+ MetaDataRetrievalFactory addMetaDataRetrievalFactory(ScopeLevel level, MetaDataRetrievalFactory factory);
+
+ /**
+ * Remove a meta data retrieval factory for the given scope level
+ *
+ * @param level the scope level
+ * @return any previous factory
+ */
+ MetaDataRetrievalFactory removeMetaDataRetrievalFactory(ScopeLevel level);
}
Added: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrievalFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrievalFactory.java (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrievalFactory.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metadata.spi.retrieval;
+
+import org.jboss.metadata.spi.scope.Scope;
+
+/**
+ * MetaDataRetrievalFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MetaDataRetrievalFactory
+{
+ /**
+ * Get a metadata retrieval
+ *
+ * @param scope the scope
+ * @return the retrieval
+ */
+ MetaDataRetrieval getMetaDataRetrieval(Scope scope);
+}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/Scope.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/Scope.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/Scope.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -38,9 +38,9 @@
private final ScopeLevel level;
/** The scope qualifier */
- private final String qualifier;
+ private final Object qualifier;
- public Scope(ScopeLevel level, String qualifier)
+ public Scope(ScopeLevel level, Object qualifier)
{
if (level == null)
throw new IllegalArgumentException("Null level");
@@ -56,7 +56,7 @@
return level;
}
- public String getQualifier()
+ public Object getQualifier()
{
return qualifier;
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKey.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKey.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKey.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -79,7 +79,7 @@
* @param level the scope level
* @param qualifier the scope qualifier
*/
- public ScopeKey(ScopeLevel level, String qualifier)
+ public ScopeKey(ScopeLevel level, Object qualifier)
{
addScope(level, qualifier);
}
@@ -139,6 +139,19 @@
{
return Collections.unmodifiableCollection(scopes.values());
}
+
+ /**
+ * Get a scope
+ *
+ * @param level the scope level
+ * @return the scope
+ */
+ public Scope getScope(ScopeLevel level)
+ {
+ if (level == null)
+ throw new IllegalArgumentException("Null level");
+ return scopes.get(level);
+ }
/**
* Get the maximum scope level
@@ -221,7 +234,7 @@
* @param qualifier the scope qualifier
* @return the previous value or null if there wasn't one
*/
- public Scope addScope(ScopeLevel level, String qualifier)
+ public Scope addScope(ScopeLevel level, Object qualifier)
{
Scope scope = new Scope(level, qualifier);
return addScope(scope);
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/ConstructorSignature.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/ConstructorSignature.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/ConstructorSignature.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -23,6 +23,8 @@
import java.lang.reflect.Constructor;
+import org.jboss.reflect.spi.ConstructorInfo;
+
/**
* Constructor Signature.
*
@@ -46,7 +48,7 @@
*
* @param parameters the parameters
*/
- public ConstructorSignature(Class... parameters)
+ public ConstructorSignature(Class<?>... parameters)
{
super(parameters);
}
@@ -60,4 +62,14 @@
{
super(constructor.getParameterTypes());
}
+
+ /**
+ * Create a new Signature.
+ *
+ * @param constructor the constructor
+ */
+ public ConstructorSignature(ConstructorInfo constructor)
+ {
+ super(convertParameterTypes(constructor.getParameterTypes()));
+ }
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/FieldSignature.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/FieldSignature.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/FieldSignature.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -23,6 +23,8 @@
import java.lang.reflect.Field;
+import org.jboss.reflect.spi.FieldInfo;
+
/**
* Field Signature.
*
@@ -50,4 +52,14 @@
{
super(field.getName());
}
+
+ /**
+ * Create a new Signature.
+ *
+ * @param field the field
+ */
+ public FieldSignature(FieldInfo field)
+ {
+ super(field.getName());
+ }
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/MethodParametersSignature.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/MethodParametersSignature.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/MethodParametersSignature.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -55,7 +55,7 @@
* @param param the parameter number
* @param parameters the parameters
*/
- public MethodParametersSignature(String name, int param, Class... parameters)
+ public MethodParametersSignature(String name, int param, Class<?>... parameters)
{
super(name, parameters);
this.param = param;
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/MethodSignature.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/MethodSignature.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/MethodSignature.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -23,6 +23,8 @@
import java.lang.reflect.Method;
+import org.jboss.reflect.spi.MethodInfo;
+
/**
* Method Signature.
*
@@ -48,7 +50,7 @@
* @param name the name
* @param parameters the parameters
*/
- public MethodSignature(String name, Class... parameters)
+ public MethodSignature(String name, Class<?>... parameters)
{
super(name, parameters);
}
@@ -62,4 +64,14 @@
{
super(method.getName(), method.getParameterTypes());
}
+
+ /**
+ * Create a new Signature.
+ *
+ * @param method the method
+ */
+ public MethodSignature(MethodInfo method)
+ {
+ super(method.getName(), convertParameterTypes(method.getParameterTypes()));
+ }
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/Signature.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/Signature.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/Signature.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -22,10 +22,20 @@
package org.jboss.metadata.spi.signature;
import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.MemberInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
/**
* Signature.
*
@@ -90,18 +100,98 @@
primitiveArrayTypesClassMap.put("S", Short.TYPE);
}
+ /**
+ * Get a signature for a member
+ *
+ * @param member the member
+ * @return the result
+ */
+ public static Signature getSignature(Member member)
+ {
+ if (member == null)
+ throw new IllegalArgumentException("Null member");
+
+ if (member instanceof Method)
+ {
+ Method method = Method.class.cast(member);
+ return new MethodSignature(method);
+ }
+ if (member instanceof Field)
+ {
+ Field field = Field.class.cast(member);
+ return new FieldSignature(field);
+ }
+ if (member instanceof Constructor)
+ {
+ Constructor<?> constructor = Constructor.class.cast(member);
+ return new ConstructorSignature(constructor);
+ }
+ throw new IllegalArgumentException("Unknown member: " + member);
+ }
+
+ /**
+ * Get a signature for a member info
+ *
+ * @param member the member
+ * @return the result
+ */
+ public static Signature getSignature(MemberInfo member)
+ {
+ if (member == null)
+ throw new IllegalArgumentException("Null member");
+
+ if (member instanceof MethodInfo)
+ {
+ MethodInfo method = MethodInfo.class.cast(member);
+ return new MethodSignature(method);
+ }
+ if (member instanceof FieldInfo)
+ {
+ FieldInfo field = FieldInfo.class.cast(member);
+ return new FieldSignature(field);
+ }
+ if (member instanceof ConstructorInfo)
+ {
+ ConstructorInfo constructor = ConstructorInfo.class.cast(member);
+ return new ConstructorSignature(constructor);
+ }
+ throw new IllegalArgumentException("Unknown member: " + member);
+ }
+
public static String getPrimativeArrayType(String name)
{
return primitiveArrayTypes.get(name);
}
+ public static String[] convertParameters(TypeInfo[] typeInfos)
+ {
+ if (typeInfos == null || typeInfos.length == 0)
+ return NO_PARAMETERS;
+
+ String[] paramTypes = new String[typeInfos.length];
+ for (int i = 0; i < typeInfos.length; ++i)
+ paramTypes[i] = typeInfos[i].getName();
+ return paramTypes;
+ }
+
+ public static Class<?>[] convertParameterTypes(TypeInfo[] typeInfos)
+ {
+ if (typeInfos == null || typeInfos.length == 0)
+ return NO_PARAMETER_TYPES;
+
+ Class<?>[] paramTypes = new Class<?>[typeInfos.length];
+ for (int i = 0; i < typeInfos.length; ++i)
+ paramTypes[i] = typeInfos[i].getType();
+ return paramTypes;
+ }
+
/**
* Convert classes to string
*
* @param parameters the parameters as classes
* @return the parameters as strings
*/
- private static String[] classesToStrings(Class... parameters)
+ private static String[] classesToStrings(Class<?>... parameters)
{
if (parameters == null || parameters.length == 0)
return NO_PARAMETERS;
@@ -123,7 +213,7 @@
* @param parameters the parameters as strings
* @return the parameters as classes
*/
- private static Class[] stringsToClasses(Class clazz, String... parameters)
+ private static Class<?>[] stringsToClasses(Class<?> clazz, String... parameters)
{
if (clazz == null)
throw new IllegalArgumentException("Null clazz");
@@ -177,7 +267,7 @@
// construct array class
return Array.newInstance(componentType, new int[arrayDimension]).getClass();
}
- return cl.loadClass(name);
+ return Class.forName(name, true, cl);
}
/**
@@ -187,7 +277,7 @@
* @param parameters the parameters as strings
* @return the parameters as classes
*/
- private static Class[] stringsToClasses(ClassLoader cl, String... parameters)
+ private static Class<?>[] stringsToClasses(ClassLoader cl, String... parameters)
{
if (cl == null)
throw new IllegalArgumentException("Null classloader");
@@ -243,7 +333,7 @@
*
* @param parameters the parameters
*/
- public Signature(Class... parameters)
+ public Signature(Class<?>... parameters)
{
this(NO_NAME, parameters, null);
}
@@ -254,7 +344,7 @@
* @param name the name
* @param parameters the parameters
*/
- public Signature(String name, Class... parameters)
+ public Signature(String name, Class<?>... parameters)
{
this(name, parameters, null);
}
@@ -277,7 +367,7 @@
* @param parameterTypes the parameterTypes
* @param parameters the parameters
*/
- private Signature(String name, Class[] parameterTypes, String[] parameters)
+ private Signature(String name, Class<?>[] parameterTypes, String[] parameters)
{
this.name = name;
this.parameters = parameters;
@@ -319,7 +409,7 @@
* @param clazz the reference class
* @return the parameter types.
*/
- public Class[] getParametersTypes(Class clazz)
+ public Class<?>[] getParametersTypes(Class<?> clazz)
{
if (parameterTypes == null)
return stringsToClasses(clazz, parameters);
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/AnnotatedElementLoaderScopeUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/AnnotatedElementLoaderScopeUnitTestCase.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/AnnotatedElementLoaderScopeUnitTestCase.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -61,7 +61,7 @@
Scope scope = scopes.iterator().next();
assertEquals(CommonLevels.CLASS, scope.getScopeLevel());
- assertEquals(TestAnnotationScopeBean.class.getName(), scope.getQualifier());
+ assertEquals(TestAnnotationScopeBean.class, scope.getQualifier());
}
public void testFieldScope() throws Exception
@@ -96,6 +96,6 @@
Scope scope = scopes.iterator().next();
assertEquals(CommonLevels.JOINPOINT, scope.getScopeLevel());
- assertEquals(member.getName(), scope.getQualifier());
+ assertEquals(member, scope.getQualifier());
}
}
Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/support/TestClass1.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/support/TestClass1.java (rev 0)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/support/TestClass1.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.test.metadata.repository.support;
+
+import org.jboss.test.metadata.shared.support.TestAnnotation1;
+
+ at TestAnnotation1
+public class TestClass1
+{
+}
Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/support/TestMetaDataRetrievalFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/support/TestMetaDataRetrievalFactory.java (rev 0)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/support/TestMetaDataRetrievalFactory.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.test.metadata.repository.support;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalFactory;
+import org.jboss.metadata.spi.scope.Scope;
+
+/**
+ * TestMetaDataRetrievalFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMetaDataRetrievalFactory implements MetaDataRetrievalFactory
+{
+ public Map<Scope, MetaDataRetrieval> retrievals = new ConcurrentHashMap<Scope, MetaDataRetrieval>();
+
+ public MetaDataRetrieval getMetaDataRetrieval(Scope scope)
+ {
+ return retrievals.get(scope);
+ }
+}
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/test/BasicMutableMetaDataRepositoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/test/BasicMutableMetaDataRepositoryUnitTestCase.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/test/BasicMutableMetaDataRepositoryUnitTestCase.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -22,7 +22,15 @@
package org.jboss.test.metadata.repository.test;
import org.jboss.metadata.plugins.repository.basic.BasicMetaDataRepository;
+import org.jboss.metadata.spi.MetaData;
import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.Scope;
+import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.test.metadata.repository.support.TestClass1;
+import org.jboss.test.metadata.shared.support.TestAnnotation1;
/**
* BasicMutableMetaDataRepositoryUnitTestCase.
@@ -41,4 +49,14 @@
{
return new BasicMetaDataRepository();
}
+
+ public void testAutoClassRetrieval() throws Exception
+ {
+ MutableMetaDataRepository repository = setupEmpty();
+ ScopeKey key = new ScopeKey(new Scope(CommonLevels.CLASS, TestClass1.class));
+ MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(key);
+ assertNotNull(retrieval);
+ MetaData metaData = new MetaDataRetrievalToMetaDataBridge(retrieval);
+ assertNotNull(metaData.getAnnotation(TestAnnotation1.class));
+ }
}
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/test/MutableMetaDataRepositoryTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/test/MutableMetaDataRepositoryTest.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/repository/test/MutableMetaDataRepositoryTest.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -31,6 +31,7 @@
import org.jboss.metadata.spi.scope.ScopeKey;
import org.jboss.metadata.spi.scope.ScopeLevel;
import org.jboss.test.metadata.AbstractMetaDataTest;
+import org.jboss.test.metadata.repository.support.TestMetaDataRetrievalFactory;
/**
* MutableMetaDataRepositoryTest.
@@ -57,6 +58,7 @@
private static Scope testScope3 = new Scope(testLevel3, testQualifier3);
private static ScopeKey testKey1 = new ScopeKey(testScope1);
+ private static ScopeKey testKey2 = new ScopeKey(testScope2);
private static ScopeKey testKey1Different = new ScopeKey(testScope1Different);
private static ScopeKey testKey12 = new ScopeKey(new Scope[] { testScope1, testScope2 });
private static ScopeKey testKey12Different = new ScopeKey(new Scope[] { testScope1, testScope2Different });
@@ -298,6 +300,78 @@
assertEquals(expected, result);
}
+ public void testAddMetaDataRetrievalFactory() throws Exception
+ {
+ MutableMetaDataRepository repository = setupEmpty();
+ assertNull(repository.getMetaDataRetrievalFactory(testLevel1));
+ TestMetaDataRetrievalFactory factory1 = new TestMetaDataRetrievalFactory();
+ assertNull(repository.addMetaDataRetrievalFactory(testLevel1, factory1));
+ assertEquals(factory1, repository.getMetaDataRetrievalFactory(testLevel1));
+ TestMetaDataRetrievalFactory factory2 = new TestMetaDataRetrievalFactory();
+ assertEquals(factory1, repository.addMetaDataRetrievalFactory(testLevel1, factory2));
+ assertEquals(factory2, repository.getMetaDataRetrievalFactory(testLevel1));
+ TestMetaDataRetrievalFactory factory3 = new TestMetaDataRetrievalFactory();
+ assertNull(repository.addMetaDataRetrievalFactory(testLevel2, factory3));
+ assertEquals(factory2, repository.getMetaDataRetrievalFactory(testLevel1));
+ assertEquals(factory3, repository.getMetaDataRetrievalFactory(testLevel2));
+ }
+
+ public void testRemoveMetaDataRetrievalFactory() throws Exception
+ {
+ MutableMetaDataRepository repository = setupEmpty();
+ assertNull(repository.getMetaDataRetrievalFactory(testLevel1));
+ TestMetaDataRetrievalFactory factory1 = new TestMetaDataRetrievalFactory();
+ assertNull(repository.addMetaDataRetrievalFactory(testLevel1, factory1));
+ assertEquals(factory1, repository.removeMetaDataRetrievalFactory(testLevel1));
+ assertNull(repository.getMetaDataRetrievalFactory(testLevel1));
+ assertNull(repository.removeMetaDataRetrievalFactory(testLevel1));
+ TestMetaDataRetrievalFactory factory2 = new TestMetaDataRetrievalFactory();
+ assertNull(repository.addMetaDataRetrievalFactory(testLevel1, factory1));
+ assertNull(repository.addMetaDataRetrievalFactory(testLevel2, factory2));
+ assertEquals(factory1, repository.removeMetaDataRetrievalFactory(testLevel1));
+ assertNull(repository.getMetaDataRetrievalFactory(testLevel1));
+ assertNull(repository.removeMetaDataRetrievalFactory(testLevel1));
+ assertEquals(factory2, repository.getMetaDataRetrievalFactory(testLevel2));
+ }
+
+ public void testBasicMetaDataRetrievalFactory() throws Exception
+ {
+ MutableMetaDataRepository repository = setupEmpty();
+ TestMetaDataRetrievalFactory factory1 = new TestMetaDataRetrievalFactory();
+ repository.addMetaDataRetrievalFactory(testLevel1, factory1);
+ MutableMetaDataLoader loader1 = createTestMutableMetaDataLoader(testKey1);
+ factory1.retrievals.put(testScope1, loader1);
+ assertEquals(loader1, repository.getMetaDataRetrieval(testKey1));
+ }
+
+ public void testMultipleRetrievalMetaDataRetrievalFactory() throws Exception
+ {
+ MutableMetaDataRepository repository = setupEmpty();
+ TestMetaDataRetrievalFactory factory1 = new TestMetaDataRetrievalFactory();
+ repository.addMetaDataRetrievalFactory(testLevel1, factory1);
+ MutableMetaDataLoader loader1 = createTestMutableMetaDataLoader(testKey1);
+ factory1.retrievals.put(testScope1, loader1);
+ MutableMetaDataLoader loader2 = createTestMutableMetaDataLoader(testKey1Different);
+ factory1.retrievals.put(testScope1Different, loader2);
+ assertEquals(loader1, repository.getMetaDataRetrieval(testKey1));
+ assertEquals(loader2, repository.getMetaDataRetrieval(testKey1Different));
+ }
+
+ public void testMultipleMetaDataRetrievalFactories() throws Exception
+ {
+ MutableMetaDataRepository repository = setupEmpty();
+ TestMetaDataRetrievalFactory factory1 = new TestMetaDataRetrievalFactory();
+ repository.addMetaDataRetrievalFactory(testLevel1, factory1);
+ TestMetaDataRetrievalFactory factory2 = new TestMetaDataRetrievalFactory();
+ repository.addMetaDataRetrievalFactory(testLevel2, factory2);
+ MutableMetaDataLoader loader1 = createTestMutableMetaDataLoader(testKey1);
+ factory1.retrievals.put(testScope1, loader1);
+ MutableMetaDataLoader loader2 = createTestMutableMetaDataLoader(testKey2);
+ factory2.retrievals.put(testScope2, loader2);
+ assertEquals(loader1, repository.getMetaDataRetrieval(testKey1));
+ assertEquals(loader2, repository.getMetaDataRetrieval(testKey2));
+ }
+
protected void assertAddMetaDataRetrieval(MutableMetaDataRepository repository, MetaDataRetrieval add, MetaDataRetrieval expected) throws Exception
{
MetaDataRetrieval previous = repository.addMetaDataRetrieval(add);
Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/scope/support/TestComponentMetaDataRepositoryPopulator.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/scope/support/TestComponentMetaDataRepositoryPopulator.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/scope/support/TestComponentMetaDataRepositoryPopulator.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -27,10 +27,9 @@
import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployerWithInput;
import org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.plugins.loader.reflection.AnnotatedElementMetaDataLoader;
import org.jboss.metadata.plugins.repository.basic.BasicMetaDataRepository;
import org.jboss.metadata.spi.MutableMetaData;
-import org.jboss.metadata.spi.scope.Scope;
+import org.jboss.metadata.spi.scope.CommonLevels;
import org.jboss.metadata.spi.scope.ScopeKey;
/**
@@ -41,8 +40,6 @@
*/
public class TestComponentMetaDataRepositoryPopulator extends AbstractRealDeployerWithInput<TestComponentMetaData>
{
- private BasicMetaDataRepository repository;
-
public TestComponentMetaDataRepositoryPopulator()
{
setDeploymentVisitor(new TestComponentMetaDataVisitor());
@@ -50,11 +47,6 @@
setOutput(TestComponentMetaData.class);
}
- public void setRepository(BasicMetaDataRepository repository)
- {
- this.repository = repository;
- }
-
public class TestComponentMetaDataVisitor implements DeploymentVisitor<TestComponentMetaData>
{
public Class<TestComponentMetaData> getVisitorType()
@@ -64,14 +56,9 @@
public void deploy(DeploymentUnit unit, TestComponentMetaData deployment) throws DeploymentException
{
- // Create a scope for the class
- AnnotatedElementMetaDataLoader loader = new AnnotatedElementMetaDataLoader(deployment.clazz);
- repository.addMetaDataRetrieval(loader);
-
- // Add it to our scope
+ // Add in the class scope
ScopeKey key = unit.getScope();
- for (Scope scope : loader.getScope().getScopes())
- key.addScope(scope);
+ key.addScope(CommonLevels.CLASS, deployment.clazz);
// Populate the instance annotations
MutableMetaData mutable = unit.getMutableMetaData();
@@ -81,9 +68,6 @@
public void undeploy(DeploymentUnit unit, TestComponentMetaData deployment)
{
- // Remove the scope
- AnnotatedElementMetaDataLoader loader = new AnnotatedElementMetaDataLoader(deployment.getClass());
- repository.removeMetaDataRetrieval(loader.getScope());
}
}
}
Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/scope/test/PopulateMetaDataRepositoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/scope/test/PopulateMetaDataRepositoryUnitTestCase.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/scope/test/PopulateMetaDataRepositoryUnitTestCase.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -157,7 +157,6 @@
DeployersImpl deployers = (DeployersImpl) super.createDeployers();
repository = new BasicMetaDataRepository();
deployers.setRepository(repository);
- deployer2.setRepository(repository);
return deployers;
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -205,7 +205,7 @@
if (setter != null)
{
visitedMethods.add(setter);
- Signature sis = new MethodSignature(setter.getName(), Configurator.getParameterTypes(trace, setter.getParameterTypes()));
+ Signature sis = new MethodSignature(setter);
MetaData cmdr = retrieval.getComponentMetaData(sis);
if (cmdr != null)
{
@@ -228,7 +228,7 @@
{
if (visitedMethods.contains(mi) == false)
{
- Signature mis = new MethodSignature(mi.getName(), Configurator.getParameterTypes(trace, mi.getParameterTypes()));
+ Signature mis = new MethodSignature(mi);
MetaData cmdr = retrieval.getComponentMetaData(mis);
if (cmdr != null)
{
@@ -251,7 +251,7 @@
{
if (smi.isStatic() && smi.isPublic())
{
- Signature mis = new MethodSignature(smi.getName(), Configurator.getParameterTypes(trace, smi.getParameterTypes()));
+ Signature mis = new MethodSignature(smi);
MetaData cmdr = retrieval.getComponentMetaData(mis);
if (cmdr != null)
{
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -153,7 +153,7 @@
if (bean != null)
className = bean;
}
- setScopeInfo(new KernelScopeInfo(getName(), className));
+ setScopeInfo(new KernelScopeInfo(getName(), className, bmd));
}
/**
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelScopeInfo.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelScopeInfo.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelScopeInfo.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -33,15 +33,12 @@
import org.jboss.kernel.plugins.config.Configurator;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
-import org.jboss.metadata.plugins.loader.reflection.AnnotatedElementMetaDataLoader;
import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
-import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
import org.jboss.metadata.spi.scope.CommonLevels;
import org.jboss.metadata.spi.scope.Scope;
import org.jboss.metadata.spi.scope.ScopeKey;
import org.jboss.metadata.spi.signature.MethodSignature;
import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.TypeInfo;
/**
* KernelScopeInfo.
@@ -51,67 +48,55 @@
*/
public class KernelScopeInfo extends AbstractScopeInfo
{
+ /** The bean metadata */
+ private BeanMetaData beanMetaData;
+
/**
* Create a new KernelScopeInfo.
*
* @param name the name
* @param className the class name
+ * @param beanMetaData the bean metadata
*/
- public KernelScopeInfo(Object name, String className)
+ public KernelScopeInfo(Object name, String className, BeanMetaData beanMetaData)
{
super(name, className);
+ this.beanMetaData = beanMetaData;
}
- /**
- * Create a new KernelScopeInfo.
- *
- * @param name the name
- */
- public KernelScopeInfo(Object name)
- {
- super(name);
- }
-
- /**
- * Create a new KernelScopeInfo.
- *
- * @param key the scope
- * @param mutable the mutable scope
- */
- public KernelScopeInfo(ScopeKey key, ScopeKey mutable)
- {
- super(key, mutable);
- }
-
@Override
- public MetaDataRetrieval initMetaDataRetrieval(MutableMetaDataRepository repository, ControllerContext context, Scope scope)
+ public ScopeKey getScope()
{
- if (scope.getScopeLevel() == CommonLevels.CLASS)
+ // THIS IS A HACK - the scope originally gets initialise with a class name, we fix it to have the class
+ ScopeKey key = super.getScope();
+ Scope scope = key.getScope(CommonLevels.CLASS);
+ if (scope == null)
+ return key;
+ Object qualifier = scope.getQualifier();
+ if (qualifier instanceof Class)
+ return key;
+
+ String className = (String) qualifier;
+ ClassLoader cl = null;
+ try
{
- if (context instanceof KernelControllerContext == false)
- return null;
- KernelControllerContext theContext = (KernelControllerContext) context;
- BeanMetaData metaData = theContext.getBeanMetaData();
- ClassLoader cl = null;
- try
- {
- cl = Configurator.getClassLoader(metaData);
- }
- catch (Throwable t)
- {
- throw new RuntimeException("Error getting classloader for " + context.getName(), t);
- }
- try
- {
- Class<?> clazz = cl.loadClass(scope.getQualifier());
- return new AnnotatedElementMetaDataLoader(clazz);
- }
- catch (ClassNotFoundException e)
- {
- throw new RuntimeException("Unable to load class: " + scope.getQualifier(), e);
- }
+ cl = Configurator.getClassLoader(beanMetaData);
}
- return null;
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error getting classloader for " + key, t);
+ }
+ Class<?> clazz = null;
+ try
+ {
+ clazz = cl.loadClass(className);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException("Unable to load class: " + className + " for " + key, e);
+ }
+ key.addScope(new Scope(CommonLevels.CLASS, clazz));
+ return key;
}
@Override
@@ -123,7 +108,6 @@
addClassAnnotations(mutable, theContext);
addPropertyAnnotations(mutable, theContext);
}
-
/**
* Add class annotations
@@ -136,15 +120,16 @@
BeanMetaData beanMetaData = context.getBeanMetaData();
if (beanMetaData != null)
{
+ ClassLoader cl = null;
try
{
- ClassLoader cl = Configurator.getClassLoader(beanMetaData);
- addAnnotations(cl, mutable, beanMetaData.getAnnotations());
+ cl = Configurator.getClassLoader(beanMetaData);
}
catch(Throwable t)
{
- throw new RuntimeException("Error getting classloader for metadata", t);
+ throw new RuntimeException("Error getting classloader for " + beanMetaData.getName(), t);
}
+ addAnnotations(cl, mutable, beanMetaData.getAnnotations());
}
}
@@ -168,17 +153,18 @@
BeanInfo beanInfo = context.getBeanInfo();
if (beanInfo == null)
return;
-
+
+ ClassLoader cl = null;
try
{
- ClassLoader cl = Configurator.getClassLoader(beanMetaData);
- for (PropertyMetaData property : properties)
- addPropertyAnnotations(cl, mutable, property, beanInfo);
+ cl = Configurator.getClassLoader(beanMetaData);
}
catch(Throwable t)
{
throw new RuntimeException("Error getting classloader for metadata");
}
+ for (PropertyMetaData property : properties)
+ addPropertyAnnotations(cl, mutable, property, beanInfo);
}
/**
@@ -223,15 +209,10 @@
*/
private void addAnnotations(ClassLoader classloader, MemoryMetaDataLoader mutable, MethodInfo methodInfo, Set<AnnotationMetaData> annotations)
{
- TypeInfo[] typeInfos = methodInfo.getParameterTypes();
- String[] paramTypes = new String[typeInfos.length];
- for (int i = 0; i < typeInfos.length; ++i)
- paramTypes[i] = typeInfos[i].getName();
-
ScopeKey scope = new ScopeKey(CommonLevels.JOINPOINT_OVERRIDE, methodInfo.getName());
MemoryMetaDataLoader loader = new MemoryMetaDataLoader(scope);
addAnnotations(classloader, loader, annotations);
- mutable.addComponentMetaDataRetrieval(new MethodSignature(methodInfo.getName(), paramTypes), loader);
+ mutable.addComponentMetaDataRetrieval(new MethodSignature(methodInfo), loader);
}
/**
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/metadata/basic/BasicKernelMetaDataRepository.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/metadata/basic/BasicKernelMetaDataRepository.java 2007-11-20 11:08:02 UTC (rev 67290)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/metadata/basic/BasicKernelMetaDataRepository.java 2007-11-20 13:16:22 UTC (rev 67291)
@@ -60,6 +60,8 @@
{
initMetaDataRetrieval(context);
metaData = repository.getMetaData(scope);
+ if (metaData == null)
+ throw new IllegalStateException("Error initialising metadata state: " + scope);
}
return metaData;
}
More information about the jboss-cvs-commits
mailing list