From 85dfc6361d16f03be8159a7a9df8b373d40804a1 Mon Sep 17 00:00:00 2001
From: Siamak Sadeghianfar <ssadeghi@redhat.com>
Date: Wed, 18 Jan 2012 16:26:17 +0100
Subject: [PATCH] web deployment processors refactored to be more extendable

---
 .../org/jboss/as/ee/structure/DeploymentType.java  |    2 +-
 .../jboss/as/web/SharedTldsMetaDataBuilder.java    |    4 +-
 .../org/jboss/as/web/SharedWebMetaDataBuilder.java |   36 +++++++++++--
 .../java/org/jboss/as/web/WebSubsystemAdd.java     |    2 +-
 .../deployment/AbstractDeploymentProcessor.java    |   32 +++++++++++
 .../as/web/deployment/EarContextRootProcessor.java |   51 +++++++++++-------
 .../JBossWebParsingDeploymentProcessor.java        |   13 ++---
 ...letContainerInitializerDeploymentProcessor.java |   23 ++++----
 .../deployment/TldParsingDeploymentProcessor.java  |   38 ++++++--------
 .../WarAnnotationDeploymentProcessor.java          |   31 +++++------
 .../WarClassloadingDependencyProcessor.java        |   36 ++++++-------
 .../WarDeploymentInitializingProcessor.java        |   23 ++++----
 .../as/web/deployment/WarDeploymentProcessor.java  |   41 +++++++++++----
 .../as/web/deployment/WarMetaDataProcessor.java    |   32 ++++++++----
 .../WarStructureDeploymentProcessor.java           |   50 ++++++++----------
 .../WebFragmentParsingDeploymentProcessor.java     |   13 ++---
 .../deployment/WebInitializeInOrderProcessor.java  |   24 +++++---
 .../deployment/WebParsingDeploymentProcessor.java  |   21 ++++----
 .../component/WebComponentProcessor.java           |   52 ++++++++----------
 .../web/deployment/jsf/JsfAnnotationProcessor.java |   37 +++++++++----
 .../deployment/jsf/JsfManagedBeanProcessor.java    |   55 ++++++++++++-------
 .../as/web/deployment/jsf/JsfVersionProcessor.java |   30 +++++++----
 22 files changed, 382 insertions(+), 264 deletions(-)
 create mode 100644 web/src/main/java/org/jboss/as/web/deployment/AbstractDeploymentProcessor.java

diff --git a/ee/src/main/java/org/jboss/as/ee/structure/DeploymentType.java b/ee/src/main/java/org/jboss/as/ee/structure/DeploymentType.java
index d139526..3ea432a 100644
--- a/ee/src/main/java/org/jboss/as/ee/structure/DeploymentType.java
+++ b/ee/src/main/java/org/jboss/as/ee/structure/DeploymentType.java
@@ -22,5 +22,5 @@
 package org.jboss.as.ee.structure;
 
 public enum DeploymentType {
-    EAR, WAR, EJB_JAR, APPLICATION_CLIENT;
+    EAR, WAR, EJB_JAR, APPLICATION_CLIENT, SIP_WAR;
 }
diff --git a/web/src/main/java/org/jboss/as/web/SharedTldsMetaDataBuilder.java b/web/src/main/java/org/jboss/as/web/SharedTldsMetaDataBuilder.java
index 9c6de06..b3060c7 100644
--- a/web/src/main/java/org/jboss/as/web/SharedTldsMetaDataBuilder.java
+++ b/web/src/main/java/org/jboss/as/web/SharedTldsMetaDataBuilder.java
@@ -28,9 +28,9 @@ import java.util.List;
 
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamReader;
+
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.web.deployment.JsfVersionMarker;
-
 import org.jboss.dmr.ModelNode;
 import org.jboss.metadata.parser.jsp.TldMetaDataParser;
 import org.jboss.metadata.parser.util.NoopXMLResolver;
