[jboss-cvs] JBossAS SVN: r95451 - in projects/jboss-deployers/trunk: deployers-impl/src/test/java/org/jboss/test/deployers/annotations/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 22 18:32:34 EDT 2009


Author: alesj
Date: 2009-10-22 18:32:34 -0400 (Thu, 22 Oct 2009)
New Revision: 95451

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/JavassistAnnotationRepositoryDeployer.java
Removed:
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationRepositoryDeployer.java
Modified:
   projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationDeployer.java
   projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/annotations/test/AnnotationEnvKeepTestCase.java
   projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/annotations/test/AnnotationsTest.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/AnnotationRepositoryDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/FilteredAnnotationRepositoryDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java
Log:
Remove ConfigurationCreator - bad idea.

Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationDeployer.java	2009-10-22 22:25:57 UTC (rev 95450)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationDeployer.java	2009-10-22 22:32:34 UTC (rev 95451)
@@ -27,7 +27,7 @@
 import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.mcann.AnnotationRepository;
-import org.jboss.mcann.repository.ConfigurationCreator;
+import org.jboss.mcann.repository.Configuration;
 import org.jboss.mcann.scanner.DefaultAnnotationScanner;
 import org.jboss.mcann.scanner.ModuleAnnotationScanner;
 
