[jboss-cvs] JBossAS SVN: r103265 - projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 30 10:21:10 EDT 2010
Author: alesj
Date: 2010-03-30 10:21:09 -0400 (Tue, 30 Mar 2010)
New Revision: 103265
Removed:
projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/ScanningPluginsDeployer.java
Modified:
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
Log:
Fix scanning deployers -- use plugin factory.
Modified: 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 2010-03-30 14:14:10 UTC (rev 103264)
+++ projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/HandleCleanupDeployer.java 2010-03-30 14:21:09 UTC (rev 103265)
@@ -25,6 +25,7 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStage;
import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.scanning.spi.ScanningPlugin;
@@ -33,7 +34,7 @@
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
-public class HandleCleanupDeployer extends ScanningPluginsDeployer
+public class HandleCleanupDeployer extends AbstractDeployer
{
public static DeploymentStage CLEANUP = new DeploymentStage("Cleanup", DeploymentStages.REAL, DeploymentStages.INSTALLED);
@@ -45,17 +46,15 @@
@SuppressWarnings("unchecked")
public void deploy(DeploymentUnit unit) throws DeploymentException
{
- for (ScanningPlugin plugin : getPlugins())
+ Iterable<ScanningPlugin> plugins = unit.getAttachment(ScanningDeployer.PLUGINS_KEY, Iterable.class);
+ if (plugins != null)
{
- Object handle = unit.removeAttachment(plugin.getHandleKey());
- if (handle != null)
- plugin.cleanupHandle(handle);
+ for (ScanningPlugin plugin : plugins)
+ {
+ 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
Modified: 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 2010-03-30 14:14:10 UTC (rev 103264)
+++ projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/ScanningDeployer.java 2010-03-30 14:21:09 UTC (rev 103265)
@@ -22,14 +22,20 @@
package org.jboss.scanning.deployers;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.annotations.ScanningMetaData;
import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
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.deployers.vfs.spi.structure.VFSDeploymentUnitFilter;
import org.jboss.scanning.plugins.AbstractScanner;
+import org.jboss.scanning.plugins.DeploymentScanningPluginFactory;
import org.jboss.scanning.plugins.DeploymentUnitScanner;
import org.jboss.scanning.spi.ScanningPlugin;
@@ -38,10 +44,14 @@
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
-public class ScanningDeployer extends ScanningPluginsDeployer
+public class ScanningDeployer extends AbstractDeployer
{
+ /** The scanning plugins attachment key */
+ public static String PLUGINS_KEY = "SCANNING_PLUGINS_KEY";
/** The filter */
private VFSDeploymentUnitFilter filter;
+ /** The plugin factories */
+ private Set<DeploymentScanningPluginFactory> factories = new CopyOnWriteArraySet<DeploymentScanningPluginFactory>();
public ScanningDeployer()
{
@@ -60,25 +70,57 @@
if (filter != null && filter.accepts(vdu) == false)
return;
- try
+ Set<ScanningPlugin> plugins = new HashSet<ScanningPlugin>();
+ for (DeploymentScanningPluginFactory factory : factories)
{
- AbstractScanner scanner = new DeploymentUnitScanner(unit, ClasspathUtils.getUrls(vdu));
- scanner.setPlugins(getPlugins());
- scanner.scan();
+ if (factory.isRelevant(unit))
+ plugins.add(factory.create(unit));
}
- catch (Exception e)
+
+ if (plugins.isEmpty() == false)
{
- throw DeploymentException.rethrowAsDeploymentException("Error scanning deployment: " + unit, e);
+ try
+ {
+ AbstractScanner scanner = new DeploymentUnitScanner(unit, ClasspathUtils.getUrls(vdu));
+ scanner.setPlugins(plugins);
+ scanner.scan();
+
+ unit.addAttachment(PLUGINS_KEY, plugins); // add used plugins as attachment
+ }
+ catch (Exception e)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Error scanning deployment: " + unit, e);
+ }
}
}
- @Override
- protected void afterAddPlugin(ScanningPlugin plugin)
+ /**
+ * Add factory.
+ *
+ * @param factory the factory
+ */
+ public void addPlugin(DeploymentScanningPluginFactory factory)
{
- addOutput(plugin.getHandleKey()); // add handle key as output
+ if (factory == null)
+ throw new IllegalArgumentException("Null factory");
+
+ factories.add(factory);
}
/**
+ * Remove the factory.
+ *
+ * @param factory the factory
+ */
+ public void removePlugin(DeploymentScanningPluginFactory factory)
+ {
+ if (factory == null)
+ return;
+
+ factories.remove(factory);
+ }
+
+ /**
* Set vfs deployment filter.
*
* @param filter the vfs deployment filter.
Deleted: 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 2010-03-30 14:14:10 UTC (rev 103264)
+++ projects/scanning/trunk/deployers/src/main/java/org/jboss/scanning/deployers/ScanningPluginsDeployer.java 2010-03-30 14:21:09 UTC (rev 103265)
@@ -1,94 +0,0 @@
-/*
- * 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
More information about the jboss-cvs-commits
mailing list