[jboss-cvs] JBossAS SVN: r110469 - in trunk/weld-int: deployer/src/main/java/org/jboss/weld/integration/deployer/scanning and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 27 00:55:27 EST 2011


Author: alesj
Date: 2011-01-27 00:55:26 -0500 (Thu, 27 Jan 2011)
New Revision: 110469

Modified:
   trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml
   trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/scanning/HackWeldScanningPluginFactory.java
   trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/scanning/WeldScanningPluginFactory.java
Log:
[JBAS-8828]; enable Weld scanning






Modified: trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml
===================================================================
--- trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml	2011-01-27 04:59:39 UTC (rev 110468)
+++ trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml	2011-01-27 05:55:26 UTC (rev 110469)
@@ -36,14 +36,14 @@
   <!-- Responsible for discovering Weld files -->
   <bean name="WeldFilesDeployer" class="org.jboss.weld.integration.deployer.metadata.WeldFilesDeployer"/>
 
-  <!-- Responsible for discovering Weld classes -->
+  <!-- Responsible for discovering Weld classes
   <bean name="ArchiveInfoDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveInfoDeployer"/>
   <bean name="ArchiveDiscoveryDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveDiscoveryDeployer"/>
-
-  <!-- Let the new MC scanning take over
-  <bean name="WeldScanningPluginFactory" class="org.jboss.weld.integration.deployer.scanning.WeldScanningPluginFactory"/>
   -->
 
+  <!-- Let the new MC scanning take over -->
+  <bean name="WeldScanningPluginFactory" class="org.jboss.weld.integration.deployer.scanning.HackWeldScanningPluginFactory"/>
+
   <!-- Responsible for Weld + EJB integration -->
   <bean name="EjbServicesDeployer" class="org.jboss.weld.integration.deployer.env.EjbServicesDeployer"/>
 

Modified: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/scanning/HackWeldScanningPluginFactory.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/scanning/HackWeldScanningPluginFactory.java	2011-01-27 04:59:39 UTC (rev 110468)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/scanning/HackWeldScanningPluginFactory.java	2011-01-27 05:55:26 UTC (rev 110469)
@@ -39,11 +39,8 @@
  */
 public class HackWeldScanningPluginFactory extends WeldScanningPluginFactory
 {
-   public boolean isRelevant(DeploymentUnit unit)
+   protected void handleRelevantDeployment(DeploymentUnit unit)
    {
-      if (super.isRelevant(unit) == false)
-         return false;
-
       // Only inspect and modify ear's
       if (unit.isTopLevel() && unit instanceof VFSDeploymentUnit)
       {
@@ -76,6 +73,6 @@
             }
          }
       }
-      return true;
+      super.handleRelevantDeployment(unit);
    }
 }

Modified: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/scanning/WeldScanningPluginFactory.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/scanning/WeldScanningPluginFactory.java	2011-01-27 04:59:39 UTC (rev 110468)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/scanning/WeldScanningPluginFactory.java	2011-01-27 05:55:26 UTC (rev 110469)
@@ -25,8 +25,11 @@
 import java.util.Collection;
 
 import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.visitor.ResourceContext;
+import org.jboss.classloading.spi.visitor.ResourceFilter;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.scanning.plugins.DeploymentScanningPluginFactory;
+import org.jboss.scanning.plugins.helpers.DelegateResourceFilter;
 import org.jboss.scanning.plugins.helpers.VoidScanningHandle;
 import org.jboss.scanning.spi.ScanningPlugin;
 import org.jboss.vfs.VirtualFile;
@@ -41,6 +44,9 @@
  */
 public class WeldScanningPluginFactory implements DeploymentScanningPluginFactory<VoidScanningHandle, Object>
 {
+   /** The filter */
+   private ResourceFilter weldDeployerFilter = new WeldDeployerFilter();
+
    /**
     * Get Weld discovery environment.
     *
@@ -97,9 +103,29 @@
 
       @SuppressWarnings("unchecked")
       Collection<VirtualFile> cpFiles = unit.getAttachment(DeployersUtils.WELD_CLASSPATH, Collection.class);
-      return (cpFiles != null && cpFiles.isEmpty() == false);
+      boolean hasCP = cpFiles != null && cpFiles.isEmpty() == false;
+
+      if (hasCP)
+         handleRelevantDeployment(unit);
+
+      return hasCP;
    }
 
+   /**
+    * Handle relevant deployment.
+    *
+    * @param unit the deployment unit
+    */
+   protected void handleRelevantDeployment(DeploymentUnit unit)
+   {
+      final String name = ResourceFilter.class.getName() + ".recurse";
+      ResourceFilter filter = unit.getAttachment(name, ResourceFilter.class);
+      if (filter != null)
+         unit.addAttachment(name, new DelegateResourceFilter(weldDeployerFilter, filter));
+      else
+         unit.addAttachment(name, weldDeployerFilter);
+   }
+
    public String getPluginOutput()
    {
       return ArchiveInfo.class.getName(); // we depend on this attachment
@@ -112,4 +138,23 @@
       WeldDiscoveryEnvironment environment = getEnv(unit);
       return new WeldScanningPlugin(environment, cpFiles);
    }
+
+   /**
+    * Set weld deployers filter.
+    * This way we exclude additional libs from scanning.
+    *
+    * @param weldDeployerFilter the filter
+    */
+   public void setWeldDeployerFilter(ResourceFilter weldDeployerFilter)
+   {
+      this.weldDeployerFilter = weldDeployerFilter;
+   }
+
+   private static class WeldDeployerFilter implements ResourceFilter
+   {
+      public boolean accepts(ResourceContext resource)
+      {
+         return resource.getUrl().toString().contains("weld.deployer") == false;
+      }
+   }
 }



More information about the jboss-cvs-commits mailing list