@@ -38,7 +38,7 @@
  */
 public class GenericAnnotationDeployer extends AbstractSimpleRealDeployer<Module>
 {
-   private ConfigurationCreator creator;
+   private Configuration configuration;
 
    public GenericAnnotationDeployer()
    {
@@ -52,8 +52,8 @@
       try
       {
          DefaultAnnotationScanner scanner = new ModuleAnnotationScanner(deployment);
-         if (creator != null)
-            scanner.setConfiguration(creator.createConfiguration());
+         if (configuration != null)
+            scanner.setConfiguration(configuration);
          
          AnnotationRepository repository = scanner.scan(unit.getClassLoader());
          unit.addAttachment(AnnotationRepository.class, repository);
@@ -65,12 +65,12 @@
    }
 
    /**
-    * Set configuration creator.
+    * Set configuration.
     *
-    * @param creator the configuration creator
+    * @param configuration the configuration creator
     */
-   public void setConfigurationCreator(ConfigurationCreator creator)
+   public void setConfiguration(Configuration configuration)
    {
-      this.creator = creator;
+      this.configuration = configuration;
    }
 }

Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/annotations/test/AnnotationEnvKeepTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/annotations/test/AnnotationEnvKeepTestCase.java	2009-10-22 22:25:57 UTC (rev 95450)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/annotations/test/AnnotationEnvKeepTestCase.java	2009-10-22 22:32:34 UTC (rev 95451)
@@ -22,7 +22,7 @@
 package org.jboss.test.deployers.annotations.test;
 
 import junit.framework.Test;
-import org.jboss.mcann.repository.DefaultConfiguration;
+import org.jboss.mcann.repository.AbstractSettings;
 
 /**
  * AnnotationEnvKeepTestCase.
@@ -43,9 +43,9 @@
    }
 
    @Override
-   protected void applyConfiguration(DefaultConfiguration configuration)
+   protected void applySettings(AbstractSettings settings)
    {
-      super.applyConfiguration(configuration);
-      configuration.setKeepAnnotations(true);
+      super.applySettings(settings);
+      settings.setKeepAnnotations(true);
    }
 }
\ No newline at end of file

Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/annotations/test/AnnotationsTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/annotations/test/AnnotationsTest.java	2009-10-22 22:25:57 UTC (rev 95450)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/annotations/test/AnnotationsTest.java	2009-10-22 22:32:34 UTC (rev 95451)
@@ -25,11 +25,11 @@
 import java.lang.reflect.AnnotatedElement;
 import java.util.Set;
 
+import org.jboss.classloader.plugins.filter.CombiningClassFilter;
 import org.jboss.classloader.spi.ClassLoaderSystem;
 import org.jboss.classloader.spi.ParentPolicy;
 import org.jboss.classloader.spi.filter.ClassFilter;
 import org.jboss.classloader.spi.filter.PackageClassFilter;
-import org.jboss.classloader.plugins.filter.CombiningClassFilter;
 import org.jboss.classloading.spi.dependency.ClassLoading;
 import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData;
 import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
@@ -47,10 +47,8 @@
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.mcann.AnnotationRepository;
 import org.jboss.mcann.Element;
-import org.jboss.mcann.repository.DefaultConfiguration;
-import org.jboss.mcann.repository.ConfigurationCreator;
-import org.jboss.mcann.repository.Configuration;
-import org.jboss.mcann.repository.javassist.JavassistTypeInfoProvider;
+import org.jboss.mcann.repository.AbstractSettings;
+import org.jboss.mcann.repository.javassist.JavassistConfiguration;
 import org.jboss.test.deployers.AbstractDeployerTest;
 import org.jboss.test.deployers.annotations.support.InterceptionClassLoader;
 import org.jboss.test.deployers.annotations.support.InterceptionClassLoaderSystem;
@@ -199,22 +197,14 @@
    protected Deployer createGenericAnnotationDeployer()
    {
       GenericAnnotationDeployer deployer = new GenericAnnotationDeployer();
-      final DefaultConfiguration configuration = new DefaultConfiguration();
-      applyConfiguration(configuration);
-      ConfigurationCreator creator = new ConfigurationCreator()
-      {
-         public Configuration createConfiguration()
-         {
-            return configuration;
-         }
-      };
-      deployer.setConfigurationCreator(creator);
+      final JavassistConfiguration configuration = new JavassistConfiguration();
+      applySettings(configuration);
+      deployer.setConfiguration(configuration);
       return deployer;
    }
 
-   protected void applyConfiguration(DefaultConfiguration configuration)
+   protected void applySettings(AbstractSettings settings)
    {
-      configuration.setTypeInfoProvider(new JavassistTypeInfoProvider());
-      configuration.setForceAnnotations(true);
+      settings.setForceAnnotations(true);
    }
 }

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/AnnotationRepositoryDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/AnnotationRepositoryDeployer.java	2009-10-22 22:25:57 UTC (rev 95450)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/AnnotationRepositoryDeployer.java	2009-10-22 22:32:34 UTC (rev 95451)
@@ -32,8 +32,10 @@
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnitFilter;
 import org.jboss.mcann.AnnotationRepository;
-import org.jboss.mcann.repository.ConfigurationCreator;
+import org.jboss.mcann.repository.Configuration;
 import org.jboss.mcann.repository.DefaultConfiguration;
+import org.jboss.mcann.repository.AbstractSettings;
+import org.jboss.mcann.repository.AbstractConfiguration;
 import org.jboss.mcann.scanner.DefaultAnnotationScanner;
 import org.jboss.mcann.scanner.ModuleAnnotationScanner;
 
@@ -44,7 +46,7 @@
  */
 public class AnnotationRepositoryDeployer extends AbstractOptionalVFSRealDeployer<Module>
 {
-   private ConfigurationCreator creator;
+   private Configuration configuration;
    private VFSDeploymentUnitFilter filter;
 
    public AnnotationRepositoryDeployer()
@@ -57,13 +59,13 @@
    }
 
    /**
-    * Set configuration creator.
+    * Set configuration.
     *
-    * @param creator the configuration creator
+    * @param configuration the configuration
     */
-   public void setConfigurationCreator(ConfigurationCreator creator)
+   public void setConfiguration(Configuration configuration)
    {
-      this.creator = creator;
+      this.configuration = configuration;
    }
 
    /**
@@ -93,10 +95,10 @@
          URL[] urls = ClasspathUtils.getUrls(unit);
          DefaultAnnotationScanner scanner = new ModuleAnnotationScanner(module);
 
-         DefaultConfiguration config = new DefaultConfiguration();
+         AbstractConfiguration config = new DefaultConfiguration();
          configureScanner(unit, scanner, config);
-         if (creator != null)
-            config.merge(creator.createConfiguration()); // override with custom config
+         if (configuration != null)
+            config.merge(configuration); // override with custom config
          scanner.setConfiguration(config);
 
          AnnotationRepository repository = scanner.scan(unit.getClassLoader(), urls);
@@ -108,14 +110,19 @@
       }
    }
 
+   protected AbstractConfiguration createConfiguration(VFSDeploymentUnit unit)
+   {
+      return new DefaultConfiguration();
+   }
+
    /**
     * Configure scanner.
     *
     * @param unit the deployment unit
     * @param scanner the annotation scanner
-    * @param configuration the configuration
+    * @param settings the settings
     */
-   protected void configureScanner(VFSDeploymentUnit unit, DefaultAnnotationScanner scanner, DefaultConfiguration configuration)
+   protected void configureScanner(VFSDeploymentUnit unit, DefaultAnnotationScanner scanner, AbstractSettings settings)
    {
    }
 
@@ -142,7 +149,7 @@
       }
 
       if (log.isTraceEnabled())
