[jboss-cvs] JBossAS SVN: r59020 - in projects/microcontainer/trunk: aop-mc-int aop-mc-int/src/main/org/jboss/aop/microcontainer/integration aop-mc-int/src/tests/org/jboss/test/microcontainer/test build container/src/main/org/jboss container/src/main/org/jboss/beans/info/plugins container/src/main/org/jboss/beans/info/spi container/src/main/org/jboss/classadapter/plugins container/src/main/org/jboss/classadapter/plugins/dependency container/src/main/org/jboss/classadapter/spi container/src/main/org/jboss/config/plugins container/src/main/org/jboss/config/plugins/property container/src/main/org/jboss/config/spi container/src/main/org/jboss/joinpoint/plugins container/src/main/org/jboss/joinpoint/spi container/src/main/org/jboss/metadata/plugins/context container/src/main/org/jboss/metadata/plugins/loader container/src/main/org/jboss/metadata/plugins/loader/memory container/src/main/org/jboss/metadata/plugins/loader/reflection container/src/main/org/jboss/metadata/spi container/s! rc/main/org/jboss/metadata/spi/retrieval container/src/main/org/jboss/metadata/spi/scope container/src/main/org/jboss/metadata/spi/signature container/src/main/org/jboss/metadata/spi/stack container/src/main/org/jboss/virtual container/src/main/org/jboss/virtual/plugins/context container/src/main/org/jboss/virtual/plugins/context/file container/src/main/org/jboss/virtual/plugins/context/jar container/src/main/org/jboss/virtual/protocol/vfsfile container/src/main/org/jboss/virtual/protocol/vfsjar container/src/main/org/jboss/virtual/spi container/src/tests/org/jboss/test container/src/tests/org/jboss/test/joinpoint/test container/src/tests/org/jboss/test/metadata/loader/memory/test container/src/tests/org/jboss/test/metadata/loader/reflection/support container/src/tests/org/jboss/test/metadata/loader/reflection/test container/src/tests/org/jboss/test/metadata/retrieval/support container/src/tests/org/jboss/test/metadata/shared container/src/tests/org/jboss/test/metadata/shar! ed/support container/src/tests/org/jboss/test/virtual/test kernel/src/main/org/jboss/kernel/plugins/dependency kernel/src/main/org/jboss/kernel/plugins/deployment kernel/src/main/org/jboss/kernel/plugins/deployment/xml kernel/src/main/org/jboss/kernel/plugins/event kernel/src/main/org/jboss/kernel/plugins/metadata/basic kern
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 13 18:52:38 EST 2006
Author: adrian at jboss.org
Date: 2006-12-13 18:51:15 -0500 (Wed, 13 Dec 2006)
New Revision: 59020
Added:
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/SimpleMetaDataLoader.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/ComponentMutableMetaData.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/
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/main/org/jboss/metadata/spi/stack/
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/stack/MetaDataStack.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/stack/MetaDataStackPermission.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/memory/test/MemoryLoaderComponentBasicAnnotationsUnitTestCase.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/ConstructorBean.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/FieldBean.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/MethodBean.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/MethodParamBean.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/AnnotatedElementLoaderComponentBasicAnnotationsUnitTestCase.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/shared/ComponentBasicAnnotationsTest.java
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_New.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NewProperty.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NoOverride.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NoOverrideProperty.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_Override.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_OverrideProperty.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationA.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationB.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationC.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestClassAnnotation.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/AbstractMetaDataTest.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/MetaDataTestSuite.java
Removed:
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPKernelRepository.java
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContext.java
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactory.java
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactoryDelegate.java
projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractInstanceBeanInfo.java
projects/microcontainer/trunk/container/src/main/org/jboss/repository/
projects/microcontainer/trunk/container/src/tests/org/jboss/test/repository/
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/metadata/MutableMetaDataContext.java
Modified:
projects/microcontainer/trunk/aop-mc-int/build.xml
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilderDelegate.java
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactory.java
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactoryBuilder.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InterceptorWithAnnotationDependencyTestCase.java
projects/microcontainer/trunk/build/build-thirdparty.xml
projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java
projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/BasicClassAdapter.java
projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/dependency/AbstractDependencyBuilder.java
projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/ClassAdapter.java
projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/DependencyBuilder.java
projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/AbstractConfiguration.java
projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/BasicConfiguration.java
projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/property/PropertyConfiguration.java
projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/property/PropertyConfigurationConstants.java
projects/microcontainer/trunk/container/src/main/org/jboss/config/spi/Configuration.java
projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/BasicJoinpointFactory.java
projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/BasicJoinpointFactoryBuilder.java
projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/spi/JoinpointFactoryBuilder.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/context/AbstractMetaDataContext.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/context/CachingMetaDataContext.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/BasicMetaDataLoader.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/spi/MetaData.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrieval.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrievalToMetaDataBridge.java
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKey.java
projects/microcontainer/trunk/container/src/main/org/jboss/virtual/VirtualFile.java
projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/VfsArchiveBrowser.java
projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/VfsArchiveBrowserFactory.java
projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/file/FileHandler.java
projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java
projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java
projects/microcontainer/trunk/container/src/main/org/jboss/virtual/protocol/vfsfile/Handler.java
projects/microcontainer/trunk/container/src/main/org/jboss/virtual/protocol/vfsjar/Handler.java
projects/microcontainer/trunk/container/src/main/org/jboss/virtual/spi/VirtualFileHandler.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/joinpoint/test/JoinpointTest.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/memory/test/MemoryMetaDataLoaderTestSuite.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/ReflectionMetaDataLoaderTestSuite.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/retrieval/support/TestMetaDataRetrieval.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/shared/support/MetaDataAndMutableMetaDataImpl.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/TestClassLoading.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.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/DescribeAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/BasicKernelDeployer.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BasicXMLDeployer.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/EntryKeyInterceptor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/EntryValueInterceptor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/event/AbstractEventEmitter.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/metadata/basic/BasicKernelMetaDataRepository.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/AbstractKernelRegistry.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/basic/BasicKernelRegistryFactory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/metadata/KernelMetaDataRepository.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/ioc/test/AbstractIoCTest.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomCollection.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomList.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomMap.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomSet.java
Log:
[JBMICROCONT-75] - AOP/MC MetaData integration
Modified: projects/microcontainer/trunk/aop-mc-int/build.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/build.xml 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/aop-mc-int/build.xml 2006-12-13 23:51:15 UTC (rev 59020)
@@ -69,6 +69,7 @@
<!-- The combined library classpath -->
<path id="library.classpath">
<path refid="apache.log4j.classpath"/>
+ <path refid="javassist.javassist.classpath"/>
<path refid="oswego.concurrent.classpath"/>
<path refid="junit.junit.classpath"/>
<path refid="jboss.aop.classpath"/>
Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -32,9 +32,10 @@
import org.jboss.aop.proxy.container.ContainerCache;
import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
import org.jboss.joinpoint.plugins.BasicConstructorJoinPoint;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.stack.MetaDataStack;
import org.jboss.reflect.spi.ConstructorInfo;
import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.repository.spi.MetaDataContext;
/**
* An AOPConstructorJoinpoint.
@@ -48,18 +49,15 @@
public class AOPConstructorJoinpoint extends BasicConstructorJoinPoint
{
AOPProxyFactory proxyFactory = new GeneratedAOPProxyFactory();
-
- MetaDataContext metaDataContext;
/**
* Create a new AOPConstructorJoinpoint.
*
* @param constructorInfo the constructor info
*/
- public AOPConstructorJoinpoint(ConstructorInfo constructorInfo, MetaDataContext metaDataContext)
+ public AOPConstructorJoinpoint(ConstructorInfo constructorInfo)
{
super(constructorInfo);
- this.metaDataContext = metaDataContext;
}
public Object dispatch() throws Throwable
@@ -70,16 +68,25 @@
{
return super.dispatch();
}
- ContainerCache cache = ContainerCache.initialise(manager, clazz, metaDataContext);
- AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
- Object target = createTarget(cache, params);
+ MetaData metaData = MetaDataStack.peek();
+ MetaDataStack.mask();
+ try
+ {
+ ContainerCache cache = ContainerCache.initialise(manager, clazz, metaData);
+ AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+ Object target = createTarget(cache, params);
- params.setProxiedClass(target.getClass());
- params.setMetaDataContext(metaDataContext);
- params.setTarget(target);
- params.setContainerCache(cache);
-
- return proxyFactory.createAdvisedProxy(params);
+ params.setProxiedClass(target.getClass());
+ params.setMetaDataContext(metaData);
+ params.setTarget(target);
+ params.setContainerCache(cache);
+
+ return proxyFactory.createAdvisedProxy(params);
+ }
+ finally
+ {
+ MetaDataStack.unmask();
+ }
}
private Object createTarget(ContainerCache cache, AOPProxyFactoryParameters params) throws Throwable
Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -26,6 +26,7 @@
import org.jboss.classadapter.plugins.dependency.AbstractDependencyBuilder;
import org.jboss.classadapter.spi.ClassAdapter;
import org.jboss.classadapter.spi.DependencyBuilder;
+import org.jboss.metadata.spi.MetaData;
/**
* The existence of this class is the signal to the kernel that we want to use the aop-mc integration.
@@ -40,14 +41,14 @@
{
DependencyBuilder delegate;
- public List getDependencies(ClassAdapter classAdapter)
+ public List<Object> getDependencies(ClassAdapter classAdapter, MetaData metaData)
{
DependencyBuilder builder = getDependencyBuilderDelegate(classAdapter);
if (builder == null)
{
- return super.getDependencies(classAdapter);
+ return super.getDependencies(classAdapter, metaData);
}
- return delegate.getDependencies(classAdapter);
+ return delegate.getDependencies(classAdapter, metaData);
}
private synchronized DependencyBuilder getDependencyBuilderDelegate(ClassAdapter classAdapter)
Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilderDelegate.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilderDelegate.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilderDelegate.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -40,6 +40,8 @@
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;
@@ -51,7 +53,6 @@
import org.jboss.reflect.spi.StringValue;
import org.jboss.reflect.spi.TypeInfo;
import org.jboss.reflect.spi.Value;
-import org.jboss.repository.spi.MetaDataContext;
/**
* Used by the AOPDependencyBuilder once the AspectManager has been installed. Finds all managed aspects that apply
@@ -66,7 +67,7 @@
private static final String DEPENDENCY_NAME_ATTRIBUTE = "name";
private static final IntrospectionTypeInfoFactoryImpl typeInfoFactory = new IntrospectionTypeInfoFactoryImpl();
- public List getDependencies(ClassAdapter classAdapter)
+ public List<Object> getDependencies(ClassAdapter classAdapter, MetaData metaData)
{
AspectManager manager = AspectManager.instance();
try
@@ -77,10 +78,8 @@
{
if (manager.isNonAdvisableClassName(className))
{
- return super.getDependencies(classAdapter);
+ return super.getDependencies(classAdapter, metaData);
}
-
- MetaDataContext metaDataContext = classAdapter.getMetaDataContext();
ClassLoader loader = classAdapter.getClassLoader();
if (loader == null)
@@ -92,7 +91,7 @@
Advisor advisor;
synchronized (ContainerCache.mapLock)
{
- ContainerCache cache = ContainerCache.initialise(manager, clazz, metaDataContext);
+ ContainerCache cache = ContainerCache.initialise(manager, clazz, metaData);
advisor = cache.getAdvisor();
}
@@ -113,7 +112,7 @@
}
}
- HashSet<Object> annotationDependencies = getAnnotationDependencies(classInfo, metaDataContext);
+ HashSet<Object> annotationDependencies = getAnnotationDependencies(classInfo, metaData);
depends.addAll(annotationDependencies);
return depends;
@@ -127,13 +126,13 @@
}
}
- private HashSet<Object> getAnnotationDependencies(ClassInfo classInfo, MetaDataContext metaDataContext)
+ private HashSet<Object> getAnnotationDependencies(ClassInfo classInfo, MetaData metaData)
{
try
{
HashSet<Object> dependencies = new HashSet<Object>();
- getClassAnnotationDependencies(classInfo, metaDataContext, dependencies);
- getMethodAnnotationDependencies(classInfo, metaDataContext, dependencies);
+ getClassAnnotationDependencies(classInfo, metaData, dependencies);
+ getMethodAnnotationDependencies(classInfo, metaData, dependencies);
return dependencies;
}
catch (RuntimeException e)
@@ -146,12 +145,12 @@
}
}
- private void getClassAnnotationDependencies(ClassInfo classInfo, MetaDataContext metaDataContext, HashSet<Object> dependencies) throws Exception
+ 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>>();
- getMetaDataContextClassAnnotationDependencies(metaDataContext, metaMap);
+ getMetaDataClassAnnotationDependencies(metaData, metaMap);
addAllDependenciesToSet(dependencies, realMap, metaMap);
}
@@ -165,19 +164,18 @@
}
}
- private void getMetaDataContextClassAnnotationDependencies(MetaDataContext metaDataContext, HashMap<String, ArrayList<String>> dependencies) throws Exception
+ private void getMetaDataClassAnnotationDependencies(MetaData metaData, HashMap<String, ArrayList<String>> dependencies) throws Exception
{
- if (metaDataContext != null)
+ if (metaData != null)
{
- for (Iterator it = metaDataContext.getAnnotations().iterator() ; it.hasNext() ; )
+ for (Object annotation : metaData.getAnnotations())
{
- Object annotation = it.next();
getDependenciesForMetaDataAnnotation(annotation, dependencies);
}
}
}
- private void getMethodAnnotationDependencies(ClassInfo classInfo, MetaDataContext metaDataContext, HashSet<Object> dependencies) throws Exception
+ private void getMethodAnnotationDependencies(ClassInfo classInfo, MetaData metaData, HashSet<Object> dependencies) throws Exception
{
Map methodMap = ClassInfoMethodHashing.getMethodMap(classInfo);
if (methodMap != null)
@@ -190,7 +188,7 @@
HashMap<String, ArrayList<String>> classMap = new HashMap<String, ArrayList<String>>();
getRealMethodAnnotationDependencies(method, classMap);
HashMap<String, ArrayList<String>> overrideMap = new HashMap<String, ArrayList<String>>();
- getMetaDataContextMethodAnnotationDependencies(method, metaDataContext, overrideMap);
+ getMetaDataMethodAnnotationDependencies(method, metaData, overrideMap);
addAllDependenciesToSet(dependencies, classMap, overrideMap);
}
}
@@ -209,16 +207,21 @@
}
}
- private void getMetaDataContextMethodAnnotationDependencies(MethodInfo method, MetaDataContext metaDataContext, HashMap<String, ArrayList<String>> dependencies) throws Exception
+ private void getMetaDataMethodAnnotationDependencies(MethodInfo method, MetaData metaData, HashMap<String, ArrayList<String>> dependencies) throws Exception
{
- if (metaDataContext != null)
+ if (metaData != null)
{
- long hash = ClassInfoMethodHashing.methodHash(method);
- List methodAnnotations = metaDataContext.getAnnotationsForMethod(hash);
- for (Iterator it = methodAnnotations.iterator() ; it.hasNext() ; )
+ 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)
{
- Object annotation = it.next();
- getDependenciesForMetaDataAnnotation(annotation, dependencies);
+ for (Object annotation : methodMetaData.getAnnotations())
+ {
+ getDependenciesForMetaDataAnnotation(annotation, dependencies);
+ }
}
}
}
Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactory.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactory.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -21,15 +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;
-import org.jboss.repository.spi.MetaDataContext;
/**
* The existence of this class is the signal to the kernel that we want to use the aop-mc integration.
@@ -42,89 +38,18 @@
*/
public class AOPJoinpointFactory extends BasicJoinpointFactory
{
- /** The AOPConstructorJoinpoint constructor one it has been loaded */
- static volatile ConstructorInfo ctorInfo;
-
/**
* Create a new AOPJoinpointFactory.
*
* @param classInfo
*/
- public AOPJoinpointFactory(ClassInfo classInfo, MetaDataContext metaDataContext)
+ public AOPJoinpointFactory(ClassInfo classInfo)
{
- super(classInfo, metaDataContext);
+ super(classInfo);
}
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 == 2)
- {
- if (ctors[i].getParameterTypes()[0].getName().equals(ConstructorInfo.class.getName()) == false)
- {
- continue;
- }
-
- if (ctors[i].getParameterTypes()[1].getName().equals(MetaDataContext.class.getName()) == false)
- {
- continue;
- }
- ctorInfo = ctors[i];
- break;
- }
- }
-
- if (ctorInfo == null)
- {
- throw new JoinpointException("No constructor found with the reqiured signature AOPConstructorJoinpoint(ConstructorInfo, MetadataContext)");
- }
- return ctorInfo;
- }
-
- private ConstructorJoinpoint createAOPConstructorJoinpoint(ConstructorInfo info, ConstructorInfo aopCtorInfo) throws JoinpointException
- {
- ConstructorJoinpoint jp = new BasicConstructorJoinPoint(info);
- jp.setArguments(new Object[] {aopCtorInfo, metaDataContext});
- try
- {
- return (ConstructorJoinpoint)jp.dispatch();
- }
- catch (Throwable e)
- {
- throw new JoinpointException("Error calling AOPConstructorJoinpoint constructor", e);
- }
-
- }
}
Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactoryBuilder.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactoryBuilder.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPJoinpointFactoryBuilder.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -24,7 +24,6 @@
import org.jboss.joinpoint.spi.JoinpointFactory;
import org.jboss.joinpoint.spi.JoinpointFactoryBuilder;
import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.repository.spi.MetaDataContext;
/**
* AOPJoinpointFactoryBuilder.
@@ -34,13 +33,8 @@
*/
public class AOPJoinpointFactoryBuilder implements JoinpointFactoryBuilder
{
- public JoinpointFactory createJoinpointFactory(ClassInfo classInfo, MetaDataContext metaDataContext)
- {
- return new AOPJoinpointFactory(classInfo, metaDataContext);
- }
-
public JoinpointFactory createJoinpointFactory(ClassInfo classInfo)
{
- return createJoinpointFactory(classInfo, null);
+ return new AOPJoinpointFactory(classInfo);
}
}
Deleted: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPKernelRepository.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPKernelRepository.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPKernelRepository.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -1,68 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.aop.microcontainer.integration;
-
-import org.jboss.repository.plugins.AbstractKernelRepository;
-import org.jboss.repository.plugins.InvocationMetaDataCombiner;
-import org.jboss.repository.plugins.KeyMetaDataCombiner;
-import org.jboss.repository.plugins.ThreadMetaDataCombiner;
-
-/**
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision$
- */
-public class AOPKernelRepository extends AbstractKernelRepository
-{
- private volatile static AOPKernelRepository instance;
-
- protected AOPKernelRepository() throws Exception
- {
- super(
- new InvocationMetaDataCombiner
- (
- new ThreadMetaDataCombiner
- (
- new KeyMetaDataCombiner()
- ), null
- )
- );
-
- }
-
- public static AOPKernelRepository instance()
- {
- try
- {
- if (instance == null)
- {
- instance = new AOPKernelRepository();
- }
- return instance;
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-}
-
Deleted: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContext.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContext.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContext.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -1,276 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.aop.microcontainer.integration;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.jboss.aop.Advised;
-import org.jboss.aop.Advisor;
-import org.jboss.aop.proxy.container.AspectManaged;
-import org.jboss.aop.util.ClassInfoMethodHashing;
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.beans.metadata.spi.AnnotationMetaData;
-import org.jboss.kernel.spi.metadata.MutableMetaDataContext;
-import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
-import org.jboss.metadata.spi.repository.MetaDataRepository;
-import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
-import org.jboss.metadata.spi.retrieval.AnnotationItem;
-import org.jboss.metadata.spi.retrieval.AnnotationsItem;
-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.reflect.spi.MethodInfo;
-import org.jboss.repository.spi.MetaDataContext;
-
-/**
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision$
- */
-public class AOPMetaDataContext implements MutableMetaDataContext
-{
- final static List<Annotation> EMPTY_ANNOTATIONS = new ArrayList<Annotation>();
- Scope scope;
- Object target;
- MutableMetaDataRepository repository;
- String beanName;
- ScopeKey instanceKey;
-
- public AOPMetaDataContext(MutableMetaDataRepository repository, String beanName)
- {
- this.repository = repository;
- this.beanName = beanName;
- //TODO: This needs linking up with the parent scopes somehow - where will that info come from?
- scope = new Scope(CommonLevels.INSTANCE, beanName);
- instanceKey = new ScopeKey(scope);
- }
-
- public <T extends Annotation> boolean hasAnnotation(Class<T> ann)
- {
- return getAnnotation(ann) != null;
- }
-
- public <T extends Annotation> Annotation getAnnotation(Class<T> ann)
- {
- return getAnnotation(instanceKey, ann);
- }
-
- public <T extends Annotation> boolean hasAnnotationForMethod(long methodHash, Class<T> ann)
- {
- return getAnnotationForMethod(methodHash, ann) != null;
- }
-
- public <T extends Annotation> Annotation getAnnotationForMethod(long methodHash, Class<T> ann)
- {
- ScopeKey joinpointKey = createHashedJoinpointKey(methodHash);
- return getAnnotation(joinpointKey, ann);
- }
-
- public List<Annotation> getAnnotations()
- {
- return getAnnotations(instanceKey);
- }
-
- public List<Annotation> getAnnotationsForMethod(long methodHash)
- {
- ScopeKey joinpointKey = createHashedJoinpointKey(methodHash);
- return getAnnotations(joinpointKey);
- }
-
- public List<Annotation> getAnnotationsForMethods(long[] methodHashes)
- {
- ArrayList<Annotation> annotations = new ArrayList<Annotation>();
- for (long hash : methodHashes)
- {
- ScopeKey joinpointKey = createHashedJoinpointKey(hash);
- List<Annotation> methodAnnotations = getAnnotations(joinpointKey);
- annotations.addAll(methodAnnotations);
- }
- return annotations;
- }
-
- public MetaDataRepository getRepository()
- {
- return repository;
- }
-
- /**
- * Add instance-level annotations
- * @param annotations a Set<AnnotationMetaData>
- */
- public void addAnnotations(Set<AnnotationMetaData> annotations)
- {
- if (annotations.size() == 0)
- {
- return;
- }
-
- MemoryMetaDataLoader retrieval = new MemoryMetaDataLoader(instanceKey);
- for (AnnotationMetaData annotationMetaData : annotations)
- {
- Annotation annotation = annotationMetaData.getAnnotationInstance();
- retrieval.addAnnotation(annotation);
- }
- repository.addMetaDataRetrieval(retrieval);
- }
-
- public void addPropertyAnnotations(String propertyName, Set<PropertyInfo> propertyInfos, Set<AnnotationMetaData> annotations)
- {
- for (PropertyInfo info : propertyInfos)
- {
- if (propertyName.equals(info.getName()))
- {
- MemoryMetaDataLoader getterRetrieval = createGetterMetaDataRetrieval(info);
- MemoryMetaDataLoader setterRetrieval = createSetterMetaDataRetrieval(info);
-
- if (getterRetrieval == null && setterRetrieval == null)
- {
- continue;
- }
-
- for (AnnotationMetaData annotation : annotations)
- {
- if (getterRetrieval != null)
- {
- getterRetrieval.addAnnotation(annotation.getAnnotationInstance());
- }
- if (setterRetrieval != null)
- {
- setterRetrieval.addAnnotation(annotation.getAnnotationInstance());
- }
- }
-
- if (getterRetrieval != null)
- {
- repository.addMetaDataRetrieval(getterRetrieval);
- }
- if (setterRetrieval != null)
- {
- repository.addMetaDataRetrieval(setterRetrieval);
- }
- }
- }
- }
-
- public void setTarget(Object tgt)
- {
- if (tgt == null)
- {
- return;
- }
-
- target = tgt;
- Advisor advisor = null;
- if (tgt instanceof AspectManaged)
- {
- advisor = (Advisor)((AspectManaged)tgt).getInstanceAdvisor();
- }
- else if (tgt instanceof Advised)
- {
- advisor = (Advisor)((Advised)tgt)._getInstanceAdvisor();
- }
-
- if (advisor != null)
- {
- MetaDataContext advCtx = advisor.getMetadataContext();
- if (advCtx != null && advCtx != this)
- {
- throw new RuntimeException("Different context being set in constructed advisor");
- }
- if (advCtx == null)
- {
- advisor.setMetadataContext(this);
- }
- }
- }
-
- private MemoryMetaDataLoader createGetterMetaDataRetrieval(PropertyInfo propertyInfo)
- {
- MethodInfo getter = propertyInfo.getGetter();
- return createMethodMetaDataRetrieval(getter);
- }
-
- private MemoryMetaDataLoader createSetterMetaDataRetrieval(PropertyInfo propertyInfo)
- {
- MethodInfo setter = propertyInfo.getSetter();
- return createMethodMetaDataRetrieval(setter);
- }
-
- private MemoryMetaDataLoader createMethodMetaDataRetrieval(MethodInfo accessor)
- {
- if (accessor == null)
- {
- return null;
- }
- long hash = ClassInfoMethodHashing.methodHash(accessor);
- ScopeKey joinpointKey = createHashedJoinpointKey(hash);
- MemoryMetaDataLoader retrieval = new MemoryMetaDataLoader(joinpointKey);
- return retrieval;
- }
-
- private ScopeKey createHashedJoinpointKey(long hash)
- {
- ScopeKey joinpointKey = new ScopeKey(instanceKey.getScopes());
- joinpointKey.addScope(CommonLevels.JOINPOINT, String.valueOf(hash));
- return joinpointKey;
- }
-
- private <T extends Annotation> Annotation getAnnotation(ScopeKey key, Class<T> ann)
- {
- MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(key);
-
- if (retrieval != null)
- {
- AnnotationItem item = retrieval.retrieveAnnotation(ann);
- if (item != null)
- {
- return item.getAnnotation();
- }
- }
- return null;
- }
-
- private List<Annotation> getAnnotations(ScopeKey key)
- {
- MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(key);
-
- if (retrieval != null)
- {
- AnnotationsItem item = retrieval.retrieveAnnotations();
- if (item != null)
- {
- AnnotationItem[] items = item.getAnnotations();
- List<Annotation> annotations = new ArrayList<Annotation>();
- for (AnnotationItem aitem : items)
- {
- annotations.add(aitem.getAnnotation());
- }
- return annotations;
- }
- }
- return EMPTY_ANNOTATIONS;
- }
-}
Deleted: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactory.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactory.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -1,80 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.aop.microcontainer.integration;
-
-import org.jboss.metadata.spi.repository.MetaDataRepository;
-import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
-import org.jboss.repository.plugins.basic.BasicMetaDataContextFactory;
-import org.jboss.repository.spi.MetaDataContext;
-import org.jboss.repository.spi.MetaDataContextFactory;
-
-/**
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision$
- */
-public class AOPMetaDataContextFactory extends BasicMetaDataContextFactory implements MetaDataContextFactory
-{
- MetaDataContextFactory delegate;
- public MetaDataContext getMetaDataContext(ClassLoader beanLoader, MetaDataRepository repository, String beanName)
- {
- MetaDataContextFactory factoryDelegate = getMetaDataContextFactoryDelegate(beanLoader);
- if (factoryDelegate == null)
- {
- return super.getMetaDataContext(beanLoader, repository, beanName);
- }
- else
- {
- return factoryDelegate.getMetaDataContext(beanLoader, repository, beanName);
- }
- }
-
- private synchronized MetaDataContextFactory getMetaDataContextFactoryDelegate(ClassLoader beanLoader)
- {
- if (delegate != null)
- {
- return delegate;
- }
-
- Class clazz = AOPDeployedChecker.getClassIfExists(
- beanLoader,
- "org.jboss.aop.microcontainer.integration.AOPMetaDataContextFactoryDelegate");
-
- if (clazz == null)
- {
- return null;
- }
-
- try
- {
- delegate = (MetaDataContextFactory)clazz.newInstance();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error instantiating AOPMetaDataContextFactoryDelegate", e);
- }
-
- return delegate;
- }
-
-
-}
Deleted: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactoryDelegate.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactoryDelegate.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPMetaDataContextFactoryDelegate.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -1,49 +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 org.jboss.metadata.spi.repository.MetaDataRepository;
-import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
-import org.jboss.repository.spi.MetaDataContext;
-import org.jboss.repository.spi.MetaDataContextFactory;
-
-/**
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class AOPMetaDataContextFactoryDelegate implements MetaDataContextFactory
-{
-
- public MetaDataContext getMetaDataContext(ClassLoader beanLoader, MetaDataRepository repository, String beanName)
- {
- if (repository instanceof MutableMetaDataRepository)
-
- {
- return new AOPMetaDataContext((MutableMetaDataRepository)repository, beanName);
- }
- else
- {
- throw new RuntimeException("The passed in repository must be of type org.jboss.metadata.spi.repository.MutableMetaDataRepository");
- }
- }
-}
Modified: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InterceptorWithAnnotationDependencyTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InterceptorWithAnnotationDependencyTestCase.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InterceptorWithAnnotationDependencyTestCase.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -229,7 +229,7 @@
SimpleBean bean = (SimpleBean) getBean(name);
assertNotNull(bean);
bean.someMethod();
- assertTrue(dependency == InterceptorWithAnnotationDependency.intercepted);
+ assertTrue(dependency + "==" + InterceptorWithAnnotationDependency.intercepted, dependency == InterceptorWithAnnotationDependency.intercepted);
}
private void checkInterceptedAndInjectedMethodAnnotatedXml(SimpleBean dependency)
Modified: projects/microcontainer/trunk/build/build-thirdparty.xml
===================================================================
--- projects/microcontainer/trunk/build/build-thirdparty.xml 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/build/build-thirdparty.xml 2006-12-13 23:51:15 UTC (rev 59020)
@@ -54,7 +54,7 @@
<componentref name="jboss/profiler/jvmti" version="1.0.0.CR4"/>
<componentref name="junit" version="3.8.1"/>
<componentref name="junit4" version="4.1"/>
- <componentref name="jboss/aop" version="2.0.0.alpha2" />
+ <componentref name="jboss/aop" version="snapshot-metadata" />
<componentref name="jboss/backport-concurrent" version="2.1.0.GA"/>
<componentref name="jboss/jbossretro" version="1.0.4.GA"/>
<componentref name="jboss/test" version="1.0.0.GA"/>
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -31,11 +31,10 @@
import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.classadapter.spi.ClassAdapter;
import org.jboss.joinpoint.spi.JoinpointFactory;
+import org.jboss.metadata.spi.MetaData;
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.reflect.spi.ConstructorInfo;
import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.repository.spi.MetaDataContext;
-import org.jboss.repository.spi.MetaDataContextFactory;
import org.jboss.util.JBossObject;
import org.jboss.util.JBossStringBuilder;
@@ -98,17 +97,6 @@
this.methods = methods;
this.events = events;
}
-
- protected AbstractBeanInfo(AbstractBeanInfo template)
- {
- this.name = template.name;
- this.classAdapter = template.classAdapter.getInstanceAdapter(template.classAdapter.getClassInfo());
- this.properties = template.properties;
- this.constructors = template.constructors;
- this.methods = template.methods;
- this.events = template.events;
- this.beanInfoFactory = template.beanInfoFactory;
- }
public String getName()
{
@@ -130,20 +118,10 @@
return classAdapter.getClassInfo();
}
- public List<Object> getDependencies()
- {
- return classAdapter.getDependencies();
- }
-
public JoinpointFactory getJoinpointFactory()
{
return classAdapter.getJoinpointFactory();
}
-
- public MetaDataContextFactory getMetaDataContextFactory()
- {
- return classAdapter.getMetaDataContextFactory();
- }
public Set<ConstructorInfo> getConstructors()
{
@@ -179,15 +157,10 @@
{
return beanInfoFactory;
}
-
- public MetaDataContext getMetaDataContext()
- {
- return classAdapter.getMetaDataContext();
- }
- public void setMetaDataContext(MetaDataContext metaCtx)
+ public List<Object> getDependencies(MetaData metaData)
{
- classAdapter.setMetaDataContext(metaCtx);
+ return classAdapter.getDependencies(metaData);
}
public boolean equals(Object object)
@@ -235,10 +208,4 @@
{
return name.hashCode();
}
-
-
- public BeanInfo getInstanceInfo()
- {
- return new AbstractInstanceBeanInfo(this);
- }
}
Deleted: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractInstanceBeanInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractInstanceBeanInfo.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractInstanceBeanInfo.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -1,64 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.beans.info.plugins;
-
-import org.jboss.beans.info.spi.BeanInfo;
-
-/**
- * A BeanInfo allowing for overriding of the MetaDataContext for a particular bean
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision$
- */
-public class AbstractInstanceBeanInfo extends AbstractBeanInfo implements BeanInfo
-{
- public AbstractInstanceBeanInfo(AbstractBeanInfo template)
- {
- super(template);
- }
-
- public boolean equals(Object object)
- {
- if (object == null || object instanceof AbstractInstanceBeanInfo == false)
- return false;
-
- AbstractInstanceBeanInfo other = (AbstractInstanceBeanInfo) object;
- if (notEqual(name, other.name))
- return false;
- else if (notEqual(classAdapter, other.classAdapter))
- return false;
- else if (notEqual(properties, other.properties))
- return false;
- else if (notEqual(methods, other.methods))
- return false;
- else if (notEqual(constructors, other.constructors))
- return false;
- else if (notEqual(events, other.events))
- return false;
- return true;
- }
-
- public BeanInfo getInstanceInfo()
- {
- return this;
- }
-}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -25,11 +25,10 @@
import java.util.Set;
import org.jboss.joinpoint.spi.JoinpointFactory;
+import org.jboss.metadata.spi.MetaData;
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.reflect.spi.ConstructorInfo;
import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.repository.spi.MetaDataContext;
-import org.jboss.repository.spi.MetaDataContextFactory;
import org.jboss.util.JBossInterface;
/**
@@ -55,21 +54,6 @@
ClassInfo getClassInfo();
/**
- * Return a BeanInfo for this bean instance
- *
- * @return an instance info for this bean
- */
- BeanInfo getInstanceInfo();
-
- /**
- * Bean may have additional dependencies
- * that the kernel cannot initially resolve. (currently defined by ClassAdapter)
- *
- * @return the list of dependencies
- */
- List<Object> getDependencies();
-
- /**
* Get the joinpoint factory
*
* @return the joinpoint factory
@@ -77,13 +61,6 @@
JoinpointFactory getJoinpointFactory();
/**
- * Get the metadata context factory
- *
- * @return the metadata context factory
- */
- MetaDataContextFactory getMetaDataContextFactory();
-
- /**
* Get the property information.
*
* @return a Set<PropertyInfo>
@@ -145,19 +122,13 @@
* @return the factory
*/
BeanInfoFactory getBeanInfoFactory();
-
-
+
/**
- * Get the metadata context
- *
- * @return the metadata context
+ * Bean may have additional dependencies
+ * that the kernel cannot initially resolve. (currently defined by ClassAdapter)
+ *
+ * @param metaData the metadata
+ * @return the list of dependencies
*/
- MetaDataContext getMetaDataContext();
-
- /**
- * Set the metadata context
- *
- * @param metaCtx a metadata context
- */
- void setMetaDataContext(MetaDataContext metaCtx);
+ List<Object> getDependencies(MetaData metaData);
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/BasicClassAdapter.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/BasicClassAdapter.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/BasicClassAdapter.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -28,9 +28,8 @@
import org.jboss.classadapter.spi.DependencyBuilder;
import org.jboss.joinpoint.spi.JoinpointFactory;
import org.jboss.joinpoint.spi.JoinpointFactoryBuilder;
+import org.jboss.metadata.spi.MetaData;
import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.repository.spi.MetaDataContext;
-import org.jboss.repository.spi.MetaDataContextFactory;
import org.jboss.util.JBossObject;
/**
@@ -45,9 +44,6 @@
/** The class info */
protected ClassInfo classInfo;
-
- /** The metadata context */
- protected MetaDataContext metaDataContext;
/**
* Create a new reflected class adapter
@@ -66,23 +62,10 @@
return classInfo;
}
- public ClassAdapter getInstanceAdapter(ClassInfo classInfo)
- {
- BasicClassAdapter clone = (BasicClassAdapter) clone();
- clone.classInfo = classInfo;
- return clone;
- }
-
- public List<Object> getDependencies()
- {
- DependencyBuilder builder = classAdapterFactory.getConfiguration().getDependencyBuilder();
- return builder.getDependencies(this);
- }
-
public JoinpointFactory getJoinpointFactory()
{
JoinpointFactoryBuilder builder = classAdapterFactory.getConfiguration().getJoinpointFactoryBuilder();
- return builder.createJoinpointFactory(classInfo, metaDataContext);
+ return builder.createJoinpointFactory(classInfo);
}
public ClassLoader getClassLoader()
@@ -90,19 +73,9 @@
return classInfo.getType().getClassLoader();
}
- public MetaDataContextFactory getMetaDataContextFactory()
+ public List<Object> getDependencies(MetaData metaData)
{
- return classAdapterFactory.getConfiguration().getMetaDataContextFactory();
+ DependencyBuilder builder = classAdapterFactory.getConfiguration().getDependencyBuilder();
+ return builder.getDependencies(this, metaData);
}
-
-
- public MetaDataContext getMetaDataContext()
- {
- return metaDataContext;
- }
-
- public void setMetaDataContext(MetaDataContext metaCtx)
- {
- metaDataContext = metaCtx;
- }
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/dependency/AbstractDependencyBuilder.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/dependency/AbstractDependencyBuilder.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/dependency/AbstractDependencyBuilder.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -25,6 +25,7 @@
import org.jboss.classadapter.spi.ClassAdapter;
import org.jboss.classadapter.spi.DependencyBuilder;
+import org.jboss.metadata.spi.MetaData;
/**
* AbstractDependencyBuilder.
@@ -34,7 +35,7 @@
*/
public class AbstractDependencyBuilder implements DependencyBuilder
{
- public List<Object> getDependencies(ClassAdapter classAdapter)
+ public List<Object> getDependencies(ClassAdapter classAdapter, MetaData metaData)
{
return null;
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/ClassAdapter.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/ClassAdapter.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/ClassAdapter.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -24,9 +24,8 @@
import java.util.List;
import org.jboss.joinpoint.spi.JoinpointFactory;
+import org.jboss.metadata.spi.MetaData;
import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.repository.spi.MetaDataContext;
-import org.jboss.repository.spi.MetaDataContextFactory;
import org.jboss.util.JBossInterface;
/**
@@ -61,21 +60,6 @@
ClassInfo getClassInfo();
/**
- * Get an instance adapter.
- *
- * @param classInfo the changed class info
- * @return instance adapter
- */
- ClassAdapter getInstanceAdapter(ClassInfo classInfo);
-
- /**
- * Get the dependencies of this adapter
- *
- * @return the list of dependencies
- */
- List<Object> getDependencies();
-
- /**
* Get the Joinpoint Factory for this adapter.
*
* @return the joinpoint factory
@@ -88,25 +72,13 @@
* @return the classloader
*/
ClassLoader getClassLoader();
-
- /**
- * Get the MetaDataContextFactory for this adpater
- *
- * @return the metadata context factory
- */
- MetaDataContextFactory getMetaDataContextFactory();
/**
- * Get the metadata context
- *
- * @return the metadata context
+ * Bean may have additional dependencies
+ * that the kernel cannot initially resolve. (currently defined by ClassAdapter)
+ *
+ * @param metaData the metadata
+ * @return the list of dependencies
*/
- MetaDataContext getMetaDataContext();
-
- /**
- * Set the metadata context
- *
- * @param metaCtx a metadata context
- */
- void setMetaDataContext(MetaDataContext metaCtx);
+ List<Object> getDependencies(MetaData metaData);
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/DependencyBuilder.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/DependencyBuilder.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/DependencyBuilder.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -23,6 +23,8 @@
import java.util.List;
+import org.jboss.metadata.spi.MetaData;
+
/**
* DependencyBuilder.
*
@@ -35,7 +37,8 @@
* Get the dependencies for this instance
*
* @param classAdapter the class adapter
+ * @param metaData the metadata
* @return the dependencies
*/
- List<Object> getDependencies(ClassAdapter classAdapter);
+ List<Object> getDependencies(ClassAdapter classAdapter, MetaData metaData);
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/AbstractConfiguration.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/AbstractConfiguration.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/AbstractConfiguration.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -31,7 +31,6 @@
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.reflect.spi.TypeInfo;
import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.repository.spi.MetaDataContextFactory;
import org.jboss.util.NestedRuntimeException;
/**
@@ -54,9 +53,6 @@
/** The default type joinpoint factory builder */
private JoinpointFactoryBuilder joinpointFactoryBuilder;
- /** The default metadata context factory */
- private MetaDataContextFactory metaDataContextFactory;
-
/** The dependency builder */
private DependencyBuilder dependencyBuilder;
@@ -145,30 +141,6 @@
return joinpointFactoryBuilder;
}
- public MetaDataContextFactory getMetaDataContextFactory()
- {
- if (metaDataContextFactory == null)
- {
- try
- {
- metaDataContextFactory = createDefaultMetaDataContextFactory();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Error e)
- {
- throw e;
- }
- catch (Throwable t)
- {
- throw new NestedRuntimeException("Cannot create MetaDataContextFactory", t);
- }
- }
- return metaDataContextFactory;
- }
-
public DependencyBuilder getDependencyBuilder()
{
if (dependencyBuilder == null)
@@ -252,14 +224,6 @@
protected abstract JoinpointFactoryBuilder createDefaultJoinpointFactoryBuilder() throws Throwable;
/**
- * Create the default metadata context factory
- *
- * @return the metadata context factory
- * @throws Throwable for any error
- */
- protected abstract MetaDataContextFactory createDefaultMetaDataContextFactory() throws Throwable;
-
- /**
* Create the default dependency builder
*
* @return the dependency builder
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/BasicConfiguration.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/BasicConfiguration.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/BasicConfiguration.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -31,8 +31,6 @@
import org.jboss.joinpoint.spi.JoinpointFactoryBuilder;
import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory;
import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.repository.plugins.basic.BasicMetaDataContextFactory;
-import org.jboss.repository.spi.MetaDataContextFactory;
/**
* Basic configuration.
@@ -71,11 +69,6 @@
return new BasicJoinpointFactoryBuilder();
}
- protected MetaDataContextFactory createDefaultMetaDataContextFactory() throws Throwable
- {
- return new BasicMetaDataContextFactory();
- }
-
protected DependencyBuilder createDefaultDependencyBuilder() throws Throwable
{
return new AbstractDependencyBuilder();
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/property/PropertyConfiguration.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/property/PropertyConfiguration.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/property/PropertyConfiguration.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -31,7 +31,6 @@
import org.jboss.joinpoint.spi.JoinpointFactoryBuilder;
import org.jboss.logging.Logger;
import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.repository.spi.MetaDataContextFactory;
/**
* PropertyConfiguration.
@@ -99,11 +98,6 @@
return (JoinpointFactoryBuilder) loadFromProperties(PropertyConfigurationConstants.JOIN_POINT_FACTORY_BUILDER_NAME, PropertyConfigurationConstants.JOIN_POINT_FACTORY_BUILDER_DEFAULT, JoinpointFactoryBuilder.class);
}
- protected MetaDataContextFactory createDefaultMetaDataContextFactory() throws Throwable
- {
- return (MetaDataContextFactory) loadFromProperties(PropertyConfigurationConstants.META_DATA_CONTEXT_FACTORY_BUILDER_NAME, PropertyConfigurationConstants.META_DATA_CONTEXT_FACTORY_BUILDER_DEFAULT, MetaDataContextFactory.class);
- }
-
protected DependencyBuilder createDefaultDependencyBuilder() throws Throwable
{
return (DependencyBuilder) loadFromProperties(PropertyConfigurationConstants.DEPENDENCY_BUILDER_NAME, PropertyConfigurationConstants.DEPENDENCY_BUILDER_DEFAULT, DependencyBuilder.class);
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/property/PropertyConfigurationConstants.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/property/PropertyConfigurationConstants.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/config/plugins/property/PropertyConfigurationConstants.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -26,7 +26,6 @@
import org.jboss.classadapter.spi.DependencyBuilder;
import org.jboss.joinpoint.spi.JoinpointFactoryBuilder;
import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.repository.spi.MetaDataContextFactory;
/**
* Constants.
@@ -60,12 +59,6 @@
/** The JoinpointFactoryBuiylder default value */
static final String JOIN_POINT_FACTORY_BUILDER_DEFAULT="org.jboss.aop.microcontainer.integration.AOPJoinpointFactoryBuilder:org.jboss.joinpoint.plugins.BasicJoinpointFactoryBuilder";
- /** The MetaDataContextFactory property name */
- static final String META_DATA_CONTEXT_FACTORY_BUILDER_NAME = MetaDataContextFactory.class.getName();
-
- /** The MetaDataContextFactory default value */
- static final String META_DATA_CONTEXT_FACTORY_BUILDER_DEFAULT="org.jboss.aop.microcontainer.integration.AOPMetaDataContextFactory:org.jboss.repository.plugins.basic.BasicMetaDataContextFactory";
-
/** The TypeInfoFactory property name */
static final String TYPE_INFO_FACTORY_NAME = TypeInfoFactory.class.getName();
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/config/spi/Configuration.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/config/spi/Configuration.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/config/spi/Configuration.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -27,7 +27,6 @@
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.reflect.spi.TypeInfo;
import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.repository.spi.MetaDataContextFactory;
/**
* Configuration.<p>
@@ -106,11 +105,4 @@
* @return the JoinpointFactoryBuilder
*/
JoinpointFactoryBuilder getJoinpointFactoryBuilder();
-
- /**
- * Get the metadata context factory
- *
- * @return the MetaDataContextFactory
- */
- MetaDataContextFactory getMetaDataContextFactory();
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/BasicJoinpointFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/BasicJoinpointFactory.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/BasicJoinpointFactory.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -31,7 +31,6 @@
import org.jboss.reflect.spi.ConstructorInfo;
import org.jboss.reflect.spi.FieldInfo;
import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.repository.spi.MetaDataContext;
import org.jboss.util.JBossObject;
import org.jboss.util.JBossStringBuilder;
@@ -45,13 +44,9 @@
/** The class info */
protected ClassInfo classInfo;
- /** The metadata context */
- protected MetaDataContext metaDataContext;
-
- public BasicJoinpointFactory(ClassInfo classInfo, MetaDataContext metaDataContext)
+ public BasicJoinpointFactory(ClassInfo classInfo)
{
this.classInfo = classInfo;
- this.metaDataContext = metaDataContext;
}
public ClassInfo getClassInfo()
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/BasicJoinpointFactoryBuilder.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/BasicJoinpointFactoryBuilder.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/BasicJoinpointFactoryBuilder.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -24,7 +24,6 @@
import org.jboss.joinpoint.spi.JoinpointFactory;
import org.jboss.joinpoint.spi.JoinpointFactoryBuilder;
import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.repository.spi.MetaDataContext;
/**
* BasicJoinpointFactoryBuilder.
@@ -34,13 +33,8 @@
*/
public class BasicJoinpointFactoryBuilder implements JoinpointFactoryBuilder
{
- public JoinpointFactory createJoinpointFactory(ClassInfo classInfo, MetaDataContext metaDataContext)
- {
- return new BasicJoinpointFactory(classInfo, metaDataContext);
- }
-
public JoinpointFactory createJoinpointFactory(ClassInfo classInfo)
{
- return createJoinpointFactory(classInfo, null);
+ return new BasicJoinpointFactory(classInfo);
}
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/spi/JoinpointFactoryBuilder.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/spi/JoinpointFactoryBuilder.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/spi/JoinpointFactoryBuilder.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -22,7 +22,6 @@
package org.jboss.joinpoint.spi;
import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.repository.spi.MetaDataContext;
/**
* JoinpointFactoryBuilder.
@@ -39,13 +38,4 @@
* @return the joinpoint factory
*/
JoinpointFactory createJoinpointFactory(ClassInfo classInfo);
-
- /**
- * Create a joinpoint factory
- *
- * @param classInfo the class info
- * @param metaDataContext the metadata context
- * @return the joinpoint factory
- */
- JoinpointFactory createJoinpointFactory(ClassInfo classInfo, MetaDataContext metaDataContext);
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/context/AbstractMetaDataContext.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/context/AbstractMetaDataContext.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/context/AbstractMetaDataContext.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -39,6 +39,7 @@
import org.jboss.metadata.spi.retrieval.cummulative.CummulativeMetaDatasItem;
import org.jboss.metadata.spi.scope.Scope;
import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.signature.Signature;
/**
* AbstractMetaDataContext.
@@ -266,4 +267,32 @@
return null;
}
+
+ public MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature)
+ {
+ if (signature == null)
+ return null;
+
+ List<MetaDataRetrieval> componentRetrievals = null;
+ for (int i = 0; i < retrievals.size(); ++i)
+ {
+ MetaDataRetrieval retrieval = retrievals.get(i);
+ retrieval = retrieval.getComponentMetaDataRetrieval(signature);
+ if (retrieval != null)
+ {
+ if (componentRetrievals == null)
+ componentRetrievals = new ArrayList<MetaDataRetrieval>();
+ componentRetrievals.add(retrieval);
+ }
+ }
+
+ MetaDataContext parentComponent = null;
+ if (parent != null)
+ parentComponent = (MetaDataContext) parent.getComponentMetaDataRetrieval(signature);
+
+ if (componentRetrievals == null)
+ return parentComponent;
+
+ return new AbstractMetaDataContext(parentComponent, componentRetrievals);
+ }
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/context/CachingMetaDataContext.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/context/CachingMetaDataContext.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/context/CachingMetaDataContext.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -33,6 +33,7 @@
import org.jboss.metadata.spi.retrieval.MetaDataItem;
import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
import org.jboss.metadata.spi.retrieval.MetaDatasItem;
+import org.jboss.metadata.spi.signature.Signature;
/**
* CachingMetaDataContext.
@@ -55,6 +56,8 @@
/** All meta data */
private volatile MetaDatasItem cachedMetaDatasItem;
+ private volatile Map<Signature, MetaDataRetrieval> cachedComponents;
+
/** The valid time */
private volatile long validTime;
@@ -221,4 +224,46 @@
return result;
}
+
+ public void append(MetaDataRetrieval retrieval)
+ {
+ super.append(retrieval);
+ cachedComponents = null;
+ }
+
+ public void prepend(MetaDataRetrieval retrieval)
+ {
+ super.prepend(retrieval);
+ cachedComponents = null;
+ }
+
+ public void remove(MetaDataRetrieval retrieval)
+ {
+ super.remove(retrieval);
+ cachedComponents = null;
+ }
+
+ public MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature)
+ {
+ if (signature == null)
+ return null;
+
+ if (cachedComponents != null)
+ {
+ MetaDataRetrieval retrieval = cachedComponents.get(signature);
+ if (retrieval != null)
+ return retrieval;
+ }
+
+ MetaDataRetrieval retrieval = super.getComponentMetaDataRetrieval(signature);
+
+ if (retrieval != null)
+ {
+ if (cachedComponents == null)
+ cachedComponents = new ConcurrentHashMap<Signature, MetaDataRetrieval>();
+ cachedComponents.put(signature, retrieval);
+ }
+
+ return retrieval;
+ }
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/BasicMetaDataLoader.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/BasicMetaDataLoader.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/BasicMetaDataLoader.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -27,7 +27,9 @@
import org.jboss.metadata.generic.GenericMatcher;
import org.jboss.metadata.spi.retrieval.AnnotationItem;
import org.jboss.metadata.spi.retrieval.MetaDataItem;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.signature.Signature;
/**
* BasicMetaDataLoader.
@@ -65,4 +67,9 @@
MetaDataItem[] metaDatas = retrieveMetaData().getMetaDatas();
return GenericMatcher.matchMetaDataItem(metaDatas, name);
}
+
+ public MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature)
+ {
+ return null;
+ }
}
Added: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/SimpleMetaDataLoader.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/SimpleMetaDataLoader.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/SimpleMetaDataLoader.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,64 @@
+/*
+* 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 org.jboss.metadata.spi.retrieval.AnnotationItem;
+import org.jboss.metadata.spi.retrieval.AnnotationsItem;
+import org.jboss.metadata.spi.retrieval.simple.SimpleAnnotationItem;
+import org.jboss.metadata.spi.retrieval.simple.SimpleAnnotationsItem;
+
+/**
+ * SimpleMetaDataLoader.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 46146 $
+ */
+public class SimpleMetaDataLoader extends BasicMetaDataLoader
+{
+ /** The annotations */
+ private AnnotationsItem annotationsItem;
+
+ /**
+ * Create a new SimpleMetaDataLoader.
+ *
+ * @param annotations the annoations
+ */
+ @SuppressWarnings("unchecked")
+ public SimpleMetaDataLoader(Annotation[] annotations)
+ {
+ if (annotations == null)
+ throw new IllegalArgumentException("Null annotations");
+
+ AnnotationItem[] annotationItems = new AnnotationItem[annotations.length];
+ for (int i = 0; i < annotations.length; ++i)
+ annotationItems[i] = new SimpleAnnotationItem(annotations[i]);
+
+ annotationsItem = new SimpleAnnotationsItem(annotationItems);
+ }
+
+ public AnnotationsItem retrieveAnnotations()
+ {
+ return annotationsItem;
+ }
+}
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 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/memory/MemoryMetaDataLoader.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -28,16 +28,19 @@
import java.util.concurrent.ConcurrentHashMap;
import org.jboss.metadata.plugins.loader.AbstractMutableMetaDataLoader;
+import org.jboss.metadata.spi.ComponentMutableMetaData;
import org.jboss.metadata.spi.retrieval.AnnotationItem;
import org.jboss.metadata.spi.retrieval.AnnotationsItem;
import org.jboss.metadata.spi.retrieval.Item;
import org.jboss.metadata.spi.retrieval.MetaDataItem;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
import org.jboss.metadata.spi.retrieval.MetaDatasItem;
import org.jboss.metadata.spi.retrieval.basic.BasicAnnotationItem;
import org.jboss.metadata.spi.retrieval.basic.BasicAnnotationsItem;
import org.jboss.metadata.spi.retrieval.basic.BasicMetaDataItem;
import org.jboss.metadata.spi.retrieval.basic.BasicMetaDatasItem;
import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.signature.Signature;
/**
* MemoryMetaDataLoader.
@@ -45,7 +48,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
-public class MemoryMetaDataLoader extends AbstractMutableMetaDataLoader
+public class MemoryMetaDataLoader extends AbstractMutableMetaDataLoader implements ComponentMutableMetaData
{
/** The annotations */
private volatile Map<String, BasicAnnotationItem> annotations;
@@ -53,12 +56,15 @@
/** MetaData by name */
private volatile Map<String, BasicMetaDataItem> metaDataByName;
+ /** The component metadata */
+ private volatile Map<Signature, MetaDataRetrieval> components;
+
/** All annotations */
private volatile BasicAnnotationsItem cachedAnnotationsItem;
/** All meta data */
private volatile BasicMetaDatasItem cachedMetaDatasItem;
-
+
/** Whether we should cache items */
private final boolean cachable;
@@ -358,6 +364,36 @@
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);
+ }
+
/**
* Invalidate the annotations item
*/
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 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/AnnotatedElementMetaDataLoader.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -23,16 +23,26 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
import java.lang.reflect.Member;
+import java.lang.reflect.Method;
import org.jboss.metadata.plugins.loader.BasicMetaDataLoader;
+import org.jboss.metadata.plugins.loader.SimpleMetaDataLoader;
import org.jboss.metadata.spi.retrieval.AnnotationItem;
import org.jboss.metadata.spi.retrieval.AnnotationsItem;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
import org.jboss.metadata.spi.retrieval.simple.SimpleAnnotationItem;
import org.jboss.metadata.spi.retrieval.simple.SimpleAnnotationsItem;
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.ConstructorSignature;
+import org.jboss.metadata.spi.signature.FieldSignature;
+import org.jboss.metadata.spi.signature.MethodParametersSignature;
+import org.jboss.metadata.spi.signature.MethodSignature;
+import org.jboss.metadata.spi.signature.Signature;
import org.jboss.util.JBossStringBuilder;
import org.jboss.util.Strings;
@@ -101,6 +111,69 @@
return new SimpleAnnotationItem<T>(annotation);
}
+ public MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature)
+ {
+ if (signature == null)
+ return null;
+
+ if (annotated instanceof Class)
+ {
+ Class clazz = (Class) annotated;
+ if (signature instanceof ConstructorSignature)
+ {
+ try
+ {
+ Constructor constructor = clazz.getConstructor(signature.getParametersTypes(clazz));
+ return new AnnotatedElementMetaDataLoader(constructor);
+ }
+ catch (NoSuchMethodException e)
+ {
+ return null;
+ }
+ }
+ else if (signature instanceof MethodSignature)
+ {
+ try
+ {
+ Method method = clazz.getMethod(signature.getName(), signature.getParametersTypes(clazz));
+ return new AnnotatedElementMetaDataLoader(method);
+ }
+ catch (NoSuchMethodException e)
+ {
+ return null;
+ }
+ }
+ else if (signature instanceof MethodParametersSignature)
+ {
+ try
+ {
+ Method method = clazz.getMethod(signature.getName(), signature.getParametersTypes(clazz));
+ Annotation[][] paramAnnotations = method.getParameterAnnotations();
+ MethodParametersSignature sig = (MethodParametersSignature) signature;
+ return new SimpleMetaDataLoader(paramAnnotations[sig.getParam()]);
+ }
+ catch (NoSuchMethodException e)
+ {
+ return null;
+ }
+ }
+ else if (signature instanceof FieldSignature)
+ {
+ try
+ {
+ Field field = clazz.getField(signature.getName());
+ return new AnnotatedElementMetaDataLoader(field);
+ }
+ catch (NoSuchFieldException e)
+ {
+ return null;
+ }
+ }
+ }
+
+ return null;
+ }
+
public String toString()
{
JBossStringBuilder buffer = new JBossStringBuilder();
Added: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/ComponentMutableMetaData.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/ComponentMutableMetaData.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/ComponentMutableMetaData.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,51 @@
+/*
+* 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.spi;
+
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.signature.Signature;
+
+/**
+ * ComponentMutableMetaData.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 57133 $
+ */
+public interface ComponentMutableMetaData
+{
+ /**
+ * Add a component metadata
+ *
+ * @param signature the signature
+ * @param component the component
+ * @return any previous component at that signature
+ */
+ MetaDataRetrieval addComponentMetaDataRetrieval(Signature signature, MetaDataRetrieval component);
+
+ /**
+ * Remove a component metadata
+ *
+ * @param signature the signature
+ * @return any previous component at that signature
+ */
+ MetaDataRetrieval removeComponentMetaDataRetrieval(Signature signature);
+}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/MetaData.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/MetaData.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/MetaData.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -23,6 +23,8 @@
import java.lang.annotation.Annotation;
+import org.jboss.metadata.spi.signature.Signature;
+
/**
* MetaData.
*
@@ -140,4 +142,12 @@
* @return true when the metadata is present
*/
boolean isMetaDataPresent(String name, Class<?> type);
+
+ /**
+ * Get the component metadata
+ *
+ * @param signature the signature
+ * @return the component metadata
+ */
+ MetaData getComponentMetaData(Signature signature);
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrieval.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrieval.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrieval.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -24,6 +24,7 @@
import java.lang.annotation.Annotation;
import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.signature.Signature;
/**
* MetaDataRetrieval.
@@ -100,4 +101,12 @@
* @return the metadata or null if not present
*/
MetaDataItem retrieveMetaData(String name);
+
+ /**
+ * Get the component metadata retrieval
+ *
+ * @param signature the signature
+ * @return the component metadata retrieval
+ */
+ MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature);
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrievalToMetaDataBridge.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrievalToMetaDataBridge.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/retrieval/MetaDataRetrievalToMetaDataBridge.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -24,6 +24,7 @@
import java.lang.annotation.Annotation;
import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.signature.Signature;
/**
* MetaDataRetrievalToMetaDataBridge.
@@ -36,6 +37,11 @@
/** The meta data retrieval method */
private MetaDataRetrieval retrieval;
+ /**
+ * Create a new MetaDataRetrievalToMetaDataBridge.
+ *
+ * @param retrieval the retrieval
+ */
public MetaDataRetrievalToMetaDataBridge(MetaDataRetrieval retrieval)
{
if (retrieval == null)
@@ -148,6 +154,35 @@
return getMetaData(name) != null;
}
+ public MetaData getComponentMetaData(Signature signature)
+ {
+ MetaDataRetrieval component = retrieval.getComponentMetaDataRetrieval(signature);
+ if (component == null)
+ return null;
+ return new MetaDataRetrievalToMetaDataBridge(component);
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+ if (obj == null || obj instanceof MetaDataRetrievalToMetaDataBridge == false)
+ return false;
+
+ MetaDataRetrievalToMetaDataBridge other = (MetaDataRetrievalToMetaDataBridge) obj;
+ return retrieval.equals(other.retrieval);
+ }
+
+ public int hashCode()
+ {
+ return retrieval.hashCode();
+ }
+
+ public String toString()
+ {
+ return super.toString() + "{" + retrieval.getScope() + "}";
+ }
+
/**
* Get the meta data retrieval
*
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 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKey.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -299,11 +299,14 @@
return scopes.hashCode();
}
- protected ScopeKey clone()
+ public ScopeKey clone()
{
try
{
- return (ScopeKey) super.clone();
+ ScopeKey result = (ScopeKey) super.clone();
+ result.scopes = Collections.synchronizedSortedMap(new TreeMap<ScopeLevel, Scope>(scopes));
+ result.frozen = false;
+ return result;
}
catch (CloneNotSupportedException e)
{
Added: 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 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/ConstructorSignature.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,63 @@
+/*
+* 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.spi.signature;
+
+import java.lang.reflect.Constructor;
+
+/**
+ * Constructor Signature.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConstructorSignature extends Signature
+{
+ /**
+ * Create a new Signature.
+ *
+ * @param parameters the parameters
+ */
+ public ConstructorSignature(String[] parameters)
+ {
+ super(parameters);
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param parameters the parameters
+ */
+ public ConstructorSignature(Class... parameters)
+ {
+ super(parameters);
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param constructor the constructor
+ */
+ public ConstructorSignature(Constructor<?> constructor)
+ {
+ super(constructor.getParameterTypes());
+ }
+}
Added: 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 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/FieldSignature.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,53 @@
+/*
+* 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.spi.signature;
+
+import java.lang.reflect.Field;
+
+/**
+ * Field Signature.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class FieldSignature extends Signature
+{
+ /**
+ * Create a new Signature.
+ *
+ * @param name the name
+ */
+ public FieldSignature(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param field the field
+ */
+ public FieldSignature(Field field)
+ {
+ super(field.getName());
+ }
+}
Added: 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 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/MethodParametersSignature.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,102 @@
+/*
+* 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.spi.signature;
+
+import java.lang.reflect.Method;
+
+/**
+ * Method parameters Signature.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodParametersSignature extends Signature
+{
+ /** The parameter number */
+ private int param;
+
+ /**
+ * Create a new Signature.
+ *
+ * @param name the name
+ * @param param the parameter number
+ * @param parameters the parameters
+ */
+ public MethodParametersSignature(String name, String[] parameters, int param)
+ {
+ super(name, parameters);
+ this.param = param;
+ checkParam();
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param name the name
+ * @param param the parameter number
+ * @param parameters the parameters
+ */
+ public MethodParametersSignature(String name, int param, Class... parameters)
+ {
+ super(name, parameters);
+ this.param = param;
+ checkParam();
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param method the method
+ * @param param the parameter number
+ */
+ public MethodParametersSignature(Method method, int param)
+ {
+ super(method.getName(), method.getParameterTypes());
+ this.param = param;
+ checkParam();
+ }
+
+ /**
+ * Get the param.
+ *
+ * @return the param.
+ */
+ public int getParam()
+ {
+ return param;
+ }
+
+ /**
+ * Check the param number makes sense
+ */
+ protected void checkParam()
+ {
+ if (param < 0 || param >= getParameters().length)
+ throw new IllegalArgumentException("param must be between 0 and " + getParameters().length);
+ }
+
+ protected void internalToString(StringBuilder builder)
+ {
+ super.internalToString(builder);
+ builder.append("#").append(param);
+ }
+}
Added: 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 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/MethodSignature.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,65 @@
+/*
+* 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.spi.signature;
+
+import java.lang.reflect.Method;
+
+/**
+ * Method Signature.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodSignature extends Signature
+{
+ /**
+ * Create a new Signature.
+ *
+ * @param name the name
+ * @param parameters the parameters
+ */
+ public MethodSignature(String name, String[] parameters)
+ {
+ super(name, parameters);
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param name the name
+ * @param parameters the parameters
+ */
+ public MethodSignature(String name, Class... parameters)
+ {
+ super(name, parameters);
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param method the method
+ */
+ public MethodSignature(Method method)
+ {
+ super(method.getName(), method.getParameterTypes());
+ }
+}
Added: 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 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/Signature.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,290 @@
+/*
+* 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.spi.signature;
+
+import java.util.Arrays;
+
+/**
+ * Signature.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class Signature
+{
+ /** No Name */
+ public static final String NO_NAME = new String("?%NO_NAME%?");
+
+ /** No Parameters */
+ public static final String[] NO_PARAMETERS = new String[0];
+
+ /** No Parameters Types */
+ public static final Class[] NO_PARAMETER_TYPES = new Class[0];
+
+ /** The name */
+ private String name;
+
+ /** The parameters */
+ private String[] parameters;
+
+ /** The parameter types */
+ private Class[] parameterTypes;
+
+ /** The cached hashcode */
+ private transient int cachedHashCode = Integer.MIN_VALUE;
+
+ /**
+ * Convert classes to string
+ *
+ * @param parameters the parameters as classes
+ * @return the parameters as strings
+ */
+ private static String[] classesToStrings(Class... parameters)
+ {
+ if (parameters == null || parameters.length == 0)
+ return NO_PARAMETERS;
+
+ String[] result = new String[parameters.length];
+ for (int i = 0; i < result.length; ++i)
+ {
+ if (parameters[i] == null)
+ throw new IllegalArgumentException("Null class");
+ result[i] = parameters[i].getName();
+ }
+ return result;
+ }
+
+ /**
+ * Convert classes to string
+ *
+ * @param clazz the reference class
+ * @param parameters the parameters as strings
+ * @return the parameters as classes
+ */
+ private static Class[] stringstoClasses(Class clazz, String... parameters)
+ {
+ if (clazz == null)
+ throw new IllegalArgumentException("Null clazz");
+
+ ClassLoader cl = clazz.getClassLoader();
+ if (cl == null)
+ cl = Class.class.getClassLoader();
+
+ return stringstoClasses(cl, parameters);
+ }
+
+ /**
+ * Convert classes to string
+ *
+ * @param cl the classloader
+ * @param parameters the parameters as strings
+ * @return the parameters as classes
+ */
+ private static Class[] stringstoClasses(ClassLoader cl, String... parameters)
+ {
+ if (cl == null)
+ throw new IllegalArgumentException("Null classloader");
+
+ if (parameters == null || parameters.length == 0)
+ return NO_PARAMETER_TYPES;
+
+ Class[] result = new Class[parameters.length];
+ for (int i = 0; i < result.length; ++i)
+ {
+ try
+ {
+ result[i] = cl.loadClass(parameters[i]);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IllegalStateException("Class not found: " + parameters[i], e);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Create a new Signature.
+ */
+ public Signature()
+ {
+ this(NO_NAME, NO_PARAMETER_TYPES, NO_PARAMETERS);
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param name the name
+ */
+ public Signature(String name)
+ {
+ this(name, null, NO_PARAMETERS);
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param parameters the parameters
+ */
+ public Signature(String... parameters)
+ {
+ this(NO_NAME, null, parameters);
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param parameters the parameters
+ */
+ public Signature(Class... parameters)
+ {
+ this(NO_NAME, parameters, null);
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param name the name
+ * @param parameters the parameters
+ */
+ public Signature(String name, Class... parameters)
+ {
+ this(name, parameters, null);
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param name the name
+ * @param parameters the parameters
+ */
+ public Signature(String name, String... parameters)
+ {
+ this(name, null, parameters);
+ }
+
+ /**
+ * Create a new Signature.
+ *
+ * @param name the name
+ * @param parameterTypes the parameterTypes
+ * @param parameters the parameters
+ */
+ private Signature(String name, Class[] parameterTypes, String[] parameters)
+ {
+ this.name = name;
+ this.parameters = parameters;
+ this.parameterTypes = parameterTypes;
+ if (name == null)
+ this.name = NO_NAME;
+ if (parameters == null)
+ this.parameters = classesToStrings(parameterTypes);
+ for (int i = 0; i < this.parameters.length; ++i)
+ {
+ if (this.parameters[i] == null)
+ throw new IllegalArgumentException("Null parameter");
+ }
+ }
+
+ /**
+ * Get the name.
+ *
+ * @return the name.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Get the parameters.
+ *
+ * @return the parameters.
+ */
+ public String[] getParameters()
+ {
+ return parameters;
+ }
+
+ /**
+ * Get the parameter types.
+ *
+ * @param clazz the reference class
+ * @return the parameter types.
+ */
+ public Class[] getParametersTypes(Class clazz)
+ {
+ if (parameterTypes == null)
+ return stringstoClasses(clazz, parameters);
+ return parameterTypes;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+ if (obj == null || obj instanceof Signature == false)
+ return false;
+
+ Signature other = (Signature) obj;
+
+ if (getName().equals(other.getName()) == false)
+ return false;
+
+ if (parameters.length != other.parameters.length)
+ return false;
+
+ for (int i = 0; i < parameters.length; ++i)
+ {
+ if (parameters[i].equals(other.parameters[i]) == false)
+ return false;
+ }
+ return true;
+ }
+
+ public int hashCode()
+ {
+ if (cachedHashCode == Integer.MIN_VALUE)
+ cachedHashCode = toString().hashCode();
+ return cachedHashCode;
+ }
+
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ internalToString(builder);
+ return builder.toString();
+ }
+
+ /**
+ * Build the to String
+ *
+ * @param builder the builder to use
+ */
+ protected void internalToString(StringBuilder builder)
+ {
+ if (name != null)
+ builder.append(name);
+ if (parameters != null)
+ builder.append(Arrays.asList(parameters));
+ }
+}
Added: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/stack/MetaDataStack.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/stack/MetaDataStack.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/stack/MetaDataStack.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,124 @@
+/*
+* 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.spi.stack;
+
+import java.util.ArrayList;
+
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ * MetaDataStack.
+ *
+ * TODO add some security to the mutable operations
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public final class MetaDataStack
+{
+ /** The stack */
+ private static ThreadLocal<ArrayList<MetaData>> stack = new ThreadLocal<ArrayList<MetaData>>()
+ {
+ protected ArrayList<MetaData> initialValue()
+ {
+ return new ArrayList<MetaData>();
+ }
+ };
+
+ /**
+ * Push some meta data
+ *
+ * @param metaData the meta data
+ */
+ public static void push(MetaData metaData)
+ {
+ /** TODO MetaDataStackPermission
+ if (metaData == null)
+ throw new IllegalArgumentException("Null meta data");
+ */
+
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(MetaDataStackPermission.MODIFY);
+
+ stack.get().add(metaData);
+ }
+
+ /**
+ * Pop some meta data
+ */
+ public static void pop()
+ {
+ /** TODO MetaDataStackPermission
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(MetaDataStackPermission.MODIFY);
+ */
+
+ ArrayList<MetaData> list = stack.get();
+ if (list.size() == 0)
+ throw new IllegalArgumentException("Empty stack");
+
+ list.remove(list.size()-1);
+ }
+
+
+ /**
+ * Peek some meta data
+ *
+ * @return the metadata or null if there isn't one
+ */
+ public static MetaData peek()
+ {
+ /** TODO MetaDataStackPermission
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(MetaDataStackPermission.PEEK);
+ */
+
+ ArrayList<MetaData> list = stack.get();
+ if (list.size() == 0)
+ return null;
+ return list.get(list.size()-1);
+ }
+
+ /**
+ * Mask the metadataa
+ */
+ public static void mask()
+ {
+ /** TODO MetaDataStackPermission
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(MetaDataStackPermission.MODIFY);
+ */
+
+ stack.get().add(null);
+ }
+
+ /**
+ * Unmask the metadata
+ */
+ public static void unmask()
+ {
+ pop();
+ }
+}
Added: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/stack/MetaDataStackPermission.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/stack/MetaDataStackPermission.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/stack/MetaDataStackPermission.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,211 @@
+/*
+* 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.spi.stack;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.security.BasicPermission;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * This permission represents "trust" in a signer or codebase.
+ *
+ * It contains a target name but no actions list. The targets are
+ * <ul>
+ * <li> modify - whether the caller can push/pop onto the stack
+ * <li> peek - whether the caller can peek onto the stack
+ * <li> * - all
+ * </ul>
+ *
+ * @author adrian at jboss.com
+ * @version $Revision: 57306 $
+ */
+public class MetaDataStackPermission extends BasicPermission
+{
+ /** For serialization */
+ private static final long serialVersionUID = 5661980843569388590L;
+
+ /** The modify permission */
+ static MetaDataStackPermission MODIFY = new MetaDataStackPermission("modify");
+
+ /** The peek permission */
+ static MetaDataStackPermission PEEK = new MetaDataStackPermission("peek");
+
+ /** Whether we have all names */
+ private transient boolean allNames;
+
+ /**
+ * Create a new Permission
+ *
+ * @param name the target
+ * @throws IllegalArgumentException for invalid name
+ * @throws NullPointerException for null name
+ */
+ public MetaDataStackPermission(String name)
+ {
+ this(name, null);
+ }
+
+ /**
+ * Create a new Permission
+ *
+ * @param name the target
+ * @param actions the actions
+ * @throws IllegalArgumentException for an invalid name or target
+ * @throws NullPointerException for null name
+ */
+ public MetaDataStackPermission(String name, String actions)
+ {
+ super(name, actions);
+ init(name, actions);
+ }
+
+ /**
+ * @return human readable string.
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer(100);
+ buffer.append(getClass().getName()).append(":");
+ buffer.append(" name=").append(getName());
+ buffer.append(" actions=").append(getActions());
+ return buffer.toString();
+ }
+
+ /**
+ * Checks if this KernelPermission object "implies" the specified
+ * permission. More specifically, this method returns true if:
+ * p is an instance of KernelPermission,
+ * p's target names are a subset of this object's target names
+ *
+ * The configure permission implies the access permission.
+ *
+ * @param p the permission
+ * @return true when the permission is implied
+ */
+ public boolean implies(Permission p)
+ {
+ if( (p instanceof MetaDataStackPermission) == false)
+ return false;
+
+ return (allNames == true);
+ }
+
+ /**
+ * Must override to handle the configure implies access relationship.
+ *
+ * @return the permission collection
+ */
+ public PermissionCollection newPermissionCollection()
+ {
+ return new MetaDataStackPermissionCollection();
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException
+ {
+ ois.defaultReadObject();
+ init(getName(), getActions());
+ }
+
+ /**
+ * Construct a new KernelPermission for a given name
+ *
+ * @param name the name of the permission to grant
+ * @param actions unused
+ * @exception NullPointerException if the name is null
+ * @exception IllegalArgumentException if the name is not * or one of the
+ * allowed names or a comma-separated list of the allowed names, or if
+ * actions is a non-null non-empty string.
+ */
+ private void init(String name, String actions)
+ {
+ if( name == null )
+ throw new NullPointerException("name cannot be null");
+
+ if( actions != null && actions.length() > 0 )
+ throw new IllegalArgumentException("actions must be null or empty");
+
+ if (name.equals("*") == false &&
+ name.equals("modify") == false &&
+ name.equals("peek") == false)
+ throw new IllegalArgumentException("Unknown name: " + name);
+ allNames = name.equals("*");
+ }
+
+ /**
+ * A MetaDataStackPermissionCollection.
+ */
+ class MetaDataStackPermissionCollection extends PermissionCollection
+ {
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 3256442516797665329L;
+
+ /** The permissions */
+ private HashSet<Permission> permissions = new HashSet<Permission>();
+
+ /** Whether we have all permissions */
+ private boolean hasAll;
+
+ public void add(Permission p)
+ {
+ if (isReadOnly())
+ throw new SecurityException("Collection is read-only");
+ if (p instanceof MetaDataStackPermission)
+ permissions.add(p);
+ if (p.getName().equals("*"))
+ hasAll = true;
+ }
+
+ public boolean implies(Permission p)
+ {
+ boolean implies = false;
+ if (p instanceof MetaDataStackPermission)
+ {
+ implies = hasAll;
+ if (implies == false)
+ implies = permissions.contains(p);
+ }
+ return implies;
+ }
+
+ public Enumeration<Permission> elements()
+ {
+ final Iterator<Permission> iter = permissions.iterator();
+ return new Enumeration<Permission>()
+ {
+ public boolean hasMoreElements()
+ {
+ return iter.hasNext();
+ }
+
+ public Permission nextElement()
+ {
+ return iter.next();
+ }
+ };
+ }
+ }
+}
\ No newline at end of file
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/VirtualFile.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/VirtualFile.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/VirtualFile.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -34,10 +34,10 @@
import java.util.concurrent.atomic.AtomicBoolean;
import org.jboss.util.collection.WeakSet;
-import org.jboss.virtual .plugins.vfs.helpers.FilterVirtualFileVisitor;
-import org.jboss.virtual .plugins.vfs.helpers.MatchAllVirtualFileFilter;
-import org.jboss.virtual .spi.VFSContext;
-import org.jboss.virtual .spi.VirtualFileHandler;
+import org.jboss.virtual.plugins.vfs.helpers.FilterVirtualFileVisitor;
+import org.jboss.virtual.plugins.vfs.helpers.MatchAllVirtualFileFilter;
+import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.spi.VirtualFileHandler;
/**
* A virtual file as seen by the user
@@ -126,6 +126,7 @@
* @return the full URI to the VF in the VFS.
* @throws URISyntaxException if a uri cannot be parsed
* @throws IllegalStateException if the file is closed
+ * @throws MalformedURLException for a bad url
*/
public URI toURI() throws MalformedURLException, URISyntaxException
{
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/VfsArchiveBrowser.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/VfsArchiveBrowser.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/VfsArchiveBrowser.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -21,19 +21,18 @@
*/
package org.jboss.virtual.plugins.context;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
import org.jboss.util.file.ArchiveBrowser;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
import org.jboss.virtual.VisitorAttributes;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
+import org.jboss.virtual.plugins.vfs.helpers.FilterVirtualFileVisitor;
import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
-import org.jboss.virtual.plugins.vfs.helpers.FilterVirtualFileVisitor;
-import org.jboss.virtual.plugins.context.jar.JarUtils;
-import java.util.Iterator;
-import java.util.List;
-import java.io.InputStream;
-import java.io.IOException;
-
/**
* This is a bridge to an older, crappier API written by myself.
*
@@ -44,6 +43,7 @@
*/
public class VfsArchiveBrowser implements Iterator
{
+ /** TODO WHAT DOES THIS DO? It is unused */
private ArchiveBrowser.Filter filter;
private VirtualFile vf;
private Iterator<VirtualFile> it;
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/VfsArchiveBrowserFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/VfsArchiveBrowserFactory.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/VfsArchiveBrowserFactory.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -21,16 +21,15 @@
*/
package org.jboss.virtual.plugins.context;
-import org.jboss.util.file.ArchiveBrowserFactory;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+
import org.jboss.util.file.ArchiveBrowser;
+import org.jboss.util.file.ArchiveBrowserFactory;
import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VFS;
import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
-import java.util.Iterator;
-import java.net.URL;
-import java.io.IOException;
-
/**
* This is a bridge to an older, crappier API written by myself.
*
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/file/FileHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/file/FileHandler.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/file/FileHandler.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -25,20 +25,19 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
-import java.net.URI;
-import java.net.URL;
import java.net.MalformedURLException;
+import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.HashMap;
import org.jboss.virtual.plugins.context.AbstractURLHandler;
import org.jboss.virtual.plugins.context.StructuredVirtualFileHandler;
import org.jboss.virtual.spi.VirtualFileHandler;
-import org.jboss.virtual.VFS;
/**
* FileHandler.
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -392,8 +392,8 @@
/**
* Convert a URL into a JarFIle
*
- * @param url
- * @return
+ * @param url the url to convert
+ * @return the jar file
* @throws IOException
*/
public static JarFile fromURL(URL url) throws IOException
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -24,10 +24,8 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.net.URL;
import java.net.URISyntaxException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/protocol/vfsfile/Handler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/protocol/vfsfile/Handler.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/protocol/vfsfile/Handler.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -21,24 +21,20 @@
*/
package org.jboss.virtual.protocol.vfsfile;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.net.URLClassLoader;
import java.net.URLConnection;
import java.net.URLStreamHandler;
-import java.net.URLClassLoader;
+import java.util.Enumeration;
+import java.util.HashSet;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
-import java.util.HashSet;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.Collections;
-import java.util.HashMap;
+import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
+
/**
* URLStreamHandler for VFS
*
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/protocol/vfsjar/Handler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/protocol/vfsjar/Handler.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/protocol/vfsjar/Handler.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -21,18 +21,14 @@
*/
package org.jboss.virtual.protocol.vfsjar;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
-
-import java.net.URLStreamHandler;
-import java.net.URLConnection;
-import java.net.URL;
-import java.net.URISyntaxException;
import java.io.IOException;
-import java.io.File;
import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
+
/**
* URLStreamHandler for VFS
*
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/spi/VirtualFileHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/spi/VirtualFileHandler.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/spi/VirtualFileHandler.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -58,7 +58,7 @@
/**
* Get a VFS-based URL
*
- * @return
+ * @return the url
* @throws MalformedURLException
* @throws URISyntaxException
*/
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/joinpoint/test/JoinpointTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/joinpoint/test/JoinpointTest.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/joinpoint/test/JoinpointTest.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -117,7 +117,7 @@
{
TypeInfoFactory typeFactory = getTypeInfoFactory();
ClassInfo info = (ClassInfo) typeFactory.getTypeInfo(clazz);
- return new BasicJoinpointFactory(info, null);
+ return new BasicJoinpointFactory(info);
}
protected abstract TypeInfoFactory getTypeInfoFactory();
Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/memory/test/MemoryLoaderComponentBasicAnnotationsUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/memory/test/MemoryLoaderComponentBasicAnnotationsUnitTestCase.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/memory/test/MemoryLoaderComponentBasicAnnotationsUnitTestCase.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,108 @@
+/*
+* 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.test.metadata.loader.memory.test;
+
+import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge;
+import org.jboss.metadata.spi.signature.ConstructorSignature;
+import org.jboss.metadata.spi.signature.FieldSignature;
+import org.jboss.metadata.spi.signature.MethodParametersSignature;
+import org.jboss.metadata.spi.signature.MethodSignature;
+import org.jboss.test.metadata.shared.ComponentBasicAnnotationsTest;
+import org.jboss.test.metadata.shared.support.TestAnnotation1Impl;
+import org.jboss.test.metadata.shared.support.TestAnnotation2Impl;
+import org.jboss.test.metadata.shared.support.TestAnnotationImpl;
+
+/**
+ * MemoryLoaderComponentBasicAnnotationsUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MemoryLoaderComponentBasicAnnotationsUnitTestCase extends ComponentBasicAnnotationsTest
+{
+ public MemoryLoaderComponentBasicAnnotationsUnitTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ protected MetaData setupField()
+ {
+ MemoryMetaDataLoader loader = new MemoryMetaDataLoader();
+ MemoryMetaDataLoader component = new MemoryMetaDataLoader();
+ loader.addComponentMetaDataRetrieval(new FieldSignature("empty"), component);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(new TestAnnotationImpl());
+ loader.addComponentMetaDataRetrieval(new FieldSignature("testAnnotation"), component);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(new TestAnnotation1Impl());
+ component.addAnnotation(new TestAnnotation2Impl());
+ loader.addComponentMetaDataRetrieval(new FieldSignature("testAnnotation12"), component);
+ return new MetaDataRetrievalToMetaDataBridge(loader);
+ }
+
+ protected MetaData setupConstructor()
+ {
+ MemoryMetaDataLoader loader = new MemoryMetaDataLoader();
+ MemoryMetaDataLoader component = new MemoryMetaDataLoader();
+ loader.addComponentMetaDataRetrieval(new ConstructorSignature(), component);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(new TestAnnotationImpl());
+ loader.addComponentMetaDataRetrieval(new ConstructorSignature(String.class), component);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(new TestAnnotation1Impl());
+ component.addAnnotation(new TestAnnotation2Impl());
+ loader.addComponentMetaDataRetrieval(new ConstructorSignature(String.class, Class.class), component);
+ return new MetaDataRetrievalToMetaDataBridge(loader);
+ }
+
+ protected MetaData setupMethod()
+ {
+ MemoryMetaDataLoader loader = new MemoryMetaDataLoader();
+ MemoryMetaDataLoader component = new MemoryMetaDataLoader();
+ loader.addComponentMetaDataRetrieval(new MethodSignature("empty"), component);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(new TestAnnotationImpl());
+ loader.addComponentMetaDataRetrieval(new MethodSignature("testAnnotation", String.class), component);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(new TestAnnotation1Impl());
+ component.addAnnotation(new TestAnnotation2Impl());
+ loader.addComponentMetaDataRetrieval(new MethodSignature("testAnnotation12", String.class, Class.class), component);
+ return new MetaDataRetrievalToMetaDataBridge(loader);
+ }
+
+ protected MetaData setupMethodParams()
+ {
+ MemoryMetaDataLoader loader = new MemoryMetaDataLoader();
+ MemoryMetaDataLoader component = new MemoryMetaDataLoader();
+ loader.addComponentMetaDataRetrieval(new MethodParametersSignature("empty", 0, String.class), component);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(new TestAnnotationImpl());
+ loader.addComponentMetaDataRetrieval(new MethodParametersSignature("testAnnotation", 0, String.class), component);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(new TestAnnotation1Impl());
+ component.addAnnotation(new TestAnnotation2Impl());
+ loader.addComponentMetaDataRetrieval(new MethodParametersSignature("testAnnotation12", 1, String.class, Class.class), component);
+ return new MetaDataRetrievalToMetaDataBridge(loader);
+ }
+}
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/memory/test/MemoryMetaDataLoaderTestSuite.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/memory/test/MemoryMetaDataLoaderTestSuite.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/memory/test/MemoryMetaDataLoaderTestSuite.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -43,6 +43,7 @@
TestSuite suite = new TestSuite("Memory MetaDataLoader Tests");
suite.addTest(new TestSuite(MemoryLoaderBasicAnnotationsUnitTestCase.class));
+ suite.addTest(new TestSuite(MemoryLoaderComponentBasicAnnotationsUnitTestCase.class));
suite.addTest(new TestSuite(MemoryLoaderMutableAnnotationsUnitTestCase.class));
suite.addTest(new TestSuite(MemoryLoaderMutableAnnotationsInvalidationUnitTestCase.class));
suite.addTest(new TestSuite(MemoryLoaderBasicMetaDataUnitTestCase.class));
Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/ConstructorBean.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/ConstructorBean.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/ConstructorBean.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,50 @@
+/*
+* 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.test.metadata.loader.reflection.support;
+
+import org.jboss.test.metadata.shared.support.TestAnnotation;
+import org.jboss.test.metadata.shared.support.TestAnnotation1;
+import org.jboss.test.metadata.shared.support.TestAnnotation2;
+
+/**
+ * ConstructorBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 45742 $
+ */
+public class ConstructorBean
+{
+ public ConstructorBean()
+ {
+ }
+
+ @TestAnnotation
+ public ConstructorBean(String p1)
+ {
+ }
+
+ @TestAnnotation1
+ @TestAnnotation2
+ public ConstructorBean(String p1, Class p2)
+ {
+ }
+}
Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/FieldBean.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/FieldBean.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/FieldBean.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,44 @@
+/*
+* 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.test.metadata.loader.reflection.support;
+
+import org.jboss.test.metadata.shared.support.TestAnnotation;
+import org.jboss.test.metadata.shared.support.TestAnnotation1;
+import org.jboss.test.metadata.shared.support.TestAnnotation2;
+
+/**
+ * FieldBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 45742 $
+ */
+public class FieldBean
+{
+ public String empty;
+
+ @TestAnnotation
+ public String testAnnotation;
+
+ @TestAnnotation1
+ @TestAnnotation2
+ public String testAnnotation12;
+}
Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/MethodBean.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/MethodBean.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/MethodBean.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,50 @@
+/*
+* 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.test.metadata.loader.reflection.support;
+
+import org.jboss.test.metadata.shared.support.TestAnnotation;
+import org.jboss.test.metadata.shared.support.TestAnnotation1;
+import org.jboss.test.metadata.shared.support.TestAnnotation2;
+
+/**
+ * MethodBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 45742 $
+ */
+public class MethodBean
+{
+ public void empty()
+ {
+ }
+
+ @TestAnnotation
+ public void testAnnotation(String p1)
+ {
+ }
+
+ @TestAnnotation1
+ @TestAnnotation2
+ public void testAnnotation12(String p1, Class p2)
+ {
+ }
+}
Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/MethodParamBean.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/MethodParamBean.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/support/MethodParamBean.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,47 @@
+/*
+* 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.test.metadata.loader.reflection.support;
+
+import org.jboss.test.metadata.shared.support.TestAnnotation;
+import org.jboss.test.metadata.shared.support.TestAnnotation1;
+import org.jboss.test.metadata.shared.support.TestAnnotation2;
+
+/**
+ * MethodParamBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 45742 $
+ */
+public class MethodParamBean
+{
+ public void empty(String p1)
+ {
+ }
+
+ public void testAnnotation(@TestAnnotation String p1)
+ {
+ }
+
+ public void testAnnotation12(String p1, @TestAnnotation1 @TestAnnotation2 Class p2)
+ {
+ }
+}
Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/AnnotatedElementLoaderComponentBasicAnnotationsUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/AnnotatedElementLoaderComponentBasicAnnotationsUnitTestCase.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/AnnotatedElementLoaderComponentBasicAnnotationsUnitTestCase.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,69 @@
+/*
+* 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.test.metadata.loader.reflection.test;
+
+import org.jboss.metadata.plugins.loader.reflection.AnnotatedElementMetaDataLoader;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge;
+import org.jboss.test.metadata.loader.reflection.support.ConstructorBean;
+import org.jboss.test.metadata.loader.reflection.support.FieldBean;
+import org.jboss.test.metadata.loader.reflection.support.MethodBean;
+import org.jboss.test.metadata.loader.reflection.support.MethodParamBean;
+import org.jboss.test.metadata.shared.ComponentBasicAnnotationsTest;
+
+/**
+ * AnnotatedElementLoaderBasicAnnotationsUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 46146 $
+ */
+public class AnnotatedElementLoaderComponentBasicAnnotationsUnitTestCase extends ComponentBasicAnnotationsTest
+{
+ public AnnotatedElementLoaderComponentBasicAnnotationsUnitTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ protected MetaData setupField()
+ {
+ AnnotatedElementMetaDataLoader loader = new AnnotatedElementMetaDataLoader(FieldBean.class);
+ return new MetaDataRetrievalToMetaDataBridge(loader);
+ }
+
+ protected MetaData setupConstructor()
+ {
+ AnnotatedElementMetaDataLoader loader = new AnnotatedElementMetaDataLoader(ConstructorBean.class);
+ return new MetaDataRetrievalToMetaDataBridge(loader);
+ }
+
+ protected MetaData setupMethod()
+ {
+ AnnotatedElementMetaDataLoader loader = new AnnotatedElementMetaDataLoader(MethodBean.class);
+ return new MetaDataRetrievalToMetaDataBridge(loader);
+ }
+
+ protected MetaData setupMethodParams()
+ {
+ AnnotatedElementMetaDataLoader loader = new AnnotatedElementMetaDataLoader(MethodParamBean.class);
+ return new MetaDataRetrievalToMetaDataBridge(loader);
+ }
+}
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/ReflectionMetaDataLoaderTestSuite.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/ReflectionMetaDataLoaderTestSuite.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/loader/reflection/test/ReflectionMetaDataLoaderTestSuite.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -43,6 +43,7 @@
TestSuite suite = new TestSuite("Reflection MetaDataLoader Tests");
suite.addTest(new TestSuite(AnnotatedElementLoaderBasicAnnotationsUnitTestCase.class));
+ suite.addTest(new TestSuite(AnnotatedElementLoaderComponentBasicAnnotationsUnitTestCase.class));
suite.addTest(new TestSuite(AnnotatedElementLoaderScopeUnitTestCase.class));
return suite;
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/retrieval/support/TestMetaDataRetrieval.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/retrieval/support/TestMetaDataRetrieval.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/retrieval/support/TestMetaDataRetrieval.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -32,6 +32,7 @@
import org.jboss.metadata.spi.scope.Scope;
import org.jboss.metadata.spi.scope.ScopeKey;
import org.jboss.metadata.spi.scope.ScopeLevel;
+import org.jboss.metadata.spi.signature.Signature;
/**
* TestMetaDataRetrieval.
@@ -98,4 +99,9 @@
lastMethod = "retrieveMetaData(String)";
return null;
}
+
+ public MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature)
+ {
+ return null;
+ }
}
Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/shared/ComponentBasicAnnotationsTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/shared/ComponentBasicAnnotationsTest.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/shared/ComponentBasicAnnotationsTest.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,209 @@
+/*
+* 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.test.metadata.shared;
+
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.signature.ConstructorSignature;
+import org.jboss.metadata.spi.signature.FieldSignature;
+import org.jboss.metadata.spi.signature.MethodParametersSignature;
+import org.jboss.metadata.spi.signature.MethodSignature;
+import org.jboss.test.metadata.AbstractMetaDataTest;
+import org.jboss.test.metadata.shared.support.ExpectedAnnotations;
+import org.jboss.test.metadata.shared.support.NotPresentAnnotation;
+import org.jboss.test.metadata.shared.support.TestAnnotation;
+import org.jboss.test.metadata.shared.support.TestAnnotation1;
+import org.jboss.test.metadata.shared.support.TestAnnotation2;
+
+/**
+ * ComponentBasicAnnotationsTest.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 46146 $
+ */
+public abstract class ComponentBasicAnnotationsTest extends AbstractMetaDataTest
+{
+ protected boolean local;
+
+ public ComponentBasicAnnotationsTest(String name, boolean local)
+ {
+ super(name);
+ this.local = local;
+ }
+
+ protected abstract MetaData setupConstructor();
+
+ protected abstract MetaData setupField();
+
+ protected abstract MetaData setupMethod();
+
+ protected abstract MetaData setupMethodParams();
+
+ public void testFieldNotFound() throws Exception
+ {
+ MetaData metaData = setupField();
+ metaData = metaData.getComponentMetaData(new FieldSignature("notFound"));
+ assertNull(metaData);
+ }
+
+ public void testConstructorNotFound() throws Exception
+ {
+ MetaData metaData = setupConstructor();
+ metaData = metaData.getComponentMetaData(new ConstructorSignature(Void.class));
+ assertNull(metaData);
+ }
+
+ public void testMethodNotFound() throws Exception
+ {
+ MetaData metaData = setupMethod();
+ metaData = metaData.getComponentMetaData(new MethodSignature("notFound"));
+ assertNull(metaData);
+ }
+
+ public void testMethodParamsNotFound() throws Exception
+ {
+ MetaData metaData = setupMethodParams();
+ metaData = metaData.getComponentMetaData(new MethodParametersSignature("notFound", 0, Void.class));
+ assertNull(metaData);
+ }
+
+ public void testFieldEmpty() throws Exception
+ {
+ MetaData metaData = setupField();
+ metaData = metaData.getComponentMetaData(new FieldSignature("empty"));
+ testEmpty(metaData);
+ }
+
+ public void testConstructorEmpty() throws Exception
+ {
+ MetaData metaData = setupConstructor();
+ metaData = metaData.getComponentMetaData(new ConstructorSignature());
+ testEmpty(metaData);
+ }
+
+ public void testMethodEmpty() throws Exception
+ {
+ MetaData metaData = setupMethod();
+ metaData = metaData.getComponentMetaData(new MethodSignature("empty"));
+ testEmpty(metaData);
+ }
+
+ public void testMethodParamsEmpty() throws Exception
+ {
+ MetaData metaData = setupMethodParams();
+ metaData = metaData.getComponentMetaData(new MethodParametersSignature("empty", 0, String.class));
+ testEmpty(metaData);
+ }
+
+ protected void testEmpty(MetaData metaData) throws Exception
+ {
+ assertNotNull(metaData);
+ ExpectedAnnotations expectedAnnotations = emptyExpectedAnnotations();
+
+ assertNoAnnotation(metaData, NotPresentAnnotation.class);
+
+ assertAllAnnotations(metaData, expectedAnnotations, local);
+ }
+
+ public void testFieldTestAnnotation() throws Exception
+ {
+ MetaData metaData = setupField();
+ metaData = metaData.getComponentMetaData(new FieldSignature("testAnnotation"));
+ testTestAnnotation(metaData);
+ }
+
+ public void testConstructorTestAnnotation() throws Exception
+ {
+ MetaData metaData = setupConstructor();
+ metaData = metaData.getComponentMetaData(new ConstructorSignature(String.class));
+ testTestAnnotation(metaData);
+ }
+
+ public void testMethodTestAnnotation() throws Exception
+ {
+ MetaData metaData = setupMethod();
+ metaData = metaData.getComponentMetaData(new MethodSignature("testAnnotation", String.class));
+ testTestAnnotation(metaData);
+ }
+
+ public void testMethodParamsTestAnnotation() throws Exception
+ {
+ MetaData metaData = setupMethodParams();
+ metaData = metaData.getComponentMetaData(new MethodParametersSignature("testAnnotation", 0, String.class));
+ testTestAnnotation(metaData);
+ }
+
+ protected void testTestAnnotation(MetaData metaData) throws Exception
+ {
+ assertNotNull(metaData);
+
+ ExpectedAnnotations expectedAnnotations = emptyExpectedAnnotations();
+
+ assertAnnotation(metaData, TestAnnotation.class);
+ assertNoAnnotation(metaData, NotPresentAnnotation.class);
+
+ expectedAnnotations.add(TestAnnotation.class);
+ assertAllAnnotations(metaData, expectedAnnotations, local);
+ }
+
+ public void testFieldTestAnnotation12() throws Exception
+ {
+ MetaData metaData = setupField();
+ metaData = metaData.getComponentMetaData(new FieldSignature("testAnnotation12"));
+ testTestAnnotation12(metaData);
+ }
+
+ public void testConstructorTestAnnotation12() throws Exception
+ {
+ MetaData metaData = setupConstructor();
+ metaData = metaData.getComponentMetaData(new ConstructorSignature(String.class, Class.class));
+ testTestAnnotation12(metaData);
+ }
+
+ public void testMethodTestAnnotation12() throws Exception
+ {
+ MetaData metaData = setupMethod();
+ metaData = metaData.getComponentMetaData(new MethodSignature("testAnnotation12", String.class, Class.class));
+ testTestAnnotation12(metaData);
+ }
+
+ public void testMethodParamTestAnnotation12() throws Exception
+ {
+ MetaData metaData = setupMethodParams();
+ metaData = metaData.getComponentMetaData(new MethodParametersSignature("testAnnotation12", 1, String.class, Class.class));
+ testTestAnnotation12(metaData);
+ }
+
+ protected void testTestAnnotation12(MetaData metaData) throws Exception
+ {
+ assertNotNull(metaData);
+
+ ExpectedAnnotations expectedAnnotations = emptyExpectedAnnotations();
+
+ assertAnnotation(metaData, TestAnnotation1.class);
+ assertAnnotation(metaData, TestAnnotation2.class);
+ assertNoAnnotation(metaData, NotPresentAnnotation.class);
+
+ expectedAnnotations.add(TestAnnotation1.class);
+ expectedAnnotations.add(TestAnnotation2.class);
+ assertAllAnnotations(metaData, expectedAnnotations, local);
+ }
+}
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/shared/support/MetaDataAndMutableMetaDataImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/shared/support/MetaDataAndMutableMetaDataImpl.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/shared/support/MetaDataAndMutableMetaDataImpl.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -25,6 +25,7 @@
import org.jboss.metadata.spi.MetaData;
import org.jboss.metadata.spi.MutableMetaData;
+import org.jboss.metadata.spi.signature.Signature;
/**
* MetaDataAndMutableMetaDataImpl.
@@ -137,4 +138,9 @@
{
return mutable.removeMetaData(name, type);
}
+
+ public MetaData getComponentMetaData(Signature signature)
+ {
+ return metaData.getComponentMetaData(signature);
+ }
}
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/TestClassLoading.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/TestClassLoading.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/TestClassLoading.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -5,7 +5,6 @@
import org.jboss.test.BaseTestCase;
import org.jboss.virtual.VFS;
import org.jboss.virtual.classloading.VFSClassLoader;
-import org.jboss.virtual.plugins.context.jar.JarUtils;
public class TestClassLoading extends BaseTestCase
{
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -25,6 +25,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.SupplyMetaData;
@@ -41,7 +43,6 @@
import org.jboss.kernel.spi.registry.KernelRegistry;
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
import org.jboss.kernel.spi.registry.KernelRegistryPlugin;
-import org.jboss.util.collection.CollectionsFactory;
/**
* Abstract Kernel controller.
@@ -58,10 +59,10 @@
protected AbstractEventEmitter emitterDelegate = new AbstractEventEmitter();
/** The supplies */
- protected Map<Object, List<KernelControllerContext>> suppliers = CollectionsFactory.createConcurrentReaderMap();
+ protected Map<Object, List<KernelControllerContext>> suppliers = new ConcurrentHashMap<Object, List<KernelControllerContext>>();
/** The contexts by class Map<Class, Set<ControllerContext>> */
- protected Map<Class, ClassContext> contextsByClass = CollectionsFactory.createConcurrentReaderMap();
+ protected Map<Class, ClassContext> contextsByClass = new ConcurrentHashMap<Class, ClassContext>();
/**
* Create an abstract kernel controller
@@ -133,7 +134,7 @@
List<KernelControllerContext> list = suppliers.get(supply);
if (list == null)
{
- list = CollectionsFactory.createCopyOnWriteList();
+ list = new CopyOnWriteArrayList<KernelControllerContext>();
suppliers.put(supply, list);
}
list.add(context);
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 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -42,8 +42,10 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.spi.metadata.MutableMetaDataContext;
-import org.jboss.repository.spi.MetaDataContext;
+import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.repository.MetaDataRepository;
+import org.jboss.metadata.spi.scope.ScopeKey;
import org.jboss.util.JBossStringBuilder;
/**
@@ -54,36 +56,27 @@
*/
public class AbstractKernelControllerContext extends AbstractControllerContext implements KernelControllerContext
{
- /**
- * The default actions
- */
+ /** The default actions */
private static final KernelControllerContextActions actions = KernelControllerContextActions.getInstance();
- /**
- * The no instantiate actions
- */
+ /** The no instantiate actions */
private static final KernelControllerContextActions noInstantiate = KernelControllerContextActions.getNoInstantiate();
- /**
- * The BeanInfo
- */
+ /** The BeanInfo */
protected BeanInfo info;
- /**
- * The meta data
- */
+ /** The meta data */
protected BeanMetaData metaData;
- /**
- * The access control context
- */
+ /** The access control context */
protected AccessControlContext accessContext;
- /**
- * Did we do a describeVisit
- */
+ /** Did we do a describeVisit */
protected boolean isDescribeProcessed;
+ /** The scope */
+ protected ScopeKey scope;
+
/**
* Create an abstract controller context
*
@@ -133,6 +126,35 @@
return metaData;
}
+ public MetaData getMetaData()
+ {
+ KernelController controller = (KernelController) getController();
+ if (controller == null)
+ throw new IllegalStateException("Context is not associated with a controller");
+ MetaDataRepository repository = controller.getKernel().getMetaDataRepository().getMetaDataRepository();
+ ScopeKey scope = getScope();
+ return repository.getMetaData(scope);
+ }
+
+ public ScopeKey getScope()
+ {
+ if (scope == null)
+ {
+ // Bootstrap (probably not really a good idea?)
+ KernelController controller = (KernelController) getController();
+ if (controller == null)
+ return null;
+ KernelMetaDataRepository repository = controller.getKernel().getMetaDataRepository();
+ scope = repository.getFullScope(this);
+ }
+ return scope;
+ }
+
+ public void setScope(ScopeKey key)
+ {
+ this.scope = key;
+ }
+
public void toString(JBossStringBuilder buffer)
{
if (metaData != null)
@@ -173,28 +195,6 @@
isDescribeProcessed = true;
}
- public MutableMetaDataContext getMetaDataContext()
- {
- if (info != null)
- {
- try
- {
- return (MutableMetaDataContext)info.getMetaDataContext();
- }
- catch (ClassCastException e)
- {
- throw new RuntimeException("MetaDataContext must be an instance of MutableMetaDataContext");
- }
- }
- return null;
- }
-
- public void setMetaDataContext(MetaDataContext mctx)
- {
- info = info.getInstanceInfo();
- info.setMetaDataContext(mctx);
- }
-
/**
* Get the access control context of the code that created this context.<p>
* <p/>
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -21,27 +21,19 @@
*/
package org.jboss.kernel.plugins.dependency;
-import java.util.Iterator;
import java.util.List;
-import java.util.Set;
import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.metadata.spi.AnnotationMetaData;
import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.PropertyMetaData;
import org.jboss.dependency.plugins.AbstractDependencyItem;
-import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.dependency.spi.DependencyInfo;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.config.KernelConfigurator;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.spi.metadata.MutableMetaDataContext;
-import org.jboss.metadata.spi.repository.MetaDataRepository;
-import org.jboss.repository.spi.KernelRepository;
-import org.jboss.repository.spi.MetaDataContext;
-import org.jboss.repository.spi.MetaDataContextFactory;
+import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
+import org.jboss.metadata.spi.MetaData;
/**
* DescribeAction.
@@ -63,112 +55,66 @@
BeanInfo info = configurator.getBeanInfo(metaData);
context.setBeanInfo(info);
- info = addAnnotations(context, metaData, info);
-
- DependencyInfo depends = context.getDependencyInfo();
- // add custom dependencies (e.g. AOP layer).
- List<Object> dependencies = info.getDependencies();
- if (dependencies != null)
+ MetaData md = addMetaData(context);
+ try
{
- for (Object dependencyName : dependencies)
+ DependencyInfo depends = context.getDependencyInfo();
+ // add custom dependencies (e.g. AOP layer).
+ List<Object> dependencies = info.getDependencies(md);
+ log.trace("Extra dependencies for " + context.getName() + " " + dependencies);
+ if (dependencies != null)
{
- AbstractDependencyItem dependency = new AbstractDependencyItem(metaData.getName(), dependencyName, ControllerState.INSTANTIATED, ControllerState.INSTALLED);
- depends.addIDependOn(dependency);
+ for (Object dependencyName : dependencies)
+ {
+ AbstractDependencyItem dependency = new AbstractDependencyItem(metaData.getName(), dependencyName, ControllerState.INSTANTIATED, ControllerState.INSTALLED);
+ depends.addIDependOn(dependency);
+ }
}
}
+ catch (Throwable t)
+ {
+ removeMetaData(context);
+ throw t;
+ }
}
}
public void uninstallAction(KernelControllerContext context)
{
- context.setMetaDataContext(null);
+ removeMetaData(context);
context.setBeanInfo(null);
}
/**
- * Adds annotations to the bean. If annotations are added, returns the bean info for the instance
- * @return The class bean info if no annotations exist or the instance bean info if annotations exist
+ * Adds annotations to the bean.
+ *
+ * @param context the context
+ * @return the metadata
*/
- private BeanInfo addAnnotations(KernelControllerContext context, BeanMetaData beanMetaData, BeanInfo beanInfo)
+ private MetaData addMetaData(KernelControllerContext context)
{
- MutableMetaDataContext metaCtx = addClassAnnotations(context, beanMetaData, beanInfo);
- addPropertyAnnotations(metaCtx, context, beanMetaData, beanInfo);
- return context.getBeanInfo();
+ KernelController controller = (KernelController) context.getController();
+ KernelMetaDataRepository repository = controller.getKernel().getMetaDataRepository();
+ repository.addMetaData(context);
+ return repository.getMetaData(context);
}
- private MutableMetaDataContext addClassAnnotations(KernelControllerContext context, BeanMetaData beanMetaData, BeanInfo beanInfo)
+ /**
+ * Remove any previously added metadata
+ *
+ * @param context the context
+ */
+ private void removeMetaData(KernelControllerContext context)
{
- Set<AnnotationMetaData> annotations = beanMetaData.getAnnotations();
-
- MutableMetaDataContext metaCtx = null;
-
- if (annotations != null && annotations.size() > 0)
+ try
{
- metaCtx = getMetaDataContext(context);
- if (metaCtx != null)
- {
- metaCtx.addAnnotations(annotations);
- }
+ KernelController controller = (KernelController) context.getController();
+ KernelMetaDataRepository repository = controller.getKernel().getMetaDataRepository();
+ repository.removeMetaData(context);
}
-
- return metaCtx;
- }
-
- private MutableMetaDataContext addPropertyAnnotations(MutableMetaDataContext metaCtx, KernelControllerContext context, BeanMetaData beanMetaData, BeanInfo beanInfo)
- {
- Set properties = beanMetaData.getProperties();
-
- if (properties != null && properties.size() > 0)
+ catch (Throwable ignored)
{
- for (Iterator it = properties.iterator() ; it.hasNext() ; )
- {
- PropertyMetaData property = (PropertyMetaData)it.next();
- Set propertyAnnotations = property.getAnnotations();
- if (propertyAnnotations != null && propertyAnnotations.size() > 0)
- {
- if (metaCtx == null)
- {
- metaCtx = getMetaDataContext(context);
- }
- if (metaCtx != null)
- {
- Set propertyInfos = beanInfo.getProperties();
- if (propertyInfos != null && propertyInfos.size() > 0)
- {
- metaCtx.addPropertyAnnotations(property.getName(), beanInfo.getProperties(), propertyAnnotations);
- }
- }
- }
- }
+ log.warn("Unexpected error removing metadata: ", ignored);
}
-
- return metaCtx;
}
-
- private MutableMetaDataContext getMetaDataContext(KernelControllerContext context)
- {
- //TODO: Hardcoding this doesn't feel right...
- ControllerContext repCtx = context.getController().getContext("Repository", ControllerState.INSTALLED);
-
- if (repCtx == null)
- {
- log.warn("You have defined annotations for bean '" + context.getName() + "', but no MetaDataRepository has been installed under the name 'Repository'");
- return null;
- }
-
- MetaDataRepository repository = (MetaDataRepository)repCtx.getTarget();
- MetaDataContextFactory metaFactory = context.getBeanInfo().getMetaDataContextFactory();
- ClassLoader beanLoader = context.getBeanInfo().getClassInfo().getType().getClassLoader();
- MetaDataContext metaCtx = metaFactory.getMetaDataContext(beanLoader, repository, (String)context.getName());
-
- if (metaCtx instanceof MutableMetaDataContext == false)
- {
- throw new RuntimeException("MetaDataContext must be mutable");
- }
-
- context.setMetaDataContext(metaCtx);
-
- return (MutableMetaDataContext)metaCtx;
- }
-
}
\ No newline at end of file
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -28,8 +28,6 @@
import org.jboss.kernel.spi.config.KernelConfigurator;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
-import org.jboss.kernel.spi.metadata.MutableMetaDataContext;
/**
* InstantiateAction.
@@ -52,12 +50,6 @@
Object object = dispatchJoinPoint(context, joinPoint);
context.setTarget(object);
- MutableMetaDataContext metaCtx = context.getMetaDataContext();
- if (metaCtx != null)
- {
- metaCtx.setTarget(object);
- }
-
try
{
if (object != null)
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -28,8 +28,12 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.joinpoint.spi.Joinpoint;
import org.jboss.kernel.plugins.config.Configurator;
+import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
import org.jboss.logging.Logger;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.stack.MetaDataStack;
/**
* KernelControllerContextAction.
@@ -39,6 +43,10 @@
*/
public class KernelControllerContextAction implements ControllerContextAction
{
+ /** Static log */
+ private static final Logger staticLog = Logger.getLogger(KernelControllerContextAction.class);
+
+ /** The log */
protected Logger log = Logger.getLogger(getClass());
/**
@@ -59,37 +67,53 @@
AbstractKernelControllerContext theContext = (AbstractKernelControllerContext) context;
access = theContext.getAccessControlContext();
}
-
- // Dispatch with the bean class loader if it exists
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+
+ KernelController controller = (KernelController) context.getController();
+ KernelMetaDataRepository repository = controller.getKernel().getMetaDataRepository();
+ MetaData md = repository.getMetaData(context);
+ if (md != null)
+ MetaDataStack.push(md);
+ else
+ staticLog.warn("NO METADATA! for " + context.getName() + " with scope " + context.getScope());
try
{
- if( cl != null && access == null )
- Thread.currentThread().setContextClassLoader(cl);
- if (access == null)
+
+ // Dispatch with the bean class loader if it exists
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ try
{
- return joinpoint.dispatch();
- }
- else
- {
- DispatchJoinPoint action = new DispatchJoinPoint(joinpoint);
- try
+ if( cl != null && access == null )
+ Thread.currentThread().setContextClassLoader(cl);
+ if (access == null)
{
- return AccessController.doPrivileged(action, access);
+ return joinpoint.dispatch();
}
- catch (PrivilegedActionException e)
+ else
{
- throw e.getCause();
+ DispatchJoinPoint action = new DispatchJoinPoint(joinpoint);
+ try
+ {
+ return AccessController.doPrivileged(action, access);
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw e.getCause();
+ }
}
}
+ finally
+ {
+ if( cl != null && access == null )
+ Thread.currentThread().setContextClassLoader(tcl);
+ }
}
finally
{
- if( cl != null && access == null )
- Thread.currentThread().setContextClassLoader(tcl);
+ if (md != null)
+ MetaDataStack.pop();
}
}
-
+
public void install(final ControllerContext context) throws Throwable
{
if (System.getSecurityManager() == null || context instanceof AbstractKernelControllerContext == false)
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -34,8 +34,6 @@
import org.jboss.kernel.spi.config.KernelConfigurator;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.repository.spi.MetaDataContext;
-import org.jboss.reflect.spi.AnnotationValue;
import org.jboss.reflect.spi.MethodInfo;
/**
@@ -180,7 +178,7 @@
}
catch (Throwable throwable)
{
- log.warn("Error during " + method, throwable);
+ log.warn("Error during " + method + " for " + context.getName(), throwable);
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
@@ -31,7 +32,6 @@
import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.jboss.util.JBossObject;
import org.jboss.util.JBossStringBuilder;
-import org.jboss.util.collection.CollectionsFactory;
/**
* An abstract kernel deployment.
@@ -48,7 +48,7 @@
protected boolean installed;
/** The installed contexts */
- protected List<KernelControllerContext> installedContexts = CollectionsFactory.createCopyOnWriteList();
+ protected List<KernelControllerContext> installedContexts = new CopyOnWriteArrayList<KernelControllerContext>();
/** The beans List<BeanMetaDataFactory> */
protected List<BeanMetaDataFactory> beanFactories;
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/BasicKernelDeployer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/BasicKernelDeployer.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/BasicKernelDeployer.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -23,11 +23,11 @@
import java.util.List;
import java.util.ListIterator;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.jboss.logging.Logger;
-import org.jboss.util.collection.CollectionsFactory;
/**
* BasicKernelDeployer.<p>
@@ -44,7 +44,7 @@
private static final Logger log = Logger.getLogger(BasicKernelDeployer.class);
/** The deployments */
- protected List<KernelDeployment> deployments = CollectionsFactory.createCopyOnWriteList();
+ protected List<KernelDeployment> deployments = new CopyOnWriteArrayList<KernelDeployment>();
/**
* Create a new BasicKernelDeployer.
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BasicXMLDeployer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BasicXMLDeployer.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BasicXMLDeployer.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -25,16 +25,16 @@
import java.net.URL;
import java.util.Collection;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.plugins.deployment.BasicKernelDeployer;
import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.jboss.logging.Logger;
-import org.jboss.util.collection.CollectionsFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
/**
* BasicXMLDeployer.
@@ -54,7 +54,7 @@
private static final SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
/** The deployments by url or name */
- private Map<String, KernelDeployment> deploymentsByName = CollectionsFactory.createConcurrentReaderMap();
+ private Map<String, KernelDeployment> deploymentsByName = new ConcurrentHashMap<String, KernelDeployment>();
/**
* Create a new XML deployer
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -1145,7 +1145,7 @@
public void add(Object parent, Object child, QName name)
{
MapEntry entry = (MapEntry) parent;
- entry.key = (ValueMetaData) child;
+ entry.key = child;
}
});
@@ -1155,7 +1155,7 @@
public void add(Object parent, Object child, QName name)
{
MapEntry entry = (MapEntry) parent;
- entry.value = (ValueMetaData) child;
+ entry.value = child;
}
});
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/EntryKeyInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/EntryKeyInterceptor.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/EntryKeyInterceptor.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -23,7 +23,6 @@
import javax.xml.namespace.QName;
-import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
/**
@@ -40,6 +39,6 @@
public void add(Object parent, Object child, QName name)
{
MapEntry entry = (MapEntry) parent;
- entry.key = (ValueMetaData) child;
+ entry.key = child;
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/EntryValueInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/EntryValueInterceptor.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/EntryValueInterceptor.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -23,7 +23,6 @@
import javax.xml.namespace.QName;
-import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
/**
@@ -40,6 +39,6 @@
public void add(Object parent, Object child, QName name)
{
MapEntry entry = (MapEntry) parent;
- entry.value = (ValueMetaData) child;
+ entry.value = child;
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/event/AbstractEventEmitter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/event/AbstractEventEmitter.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/event/AbstractEventEmitter.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -25,13 +25,14 @@
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.kernel.spi.event.KernelEvent;
import org.jboss.kernel.spi.event.KernelEventEmitter;
import org.jboss.kernel.spi.event.KernelEventFilter;
import org.jboss.kernel.spi.event.KernelEventListener;
import org.jboss.logging.Logger;
-import org.jboss.util.collection.CollectionsFactory;
/**
* Abstract Event emitter.
@@ -57,7 +58,7 @@
};
/** The registry Map<filter, Map<handback, List<listener>>>*/
- protected Map<KernelEventFilter, Map<Object, List<KernelEventListener>>> eventListenerRegistry = CollectionsFactory.createConcurrentReaderMap();
+ protected Map<KernelEventFilter, Map<Object, List<KernelEventListener>>> eventListenerRegistry = new ConcurrentHashMap<KernelEventFilter, Map<Object,List<KernelEventListener>>>();
/** The sequence number of this emitter */
private long emitterSequence = 0;
@@ -74,6 +75,10 @@
/**
* Make a new event
+ *
+ * @param type the event type
+ * @param context the context
+ * @return the event
*/
public KernelEvent createEvent(String type, Object context)
{
@@ -90,13 +95,13 @@
Map<Object, List<KernelEventListener>> handbacks = eventListenerRegistry.get(filterObject);
if (handbacks == null)
{
- handbacks = CollectionsFactory.createConcurrentReaderMap();
+ handbacks = new ConcurrentHashMap<Object, List<KernelEventListener>>();
eventListenerRegistry.put(filterObject, handbacks);
}
List<KernelEventListener> listeners = handbacks.get(handbackObject);
if (listeners == null)
{
- listeners = CollectionsFactory.createCopyOnWriteList();
+ listeners = new CopyOnWriteArrayList<KernelEventListener>();
handbacks.put(handbackObject, listeners);
}
listeners.add(listener);
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 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/metadata/basic/BasicKernelMetaDataRepository.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -21,8 +21,30 @@
*/
package org.jboss.kernel.plugins.metadata.basic;
+import java.util.ArrayList;
+import java.util.Set;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
import org.jboss.kernel.plugins.metadata.AbstractKernelMetaDataRepository;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.metadata.plugins.context.AbstractMetaDataContext;
+import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
+import org.jboss.metadata.plugins.loader.reflection.AnnotatedElementMetaDataLoader;
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.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.metadata.spi.stack.MetaDataStack;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
/**
* BasicKernelMetaDataRepository.
@@ -39,4 +61,221 @@
{
super(new BasicMetaDataRepository());
}
+
+ public MetaData getMetaData(KernelControllerContext context)
+ {
+ MutableMetaDataRepository repository = getMetaDataRepository();
+ ScopeKey scope = context.getScope();
+ MetaData metaData = repository.getMetaData(scope);
+ if (metaData == null)
+ {
+ initMetaDataRetrieval(context);
+ metaData = repository.getMetaData(scope);
+ }
+ return metaData;
+ }
+
+ public MetaDataRetrieval getMetaDataRetrieval(KernelControllerContext context)
+ {
+ MutableMetaDataRepository repository = getMetaDataRepository();
+ ScopeKey scope = context.getScope();
+ MetaDataRetrieval metaDataRetrieval = repository.getMetaDataRetrieval(scope);
+ if (metaDataRetrieval == null)
+ metaDataRetrieval = initMetaDataRetrieval(context);
+ return metaDataRetrieval;
+ }
+
+ public void popMetaData(KernelControllerContext context)
+ {
+ MetaDataStack.pop();
+ }
+
+ public void addMetaData(KernelControllerContext context)
+ {
+ MutableMetaDataRepository repository = getMetaDataRepository();
+ ScopeKey scope = getMutableScope(context);
+ MemoryMetaDataLoader mutable = new MemoryMetaDataLoader(scope);
+ repository.addMetaDataRetrieval(mutable);
+ addClassAnnotations(mutable, context);
+ addPropertyAnnotations(mutable, context);
+ }
+
+ public void removeMetaData(KernelControllerContext context)
+ {
+ MutableMetaDataRepository repository = getMetaDataRepository();
+ // Remove the read only/full scope
+ ScopeKey scope = context.getScope();
+ repository.removeMetaDataRetrieval(scope);
+ // Remove the mutable scope
+ scope = getMutableScope(context);
+ repository.removeMetaDataRetrieval(scope);
+ }
+
+ public ScopeKey getFullScope(KernelControllerContext context)
+ {
+ ScopeKey scope = ScopeKey.DEFAULT_SCOPE.clone();
+ scope.addScope(CommonLevels.INSTANCE, context.getName().toString());
+ BeanMetaData beanMetaData = context.getBeanMetaData();
+ if (beanMetaData != null)
+ {
+ String bean = beanMetaData.getBean();
+ if (bean != null)
+ scope.addScope(CommonLevels.CLASS, bean);
+ }
+ return scope;
+ }
+
+ public ScopeKey getMutableScope(KernelControllerContext context)
+ {
+ return new ScopeKey(CommonLevels.INSTANCE, context.getName().toString());
+ }
+
+ /**
+ * Initialise metadata retrieval
+ *
+ * TODO lots more work
+ * @param context the context
+ * @return the retrieval
+ */
+ protected MetaDataRetrieval initMetaDataRetrieval(KernelControllerContext context)
+ {
+ MutableMetaDataRepository repository = getMetaDataRepository();
+ ScopeKey scopeKey = context.getScope();
+ ArrayList<MetaDataRetrieval> retrievals = new ArrayList<MetaDataRetrieval>();
+ for (Scope scope : scopeKey.getScopes())
+ {
+ ScopeKey thisScope = new ScopeKey(scope);
+ MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(thisScope);
+ if (retrieval == null)
+ {
+ if (scope.getScopeLevel() == CommonLevels.CLASS)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Class clazz = cl.loadClass(scope.getQualifier());
+ retrieval = new AnnotatedElementMetaDataLoader(clazz);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException("Unable to load class: " + scope.getQualifier(), e);
+ }
+ }
+ else
+ {
+ retrieval = new MemoryMetaDataLoader(thisScope);
+ repository.addMetaDataRetrieval(retrieval);
+ }
+ }
+ retrievals.add(0, retrieval);
+ }
+ AbstractMetaDataContext metaDataContext = new AbstractMetaDataContext(null, retrievals);
+ repository.addMetaDataRetrieval(metaDataContext);
+ return metaDataContext;
+ }
+
+ /**
+ * Add class annotations
+ *
+ * @param mutable the mutable metadata
+ * @param context the context
+ */
+ private void addClassAnnotations(MemoryMetaDataLoader mutable, KernelControllerContext context)
+ {
+ BeanMetaData beanMetaData = context.getBeanMetaData();
+ if (beanMetaData != null)
+ addAnnotations(mutable, beanMetaData.getAnnotations());
+ }
+
+ /**
+ * Add property annotations
+ *
+ * @param mutable the mutable
+ * @param beanMetaData the bean metadata
+ * @param beanInfo the bean info
+ */
+ private void addPropertyAnnotations(MemoryMetaDataLoader mutable, KernelControllerContext context)
+ {
+ BeanMetaData beanMetaData = context.getBeanMetaData();
+ if (beanMetaData == null)
+ return;
+
+ Set<PropertyMetaData> properties = beanMetaData.getProperties();
+
+ if (properties == null || properties.size() == 0)
+ return;
+
+ BeanInfo beanInfo = context.getBeanInfo();
+ if (beanInfo == null)
+ return;
+
+ for (PropertyMetaData property : properties)
+ addPropertyAnnotations(mutable, property, beanInfo);
+ }
+
+ /**
+ * Add property annotations
+ *
+ * @param mutable the mutable
+ * @param propertyMetaData the property
+ * @param beanInfo the bean info
+ */
+ private void addPropertyAnnotations(MemoryMetaDataLoader mutable, PropertyMetaData propertyMetaData, BeanInfo beanInfo)
+ {
+ Set<AnnotationMetaData> propertyAnnotations = propertyMetaData.getAnnotations();
+ if (propertyAnnotations == null || propertyAnnotations.size() == 0)
+ return;
+
+ Set<PropertyInfo> propertyInfos = beanInfo.getProperties();
+ if (propertyInfos != null && propertyInfos.size() > 0)
+ {
+ for (PropertyInfo propertyInfo : propertyInfos)
+ {
+ if (propertyInfo.getName().equals(propertyMetaData.getName()))
+ {
+ MethodInfo methodInfo = propertyInfo.getGetter();
+ if (methodInfo != null)
+ addAnnotations(mutable, methodInfo, propertyAnnotations);
+ methodInfo = propertyInfo.getSetter();
+ if (methodInfo != null)
+ addAnnotations(mutable, methodInfo, propertyAnnotations);
+ }
+ }
+ }
+ }
+
+ /**
+ * Add annotations for a method
+ *
+ * @param mutable the mutable metadata
+ * @param methodInfo the method info
+ * @param annotations the annotations
+ */
+ private void addAnnotations(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(loader, annotations);
+ mutable.addComponentMetaDataRetrieval(new MethodSignature(methodInfo.getName(), paramTypes), loader);
+ }
+
+ /**
+ * Add annotations to a mutable metadata
+ *
+ * @param mutable the mutable metadata
+ * @param annotations the annotations
+ */
+ private void addAnnotations(MemoryMetaDataLoader mutable, Set<AnnotationMetaData> annotations)
+ {
+ if (annotations == null || annotations.size() == 0)
+ return;
+
+ for (AnnotationMetaData annotation : annotations)
+ mutable.addAnnotation(annotation.getAnnotationInstance());
+ }
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/AbstractKernelRegistry.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/AbstractKernelRegistry.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/AbstractKernelRegistry.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -24,13 +24,13 @@
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.kernel.plugins.AbstractKernelObject;
import org.jboss.kernel.spi.registry.KernelRegistry;
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
import org.jboss.kernel.spi.registry.KernelRegistryEntryNotFoundException;
import org.jboss.kernel.spi.registry.KernelRegistryPlugin;
-import org.jboss.util.collection.CollectionsFactory;
/**
* Abstract Kernel registry.
@@ -42,7 +42,7 @@
public abstract class AbstractKernelRegistry extends AbstractKernelObject implements KernelRegistry
{
/** The registry factories */
- protected List<KernelRegistryPlugin> factories = CollectionsFactory.createCopyOnWriteList();
+ protected List<KernelRegistryPlugin> factories = new CopyOnWriteArrayList<KernelRegistryPlugin>();
/**
* Create an abstract kernel registry
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/basic/BasicKernelRegistryFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/basic/BasicKernelRegistryFactory.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/basic/BasicKernelRegistryFactory.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -22,13 +22,13 @@
package org.jboss.kernel.plugins.registry.basic;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
import org.jboss.kernel.spi.registry.KernelRegistryEntryAlreadyRegisteredException;
import org.jboss.kernel.spi.registry.KernelRegistryEntryNotFoundException;
import org.jboss.kernel.spi.registry.KernelRegistryPlugin;
import org.jboss.logging.Logger;
-import org.jboss.util.collection.CollectionsFactory;
/**
* Basic Kernel registry factory.
@@ -42,7 +42,7 @@
private static final Logger log = Logger.getLogger(BasicKernelRegistryFactory.class);
/** The registred entries */
- protected Map<Object, KernelRegistryEntry> entries = CollectionsFactory.createConcurrentReaderMap();
+ protected Map<Object, KernelRegistryEntry> entries = new ConcurrentHashMap<Object, KernelRegistryEntry>();
/**
* Create a new basic registry factory
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -24,9 +24,9 @@
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.metadata.MutableMetaDataContext;
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
-import org.jboss.repository.spi.MetaDataContext;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.scope.ScopeKey;
/**
* Information about dependencies and state.
*
@@ -71,16 +71,23 @@
void setTarget(Object target);
/**
- * Get the metadata context
+ * Get the metadata
*
- * @return the metadata context
+ * @return the metadata
*/
- MutableMetaDataContext getMetaDataContext();
+ MetaData getMetaData();
/**
- * Set the metadata context
+ * Get the scope
*
- * @param mctx the metadata context
+ * @return the scope
*/
- void setMetaDataContext(MetaDataContext mctx);
+ ScopeKey getScope();
+
+ /**
+ * Set the scope
+ *
+ * @param key the scope key
+ */
+ void setScope(ScopeKey key);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/metadata/KernelMetaDataRepository.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/metadata/KernelMetaDataRepository.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/metadata/KernelMetaDataRepository.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -22,7 +22,11 @@
package org.jboss.kernel.spi.metadata;
import org.jboss.kernel.spi.KernelObject;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+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.scope.ScopeKey;
/**
* KernelMetaDataRepository.
@@ -38,4 +42,52 @@
* @return the meta data repository
*/
MutableMetaDataRepository getMetaDataRepository();
+
+ /**
+ * Get MetaData
+ *
+ * @param context the context
+ * @return the metadata
+ */
+ MetaData getMetaData(KernelControllerContext context);
+
+ /**
+ * Get the MetaData retrieval
+ *
+ * @param context the context
+ * @return the metadata retrieval
+ */
+ MetaDataRetrieval getMetaDataRetrieval(KernelControllerContext context);
+
+ /**
+ * Add metadata to the bean.
+ *
+ * @param context the context
+ * @param beanMetaData the bean metadata
+ * @param beanInfo the bean info
+ */
+ void addMetaData(KernelControllerContext context);
+
+ /**
+ * Remove any previously added metadata
+ *
+ * @param context the context
+ */
+ void removeMetaData(KernelControllerContext context);
+
+ /**
+ * Get the default scope for a context
+ *
+ * @param context the context
+ * @return the default scope
+ */
+ ScopeKey getFullScope(KernelControllerContext context);
+
+ /**
+ * Get the mutable scope for a context
+ *
+ * @param context the context
+ * @return the default scope
+ */
+ ScopeKey getMutableScope(KernelControllerContext context);
}
Deleted: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/metadata/MutableMetaDataContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/metadata/MutableMetaDataContext.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/metadata/MutableMetaDataContext.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -1,43 +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.kernel.spi.metadata;
-
-import java.util.Set;
-
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.beans.metadata.spi.AnnotationMetaData;
-import org.jboss.repository.spi.MetaDataContext;
-
-/**
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public interface MutableMetaDataContext extends MetaDataContext
-{
- public abstract void addAnnotations(Set<AnnotationMetaData> annotations);
-
- public abstract void addPropertyAnnotations(String propertyName, Set<PropertyInfo> propertyInfos, Set<AnnotationMetaData> annotations);
-
- public abstract void setTarget(Object tgt);
-
-}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -26,6 +26,7 @@
import org.jboss.dependency.spi.ControllerState;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
import org.jboss.test.AbstractTestCaseWithSetup;
import org.jboss.test.AbstractTestDelegate;
@@ -176,6 +177,17 @@
{
getMCDelegate().validate();
}
+
+ /**
+ * Get the metadata repository
+ *
+ * @return the metadata repository
+ * @throws IllegalStateException when the bean does not exist at that state
+ */
+ protected KernelMetaDataRepository getMetaDataRepository()
+ {
+ return getMCDelegate().getMetaDataRepository();
+ }
/**
* Get the delegate
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -31,6 +31,7 @@
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
import org.jboss.test.AbstractTestDelegate;
/**
@@ -125,6 +126,16 @@
}
/**
+ * Get the metadata repository
+ * @return the metadata repository
+ * @throws IllegalStateException when the bean does not exist at that state
+ */
+ protected KernelMetaDataRepository getMetaDataRepository()
+ {
+ return kernel.getMetaDataRepository();
+ }
+
+ /**
* Get a context
*
* @param name the name of the bean
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_New.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_New.xml 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_New.xml 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="Name1" class="org.jboss.test.kernel.metadata.support.TestClassAnnotation">
+ <annotation>@org.jboss.test.kernel.metadata.support.TestAnnotationC</annotation>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NewProperty.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NewProperty.xml 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NewProperty.xml 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="Name1" class="org.jboss.test.kernel.metadata.support.TestClassAnnotation">
+ <property name="something">Hello
+ <annotation>@org.jboss.test.kernel.metadata.support.TestAnnotationC</annotation>
+ </property>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NoOverride.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NoOverride.xml 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NoOverride.xml 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="Name1" class="org.jboss.test.kernel.metadata.support.TestClassAnnotation">
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NoOverrideProperty.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NoOverrideProperty.xml 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_NoOverrideProperty.xml 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="Name1" class="org.jboss.test.kernel.metadata.support.TestClassAnnotation">
+ <property name="something">Hello</property>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_Override.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_Override.xml 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_Override.xml 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="Name1" class="org.jboss.test.kernel.metadata.support.TestClassAnnotation">
+ <annotation>@org.jboss.test.kernel.metadata.support.TestAnnotationA("Overridden")</annotation>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_OverrideProperty.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_OverrideProperty.xml 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase_OverrideProperty.xml 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="Name1" class="org.jboss.test.kernel.metadata.support.TestClassAnnotation">
+ <property name="something">Hello
+ <annotation>@org.jboss.test.kernel.metadata.support.TestAnnotationA("Overridden")</annotation>
+ </property>
+ </bean>
+</deployment>
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/ioc/test/AbstractIoCTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/ioc/test/AbstractIoCTest.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/ioc/test/AbstractIoCTest.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -46,6 +46,7 @@
/**
* Unmarshal some xml
*
+ * @param <T> the expected type
* @param name the name
* @param expected the expected type
* @return the unmarshalled object
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -34,6 +34,7 @@
import org.jboss.test.kernel.event.test.EventTestSuite;
import org.jboss.test.kernel.registry.test.RegistryTestSuite;
import org.jboss.test.kernel.inject.test.ContextualInjectionTestSuite;
+import org.jboss.test.kernel.metadata.test.MetaDataTestSuite;
/**
* Kernel Test Suite.
@@ -61,6 +62,7 @@
suite.addTest(DeploymentTestSuite.suite());
suite.addTest(ContextualInjectionTestSuite.suite());
suite.addTest(XMLTestSuite.suite());
+ suite.addTest(MetaDataTestSuite.suite());
return suite;
}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomCollection.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomCollection.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomCollection.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -29,7 +29,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
-public class CustomCollection extends ArrayList
+public class CustomCollection extends ArrayList<String>
{
/** The serialVersionUID */
private static final long serialVersionUID = 3762538897183683896L;
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomList.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomList.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomList.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -29,7 +29,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
-public class CustomList extends ArrayList
+public class CustomList extends ArrayList<String>
{
/** The serialVersionUID */
private static final long serialVersionUID = 3762538897183683896L;
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomMap.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomMap.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomMap.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -29,7 +29,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
-public class CustomMap extends HashMap
+public class CustomMap extends HashMap<String, String>
{
/** The serialVersionUID */
private static final long serialVersionUID = 3762538897183683896L;
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomSet.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomSet.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/CustomSet.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -29,7 +29,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
-public class CustomSet extends HashSet
+public class CustomSet extends HashSet<String>
{
/** The serialVersionUID */
private static final long serialVersionUID = 3762538897183683896L;
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationA.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationA.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationA.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,37 @@
+/*
+* 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.test.kernel.metadata.support;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * TestAnnotation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface TestAnnotationA
+{
+ String value();
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationB.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationB.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationB.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,37 @@
+/*
+* 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.test.kernel.metadata.support;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * TestOverrideAnnotation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface TestAnnotationB
+{
+ String value();
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationC.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationC.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestAnnotationC.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,36 @@
+/*
+* 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.test.kernel.metadata.support;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * TestAnnotation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface TestAnnotationC
+{
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestClassAnnotation.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestClassAnnotation.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/support/TestClassAnnotation.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,53 @@
+/*
+* 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.test.kernel.metadata.support;
+
+import org.jboss.test.kernel.metadata.test.AbstractMetaDataTest;
+
+/**
+ * TestClassAnnotation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at TestAnnotationA("NotOverridden")
+ at TestAnnotationB("NotOverridden")
+public class TestClassAnnotation
+{
+ public TestClassAnnotation()
+ {
+ AbstractMetaDataTest.peekMetaData();
+ }
+
+ @TestAnnotationA("NotOverridden")
+ @TestAnnotationB("NotOverridden")
+ public String getSomething()
+ {
+ return null;
+ }
+
+ @TestAnnotationA("NotOverridden")
+ @TestAnnotationB("NotOverridden")
+ public void setSomething(String p1)
+ {
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/AbstractMetaDataTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/AbstractMetaDataTest.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/AbstractMetaDataTest.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,116 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.metadata.test;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.repository.MetaDataRepository;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.stack.MetaDataStack;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+
+/**
+ * MetaData Test Case.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 40428 $
+ */
+public class AbstractMetaDataTest extends MicrocontainerTest
+{
+ public AbstractMetaDataTest(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ private static MetaData peekedMetaData;
+
+ public static void peekMetaData()
+ {
+ peekedMetaData = MetaDataStack.peek();
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ peekedMetaData = null;
+ }
+
+ protected MetaData assertPeekedMetaData()
+ {
+ assertNotNull(peekedMetaData);
+ return peekedMetaData;
+ }
+
+ protected ScopeKey assertRetrievals(String name)
+ {
+ KernelControllerContext context = getControllerContext(name);
+ MetaDataRepository repository = getMetaDataRepository().getMetaDataRepository();
+ ScopeKey result = context.getScope();
+ assertNotNull(repository.getMetaDataRetrieval(result));
+ assertNotNull(repository.getMetaDataRetrieval(new ScopeKey(CommonLevels.INSTANCE, name)));
+ return result;
+ }
+
+ protected void assertNoRetrievals(String name, ScopeKey scope)
+ {
+ MetaDataRepository repository = getMetaDataRepository().getMetaDataRepository();
+ assertNull(repository.getMetaDataRetrieval(scope));
+ assertNull(repository.getMetaDataRetrieval(new ScopeKey(CommonLevels.INSTANCE, name)));
+ }
+
+ protected <T extends Annotation> T assertAnnotation(MetaData metaData, Class<T> annotationClass)
+ {
+ T result = metaData.getAnnotation(annotationClass);
+ assertNotNull(result);
+ return result;
+ }
+
+ protected <T extends Annotation> void assertNoAnnotation(MetaData metaData, Class<T> annotationClass)
+ {
+ T result = metaData.getAnnotation(annotationClass);
+ assertNull(result);
+ }
+
+ /**
+ * Default setup with security manager enabled
+ *
+ * @param clazz the class
+ * @return the delegate
+ * @throws Exception for any error
+ */
+ public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+ {
+ AbstractTestDelegate delegate = MicrocontainerTest.getDelegate(clazz);
+ //delegate.enableSecurity = true;
+ return delegate;
+ }
+
+ protected void configureLogging()
+ {
+ //enableTrace("org.jboss.dependency");
+ //enableTrace("org.jboss.kernel.plugins.dependency");
+ }
+}
\ No newline at end of file
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/ClassAnnotationTestCase.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,204 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.metadata.test;
+
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.signature.MethodSignature;
+import org.jboss.test.kernel.metadata.support.TestAnnotationA;
+import org.jboss.test.kernel.metadata.support.TestAnnotationB;
+import org.jboss.test.kernel.metadata.support.TestAnnotationC;
+
+import junit.framework.Test;
+
+/**
+ * ClassAnnotationTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassAnnotationTestCase extends AbstractMetaDataTest
+{
+ public static Test suite()
+ {
+ return suite(ClassAnnotationTestCase.class);
+ }
+
+ public ClassAnnotationTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public void testClassAnnotationNoOverride() throws Throwable
+ {
+ ScopeKey scope = null;
+ KernelDeployment deployment = deploy("ClassAnnotationTestCase_NoOverride.xml");
+ try
+ {
+ scope = assertRetrievals("Name1");
+ MetaData metaData = assertPeekedMetaData();
+ TestAnnotationA a = assertAnnotation(metaData, TestAnnotationA.class);
+ assertEquals("NotOverridden", a.value());
+ TestAnnotationB b = assertAnnotation(metaData, TestAnnotationB.class);
+ assertEquals("NotOverridden", b.value());
+ assertNoAnnotation(metaData, TestAnnotationC.class);
+ }
+ finally
+ {
+ undeploy(deployment);
+ if (scope != null)
+ assertNoRetrievals("Name1", scope);
+ }
+ }
+
+ public void testClassAnnotationOverride() throws Throwable
+ {
+ ScopeKey scope = null;
+ KernelDeployment deployment = deploy("ClassAnnotationTestCase_Override.xml");
+ try
+ {
+ scope = assertRetrievals("Name1");
+ MetaData metaData = assertPeekedMetaData();
+ TestAnnotationA a = assertAnnotation(metaData, TestAnnotationA.class);
+ assertEquals("Overridden", a.value());
+ TestAnnotationB b = assertAnnotation(metaData, TestAnnotationB.class);
+ assertEquals("NotOverridden", b.value());
+ assertNoAnnotation(metaData, TestAnnotationC.class);
+ }
+ finally
+ {
+ undeploy(deployment);
+ if (scope != null)
+ assertNoRetrievals("Name1", scope);
+ }
+ }
+
+ public void testClassAnnotationNew() throws Throwable
+ {
+ ScopeKey scope = null;
+ KernelDeployment deployment = deploy("ClassAnnotationTestCase_New.xml");
+ try
+ {
+ scope = assertRetrievals("Name1");
+ MetaData metaData = assertPeekedMetaData();
+ TestAnnotationA a = assertAnnotation(metaData, TestAnnotationA.class);
+ assertEquals("NotOverridden", a.value());
+ TestAnnotationB b = assertAnnotation(metaData, TestAnnotationB.class);
+ assertEquals("NotOverridden", b.value());
+ assertAnnotation(metaData, TestAnnotationC.class);
+ }
+ finally
+ {
+ undeploy(deployment);
+ if (scope != null)
+ assertNoRetrievals("Name1", scope);
+ }
+ }
+
+ public void testPropertyAnnotationNoOverride() throws Throwable
+ {
+ ScopeKey scope = null;
+ KernelDeployment deployment = deploy("ClassAnnotationTestCase_NoOverrideProperty.xml");
+ try
+ {
+ scope = assertRetrievals("Name1");
+ MetaData classMetaData = assertPeekedMetaData();
+ MetaData metaData = classMetaData.getComponentMetaData(new MethodSignature("getSomething"));
+ TestAnnotationA a = assertAnnotation(metaData, TestAnnotationA.class);
+ assertEquals("NotOverridden", a.value());
+ TestAnnotationB b = assertAnnotation(metaData, TestAnnotationB.class);
+ assertEquals("NotOverridden", b.value());
+ assertNoAnnotation(metaData, TestAnnotationC.class);
+ metaData = classMetaData.getComponentMetaData(new MethodSignature("setSomething", String.class));
+ a = assertAnnotation(metaData, TestAnnotationA.class);
+ assertEquals("NotOverridden", a.value());
+ b = assertAnnotation(metaData, TestAnnotationB.class);
+ assertEquals("NotOverridden", b.value());
+ assertNoAnnotation(metaData, TestAnnotationC.class);
+ }
+ finally
+ {
+ undeploy(deployment);
+ if (scope != null)
+ assertNoRetrievals("Name1", scope);
+ }
+ }
+
+ public void testPropertyAnnotationOverride() throws Throwable
+ {
+ ScopeKey scope = null;
+ KernelDeployment deployment = deploy("ClassAnnotationTestCase_OverrideProperty.xml");
+ try
+ {
+ scope = assertRetrievals("Name1");
+ MetaData classMetaData = assertPeekedMetaData();
+ MetaData metaData = classMetaData.getComponentMetaData(new MethodSignature("getSomething"));
+ TestAnnotationA a = assertAnnotation(metaData, TestAnnotationA.class);
+ assertEquals("Overridden", a.value());
+ TestAnnotationB b = assertAnnotation(metaData, TestAnnotationB.class);
+ assertEquals("NotOverridden", b.value());
+ assertNoAnnotation(metaData, TestAnnotationC.class);
+ metaData = classMetaData.getComponentMetaData(new MethodSignature("setSomething", String.class));
+ a = assertAnnotation(metaData, TestAnnotationA.class);
+ assertEquals("Overridden", a.value());
+ b = assertAnnotation(metaData, TestAnnotationB.class);
+ assertEquals("NotOverridden", b.value());
+ assertNoAnnotation(metaData, TestAnnotationC.class);
+ }
+ finally
+ {
+ undeploy(deployment);
+ if (scope != null)
+ assertNoRetrievals("Name1", scope);
+ }
+ }
+
+ public void testPropertyAnnotationNew() throws Throwable
+ {
+ ScopeKey scope = null;
+ KernelDeployment deployment = deploy("ClassAnnotationTestCase_NewProperty.xml");
+ try
+ {
+ scope = assertRetrievals("Name1");
+ MetaData classMetaData = assertPeekedMetaData();
+ MetaData metaData = classMetaData.getComponentMetaData(new MethodSignature("getSomething"));
+ TestAnnotationA a = assertAnnotation(metaData, TestAnnotationA.class);
+ assertEquals("NotOverridden", a.value());
+ TestAnnotationB b = assertAnnotation(metaData, TestAnnotationB.class);
+ assertEquals("NotOverridden", b.value());
+ assertAnnotation(metaData, TestAnnotationC.class);
+ metaData = classMetaData.getComponentMetaData(new MethodSignature("setSomething", String.class));
+ a = assertAnnotation(metaData, TestAnnotationA.class);
+ assertEquals("NotOverridden", a.value());
+ b = assertAnnotation(metaData, TestAnnotationB.class);
+ assertEquals("NotOverridden", b.value());
+ assertAnnotation(metaData, TestAnnotationC.class);
+ }
+ finally
+ {
+ undeploy(deployment);
+ if (scope != null)
+ assertNoRetrievals("Name1", scope);
+ }
+ }
+}
\ No newline at end of file
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/MetaDataTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/MetaDataTestSuite.java 2006-12-13 23:45:58 UTC (rev 59019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/metadata/test/MetaDataTestSuite.java 2006-12-13 23:51:15 UTC (rev 59020)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.metadata.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * MetaData Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 55945 $
+ */
+public class MetaDataTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("MetaData Tests");
+
+ suite.addTest(ClassAnnotationTestCase.suite());
+
+ return suite;
+ }
+}
More information about the jboss-cvs-commits
mailing list