[jboss-cvs] JBossAS SVN: r103262 - in projects/scanning/trunk: deployers and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 30 10:00:53 EDT 2010


Author: alesj
Date: 2010-03-30 10:00:52 -0400 (Tue, 30 Mar 2010)
New Revision: 103262

Added:
   projects/scanning/trunk/deployers/
   projects/scanning/trunk/deployers/pom.xml
   projects/scanning/trunk/deployers/src/
   projects/scanning/trunk/deployers/src/main/
   projects/scanning/trunk/deployers/src/main/java/
   projects/scanning/trunk/deployers/src/main/java/org/
   projects/scanning/trunk/deployers/src/main/java/org/jboss/
   projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/
   projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/
   projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/HandleCleanupDeployer.java
   projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/ScanningDeployer.java
   projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/ScanningPluginsDeployer.java
Modified:
   projects/scanning/trunk/pom.xml
   projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/AbstractScanner.java
Log:
Add scanning deployers.

Added: projects/scanning/trunk/deployers/pom.xml
===================================================================
--- projects/scanning/trunk/deployers/pom.xml	                        (rev 0)
+++ projects/scanning/trunk/deployers/pom.xml	2010-03-30 14:00:52 UTC (rev 103262)
@@ -0,0 +1,77 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jboss.scanning</groupId>
+    <artifactId>scanning-build</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>scanning-deployers</artifactId>
+  <packaging>jar</packaging>
+  <name>JBoss Scanning Deployers</name>
+  <url>http://www.jboss.org</url>
+  <description>JBoss Scanning Deployers</description>
+
+  <dependencies>
+      <dependency>
+        <groupId>org.jboss.scanning</groupId>
+        <artifactId>scanning-spi</artifactId>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.scanning</groupId>
+        <artifactId>scanning-impl</artifactId>
+      </dependency>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-common-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-vfs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-reflect</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.man</groupId>
+      <artifactId>jboss-managed</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.man</groupId>
+      <artifactId>jboss-metatype</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.cl</groupId>
+      <artifactId>jboss-classloading</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.cl</groupId>
+      <artifactId>jboss-classloading-vfs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>javassist</groupId>
+      <artifactId>javassist</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-vfs</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.test</groupId>
+      <artifactId>jboss-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Added: projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/HandleCleanupDeployer.java
===================================================================
--- projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/HandleCleanupDeployer.java	                        (rev 0)
+++ projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/HandleCleanupDeployer.java	2010-03-30 14:00:52 UTC (rev 103262)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.scanning.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStage;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.scanning.spi.ScanningPlugin;
+
+/**
+ * Scanning handle cleanup deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class HandleCleanupDeployer extends ScanningPluginsDeployer
+{
+   public static DeploymentStage CLEANUP = new DeploymentStage("Cleanup", DeploymentStages.REAL, DeploymentStages.INSTALLED);
+
+   public HandleCleanupDeployer()
+   {
+      setStage(CLEANUP);      
+   }
+
+   @SuppressWarnings("unchecked")
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      for (ScanningPlugin plugin : getPlugins())
+      {
+         Object handle = unit.removeAttachment(plugin.getHandleKey());
+         if (handle != null)
+            plugin.cleanupHandle(handle);
+      }
+   }
+
+   @Override
+   protected void afterAddPlugin(ScanningPlugin plugin)
+   {
+      addInput(plugin.getHandleKey()); // add to inputs
+   }
+}
\ No newline at end of file

Added: projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/ScanningDeployer.java
===================================================================
--- projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/ScanningDeployer.java	                        (rev 0)
+++ projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/ScanningDeployer.java	2010-03-30 14:00:52 UTC (rev 103262)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.scanning.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.annotations.ScanningMetaData;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.plugins.util.ClasspathUtils;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.scanning.plugins.AbstractScanner;
+import org.jboss.scanning.plugins.DeploymentUnitScanner;
+import org.jboss.scanning.spi.ScanningPlugin;
+
+/**
+ * Scanning deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ScanningDeployer extends ScanningPluginsDeployer
+{
+   public ScanningDeployer()
+   {
+      setStage(DeploymentStages.POST_CLASSLOADER);
+      addInput(ScanningMetaData.class);
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      if (unit instanceof VFSDeploymentUnit == false)
+         return;
+
+      VFSDeploymentUnit vdu = VFSDeploymentUnit.class.cast(unit);
+      try
+      {
+         AbstractScanner scanner = new DeploymentUnitScanner(unit, ClasspathUtils.getUrls(vdu));
+         scanner.setPlugins(getPlugins());
+         scanner.scan();
+      }
+      catch (Exception e)
+      {
+         throw DeploymentException.rethrowAsDeploymentException("Error scanning deployment: " + unit, e);
+      }
+   }
+
+   @Override
+   protected void afterAddPlugin(ScanningPlugin plugin)
+   {
+      addOutput(plugin.getHandleKey()); // add handle key as output
+   }
+}

Added: projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/ScanningPluginsDeployer.java
===================================================================
--- projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/ScanningPluginsDeployer.java	                        (rev 0)
+++ projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/ScanningPluginsDeployer.java	2010-03-30 14:00:52 UTC (rev 103262)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.scanning.deployers;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.scanning.spi.ScanningPlugin;
+
+/**
+ * Scanning plugins holder deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class ScanningPluginsDeployer extends AbstractDeployer
+{
+   /** The plugins */
+   private Set<ScanningPlugin> plugins = new CopyOnWriteArraySet<ScanningPlugin>();
+
+   /**
+    * Add plugin.
+    *
+    * @param plugin the plugin
+    */
+   public void addPlugin(ScanningPlugin plugin)
+   {
+      if (plugin == null)
+         throw new IllegalArgumentException("Null plugin");
+
+      plugins.add(plugin);
+      afterAddPlugin(plugin);
+   }
+
+   protected void afterAddPlugin(ScanningPlugin plugin)
+   {
+   }
+
+   /***
+    * Get plugins copy.
+    *
+    * @return new plugins set
+    */
+   protected Set<ScanningPlugin> getPlugins()
+   {
+      return new HashSet<ScanningPlugin>(plugins);
+   }
+
+   /**
+    * Remove the plugin.
+    *
+    * @param plugin the plugin
+    */
+   public void removePlugin(ScanningPlugin plugin)
+   {
+      if (plugin == null)
+         return;
+
+      plugins.remove(plugin);
+   }
+
+   /**
+    * Set the plugins.
+    *
+    * @param plugins the plugins
+    */
+   public void setPlugins(Set<ScanningPlugin> plugins)
+   {
+      if (plugins == null)
+         throw new IllegalArgumentException("Null plugins");
+      this.plugins = plugins;
+   }
+}
\ No newline at end of file