-         log.trace("Creating AnnotationRepository for " + unit.getName() + ", module: " + module + ", configuration: " + creator);
+         log.trace("Creating AnnotationRepository for " + unit.getName() + ", module: " + module + ", configuration: " + configuration);
 
       visitModule(unit, module);
    }

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/FilteredAnnotationRepositoryDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/FilteredAnnotationRepositoryDeployer.java	2009-10-22 22:25:57 UTC (rev 95450)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/FilteredAnnotationRepositoryDeployer.java	2009-10-22 22:32:34 UTC (rev 95451)
@@ -24,7 +24,8 @@
 import org.jboss.classloading.spi.visitor.ResourceFilter;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.mcann.repository.DefaultConfiguration;
+import org.jboss.mcann.repository.AbstractSettings;
+import org.jboss.mcann.repository.AbstractConfiguration;
 import org.jboss.mcann.scanner.DefaultAnnotationScanner;
 
 /**
@@ -36,7 +37,7 @@
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class FilteredAnnotationRepositoryDeployer extends ScopedAnnotationRepositoryDeployer
+public class FilteredAnnotationRepositoryDeployer extends AnnotationRepositoryDeployer
 {
    private ResourceFilter resourceFilter;
    private ResourceFilter recurseFilter;
@@ -48,25 +49,30 @@
    }
 
    /**
-    * Get filter.
-    * Try attachment first, then deployer's filter.
+    * Try attachment first, then default value.
     *
     * @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
+    * @return attchment or default value
     */
-   protected <T> T getFilter(DeploymentUnit unit, Class<T> expectedClass, String suffix, T defaultValue)
+   protected <T> T getAttachment(DeploymentUnit unit, Class<T> expectedClass, String suffix, T defaultValue)
    {
-      String name = expectedClass.getName() + "." + (suffix != null ? suffix : "");
+      String name = expectedClass.getName() + (suffix != null ? ("." + suffix) : "");
       T result = unit.getAttachment(name, expectedClass);
       if (result == null)
          result = defaultValue;
       return result;
    }
 
+   @Override
+   protected AbstractConfiguration createConfiguration(VFSDeploymentUnit unit)
+   {
+      return getAttachment(unit, AbstractConfiguration.class, null, super.createConfiguration(unit)); 
+   }
+
    /**
     * We look for filter attachments:
     * * org.jboss.classloading.spi.visitor.ResourceFilter.resource - plain resource filter
@@ -74,17 +80,17 @@
     *
     * @param unit the deployment unit
     * @param scanner the annotation scanner
-    * @param configuration the configuration
+    * @param settings the settings
     */
    @Override
