[jboss-cvs] JBossAS SVN: r76600 - in projects/jboss-deployers/trunk: deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations and 20 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 4 05:54:01 EDT 2008


Author: alesj
Date: 2008-08-04 05:54:01 -0400 (Mon, 04 Aug 2008)
New Revision: 76600

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/FilteredAnnotationEnvironmentDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationEnvironmentDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/META-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/META-INF/application.properties
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/jar/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/jar/META-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/jar/META-INF/MANIFEST.MF
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/web/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/web/WEB-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/web/WEB-INF/web.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/annotations/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/annotations/test/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/Marked.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/NoExtRecurseFilter.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/ext/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/ext/External.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClass.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnFiled.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnMethod.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/util/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/util/Util.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClass.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnFiled.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnMethod.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/test/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.java
Modified:
   projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/FilteredGenericAnnotationDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/AnnotationEnvironmentDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTest.java
Log:
AnnEnvDeployer tests.

Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/FilteredGenericAnnotationDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/FilteredGenericAnnotationDeployer.java	2008-08-04 07:12:01 UTC (rev 76599)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/FilteredGenericAnnotationDeployer.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -71,7 +71,7 @@
    protected void visitModule(DeploymentUnit unit, Module module, GenericAnnotationResourceVisitor visitor)
    {
       ResourceFilter filter = getFilter(unit, ResourceFilter.class, "resource", resourceFilter);
-      if (filter != null)
+      if (filter == null)
          filter = visitor.getFilter();
       ResourceFilter recurse = getFilter(unit, ResourceFilter.class, "recurse", recurseFilter);
       module.visit(visitor, filter, recurse, getUrls(unit));

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/AnnotationEnvironmentDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/AnnotationEnvironmentDeployer.java	2008-08-04 07:12:01 UTC (rev 76599)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/AnnotationEnvironmentDeployer.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -136,7 +136,7 @@
    {
       try
       {
-         module.visit(visitor, null, null, getURL(unit));
+         module.visit(visitor, visitor.getFilter(), null, getUrls(unit));
       }
       catch (Exception e)
       {
@@ -151,7 +151,7 @@
     * @return matching urls
     * @throws Exception for any error
     */
-   protected URL[] getURL(VFSDeploymentUnit unit) throws Exception
+   protected URL[] getUrls(VFSDeploymentUnit unit) throws Exception
    {
       List<VirtualFile> classpath = unit.getClassPath();
       if (classpath != null && classpath.isEmpty() == false)

Added: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/FilteredAnnotationEnvironmentDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/FilteredAnnotationEnvironmentDeployer.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/FilteredAnnotationEnvironmentDeployer.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,109 @@
+/*
+* 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.deployers.vfs.plugins.annotations;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.visitor.ResourceFilter;
+import org.jboss.deployers.plugins.annotations.GenericAnnotationResourceVisitor;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployers.spi.DeploymentException;
+
+/**
+ * Filtered annotation environment deployer.
+ *
+ * It first checks if there are some filters present
+ * in deployment unit as attachment,
+ * else falls back to deployers filters.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FilteredAnnotationEnvironmentDeployer extends ScopedAnnotationEnvironmentDeployer
+{
+   private ResourceFilter resourceFilter;
+   private ResourceFilter recurseFilter;
+
+   /**
+    * Get filter.
+    * Try attachment first, then deployer's filter.
+    *
+    * @param <T> the expected class type
+    * @param unit the deployment unit
+    * @param expectedClass the expected class
+    * @param suffix the suffix
+    * @param defaultValue the default value
+    * @return found filter or null
+    */
+   protected <T> T getFilter(DeploymentUnit unit, Class<T> expectedClass, String suffix, T defaultValue)
+   {
+      String name = expectedClass.getName() + "." + (suffix != null ? suffix : "");
+      T result = unit.getAttachment(name, expectedClass);
+      if (result == null)
+         result = defaultValue;
+      return result;
+   }
+
+   /**
+    * We look for filter attachments:
+    * * org.jboss.classloading.spi.visitor.ResourceFilter.resource - plain resource filter
+    * * org.jboss.classloading.spi.visitor.ResourceFilter.recurse  - recurse resource filter
+    *
+    * @param unit the deployment unit
+    * @param module the underlying module
+    * @param visitor the current generic annotation resource visitor
+    */
+   protected void visitModule(VFSDeploymentUnit unit, Module module, GenericAnnotationResourceVisitor visitor) throws DeploymentException
+   {
+      ResourceFilter filter = getFilter(unit, ResourceFilter.class, "resource", resourceFilter);
+      if (filter == null)
+         filter = visitor.getFilter();
+      ResourceFilter recurse = getFilter(unit, ResourceFilter.class, "recurse", recurseFilter);
+      try
+      {
+         module.visit(visitor, filter, recurse, getUrls(unit));
+      }
+      catch (Exception e)
+      {
+         throw DeploymentException.rethrowAsDeploymentException("Exception visiting module", e);
+      }
+   }
+
+   /**
+    * Set resource filter.
+    *
+     * @param resourceFilter the resource filter
+    */
+   public void setResourceFilter(ResourceFilter resourceFilter)
+   {
+      this.resourceFilter = resourceFilter;
+   }
+
+   /**
+    * Set recurse filter.
+    *
+    * @param recurseFilter the recurse filter
+    */
+   public void setRecurseFilter(ResourceFilter recurseFilter)
+   {
+      this.recurseFilter = recurseFilter;
+   }
+}
\ No newline at end of file

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationEnvironmentDeployer.java (from rev 76599, projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/AnnotationEnvironmentDeployer.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationEnvironmentDeployer.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationEnvironmentDeployer.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -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.deployers.vfs.plugins.annotations;
+
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+/**
+ * Scoped class pool usage annotation environment deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ScopedAnnotationEnvironmentDeployer extends AnnotationEnvironmentDeployer
+{
+   private ScopedClassPoolRepository repository;
+
+   public ScopedAnnotationEnvironmentDeployer()
+   {
+      super();
+   }
+
+   public ScopedAnnotationEnvironmentDeployer(ScopedClassPoolRepository repository)
+   {
+      this();
+      this.repository = repository;
+   }
+
+   /**
+    * Set scoped class pool repository.
+    *
+    * @param repository the scoped class pool repository
+    */
+   public void setRepository(ScopedClassPoolRepository repository)
+   {
+      this.repository = repository;
+   }
+
+   protected ClassPool createClassPool(ClassLoader classLoader)
+   {
+      if (repository != null)
+         return repository.findClassPool(classLoader);
+
+      return super.createClassPool(classLoader);
+   }
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/META-INF/application.properties
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/META-INF/application.properties	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/META-INF/application.properties	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,2 @@
+jar-module=simple.jar
+web-module=simple.war

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/jar/META-INF/MANIFEST.MF (from rev 76599, projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/classloader/manifest/scoped/META-INF/MANIFEST.MF)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/jar/META-INF/MANIFEST.MF	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/jar/META-INF/MANIFEST.MF	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Created-By: hand
+Class-Path: lib/util.jar

Added: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/web/WEB-INF/web.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/web/WEB-INF/web.xml	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/annotations/basic-scan/web/WEB-INF/web.xml	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1 @@
+<web/>
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.xml	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.xml	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,12 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="EarStructure" class="org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer"/>
+  <bean name="WarStructure" class="org.jboss.deployers.vfs.plugins.structure.war.WARStructure"/>
+
+  <bean name="AnnEnvDeployer" class="org.jboss.deployers.vfs.plugins.annotations.FilteredAnnotationEnvironmentDeployer">
+    <property name="recurseFilter">
+      <bean class="org.jboss.test.deployers.vfs.annotations.support.NoExtRecurseFilter"/>
+    </property>
+  </bean>
+
+</deployment>

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTest.java	2008-08-04 07:12:01 UTC (rev 76599)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTest.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -289,9 +289,14 @@
 
    protected AssembledDirectory createAssembledDirectory(String name) throws Exception
    {
-      return AssembledDirectory.createAssembledDirectory(name, "");
+      return createAssembledDirectory(name, "");     
    }
 
+   protected AssembledDirectory createAssembledDirectory(String name, String rootName) throws Exception
+   {
+      return AssembledDirectory.createAssembledDirectory(name, rootName);
+   }
+
    protected void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
    {
       String packagePath = ClassLoaderUtils.packageNameToPath(reference.getName());

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/Marked.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/Marked.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/Marked.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,33 @@
+/*
+* 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.deployers.vfs.annotations.support;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})
+public @interface Marked
+{
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/NoExtRecurseFilter.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/NoExtRecurseFilter.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/NoExtRecurseFilter.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -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.deployers.vfs.annotations.support;
+
+import org.jboss.classloading.spi.visitor.ResourceFilter;
+import org.jboss.classloading.spi.visitor.ResourceContext;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class NoExtRecurseFilter implements ResourceFilter
+{
+   public boolean accepts(ResourceContext resource)
+   {
+      String urlString = resource.getUrl().toExternalForm();
+      return urlString.contains("ext.jar") == false;
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/ext/External.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/ext/External.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/ext/External.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,39 @@
+/*
+* 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.deployers.vfs.annotations.support.ext;
+
+import org.jboss.test.deployers.vfs.annotations.support.Marked;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Marked
+public class External
+{
+   private @Marked Object foo;
+
+   @Marked
+   public int getInt()
+   {
+      return 0;
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClass.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClass.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnClass.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,32 @@
+/*
+* 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.deployers.vfs.annotations.support.jar;
+
+import org.jboss.test.deployers.vfs.annotations.support.Marked;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Marked
+public class JarMarkOnClass
+{
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnFiled.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnFiled.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnFiled.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,32 @@
+/*
+* 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.deployers.vfs.annotations.support.jar;
+
+import org.jboss.test.deployers.vfs.annotations.support.Marked;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JarMarkOnFiled
+{
+   private @Marked Object field;
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnMethod.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnMethod.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/jar/JarMarkOnMethod.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -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.deployers.vfs.annotations.support.jar;
+
+import org.jboss.test.deployers.vfs.annotations.support.Marked;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JarMarkOnMethod
+{
+   @Marked
+   public String getJndiName()
+   {
+      return null;
+   }
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/util/Util.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/util/Util.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/util/Util.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,38 @@
+/*
+* 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.deployers.vfs.annotations.support.util;
+
+import org.jboss.test.deployers.vfs.annotations.support.Marked;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Marked
+public class Util
+{
+   private @Marked Object marked;
+
+   @Marked
+   public void setSomething(String something)
+   {
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClass.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClass.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnClass.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,32 @@
+/*
+* 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.deployers.vfs.annotations.support.war;
+
+import org.jboss.test.deployers.vfs.annotations.support.Marked;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Marked
+public class WebMarkOnClass
+{
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnFiled.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnFiled.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnFiled.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,32 @@
+/*
+* 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.deployers.vfs.annotations.support.war;
+
+import org.jboss.test.deployers.vfs.annotations.support.Marked;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class WebMarkOnFiled
+{
+   private @Marked Object field;
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnMethod.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnMethod.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/support/war/WebMarkOnMethod.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -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.deployers.vfs.annotations.support.war;
+
+import org.jboss.test.deployers.vfs.annotations.support.Marked;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class WebMarkOnMethod
+{
+   @Marked
+   public String getJndiName()
+   {
+      return null;
+   }
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/annotations/test/AnnotationsScanningUnitTestCase.java	2008-08-04 09:54:01 UTC (rev 76600)
@@ -0,0 +1,112 @@
+/*
+* 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.deployers.vfs.annotations.test;
+
+import java.util.Set;
+
+import junit.framework.Test;
+import org.jboss.deployers.spi.annotations.AnnotationEnvironment;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+import org.jboss.test.deployers.vfs.annotations.support.jar.JarMarkOnClass;
+import org.jboss.test.deployers.vfs.annotations.support.util.Util;
+import org.jboss.test.deployers.vfs.annotations.support.war.WebMarkOnClass;
+import org.jboss.test.deployers.vfs.annotations.support.ext.External;
+import org.jboss.virtual.AssembledDirectory;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationsScanningUnitTestCase extends BootstrapDeployersTest
+{
+   public AnnotationsScanningUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(AnnotationsScanningUnitTestCase.class);
+   }
+
+   public void testBasicScanning() throws Throwable
+   {
+      AssembledDirectory ear = createTopLevelWithUtil();
+
+      AssembledDirectory jar = ear.mkdir("simple.jar");
+      addPackage(jar, JarMarkOnClass.class);
+      addPath(jar, "/annotations/basic-scan/jar", "META-INF");
+
+      AssembledDirectory war = ear.mkdir("simple.war");
+      AssembledDirectory webinf = war.mkdir("WEB-INF");
+      AssembledDirectory classes = webinf.mkdir("classes");
+      addPackage(classes, WebMarkOnClass.class);
+      addPath(war, "/annotations/basic-scan/web", "WEB-INF");
+
+      enableTrace("org.jboss.deployers");
+
+      VFSDeploymentUnit unit = assertDeploy(ear);
+      assertAnnotations(unit, 1, 1, 1);
+      try
+      {
+         DeploymentUnit jarUnit = assertChild(unit, "simple.jar");
+         assertAnnotations(jarUnit, 1, 1, 1);
+         DeploymentUnit webUnit = assertChild(unit, "simple.war");
+         assertAnnotations(webUnit, 1, 1, 1);
+      }
+      finally
+      {
+         undeploy(unit);
+      }
+   }
+
+   protected void assertAnnotations(DeploymentUnit unit, int onClass, int onMethod, int onFiled)
+   {
+      AnnotationEnvironment env = unit.getAttachment(AnnotationEnvironment.class);
+      assertNotNull(env);
+
+      Set classes = env.classIsAnnotatedWith("org.jboss.test.deployers.vfs.annotations.support.Marked");
+      assertNotNull(classes);
+      assertEquals(onClass, classes.size());
+
+      Set methods = env.classHasMethodAnnotatedWith("org.jboss.test.deployers.vfs.annotations.support.Marked");
+      assertNotNull(methods);
+      assertEquals(onMethod, methods.size());
+
+      Set fields = env.classHasFieldAnnotatedWith("org.jboss.test.deployers.vfs.annotations.support.Marked");
+      assertNotNull(fields);
+      assertEquals(onFiled, fields.size());
+   }
+
+   protected AssembledDirectory createTopLevelWithUtil() throws Exception
+   {
+      AssembledDirectory topLevel = createAssembledDirectory("top-level.ear", "top-level.ear");
+      addPath(topLevel, "/annotations/basic-scan", "META-INF");
+      AssembledDirectory earLib = topLevel.mkdir("lib");
+      AssembledDirectory util = earLib.mkdir("util.jar");
+      addPackage(util, Util.class);
+      AssembledDirectory ext = earLib.mkdir("ext.jar");
+      addPackage(ext, External.class);
+      return topLevel;
+   }
+}




More information about the jboss-cvs-commits mailing list