Modified: projects/scanning/trunk/pom.xml
===================================================================
--- projects/scanning/trunk/pom.xml	2010-03-30 13:55:45 UTC (rev 103261)
+++ projects/scanning/trunk/pom.xml	2010-03-30 14:00:52 UTC (rev 103262)
@@ -22,6 +22,7 @@
     <module>scanning-spi</module>
     <module>scanning-impl</module>
     <module>plugins</module>
+    <module>deployers</module>
     <module>indexer</module>
   </modules>
 
@@ -155,6 +156,17 @@
         </exclusions>
       </dependency>
       <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-vfs</artifactId>
+        <version>${version.org.jboss.deployers}</version>
+        <exclusions>
+            <exclusion>
+                <groupId>org.jboss.mcann</groupId>
+                <artifactId>mcann-core</artifactId>
+            </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
         <groupId>javassist</groupId>
         <artifactId>javassist</artifactId>
         <version>${version.javassist}</version>

Modified: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/AbstractScanner.java
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/AbstractScanner.java	2010-03-30 13:55:45 UTC (rev 103261)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/AbstractScanner.java	2010-03-30 14:00:52 UTC (rev 103262)
@@ -46,6 +46,9 @@
     */
    public void addPlugin(ScanningPlugin plugin)
    {
+      if (plugin == null)
+         throw new IllegalArgumentException("Null plugin");
+
       plugins.add(plugin);
    }
 
@@ -56,6 +59,9 @@
     */
    public void removePlugin(ScanningPlugin plugin)
    {
+      if (plugin == null)
+         return;
+
       plugins.remove(plugin);
    }
 




More information about the jboss-cvs-commits mailing list