-   protected void configureScanner(VFSDeploymentUnit unit, DefaultAnnotationScanner scanner, DefaultConfiguration configuration)
+   protected void configureScanner(VFSDeploymentUnit unit, DefaultAnnotationScanner scanner, AbstractSettings settings)
    {
-      super.configureScanner(unit, scanner, configuration);
+      super.configureScanner(unit, scanner, settings);
 
-      ResourceFilter filter = getFilter(unit, ResourceFilter.class, "resource", resourceFilter);
-      configuration.setResourceFilter(filter);
+      ResourceFilter filter = getAttachment(unit, ResourceFilter.class, "resource", resourceFilter);
+      settings.setResourceFilter(filter);
 
-      ResourceFilter recurse = getFilter(unit, ResourceFilter.class, "recurse", recurseFilter);
+      ResourceFilter recurse = getAttachment(unit, ResourceFilter.class, "recurse", recurseFilter);
       scanner.setRecurseFilter(recurse);
    }
 

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/JavassistAnnotationRepositoryDeployer.java (from rev 95387, projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationRepositoryDeployer.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/JavassistAnnotationRepositoryDeployer.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/JavassistAnnotationRepositoryDeployer.java	2009-10-22 22:32:34 UTC (rev 95451)
@@ -0,0 +1,40 @@
+/*
+* 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.mcann.repository.AbstractConfiguration;
+import org.jboss.mcann.repository.javassist.JavassistConfiguration;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+
+/**
+ * Javassist annotation repository deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JavassistAnnotationRepositoryDeployer extends FilteredAnnotationRepositoryDeployer
+{
+   @Override
+   protected AbstractConfiguration createConfiguration(VFSDeploymentUnit unit)
+   {
+      return new JavassistConfiguration();
+   }
+}
\ No newline at end of file

Deleted: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationRepositoryDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationRepositoryDeployer.java	2009-10-22 22:25:57 UTC (rev 95450)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/annotations/ScopedAnnotationRepositoryDeployer.java	2009-10-22 22:32:34 UTC (rev 95451)
@@ -1,72 +0,0 @@
-/*
-* 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;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.mcann.repository.DefaultConfiguration;
-import org.jboss.mcann.repository.TypeInfoProvider;
-import org.jboss.mcann.repository.javassist.JavassistTypeInfoProvider;
-import org.jboss.mcann.scanner.DefaultAnnotationScanner;
-
-/**
- * Scoped class pool usage annotation environment deployer.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class ScopedAnnotationRepositoryDeployer extends AnnotationRepositoryDeployer
-{
-   private ScopedClassPoolRepository repository;
-
-   public ScopedAnnotationRepositoryDeployer()
-   {
-   }
-
-   public ScopedAnnotationRepositoryDeployer(ScopedClassPoolRepository repository)
-   {
-      this.repository = repository;
-   }
-
-   /**
-    * Set scoped class pool repository.
-    *
-    * @param repository the scoped class pool repository
-    */
-   public void setRepository(ScopedClassPoolRepository repository)
-   {
-      this.repository = repository;
-   }
-
-   @Override
-   protected void configureScanner(VFSDeploymentUnit unit, DefaultAnnotationScanner scanner, DefaultConfiguration configuration)
-   {
-      super.configureScanner(unit, scanner, configuration);
-
-      if (repository != null)
-      {
-         ClassPool pool = repository.findClassPool(unit.getClassLoader());
-         TypeInfoProvider provider = new JavassistTypeInfoProvider(pool);
-         configuration.setTypeInfoProvider(provider);
-      }
-   }
-}
\ No newline at end of file

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java	2009-10-22 22:25:57 UTC (rev 95450)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java	2009-10-22 22:32:34 UTC (rev 95451)
@@ -27,7 +27,7 @@
 import org.jboss.deployers.structure.spi.helpers.DeploymentResourceClassLoader;
 import org.jboss.deployers.vfs.spi.structure.helpers.AbstractStructureDeployer;
 import org.jboss.mcann.AnnotationRepository;
-import org.jboss.mcann.repository.ConfigurationCreator;
+import org.jboss.mcann.repository.Configuration;
 import org.jboss.mcann.scanner.DefaultAnnotationScanner;
 import org.jboss.virtual.VirtualFile;
 
@@ -41,7 +41,7 @@
    private ClassFilter included;
    private ClassFilter excluded;
    private ResourceFilter recurseFilter;
-   private ConfigurationCreator creator;
+   private Configuration configuration;
 
    protected AnnotationRepository createAnnotationRepository(VirtualFile root)
    {
@@ -51,8 +51,8 @@
       scanner.setIncluded(included);
       scanner.setExcluded(excluded);
       scanner.setRecurseFilter(recurseFilter);
-      if (creator != null)
-         scanner.setConfiguration(creator.createConfiguration());
+      if (configuration != null)
+         scanner.setConfiguration(configuration);
 
       try
       {
@@ -95,12 +95,12 @@
    }
 
    /**
-    * Set configuration creator.
+    * Set configuration.
     *
-    * @param creator the configuration creator
+    * @param configuration the configuration
     */
-   public void setConfigurationCreator(ConfigurationCreator creator)
+   public void setConfiguration(Configuration configuration)
    {
-      this.creator = creator;
+      this.configuration = configuration;
    }
 }




More information about the jboss-cvs-commits mailing list