@@ -58,7 +58,7 @@ public class SharedTldsMetaDataBuilder {
     /** The common container config. */
     //private final ModelNode containerConfig;
 
-    SharedTldsMetaDataBuilder(final ModelNode containerConfig) {
+    public SharedTldsMetaDataBuilder(final ModelNode containerConfig) {
         //this.containerConfig = containerConfig;
         init();
     }
diff --git a/web/src/main/java/org/jboss/as/web/SharedWebMetaDataBuilder.java b/web/src/main/java/org/jboss/as/web/SharedWebMetaDataBuilder.java
index 8427d39..b8ae60b 100644
--- a/web/src/main/java/org/jboss/as/web/SharedWebMetaDataBuilder.java
+++ b/web/src/main/java/org/jboss/as/web/SharedWebMetaDataBuilder.java
@@ -21,12 +21,40 @@
  */
 package org.jboss.as.web;
 
-import static org.jboss.as.web.Constants.*;
+import static org.jboss.as.web.Constants.CHECK_INTERVAL;
+import static org.jboss.as.web.Constants.DEVELOPMENT;
+import static org.jboss.as.web.Constants.DISABLED;
+import static org.jboss.as.web.Constants.DISPLAY_SOURCE_FRAGMENT;
+import static org.jboss.as.web.Constants.DUMP_SMAP;
+import static org.jboss.as.web.Constants.ERROR_ON_USE_BEAN_INVALID_CLASS_ATTRIBUTE;
+import static org.jboss.as.web.Constants.FILE_ENCONDING;
+import static org.jboss.as.web.Constants.GENERATE_STRINGS_AS_CHAR_ARRAYS;
+import static org.jboss.as.web.Constants.JAVA_ENCODING;
+import static org.jboss.as.web.Constants.JSP_CONFIGURATION;
+import static org.jboss.as.web.Constants.KEEP_GENERATED;
+import static org.jboss.as.web.Constants.LISTINGS;
+import static org.jboss.as.web.Constants.MAPPED_FILE;
+import static org.jboss.as.web.Constants.MAX_DEPTH;
+import static org.jboss.as.web.Constants.MODIFIFICATION_TEST_INTERVAL;
+import static org.jboss.as.web.Constants.READ_ONLY;
+import static org.jboss.as.web.Constants.RECOMPILE_ON_FAIL;
+import static org.jboss.as.web.Constants.SCRATCH_DIR;
+import static org.jboss.as.web.Constants.SECRET;
+import static org.jboss.as.web.Constants.SENDFILE;
+import static org.jboss.as.web.Constants.SMAP;
+import static org.jboss.as.web.Constants.SOURCE_VM;
+import static org.jboss.as.web.Constants.STATIC_RESOURCES;
+import static org.jboss.as.web.Constants.TAG_POOLING;
+import static org.jboss.as.web.Constants.TARGET_VM;
+import static org.jboss.as.web.Constants.TRIM_SPACES;
+import static org.jboss.as.web.Constants.WEBDAV;
+import static org.jboss.as.web.Constants.X_POWERED_BY;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+
 import org.jboss.dmr.ModelNode;
 import org.jboss.dmr.Property;
 import org.jboss.metadata.javaee.spec.ParamValueMetaData;
@@ -43,7 +71,7 @@ import org.jboss.metadata.web.spec.WelcomeFileListMetaData;
  *
  * @author Emanuel Muckenhuber
  */
-class SharedWebMetaDataBuilder {
+public class SharedWebMetaDataBuilder {
 
     static final List<String> welcomeFiles = new ArrayList<String>();
     static final List<MimeMappingMetaData> mimeMappings = new ArrayList<MimeMappingMetaData>();
@@ -59,7 +87,7 @@ class SharedWebMetaDataBuilder {
     /** The common container config. */
     private final ModelNode containerConfig;
 
-    SharedWebMetaDataBuilder(final ModelNode containerConfig) {
+    public SharedWebMetaDataBuilder(final ModelNode containerConfig) {
         this.containerConfig = containerConfig;
         init();
     }
@@ -77,7 +105,7 @@ class SharedWebMetaDataBuilder {
         }
     }
 
-    WebMetaData create() {
+    public WebMetaData create() {
         final WebMetaData metadata = new WebMetaData();
 
         metadata.setServlets(new ServletsMetaData());
diff --git a/web/src/main/java/org/jboss/as/web/WebSubsystemAdd.java b/web/src/main/java/org/jboss/as/web/WebSubsystemAdd.java
index 054111b..9bafd1c 100644
--- a/web/src/main/java/org/jboss/as/web/WebSubsystemAdd.java
+++ b/web/src/main/java/org/jboss/as/web/WebSubsystemAdd.java
@@ -68,7 +68,7 @@ import org.jboss.msc.service.ServiceName;
 class WebSubsystemAdd extends AbstractBoottimeAddStepHandler implements DescriptionProvider {
 
     static final WebSubsystemAdd INSTANCE = new WebSubsystemAdd();
-    private static final String DEFAULT_VIRTUAL_SERVER = "default-host";
+    protected static final String DEFAULT_VIRTUAL_SERVER = "default-host";
     private static final boolean DEFAULT_NATIVE = true;
     private static final String TEMP_DIR = "jboss.server.temp.dir";
 
diff --git a/web/src/main/java/org/jboss/as/web/deployment/AbstractDeploymentProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/AbstractDeploymentProcessor.java
new file mode 100644
index 0000000..97f02bb
--- /dev/null
+++ b/web/src/main/java/org/jboss/as/web/deployment/AbstractDeploymentProcessor.java
@@ -0,0 +1,32 @@
+package org.jboss.as.web.deployment;
+
+import org.jboss.as.server.deployment.DeploymentPhaseContext;
+import org.jboss.as.server.deployment.DeploymentUnit;
+import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
+import org.jboss.as.server.deployment.DeploymentUnitProcessor;
+
+
+/**
+ * Abstract implementation of {@link DeploymentUnitProcessor} with an explicit check
+ * for the deployments it can handle
+ *
+ * @author Siamak Sadeghianfar (ssadeghi@redhat.com)
+ */
+public abstract class AbstractDeploymentProcessor implements DeploymentUnitProcessor {
+
+    @Override
+    public void deploy(DeploymentPhaseContext phaseContext)
+            throws DeploymentUnitProcessingException {
+        if (canHandle(phaseContext.getDeploymentUnit())) {
+            doDeploy(phaseContext);
+        }
+    }
+
+    @Override
+    public void undeploy(DeploymentUnit context) {
+    }
+
+    protected abstract boolean canHandle(DeploymentUnit deploymentUnit);
+
+    protected abstract void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException;
+}
diff --git a/web/src/main/java/org/jboss/as/web/deployment/EarContextRootProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/EarContextRootProcessor.java
index 0a8f596..b232a0d 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/EarContextRootProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/EarContextRootProcessor.java
@@ -22,17 +22,17 @@
 
 package org.jboss.as.web.deployment;
 
+import static org.jboss.metadata.ear.spec.ModuleMetaData.ModuleType.Web;
+
 import org.jboss.as.ee.structure.Attachments;
 import org.jboss.as.ee.structure.DeploymentType;
 import org.jboss.as.ee.structure.DeploymentTypeMarker;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.module.ResourceRoot;
 import org.jboss.metadata.ear.spec.EarMetaData;
 import org.jboss.metadata.ear.spec.ModuleMetaData;
-import static org.jboss.metadata.ear.spec.ModuleMetaData.ModuleType.Web;
 import org.jboss.metadata.ear.spec.ModulesMetaData;
 import org.jboss.metadata.ear.spec.WebModuleMetaData;
 import org.jboss.metadata.web.jboss.JBoss70WebMetaData;
@@ -44,29 +44,15 @@ import org.jboss.metadata.web.jboss.JBossWebMetaData;
  *
  * @author John Bailey
  */
-public class EarContextRootProcessor implements DeploymentUnitProcessor {
+public class EarContextRootProcessor extends AbstractDeploymentProcessor {
 
-    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    @Override
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
         final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
-        if(warMetaData == null) {
-            return; // Nothing we can do without WarMetaData
-        }
         final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
-        if(deploymentRoot == null) {
-            return; // We don't have a root to work with
-        }
-
         final DeploymentUnit parent = deploymentUnit.getParent();
-        if(parent == null || !DeploymentTypeMarker.isType(DeploymentType.EAR, parent)) {
-            return;  // Only care if this war is nested in an EAR
-        }
-
         final EarMetaData earMetaData = parent.getAttachment(Attachments.EAR_METADATA);
-        if(earMetaData == null) {
-            return; // Nothing to see here
-        }
-
         final ModulesMetaData modulesMetaData = earMetaData.getModules();
         if(modulesMetaData != null) for(ModuleMetaData moduleMetaData : modulesMetaData) {
             if(Web.equals(moduleMetaData.getType()) && moduleMetaData.getFileName().equals(deploymentRoot.getRootName())) {
@@ -90,6 +76,31 @@ public class EarContextRootProcessor implements DeploymentUnitProcessor {
         }
     }
 
-    public void undeploy(final DeploymentUnit context) {
+    @Override
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
+            return false;
+        }
+
+        final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
+        if(warMetaData == null) {
+            return false; // Nothing we can do without WarMetaData
+        }
+        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
+        if(deploymentRoot == null) {
+            return false; // We don't have a root to work with
+        }
+
+        final DeploymentUnit parent = deploymentUnit.getParent();
+        if(parent == null || !DeploymentTypeMarker.isType(DeploymentType.EAR, parent)) {
+            return false;  // Only care if this war is nested in an EAR
+        }
+
+        final EarMetaData earMetaData = parent.getAttachment(Attachments.EAR_METADATA);
+        if(earMetaData == null) {
+            return false; // Nothing to see here
+        }
+
+        return true;
     }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/JBossWebParsingDeploymentProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/JBossWebParsingDeploymentProcessor.java
index 85ba5be..62fb7d6 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/JBossWebParsingDeploymentProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/JBossWebParsingDeploymentProcessor.java
@@ -34,7 +34,6 @@ import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.metadata.parser.jbossweb.JBossWebMetaDataParser;
 import org.jboss.metadata.parser.util.NoopXMLResolver;
 import org.jboss.vfs.VirtualFile;
@@ -42,16 +41,13 @@ import org.jboss.vfs.VirtualFile;
 /**
  * @author Jean-Frederic Clere
  */
-public class JBossWebParsingDeploymentProcessor implements DeploymentUnitProcessor {
+public class JBossWebParsingDeploymentProcessor extends AbstractDeploymentProcessor {
 
-    private static final String JBOSS_WEB_XML = "WEB-INF/jboss-web.xml";
+    protected static final String JBOSS_WEB_XML = "WEB-INF/jboss-web.xml";
 
     @Override
-    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
-        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
-            return; // Skip non web deployments
-        }
         final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
         final VirtualFile jbossWebXml = deploymentRoot.getChild(JBOSS_WEB_XML);
         WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
@@ -81,6 +77,7 @@ public class JBossWebParsingDeploymentProcessor implements DeploymentUnitProcess
     }
 
     @Override
-    public void undeploy(DeploymentUnit context) {
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        return DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit);
     }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/ServletContainerInitializerDeploymentProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/ServletContainerInitializerDeploymentProcessor.java
index 4e6a1e1..385964e 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/ServletContainerInitializerDeploymentProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/ServletContainerInitializerDeploymentProcessor.java
@@ -41,7 +41,6 @@ import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.annotation.CompositeIndex;
 import org.jboss.as.server.deployment.module.ModuleDependency;
 import org.jboss.as.server.deployment.module.ModuleSpecification;
@@ -64,18 +63,16 @@ import org.jboss.vfs.VirtualFile;
  * @author Emanuel Muckenhuber
  * @author Remy Maucherat
  */
-public class ServletContainerInitializerDeploymentProcessor implements DeploymentUnitProcessor {
+public class ServletContainerInitializerDeploymentProcessor extends AbstractDeploymentProcessor {
 
     /**
      * Process SCIs.
      */
-    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    @Override
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
         final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
         final ServiceModuleLoader loader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
-        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
-            return; // Skip non web deployments
-        }
         WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
         assert warMetaData != null;
         final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
@@ -163,10 +160,7 @@ public class ServletContainerInitializerDeploymentProcessor implements Deploymen
         }
     }
 
-    public void undeploy(final DeploymentUnit context) {
-    }
-
-    private ServletContainerInitializer loadSci(ClassLoader classLoader, VirtualFile sci, String jar, boolean error) throws DeploymentUnitProcessingException {
+    protected ServletContainerInitializer loadSci(ClassLoader classLoader, VirtualFile sci, String jar, boolean error) throws DeploymentUnitProcessingException {
         ServletContainerInitializer service = null;
         InputStream is = null;
         try {
@@ -198,7 +192,7 @@ public class ServletContainerInitializerDeploymentProcessor implements Deploymen
         return service;
     }
 
-    private Set<ClassInfo> processHandlesType(DotName typeName, Class<?> type, CompositeIndex index) throws DeploymentUnitProcessingException {
+    protected Set<ClassInfo> processHandlesType(DotName typeName, Class<?> type, CompositeIndex index) throws DeploymentUnitProcessingException {
         Set<ClassInfo> classes = new HashSet<ClassInfo>();
         if (type.isAnnotation()) {
             List<AnnotationInstance> instances = index.getAnnotations(typeName);
@@ -220,7 +214,7 @@ public class ServletContainerInitializerDeploymentProcessor implements Deploymen
         return classes;
     }
 
-    private Set<Class<?>> loadClassInfoSet(Set<ClassInfo> classInfos, ClassLoader classLoader) throws DeploymentUnitProcessingException {
+    protected Set<Class<?>> loadClassInfoSet(Set<ClassInfo> classInfos, ClassLoader classLoader) throws DeploymentUnitProcessingException {
         Set<Class<?>> classes = new HashSet<Class<?>>();
         for (ClassInfo classInfo : classInfos) {
             Class<?> type = null;
@@ -233,4 +227,9 @@ public class ServletContainerInitializerDeploymentProcessor implements Deploymen
         }
         return classes;
     }
+
+    @Override
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        return DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit);
+    }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/TldParsingDeploymentProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/TldParsingDeploymentProcessor.java
index 5374873..7c6bae9 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/TldParsingDeploymentProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/TldParsingDeploymentProcessor.java
@@ -37,7 +37,6 @@ import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.module.ResourceRoot;
 import org.jboss.metadata.parser.jsp.TldMetaDataParser;
 import org.jboss.metadata.parser.util.NoopXMLResolver;
@@ -47,21 +46,18 @@ import org.jboss.vfs.VirtualFile;
 /**
  * @author Remy Maucherat
  */
-public class TldParsingDeploymentProcessor implements DeploymentUnitProcessor {
+public class TldParsingDeploymentProcessor extends AbstractDeploymentProcessor {
 
-    private static final String TLD = ".tld";
-    private static final String META_INF = "META-INF";
-    private static final String WEB_INF = "WEB-INF";
-    private static final String CLASSES = "classes";
-    private static final String LIB = "lib";
-    private static final String IMPLICIT_TLD = "implicit.tld";
+    protected static final String TLD = ".tld";
+    protected static final String META_INF = "META-INF";
+    protected static final String WEB_INF = "WEB-INF";
+    protected static final String CLASSES = "classes";
+    protected static final String LIB = "lib";
+    protected static final String IMPLICIT_TLD = "implicit.tld";
 
     @Override
-    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
-        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
-            return; // Skip non web deployments
-        }
         final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
         TldsMetaData tldsMetaData = deploymentUnit.getAttachment(TldsMetaData.ATTACHMENT_KEY);
         if (tldsMetaData == null) {
@@ -94,12 +90,8 @@ public class TldParsingDeploymentProcessor implements DeploymentUnitProcessor {
         }
     }
 
-    @Override
-    public void undeploy(final DeploymentUnit context) {
-    }
-
-    private void processTlds(VirtualFile root, List<VirtualFile> files, Map<String, TldMetaData> tlds)
-    throws DeploymentUnitProcessingException {
+    protected void processTlds(VirtualFile root, List<VirtualFile> files, Map<String, TldMetaData> tlds)
+            throws DeploymentUnitProcessingException {
         for (VirtualFile file : files) {
             if (file.isFile() && file.getLowerCaseName().endsWith(TLD)) {
                 tlds.put("/" + file.getPathNameRelativeTo(root), parseTLD(file));
@@ -109,8 +101,7 @@ public class TldParsingDeploymentProcessor implements DeploymentUnitProcessor {
         }
     }
 
-    private TldMetaData parseTLD(VirtualFile tld)
-    throws DeploymentUnitProcessingException {
+    protected TldMetaData parseTLD(VirtualFile tld) throws DeploymentUnitProcessingException {
         if (IMPLICIT_TLD.equals(tld.getName())) {
             // Implicit TLDs are different from regular TLDs
             return new TldMetaData();
@@ -123,7 +114,8 @@ public class TldParsingDeploymentProcessor implements DeploymentUnitProcessor {
             XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(is);
             return TldMetaDataParser.parse(xmlReader);
         } catch (XMLStreamException e) {
-            throw new DeploymentUnitProcessingException("Failed to parse " + tld + " at [" + e.getLocation().getLineNumber() + "," +  e.getLocation().getColumnNumber() + "]");
+            throw new DeploymentUnitProcessingException("Failed to parse " + tld + " at [" + e.getLocation().getLineNumber()
+                    + "," + e.getLocation().getColumnNumber() + "]");
         } catch (IOException e) {
             throw new DeploymentUnitProcessingException("Failed to parse " + tld, e);
         } finally {
@@ -137,4 +129,8 @@ public class TldParsingDeploymentProcessor implements DeploymentUnitProcessor {
         }
     }
 
+    @Override
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        return DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit);
+    }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/WarAnnotationDeploymentProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/WarAnnotationDeploymentProcessor.java
index cc4f513..64cdd41 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/WarAnnotationDeploymentProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/WarAnnotationDeploymentProcessor.java
@@ -43,7 +43,6 @@ import org.jboss.as.ee.structure.DeploymentTypeMarker;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.annotation.AnnotationIndexUtils;
 import org.jboss.as.server.deployment.module.ResourceRoot;
 import org.jboss.jandex.AnnotationInstance;
@@ -87,25 +86,22 @@ import org.jboss.metadata.web.spec.WebMetaData;
  * @author Emanuel Muckenhuber
  * @author Remy Maucherat
  */
-public class WarAnnotationDeploymentProcessor implements DeploymentUnitProcessor {
+public class WarAnnotationDeploymentProcessor extends AbstractDeploymentProcessor {
 
-    private static final DotName webFilter = DotName.createSimple(WebFilter.class.getName());
-    private static final DotName webListener = DotName.createSimple(WebListener.class.getName());
-    private static final DotName webServlet = DotName.createSimple(WebServlet.class.getName());
-    private static final DotName runAs = DotName.createSimple(RunAs.class.getName());
-    private static final DotName declareRoles = DotName.createSimple(DeclareRoles.class.getName());
-    private static final DotName multipartConfig = DotName.createSimple(MultipartConfig.class.getName());
-    private static final DotName servletSecurity = DotName.createSimple(ServletSecurity.class.getName());
+    protected static final DotName webFilter = DotName.createSimple(WebFilter.class.getName());
+    protected static final DotName webListener = DotName.createSimple(WebListener.class.getName());
+    protected static final DotName webServlet = DotName.createSimple(WebServlet.class.getName());
+    protected static final DotName runAs = DotName.createSimple(RunAs.class.getName());
+    protected static final DotName declareRoles = DotName.createSimple(DeclareRoles.class.getName());
+    protected static final DotName multipartConfig = DotName.createSimple(MultipartConfig.class.getName());
+    protected static final DotName servletSecurity = DotName.createSimple(ServletSecurity.class.getName());
 
     /**
      * Process web annotations.
      */
-    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    @Override
+    protected void doDeploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
-        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
-            return; // Skip non web deployments
-        }
-
         WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
         assert warMetaData != null;
         Map<String, WebMetaData> annotationsMetaData = warMetaData.getAnnotationsMetaData();
@@ -122,9 +118,6 @@ public class WarAnnotationDeploymentProcessor implements DeploymentUnitProcessor
         }
     }
 
-    public void undeploy(final DeploymentUnit context) {
-    }
-
     /**
      * Process a single index.
      *
@@ -582,4 +575,8 @@ public class WarAnnotationDeploymentProcessor implements DeploymentUnitProcessor
         return dg;
     }
 
+    @Override
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        return DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit);
+    }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/WarClassloadingDependencyProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/WarClassloadingDependencyProcessor.java
index fe92283..2090959 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/WarClassloadingDependencyProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/WarClassloadingDependencyProcessor.java
@@ -27,7 +27,6 @@ import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.module.ModuleDependency;
 import org.jboss.as.server.deployment.module.ModuleSpecification;
 import org.jboss.logging.Logger;
@@ -42,18 +41,18 @@ import org.jboss.modules.filter.PathFilters;
  * @author Emanuel Muckenhuber
  * @author Stan Silvert
  */
-public class WarClassloadingDependencyProcessor implements DeploymentUnitProcessor {
+public class WarClassloadingDependencyProcessor extends AbstractDeploymentProcessor {
 
-    private static final ModuleIdentifier JAVAX_EE_API = ModuleIdentifier.create("javaee.api");
+    protected static final ModuleIdentifier JAVAX_EE_API = ModuleIdentifier.create("javaee.api");
 
-    private static final ModuleIdentifier JSF_IMPL = ModuleIdentifier.create("com.sun.jsf-impl");
-    private static final ModuleIdentifier JSF_API = ModuleIdentifier.create("javax.faces.api");
-    private static final ModuleIdentifier JSF_1_2_IMPL = ModuleIdentifier.create("com.sun.jsf-impl", "1.2");
-    private static final ModuleIdentifier JSF_1_2_API = ModuleIdentifier.create("javax.faces.api", "1.2");
-    private static final ModuleIdentifier BEAN_VALIDATION = ModuleIdentifier.create("org.hibernate.validator");
-    private static final ModuleIdentifier JSTL = ModuleIdentifier.create("javax.servlet.jstl.api");
+    protected static final ModuleIdentifier JSF_IMPL = ModuleIdentifier.create("com.sun.jsf-impl");
+    protected static final ModuleIdentifier JSF_API = ModuleIdentifier.create("javax.faces.api");
+    protected static final ModuleIdentifier JSF_1_2_IMPL = ModuleIdentifier.create("com.sun.jsf-impl", "1.2");
+    protected static final ModuleIdentifier JSF_1_2_API = ModuleIdentifier.create("javax.faces.api", "1.2");
+    protected static final ModuleIdentifier BEAN_VALIDATION = ModuleIdentifier.create("org.hibernate.validator");
+    protected static final ModuleIdentifier JSTL = ModuleIdentifier.create("javax.servlet.jstl.api");
 
-    private static final ModuleIdentifier JBOSS_WEB = ModuleIdentifier.create("org.jboss.as.web");
+    protected static final ModuleIdentifier JBOSS_WEB = ModuleIdentifier.create("org.jboss.as.web");
 
     static {
         Module.registerURLStreamHandlerFactoryModule(Module.forClass(WarClassloadingDependencyProcessor.class));
@@ -61,13 +60,10 @@ public class WarClassloadingDependencyProcessor implements DeploymentUnitProcess
 
     private static final Logger logger = Logger.getLogger(WarClassloadingDependencyProcessor.class);
 
-    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
-        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
-
-        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
-            return; // Skip non web deployments
-        }
 
+    @Override
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
         final DeploymentUnit topLevelDeployment = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
         final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
         final ModuleLoader moduleLoader = Module.getBootModuleLoader();
@@ -90,7 +86,7 @@ public class WarClassloadingDependencyProcessor implements DeploymentUnitProcess
 
     }
 
-    private void addJSFAPI(String jsfVersion, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
+    protected void addJSFAPI(String jsfVersion, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
         if (jsfVersion.equals(JsfVersionMarker.WAR_BUNDLES_JSF_IMPL)) return;
 
         ModuleIdentifier jsfModule = JSF_API;
@@ -98,7 +94,7 @@ public class WarClassloadingDependencyProcessor implements DeploymentUnitProcess
         moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, jsfModule, false, false, false));
     }
 
-    private void addJSFImpl(String jsfVersion, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
+    protected void addJSFImpl(String jsfVersion, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
         if (jsfVersion.equals(JsfVersionMarker.WAR_BUNDLES_JSF_IMPL)) return;
 
         ModuleIdentifier jsfModule = null;
@@ -114,6 +110,8 @@ public class WarClassloadingDependencyProcessor implements DeploymentUnitProcess
         moduleSpecification.addSystemDependency(jsf);
     }
 
-    public void undeploy(final DeploymentUnit context) {
+    @Override
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        return DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit);
     }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/WarDeploymentInitializingProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/WarDeploymentInitializingProcessor.java
index 7bb0cb6..e930c50 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/WarDeploymentInitializingProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/WarDeploymentInitializingProcessor.java
@@ -28,28 +28,27 @@ import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
-import org.jboss.as.server.deployment.MountExplodedMarker;
 
 /**
  * Processor that marks a war deployment.
  *
  * @author John Bailey
  */
-public class WarDeploymentInitializingProcessor implements DeploymentUnitProcessor {
+public class WarDeploymentInitializingProcessor extends AbstractDeploymentProcessor {
 
-    static final String WAR_EXTENSION = ".war";
+    protected static final String WAR_EXTENSION = ".war";
 
-    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    @Override
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        return !deploymentUnit.hasAttachment(Attachments.OSGI_MANIFEST);
+    }
+
+    @Override
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
-        if(deploymentUnit.hasAttachment(Attachments.OSGI_MANIFEST)) {
-            return;
-        }
-        if(deploymentUnit.getName().toLowerCase().endsWith(WAR_EXTENSION)) {
+
+        if (deploymentUnit.getName().toLowerCase().endsWith(WAR_EXTENSION)) {
             DeploymentTypeMarker.setType(DeploymentType.WAR, deploymentUnit);
         }
     }
-
-    public void undeploy(final DeploymentUnit context) {
-    }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/WarDeploymentProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/WarDeploymentProcessor.java
index f31c11a..0a08aea 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/WarDeploymentProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/WarDeploymentProcessor.java
@@ -40,6 +40,8 @@ import org.jboss.as.clustering.web.DistributedCacheManagerFactory;
 import org.jboss.as.clustering.web.DistributedCacheManagerFactoryService;
 import org.jboss.as.controller.PathElement;
 import org.jboss.as.ee.component.EEModuleDescription;
+import org.jboss.as.ee.structure.DeploymentType;
+import org.jboss.as.ee.structure.DeploymentTypeMarker;
 import org.jboss.as.naming.deployment.JndiNamingDependencyProcessor;
 import org.jboss.as.security.deployment.AbstractSecurityDeployer;
 import org.jboss.as.security.plugins.SecurityDomainContext;
@@ -49,7 +51,6 @@ import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.SetupAction;
 import org.jboss.as.web.VirtualHost;
 import org.jboss.as.web.WebSubsystemServices;
@@ -79,7 +80,7 @@ import org.jboss.vfs.VirtualFile;
  * @author Emanuel Muckenhuber
  * @author Anil.Saldhana@redhat.com
  */
-public class WarDeploymentProcessor implements DeploymentUnitProcessor {
+public class WarDeploymentProcessor extends AbstractDeploymentProcessor {
 
     private final String defaultHost;
 
@@ -94,12 +95,9 @@ public class WarDeploymentProcessor implements DeploymentUnitProcessor {
      * {@inheritDoc}
      */
     @Override
-    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
         final WarMetaData metaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
-        if (metaData == null) {
-            return;
-        }
         String hostName = hostNameOfDeployment(metaData, defaultHost);
         processDeployment(hostName, metaData, deploymentUnit, phaseContext.getServiceTarget());
     }
@@ -138,8 +136,8 @@ public class WarDeploymentProcessor implements DeploymentUnitProcessor {
                 .getAttachmentList(org.jboss.as.ee.component.Attachments.WEB_SETUP_ACTIONS);
 
         // Create the context
-        final StandardContext webContext = new StandardContext();
-        final JBossContextConfig config = new JBossContextConfig(deploymentUnit);
+        final StandardContext webContext = createContext(deploymentUnit);
+        final JBossContextConfig config = createContextConfig(webContext, deploymentUnit);
 
         // add SecurityAssociationValve right at the beginning
         webContext.addValve(new SecurityContextAssociationValve(deploymentUnit));
@@ -155,7 +153,6 @@ public class WarDeploymentProcessor implements DeploymentUnitProcessor {
         } catch (IOException e) {
             throw new DeploymentUnitProcessingException(e);
         }
-        webContext.addLifecycleListener(config);
 
         final String pathName = pathNameOfDeployment(deploymentUnit, metaData);
         webContext.setPath(pathName);
@@ -306,7 +303,7 @@ public class WarDeploymentProcessor implements DeploymentUnitProcessor {
         return pathName;
     }
 
-    void processManagement(final DeploymentUnit unit, JBossWebMetaData metaData) {
+    protected void processManagement(final DeploymentUnit unit, JBossWebMetaData metaData) {
         for (final JBossServletMetaData servlet : metaData.getServlets()) {
             try {
                 final String name = servlet.getName().replace(' ', '_');
@@ -318,6 +315,30 @@ public class WarDeploymentProcessor implements DeploymentUnitProcessor {
                 continue;
             }
         }
+    }
+
+    @Override
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
+            return false;
+        }
+
+        final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
+        if(warMetaData == null) {
+            return false;
+        }
+
+        return true;
+    }
+
+    protected StandardContext createContext(DeploymentUnit deploymentUnit) {
+        return new StandardContext();
+    }
+
+    protected JBossContextConfig createContextConfig(StandardContext webContext, DeploymentUnit deploymentUnit) {
+        JBossContextConfig config = new JBossContextConfig(deploymentUnit);
+        webContext.addLifecycleListener(config);
 
+        return config;
     }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/WarMetaDataProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/WarMetaDataProcessor.java
index 0ebce66..d5f9899 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/WarMetaDataProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/WarMetaDataProcessor.java
@@ -41,7 +41,6 @@ import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.module.ResourceRoot;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ear.spec.EarMetaData;
@@ -65,20 +64,16 @@ import org.jboss.vfs.VirtualFile;
  *
  * @author Remy Maucherat
  */
-public class WarMetaDataProcessor implements DeploymentUnitProcessor {
+public class WarMetaDataProcessor extends AbstractDeploymentProcessor {
 
     /**
      * Merge everything into WarMetaData.
      */
-    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    @Override
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
-        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
-            return; // Skip non web deployments
-        }
         WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
-        assert warMetaData != null;
         List<ResourceRoot> resourceRoots = deploymentUnit.getAttachment(Attachments.RESOURCE_ROOTS);
-        assert resourceRoots != null;
 
         WebMetaData specMetaData = warMetaData.getWebMetaData();
         boolean isComplete = false;
@@ -360,9 +355,6 @@ public class WarMetaDataProcessor implements DeploymentUnitProcessor {
         }
     }
 
-    public void undeploy(final DeploymentUnit context) {
-    }
-
     /**
      * Utility class to associate the logical name with the JAR name, needed
      * during the order resolving.
@@ -708,4 +700,22 @@ public class WarMetaDataProcessor implements DeploymentUnitProcessor {
 
     }
 
+    @Override
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
+            return false;
+        }
+
+        WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
+        if (warMetaData == null) {
+            return false;
+        }
+
+        List<ResourceRoot> resourceRoots = deploymentUnit.getAttachment(Attachments.RESOURCE_ROOTS);
+        if (resourceRoots == null) {
+            return false;
+        }
+
+        return true;
+    }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/WarStructureDeploymentProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/WarStructureDeploymentProcessor.java
index 2e63584..1281528 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/WarStructureDeploymentProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/WarStructureDeploymentProcessor.java
@@ -22,13 +22,17 @@
 
 package org.jboss.as.web.deployment;
 
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.jboss.as.ee.structure.DeploymentType;
 import org.jboss.as.ee.structure.DeploymentTypeMarker;
 import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.PrivateSubDeploymentMarker;
 import org.jboss.as.server.deployment.module.ModuleRootMarker;
 import org.jboss.as.server.deployment.module.ModuleSpecification;
@@ -44,44 +48,34 @@ import org.jboss.vfs.VirtualFileFilter;
 import org.jboss.vfs.VisitorAttributes;
 import org.jboss.vfs.util.SuffixMatchFilter;
 
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * Create and mount classpath entries in the .war deployment.
  *
  * @author Emanuel Muckenhuber
  */
-public class WarStructureDeploymentProcessor implements DeploymentUnitProcessor {
+public class WarStructureDeploymentProcessor extends AbstractDeploymentProcessor {
 
     private static final Logger logger = Logger.getLogger(WarStructureDeploymentProcessor.class);
 
     public static final String WEB_INF_LIB = "WEB-INF/lib";
     public static final String WEB_INF_CLASSES = "WEB-INF/classes";
 
-    private static final ResourceRoot[] NO_ROOTS = new ResourceRoot[0];
+    protected static final ResourceRoot[] NO_ROOTS = new ResourceRoot[0];
 
     public static final VirtualFileFilter DEFAULT_WEB_INF_LIB_FILTER = new SuffixMatchFilter(".jar", VisitorAttributes.DEFAULT);
 
     private final WebMetaData sharedWebMetaData;
     private final SharedTldsMetaDataBuilder sharedTldsMetaData;
 
-    public WarStructureDeploymentProcessor(final WebMetaData sharedWebMetaData, final SharedTldsMetaDataBuilder sharedTldsMetaData) {
+    public WarStructureDeploymentProcessor(final WebMetaData sharedWebMetaData,
+            final SharedTldsMetaDataBuilder sharedTldsMetaData) {
         this.sharedWebMetaData = sharedWebMetaData;
         this.sharedTldsMetaData = sharedTldsMetaData;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    @Override
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
-        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
-            return; // Skip non web deployments
-        }
-
         final ResourceRoot deploymentResourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
 
         final VirtualFile deploymentRoot = deploymentResourceRoot.getRoot();
@@ -127,24 +121,20 @@ public class WarStructureDeploymentProcessor implements DeploymentUnitProcessor
         deploymentUnit.putAttachment(TldsMetaData.ATTACHMENT_KEY, tldsMetaData);
     }
 
-    public void undeploy(final DeploymentUnit context) {
-    }
-
     /**
      * Create the resource roots for a .war deployment
      *
      * @param deploymentRoot the deployment root
-     * @param mountHandle    the root mount handle
+     * @param mountHandle the root mount handle
      * @return the resource roots
      * @throws IOException for any error
      */
-    private List<ResourceRoot> createResourceRoots(final VirtualFile deploymentRoot, MountHandle mountHandle)
-            throws IOException,
-            DeploymentUnitProcessingException {
+    protected List<ResourceRoot> createResourceRoots(final VirtualFile deploymentRoot, MountHandle mountHandle)
+            throws IOException, DeploymentUnitProcessingException {
         final List<ResourceRoot> entries = new ArrayList<ResourceRoot>();
         // WEB-INF classes
-        final ResourceRoot webInfClassesRoot = new ResourceRoot(deploymentRoot.getChild(WEB_INF_CLASSES).getName(), deploymentRoot
-                .getChild(WEB_INF_CLASSES), null);
+        final ResourceRoot webInfClassesRoot = new ResourceRoot(deploymentRoot.getChild(WEB_INF_CLASSES).getName(),
+                deploymentRoot.getChild(WEB_INF_CLASSES), null);
         ModuleRootMarker.mark(webInfClassesRoot);
         entries.add(webInfClassesRoot);
         // WEB-INF lib
@@ -166,7 +156,8 @@ public class WarStructureDeploymentProcessor implements DeploymentUnitProcessor
             for (final VirtualFile archive : archives) {
                 try {
                     final Closeable closable = VFS.mountZip(archive, archive, TempFileProviderService.provider());
-                    final ResourceRoot webInfArchiveRoot = new ResourceRoot(archive.getName(), archive, new MountHandle(closable));
+                    final ResourceRoot webInfArchiveRoot = new ResourceRoot(archive.getName(), archive, new MountHandle(
+                            closable));
                     ModuleRootMarker.mark(webInfArchiveRoot);
                     entries.add(webInfArchiveRoot);
                 } catch (IOException e) {
@@ -175,4 +166,9 @@ public class WarStructureDeploymentProcessor implements DeploymentUnitProcessor
             }
         }
     }
+
+    @Override
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        return DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit);
+    }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/WebFragmentParsingDeploymentProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/WebFragmentParsingDeploymentProcessor.java
index 4137602..7f88651 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/WebFragmentParsingDeploymentProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/WebFragmentParsingDeploymentProcessor.java
@@ -37,7 +37,6 @@ import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.module.ResourceRoot;
 import org.jboss.metadata.parser.servlet.WebFragmentMetaDataParser;
 import org.jboss.metadata.parser.util.NoopXMLResolver;
@@ -47,16 +46,13 @@ import org.jboss.vfs.VirtualFile;
 /**
  * @author Remy Maucherat
  */
-public class WebFragmentParsingDeploymentProcessor implements DeploymentUnitProcessor {
+public class WebFragmentParsingDeploymentProcessor extends AbstractDeploymentProcessor {
 
-    private static final String WEB_FRAGMENT_XML = "META-INF/web-fragment.xml";
+    protected static final String WEB_FRAGMENT_XML = "META-INF/web-fragment.xml";
 
     @Override
-    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
-        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
-            return; // Skip non web deployments
-        }
         WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
         assert warMetaData != null;
         Map<String, WebFragmentMetaData> webFragments = warMetaData.getWebFragmentsMetaData();
@@ -98,6 +94,7 @@ public class WebFragmentParsingDeploymentProcessor implements DeploymentUnitProc
     }
 
     @Override
-    public void undeploy(final DeploymentUnit context) {
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        return DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit);
     }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/WebInitializeInOrderProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/WebInitializeInOrderProcessor.java
index 288d6e0..95af02a 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/WebInitializeInOrderProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/WebInitializeInOrderProcessor.java
@@ -1,10 +1,11 @@
 package org.jboss.as.web.deployment;
 
 import org.jboss.as.ee.structure.Attachments;
+import org.jboss.as.ee.structure.DeploymentType;
+import org.jboss.as.ee.structure.DeploymentTypeMarker;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.web.WebSubsystemServices;
 import org.jboss.msc.service.ServiceName;
 
@@ -14,7 +15,7 @@ import org.jboss.msc.service.ServiceName;
  *
  * @author Stuart Douglas
  */
-public class WebInitializeInOrderProcessor implements DeploymentUnitProcessor {
+public class WebInitializeInOrderProcessor extends AbstractDeploymentProcessor {
 
     private final String defaultHost;
 
@@ -26,18 +27,14 @@ public class WebInitializeInOrderProcessor implements DeploymentUnitProcessor {
     }
 
     @Override
-    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
-
+    protected void doDeploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
         final WarMetaData metaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
-        if (metaData == null) {
-            return;
-        }
         final String hostName = WarDeploymentProcessor.hostNameOfDeployment(metaData, defaultHost);
         processDeployment(hostName, metaData, deploymentUnit);
     }
 
-    private void processDeployment(final String hostName, final WarMetaData metaData, final DeploymentUnit deploymentUnit) {
+    protected void processDeployment(final String hostName, final WarMetaData metaData, final DeploymentUnit deploymentUnit) {
         final String pathName = WarDeploymentProcessor.pathNameOfDeployment(deploymentUnit, metaData.getMergedJBossWebMetaData());
         final ServiceName deploymentServiceName = WebSubsystemServices.deploymentServiceName(hostName, pathName);
         final ServiceName realmServiceName = deploymentServiceName.append("realm");
@@ -46,7 +43,16 @@ public class WebInitializeInOrderProcessor implements DeploymentUnitProcessor {
     }
 
     @Override
-    public void undeploy(final DeploymentUnit context) {
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
+            return false;
+        }
+
+        final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
+        if(warMetaData == null) {
+            return false;
+        }
 
+        return true;
     }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/WebParsingDeploymentProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/WebParsingDeploymentProcessor.java
index b7e44ed..2836051 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/WebParsingDeploymentProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/WebParsingDeploymentProcessor.java
@@ -34,7 +34,6 @@ import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.module.ResourceRoot;
 import org.jboss.metadata.parser.servlet.WebMetaDataParser;
 import org.jboss.metadata.parser.util.MetaDataElementParser;
@@ -48,9 +47,9 @@ import org.xml.sax.SAXException;
  * @author Jean-Frederic Clere
  * @author Thomas.Diesler@jboss.com
  */
-public class WebParsingDeploymentProcessor implements DeploymentUnitProcessor {
+public class WebParsingDeploymentProcessor extends AbstractDeploymentProcessor {
 
-    private static final String WEB_XML = "WEB-INF/web.xml";
+    protected static final String WEB_XML = "WEB-INF/web.xml";
     private final boolean schemaValidation;
 
     public WebParsingDeploymentProcessor() {
@@ -59,13 +58,11 @@ public class WebParsingDeploymentProcessor implements DeploymentUnitProcessor {
     }
 
     @Override
-    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
-        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
-            return; // Skip non web deployments
-        }
         final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
-        final VirtualFile alternateDescriptor = deploymentRoot.getAttachment(org.jboss.as.ee.structure.Attachments.ALTERNATE_WEB_DEPLOYMENT_DESCRIPTOR);
+        final VirtualFile alternateDescriptor = deploymentRoot
+                .getAttachment(org.jboss.as.ee.structure.Attachments.ALTERNATE_WEB_DEPLOYMENT_DESCRIPTOR);
         // Locate the descriptor
         final VirtualFile webXml;
         if (alternateDescriptor != null) {
@@ -92,7 +89,7 @@ public class WebParsingDeploymentProcessor implements DeploymentUnitProcessor {
                     try {
                         if (webMetaData.is23())
                             validator.validate("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN", xmlInput);
-                        else if(webMetaData.is24())
+                        else if (webMetaData.is24())
                             validator.validate("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd", xmlInput);
                         else if (webMetaData.is25())
                             validator.validate("http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd", xmlInput);
@@ -109,7 +106,8 @@ public class WebParsingDeploymentProcessor implements DeploymentUnitProcessor {
                 warMetaData.setWebMetaData(webMetaData);
 
             } catch (XMLStreamException e) {
-                throw new DeploymentUnitProcessingException("Failed to parse " + webXml + " at [" + e.getLocation().getLineNumber() + "," + e.getLocation().getColumnNumber() + "]");
+                throw new DeploymentUnitProcessingException("Failed to parse " + webXml + " at ["
+                        + e.getLocation().getLineNumber() + "," + e.getLocation().getColumnNumber() + "]");
             } catch (IOException e) {
                 throw new DeploymentUnitProcessingException("Failed to parse " + webXml, e);
             } finally {
@@ -125,6 +123,7 @@ public class WebParsingDeploymentProcessor implements DeploymentUnitProcessor {
     }
 
     @Override
-    public void undeploy(final DeploymentUnit context) {
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        return DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit);
     }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/component/WebComponentProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/component/WebComponentProcessor.java
index 641813a..adcb554 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/component/WebComponentProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/component/WebComponentProcessor.java
@@ -22,6 +22,13 @@
 
 package org.jboss.as.web.deployment.component;
 
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.AsyncListener;
+
 import org.jboss.as.ee.component.Attachments;
 import org.jboss.as.ee.component.ComponentDescription;
 import org.jboss.as.ee.component.EEApplicationClasses;
@@ -31,8 +38,8 @@ import org.jboss.as.ee.structure.DeploymentTypeMarker;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.annotation.CompositeIndex;
+import org.jboss.as.web.deployment.AbstractDeploymentProcessor;
 import org.jboss.as.web.deployment.TldsMetaData;
 import org.jboss.as.web.deployment.WarMetaData;
 import org.jboss.as.web.deployment.WebAttachments;
@@ -47,13 +54,6 @@ import org.jboss.metadata.web.spec.WebCommonMetaData;
 import org.jboss.metadata.web.spec.WebFragmentMetaData;
 import org.jboss.metadata.web.spec.WebMetaData;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.AsyncListener;
-
 /**
  * Processor that figures out what type of component a servlet/listener is, and registers the appropriate metadata.
  * The different types are:
@@ -69,35 +69,27 @@ import javax.servlet.AsyncListener;
  * <p/>
  * For now we are just using managed bean components as servlets. We may need a custom component type in future.
  */
-public class WebComponentProcessor implements DeploymentUnitProcessor {
+public class WebComponentProcessor extends AbstractDeploymentProcessor {
 
     /**
      * Tags in these packages do not need to be computerized
      */
-    private static final String[] BUILTIN_TAGLIBS = {"org.apache.taglibs.standard", "com.sun.faces.taglib.jsf_core",  "com.sun.faces.ext.taglib", "com.sun.faces.taglib.html_basic",};
+    protected static final String[] BUILTIN_TAGLIBS = {"org.apache.taglibs.standard", "com.sun.faces.taglib.jsf_core",  "com.sun.faces.ext.taglib", "com.sun.faces.taglib.html_basic",};
 
     /**
      * Dotname for AsyncListener, which can be injected dynamically.
      */
-    private static final DotName ASYNC_LISTENER_INTERFACE = DotName.createSimple(AsyncListener.class.getName());
+    protected static final DotName ASYNC_LISTENER_INTERFACE = DotName.createSimple(AsyncListener.class.getName());
 
     @Override
-    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
-
-        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
-            return;
-        }
-
         final Map<String, ComponentDescription> componentByClass = new HashMap<String, ComponentDescription>();
         final Map<String, ComponentInstantiator> webComponents = new HashMap<String, ComponentInstantiator>();
         final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
         final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
         final CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
-        final String applicationName = deploymentUnit.getParent() == null ? deploymentUnit.getName() : deploymentUnit.getParent().getName();
-        if (moduleDescription == null) {
-            return; //not an ee deployment
-        }
+
         for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
             componentByClass.put(component.getComponentClassName(), component);
         }
@@ -141,17 +133,13 @@ public class WebComponentProcessor implements DeploymentUnitProcessor {
         deploymentUnit.putAttachment(WebAttachments.WEB_COMPONENT_INSTANTIATORS, webComponents);
     }
 
-    @Override
-    public void undeploy(DeploymentUnit context) {
-    }
-
     /**
      * Gets all classes that are eligible for injection etc
      *
      * @param metaData
      * @return
      */
-    private Set<String> getAllComponentClasses(DeploymentUnit deploymentUnit, CompositeIndex index, WarMetaData metaData, TldsMetaData tldsMetaData) {
+    protected Set<String> getAllComponentClasses(DeploymentUnit deploymentUnit, CompositeIndex index, WarMetaData metaData, TldsMetaData tldsMetaData) {
         final Set<String> classes = new HashSet<String>();
         if (metaData.getAnnotationsMetaData() != null)
             for (Map.Entry<String, WebMetaData> webMetaData : metaData.getAnnotationsMetaData().entrySet()) {
@@ -179,7 +167,7 @@ public class WebComponentProcessor implements DeploymentUnitProcessor {
         return classes;
     }
 
-    private void getAllComponentClasses(WebCommonMetaData metaData, Set<String> classes) {
+    protected void getAllComponentClasses(WebCommonMetaData metaData, Set<String> classes) {
         if (metaData.getServlets() != null)
             for (ServletMetaData servlet : metaData.getServlets()) {
                 if (servlet.getServletClass() != null) {
@@ -196,7 +184,7 @@ public class WebComponentProcessor implements DeploymentUnitProcessor {
             }
     }
 
-    private void getAllComponentClasses(TldMetaData metaData, Set<String> classes) {
+    protected void getAllComponentClasses(TldMetaData metaData, Set<String> classes) {
         if (metaData.getValidator() != null) {
             classes.add(metaData.getValidator().getValidatorClass());
         }
@@ -210,7 +198,7 @@ public class WebComponentProcessor implements DeploymentUnitProcessor {
             }
     }
 
-    private void getAllAsyncListenerClasses(CompositeIndex index, Set<String> classes) {
+    protected void getAllAsyncListenerClasses(CompositeIndex index, Set<String> classes) {
         if (index != null) {
             Set<ClassInfo> classInfos = index.getAllKnownImplementors(ASYNC_LISTENER_INTERFACE);
             for (ClassInfo classInfo : classInfos) {
@@ -218,4 +206,10 @@ public class WebComponentProcessor implements DeploymentUnitProcessor {
             }
         }
     }
+
+    @Override
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        return DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit) &&
+                deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION) != null; // ee deployment
+    }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfAnnotationProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfAnnotationProcessor.java
index 01f006b..62750cb 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfAnnotationProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfAnnotationProcessor.java
@@ -28,6 +28,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+
 import javax.faces.bean.ManagedBean;
 import javax.faces.component.FacesComponent;
 import javax.faces.component.behavior.FacesBehavior;
@@ -36,12 +37,16 @@ import javax.faces.event.NamedEvent;
 import javax.faces.render.FacesBehaviorRenderer;
 import javax.faces.render.FacesRenderer;
 import javax.faces.validator.FacesValidator;
+
+import org.jboss.as.ee.structure.DeploymentType;
+import org.jboss.as.ee.structure.DeploymentTypeMarker;
 import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
 import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.annotation.CompositeIndex;
+import org.jboss.as.web.deployment.AbstractDeploymentProcessor;
 import org.jboss.as.web.deployment.ServletContextAttribute;
 import org.jboss.jandex.AnnotationInstance;
 import org.jboss.jandex.AnnotationTarget;
@@ -55,9 +60,9 @@ import org.jboss.modules.Module;
  *
  * @author John Bailey
  */
-public class JsfAnnotationProcessor implements DeploymentUnitProcessor {
+public class JsfAnnotationProcessor extends AbstractDeploymentProcessor {
 
-    private enum FacesAnnotation {
+    protected enum FacesAnnotation {
         FACES_COMPONENT(FacesComponent.class),
         FACES_CONVERTER(FacesConverter.class),
         FACES_VALIDATOR(FacesValidator.class),
@@ -77,20 +82,14 @@ public class JsfAnnotationProcessor implements DeploymentUnitProcessor {
     }
 
 
-    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    @Override
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
 
         final Map<Class<? extends Annotation>, Set<Class<?>>> instances = new HashMap<Class<? extends Annotation>, Set<Class<?>>>();
 
         final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
-        if (compositeIndex == null) {
-            return; // Can not continue without index
-        }
-
         final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
-        if (module == null) {
-            return; // Can not continue without module
-        }
         final ClassLoader classLoader = module.getClassLoader();
 
         for (FacesAnnotation annotation : FacesAnnotation.values()) {
@@ -119,7 +118,23 @@ public class JsfAnnotationProcessor implements DeploymentUnitProcessor {
         deploymentUnit.addToAttachmentList(ServletContextAttribute.ATTACHMENT_KEY, new ServletContextAttribute(JandexAnnotationProvider.FACES_ANNOTATIONS, instances));
     }
 
-    public void undeploy(DeploymentUnit context) {
 
+    @Override
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
+            return false;
+        }
+
+        final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
+        if (compositeIndex == null) {
+            return false; // Can not continue without index
+        }
+
+        final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
+        if (module == null) {
+            return false; // Can not continue without module
+        }
+
+        return true;
     }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfManagedBeanProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfManagedBeanProcessor.java
index 270df46..1656a22 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfManagedBeanProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfManagedBeanProcessor.java
@@ -21,6 +21,16 @@
  */
 package org.jboss.as.web.deployment.jsf;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
 import org.jboss.as.ee.component.ComponentDescription;
 import org.jboss.as.ee.component.EEApplicationClasses;
 import org.jboss.as.ee.component.EEModuleDescription;
@@ -30,10 +40,10 @@ import org.jboss.as.server.deployment.Attachments;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
 import org.jboss.as.server.deployment.DeploymentUtils;
 import org.jboss.as.server.deployment.annotation.CompositeIndex;
 import org.jboss.as.server.deployment.module.ResourceRoot;
+import org.jboss.as.web.deployment.AbstractDeploymentProcessor;
 import org.jboss.as.web.deployment.WarMetaData;
 import org.jboss.as.web.deployment.WebAttachments;
 import org.jboss.as.web.deployment.component.WebComponentDescription;
@@ -49,36 +59,27 @@ import org.jboss.metadata.web.spec.WebMetaData;
 import org.jboss.modules.Module;
 import org.jboss.vfs.VirtualFile;
 
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
 /**
  * Sets up JSF managed beans as components using information in the annotations and
  *
  * @author Stuart Douglas
  */
-public class JsfManagedBeanProcessor implements DeploymentUnitProcessor {
+public class JsfManagedBeanProcessor extends AbstractDeploymentProcessor {
 
     public static final DotName MANAGED_BEAN_ANNOTATION = DotName.createSimple("javax.faces.bean.ManagedBean");
 
-    private static final String WEB_INF_FACES_CONFIG = "WEB-INF/faces-config.xml";
+    protected static final String WEB_INF_FACES_CONFIG = "WEB-INF/faces-config.xml";
 
 
     private static final Logger log = Logger.getLogger("org.jboss.as.web.jsf");
 
-    private static final String MANAGED_BEAN = "managed-bean";
-    private static final String MANAGED_BEAN_CLASS = "managed-bean-class";
+    protected static final String MANAGED_BEAN = "managed-bean";
+    protected static final String MANAGED_BEAN_CLASS = "managed-bean-class";
 
-    private static final String CONFIG_FILES = "javax.faces.CONFIG_FILES";
+    protected static final String CONFIG_FILES = "javax.faces.CONFIG_FILES";
 
     @Override
-    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    protected void doDeploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
         final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
         final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
@@ -119,7 +120,7 @@ public class JsfManagedBeanProcessor implements DeploymentUnitProcessor {
      * Parse the faces config files looking for managed bean classes. The parser is quite
      * simplistic as the only information we need is the managed-bean-class element
      */
-    private void processXmlManagedBeans(final DeploymentUnit deploymentUnit, final Set<String> managedBeanClasses) {
+    protected void processXmlManagedBeans(final DeploymentUnit deploymentUnit, final Set<String> managedBeanClasses) {
         for (final VirtualFile facesConfig : getConfigurationFiles(deploymentUnit)) {
             InputStream is = null;
             try {
@@ -228,7 +229,7 @@ public class JsfManagedBeanProcessor implements DeploymentUnitProcessor {
         return ret;
     }
 
-    private void handleAnnotations(final CompositeIndex index, final Set<String> managedBeanClasses) throws DeploymentUnitProcessingException {
+    protected void handleAnnotations(final CompositeIndex index, final Set<String> managedBeanClasses) throws DeploymentUnitProcessingException {
         final List<AnnotationInstance> annotations = index.getAnnotations(MANAGED_BEAN_ANNOTATION);
         if (annotations != null) {
             for (final AnnotationInstance annotation : annotations) {
@@ -244,14 +245,28 @@ public class JsfManagedBeanProcessor implements DeploymentUnitProcessor {
         }
     }
 
-    private void installManagedBeanComponent(String className, final EEModuleDescription moduleDescription, final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClassesDescription) {
+    protected void installManagedBeanComponent(String className, final EEModuleDescription moduleDescription, final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClassesDescription) {
         final ComponentDescription componentDescription = new WebComponentDescription(MANAGED_BEAN.toString() + "." + className, className, moduleDescription, deploymentUnit.getServiceName(), applicationClassesDescription);
         moduleDescription.addComponent(componentDescription);
         deploymentUnit.getAttachment(WebAttachments.WEB_COMPONENT_INSTANTIATORS).put(componentDescription.getComponentClassName(), new WebComponentInstantiator(deploymentUnit, componentDescription));
     }
 
     @Override
-    public void undeploy(final DeploymentUnit context) {
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
+        if (index == null) {
+            return false;
+        }
+
+        final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
+        if (module == null) {
+            return false;
+        }
+
+        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
+            return false;
+        }
 
+        return true;
     }
 }
diff --git a/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfVersionProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfVersionProcessor.java
index 6f47bd0..6639da2 100644
--- a/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfVersionProcessor.java
+++ b/web/src/main/java/org/jboss/as/web/deployment/jsf/JsfVersionProcessor.java
@@ -21,37 +21,35 @@
  */
 package org.jboss.as.web.deployment.jsf;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.as.ee.structure.DeploymentType;
+import org.jboss.as.ee.structure.DeploymentTypeMarker;
 import org.jboss.as.server.deployment.DeploymentPhaseContext;
 import org.jboss.as.server.deployment.DeploymentUnit;
 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.as.server.deployment.DeploymentUnitProcessor;
+import org.jboss.as.web.deployment.AbstractDeploymentProcessor;
 import org.jboss.as.web.deployment.JsfVersionMarker;
 import org.jboss.as.web.deployment.WarMetaData;
 import org.jboss.metadata.javaee.spec.ParamValueMetaData;
 import org.jboss.metadata.web.spec.WebFragmentMetaData;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * @author Stuart Douglas
  * @author Stan Silvert
  */
-public class JsfVersionProcessor implements DeploymentUnitProcessor {
+public class JsfVersionProcessor extends AbstractDeploymentProcessor {
 
     public static final String JSF_CONFIG_NAME_PARAM = "org.jboss.jbossfaces.JSF_CONFIG_NAME";
     public static final String WAR_BUNDLES_JSF_IMPL_PARAM = "org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL";
 
     @Override
-    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+    protected void doDeploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
         final DeploymentUnit topLevelDeployment = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
         final WarMetaData metaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
 
-        if (metaData == null) {
-            return;
-        }
-
         List<ParamValueMetaData> contextParams = new ArrayList<ParamValueMetaData>();
 
         if ((metaData.getWebMetaData() != null) && (metaData.getWebMetaData().getContextParams() != null)) {
@@ -86,6 +84,16 @@ public class JsfVersionProcessor implements DeploymentUnitProcessor {
     }
 
     @Override
-    public void undeploy(final DeploymentUnit context) {
+    protected boolean canHandle(DeploymentUnit deploymentUnit) {
+        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
+            return false;
+        }
+
+        final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
+        if(warMetaData == null) {
+            return false;
+        }
+
+        return true;
     }
 }
-- 
1.7.7.5

