You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ro...@apache.org on 2019/12/10 22:11:27 UTC

[aries-cdi] branch master updated: servlet refactoring

This is an automated email from the ASF dual-hosted git repository.

rotty3000 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-cdi.git


The following commit(s) were added to refs/heads/master by this push:
     new 95f132b  servlet refactoring
     new 29c1804  Merge pull request #31 from rotty3000/master
95f132b is described below

commit 95f132bb0d7c7a4d449dea5f2f2279d2f77f604c
Author: Raymond Augé <ro...@apache.org>
AuthorDate: Tue Dec 10 15:22:44 2019 -0500

    servlet refactoring
    
    Signed-off-by: Raymond Augé <ro...@apache.org>
---
 cdi-bom/pom.xml                                    |  24 +-
 .../aries/cdi/extension/http/HttpExtension.java    | 348 ---------------------
 .../aries/cdi/extension/http/HttpExtension.java    | 333 --------------------
 .../LICENSE                                        |   0
 .../NOTICE                                         |   0
 .../pom.xml                                        |  11 +-
 .../servlet/common/WebFilterProcessor.java         |  97 ++++++
 .../servlet/common/WebListenerProcessor.java       | 101 ++++++
 .../servlet/common/WebServletProcessor.java        | 102 ++++++
 .../cdi/extension/servlet/common/package-info.java |  17 +
 .../LICENSE                                        |   0
 .../NOTICE                                         |   0
 .../pom.xml                                        |   9 +-
 .../extension/servlet/owb/OWBServletExtension.java | 188 +++++++++++
 .../extension/servlet/owb/ServletActivator.java    |   6 +-
 .../servlet/owb/ServletExtensionFactory.java       |   6 +-
 .../cdi/extension/servlet/owb}/package-info.java   |   2 +-
 .../LICENSE                                        |   0
 .../NOTICE                                         |   0
 .../pom.xml                                        |   9 +-
 .../extension/servlet/weld/ServletActivator.java   |   6 +-
 .../servlet/weld/ServletExtensionFactory.java      |   6 +-
 .../servlet/weld/WeldServletExtension.java         | 180 +++++++++++
 .../cdi/extension/servlet/weld}/package-info.java  |   2 +-
 cdi-itests/owb-itest.bndrun                        |   3 +-
 cdi-itests/weld-itest.bndrun                       |   3 +-
 pom.xml                                            |   5 +-
 27 files changed, 738 insertions(+), 720 deletions(-)

diff --git a/cdi-bom/pom.xml b/cdi-bom/pom.xml
index 7e38a13..f86b2d6 100644
--- a/cdi-bom/pom.xml
+++ b/cdi-bom/pom.xml
@@ -59,33 +59,39 @@
 			</dependency>
 			<dependency>
 				<groupId>org.apache.aries.cdi</groupId>
-				<artifactId>org.apache.aries.cdi.extension.http.owb</artifactId>
+				<artifactId>org.apache.aries.cdi.extension.jndi</artifactId>
 				<version>${project.version}</version>
 				<scope>runtime</scope>
 			</dependency>
 			<dependency>
 				<groupId>org.apache.aries.cdi</groupId>
-				<artifactId>org.apache.aries.cdi.extension.http.weld</artifactId>
+				<artifactId>org.apache.aries.cdi.extension.mp-config</artifactId>
 				<version>${project.version}</version>
-				<scope>runtime</scope>
+				<scope>compile</scope>
 			</dependency>
 			<dependency>
 				<groupId>org.apache.aries.cdi</groupId>
-				<artifactId>org.apache.aries.cdi.extension.jndi</artifactId>
+				<artifactId>org.apache.aries.cdi.extension.mp-metrics</artifactId>
+				<version>${project.version}</version>
+				<scope>compile</scope>
+			</dependency>
+			<dependency>
+				<groupId>org.apache.aries.cdi</groupId>
+				<artifactId>org.apache.aries.cdi.extension.servlet.common</artifactId>
 				<version>${project.version}</version>
 				<scope>runtime</scope>
 			</dependency>
 			<dependency>
 				<groupId>org.apache.aries.cdi</groupId>
-				<artifactId>org.apache.aries.cdi.extension.mp-config</artifactId>
+				<artifactId>org.apache.aries.cdi.extension.servlet.owb</artifactId>
 				<version>${project.version}</version>
-				<scope>compile</scope>
+				<scope>runtime</scope>
 			</dependency>
 			<dependency>
 				<groupId>org.apache.aries.cdi</groupId>
-				<artifactId>org.apache.aries.cdi.extension.mp-metrics</artifactId>
+				<artifactId>org.apache.aries.cdi.extension.servlet.weld</artifactId>
 				<version>${project.version}</version>
-				<scope>compile</scope>
+				<scope>runtime</scope>
 			</dependency>
 			<dependency>
 				<groupId>org.apache.aries.cdi</groupId>
@@ -161,4 +167,4 @@
 			</dependency>
 		</dependencies>
 	</dependencyManagement>
-</project>
\ No newline at end of file
+</project>
diff --git a/cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/HttpExtension.java b/cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/HttpExtension.java
deleted file mode 100644
index f5cc667..0000000
--- a/cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/HttpExtension.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.aries.cdi.extension.http;
-
-import static java.util.Collections.list;
-import static java.util.Optional.ofNullable;
-import static javax.interceptor.Interceptor.Priority.LIBRARY_AFTER;
-import static org.osgi.framework.Constants.SERVICE_DESCRIPTION;
-import static org.osgi.framework.Constants.SERVICE_RANKING;
-import static org.osgi.framework.Constants.SERVICE_VENDOR;
-import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
-import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.annotation.Priority;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.AfterDeploymentValidation;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.BeforeShutdown;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-import javax.enterprise.inject.spi.WithAnnotations;
-import javax.servlet.Filter;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.ServletRequestListener;
-import javax.servlet.annotation.MultipartConfig;
-import javax.servlet.annotation.WebFilter;
-import javax.servlet.annotation.WebListener;
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpSessionListener;
-
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardContextSelect;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterAsyncSupported;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterDispatcher;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterName;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterPattern;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterServlet;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardListener;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletAsyncSupported;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletMultipart;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletName;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletPattern;
-import org.apache.aries.cdi.extra.propertytypes.ServiceDescription;
-import org.apache.aries.cdi.extra.propertytypes.ServiceRanking;
-import org.apache.aries.cdi.spi.configuration.Configuration;
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.spi.ContainerLifecycle;
-import org.apache.webbeans.web.lifecycle.test.MockServletContext;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cdi.annotations.Service;
-
-@SuppressWarnings("serial")
-public class HttpExtension extends ServletContextEvent implements Extension {
-
-	private final BundleContext bundleContext;
-	private final ServletContext proxyContext;
-	private volatile Configuration configuration;
-	private volatile ServletContext delegateContext;
-
-	public HttpExtension(Bundle bundle) {
-		super(new MockServletContext());
-
-		this.bundleContext = bundle.getBundleContext();
-
-		// ensure we can switch the impl and keep ServletContextBean working with an updated context
-		this.proxyContext = ServletContext.class.cast(Proxy.newProxyInstance(ServletContext.class.getClassLoader(),
-				new Class<?>[]{ServletContext.class},
-				(proxy, method, args) -> {
-					try {
-						return method.invoke(ofNullable(delegateContext).orElseGet(HttpExtension.super::getServletContext), args);
-					}
-					catch (final InvocationTargetException ite) {
-						throw ite.getTargetException();
-					}
-				}));
-	}
-
-	public void setDelegate(final ServletContext delegateContext) {
-		this.delegateContext = delegateContext;
-	}
-
-	public ServletContext getOriginal() {
-		return super.getServletContext();
-	}
-
-	@Override
-	public ServletContext getServletContext() {
-		return proxyContext;
-	}
-
-	void getConfiguration(@Observes Configuration configuration) {
-		this.configuration = configuration;
-	}
-
-	<X> void processWebFilter(
-		@Observes @WithAnnotations(WebFilter.class) ProcessAnnotatedType<X> pat) {
-
-		final AnnotatedType<X> annotatedType = pat.getAnnotatedType();
-
-		WebFilter webFilter = annotatedType.getAnnotation(WebFilter.class);
-
-		final Set<Annotation> annotationsToAdd = new HashSet<>();
-
-		if (!annotatedType.isAnnotationPresent(Service.class)) {
-			annotationsToAdd.add(Service.Literal.of(new Class[] {Filter.class}));
-		}
-
-		if(!annotatedType.isAnnotationPresent(HttpWhiteboardContextSelect.class)) {
-			annotationsToAdd.add(HttpWhiteboardContextSelect.Literal.of((String)configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT)));
-		}
-
-		if (!webFilter.description().isEmpty()) {
-			annotationsToAdd.add(ServiceDescription.Literal.of(webFilter.description()));
-		}
-
-		if (!webFilter.filterName().isEmpty()) {
-			annotationsToAdd.add(HttpWhiteboardFilterName.Literal.of(webFilter.filterName()));
-		}
-
-		if (webFilter.servletNames().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardFilterServlet.Literal.of(webFilter.servletNames()));
-		}
-
-		if (webFilter.value().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardFilterPattern.Literal.of(webFilter.value()));
-		}
-		else if (webFilter.urlPatterns().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardFilterPattern.Literal.of(webFilter.urlPatterns()));
-		}
-
-		if (webFilter.dispatcherTypes().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardFilterDispatcher.Literal.of(webFilter.dispatcherTypes()));
-		}
-
-		annotationsToAdd.add(HttpWhiteboardFilterAsyncSupported.Literal.of(webFilter.asyncSupported()));
-
-		if (!annotationsToAdd.isEmpty()) {
-			annotationsToAdd.forEach(pat.configureAnnotatedType()::add);
-		}
-	}
-
-	<X> void processWebListener(
-		@Observes @WithAnnotations(WebListener.class) ProcessAnnotatedType<X> pat) {
-
-		final AnnotatedType<X> annotatedType = pat.getAnnotatedType();
-
-		WebListener webListener = annotatedType.getAnnotation(WebListener.class);
-
-		final Set<Annotation> annotationsToAdd = new HashSet<>();
-
-		if (!annotatedType.isAnnotationPresent(Service.class)) {
-			List<Class<?>> listenerTypes = new ArrayList<>();
-
-			Class<X> javaClass = annotatedType.getJavaClass();
-
-			if (javax.servlet.ServletContextListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.ServletContextListener.class);
-			}
-			if (javax.servlet.ServletContextAttributeListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.ServletContextAttributeListener.class);
-			}
-			if (javax.servlet.ServletRequestListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.ServletRequestListener.class);
-			}
-			if (javax.servlet.ServletRequestAttributeListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.ServletRequestAttributeListener.class);
-			}
-			if (javax.servlet.http.HttpSessionListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.http.HttpSessionListener.class);
-			}
-			if (javax.servlet.http.HttpSessionAttributeListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.http.HttpSessionAttributeListener.class);
-			}
-			if (javax.servlet.http.HttpSessionIdListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.http.HttpSessionIdListener.class);
-			}
-
-			annotationsToAdd.add(Service.Literal.of(listenerTypes.toArray(new Class<?>[0])));
-		}
-
-		if(!annotatedType.isAnnotationPresent(HttpWhiteboardContextSelect.class)) {
-			annotationsToAdd.add(HttpWhiteboardContextSelect.Literal.of((String)configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT)));
-		}
-
-		annotationsToAdd.add(HttpWhiteboardListener.Literal.INSTANCE);
-
-		if (!webListener.value().isEmpty()) {
-			annotationsToAdd.add(ServiceDescription.Literal.of(webListener.value()));
-		}
-
-		if (!annotationsToAdd.isEmpty()) {
-			annotationsToAdd.forEach(pat.configureAnnotatedType()::add);
-		}
-	}
-
-	<X> void processWebServlet(
-		@Observes @WithAnnotations(WebServlet.class) ProcessAnnotatedType<X> pat) {
-
-		final AnnotatedType<X> annotatedType = pat.getAnnotatedType();
-
-		WebServlet webServlet = annotatedType.getAnnotation(WebServlet.class);
-
-		final Set<Annotation> annotationsToAdd = new HashSet<>();
-
-		if (!annotatedType.isAnnotationPresent(Service.class)) {
-			annotationsToAdd.add(Service.Literal.of(new Class[] {Servlet.class}));
-		}
-
-		if(!annotatedType.isAnnotationPresent(HttpWhiteboardContextSelect.class)) {
-			annotationsToAdd.add(HttpWhiteboardContextSelect.Literal.of((String)configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT)));
-		}
-
-		if (!webServlet.name().isEmpty()) {
-			annotationsToAdd.add(HttpWhiteboardServletName.Literal.of(webServlet.name()));
-		}
-
-		if (webServlet.value().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardServletPattern.Literal.of(webServlet.value()));
-		}
-		else if (webServlet.urlPatterns().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardServletPattern.Literal.of(webServlet.urlPatterns()));
-		}
-
-		annotationsToAdd.add(ServiceRanking.Literal.of(webServlet.loadOnStartup()));
-
-		// TODO Howto: INIT PARAMS ???
-
-		annotationsToAdd.add(HttpWhiteboardServletAsyncSupported.Literal.of(webServlet.asyncSupported()));
-
-		if (!webServlet.description().isEmpty()) {
-			annotationsToAdd.add(ServiceDescription.Literal.of(webServlet.description()));
-		}
-
-		MultipartConfig multipartConfig = annotatedType.getAnnotation(MultipartConfig.class);
-
-		if (multipartConfig != null) {
-			annotationsToAdd.add(HttpWhiteboardServletMultipart.Literal.of(true, multipartConfig.fileSizeThreshold(), multipartConfig.location(), multipartConfig.maxFileSize(), multipartConfig.maxRequestSize()));
-		}
-
-		// TODO HowTo: ServletSecurity ???
-
-		if (!annotationsToAdd.isEmpty()) {
-			annotationsToAdd.forEach(pat.configureAnnotatedType()::add);
-		}
-	}
-
-	void afterDeploymentValidation(
-		@Observes @Priority(LIBRARY_AFTER + 800)
-		AfterDeploymentValidation adv, BeanManager beanManager) {
-
-		Dictionary<String, Object> properties = new Hashtable<>();
-		properties.put(SERVICE_DESCRIPTION, "Aries CDI - HTTP Portable Extension for OpenWebBeans");
-		properties.put(SERVICE_VENDOR, "Apache Software Foundation");
-		properties.put(HTTP_WHITEBOARD_CONTEXT_SELECT, configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT));
-		properties.put(HTTP_WHITEBOARD_LISTENER, Boolean.TRUE.toString());
-		properties.put(SERVICE_RANKING, Integer.MAX_VALUE - 100);
-
-		_listenerRegistration = bundleContext.registerService(
-			LISTENER_CLASSES, new CdiListener(WebBeansContext.currentInstance()), properties);
-	}
-
-	void beforeShutdown(@Observes BeforeShutdown bs) {
-		if (_listenerRegistration != null && !destroyed.get()) {
-			try {
-				_listenerRegistration.unregister();
-			}
-			catch (IllegalStateException ise) {
-				// the service was already unregistered.
-			}
-		}
-	}
-
-	private static final String[] LISTENER_CLASSES = new String[] {
-		ServletContextListener.class.getName(),
-		ServletRequestListener.class.getName(),
-		HttpSessionListener.class.getName()
-	};
-
-	private volatile ServiceRegistration<?> _listenerRegistration;
-	private final AtomicBoolean destroyed = new AtomicBoolean(false);
-
-	private class CdiListener extends org.apache.webbeans.servlet.WebBeansConfigurationListener {
-		private final WebBeansContext webBeansContext;
-
-		private CdiListener(final WebBeansContext webBeansContext) {
-			this.webBeansContext = webBeansContext;
-		}
-
-		@Override
-		public void contextInitialized(ServletContextEvent event) {
-			ServletContext realSC = event.getServletContext();
-
-			// update the sce to have the real one in CDI
-			setDelegate(realSC);
-
-			// propagate attributes from the temporary sc
-			list(getOriginal().getAttributeNames()).forEach(
-				attr -> realSC.setAttribute(attr, getOriginal().getAttribute(attr)));
-
-			realSC.setAttribute(BundleContext.class.getName(), bundleContext);
-			realSC.setAttribute(WebBeansContext.class.getName(), webBeansContext);
-
-			// already started in the activator so let's skip it, just ensure it is skipped if re-called
-			event.getServletContext().setAttribute(getClass().getName(), true);
-			if (lifeCycle == null) {
-				lifeCycle = webBeansContext.getService(ContainerLifecycle.class);
-			}
-		}
-
-		@Override
-		public void contextDestroyed(ServletContextEvent sce) {
-			try {
-				super.contextDestroyed(sce);
-			}
-			finally {
-				destroyed.set(true);
-			}
-		}
-	}
-}
diff --git a/cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/HttpExtension.java b/cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/HttpExtension.java
deleted file mode 100644
index 7459038..0000000
--- a/cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/HttpExtension.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.aries.cdi.extension.http;
-
-import static javax.interceptor.Interceptor.Priority.LIBRARY_AFTER;
-import static org.osgi.framework.Constants.SERVICE_DESCRIPTION;
-import static org.osgi.framework.Constants.SERVICE_RANKING;
-import static org.osgi.framework.Constants.SERVICE_VENDOR;
-import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
-import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.annotation.Priority;
-import javax.enterprise.event.Observes;
-import javax.enterprise.event.ObservesAsync;
-import javax.enterprise.inject.spi.AfterDeploymentValidation;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.BeforeShutdown;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.InjectionTargetFactory;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-import javax.enterprise.inject.spi.WithAnnotations;
-import javax.servlet.Filter;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.ServletRequestEvent;
-import javax.servlet.ServletRequestListener;
-import javax.servlet.annotation.MultipartConfig;
-import javax.servlet.annotation.WebFilter;
-import javax.servlet.annotation.WebListener;
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpSessionListener;
-
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardContextSelect;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterAsyncSupported;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterDispatcher;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterName;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterPattern;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterServlet;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardListener;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletAsyncSupported;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletMultipart;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletName;
-import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletPattern;
-import org.apache.aries.cdi.extra.propertytypes.ServiceDescription;
-import org.apache.aries.cdi.extra.propertytypes.ServiceRanking;
-import org.apache.aries.cdi.spi.configuration.Configuration;
-import org.jboss.weld.module.web.servlet.WeldInitialListener;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cdi.annotations.Service;
-
-public class HttpExtension implements Extension {
-
-	private volatile Configuration configuration;
-
-	void getConfiguration(@Observes Configuration configuration) {
-		this.configuration = configuration;
-	}
-
-	<X> void processWebFilter(
-		@Observes @WithAnnotations(WebFilter.class) ProcessAnnotatedType<X> pat) {
-
-		final AnnotatedType<X> annotatedType = pat.getAnnotatedType();
-
-		WebFilter webFilter = annotatedType.getAnnotation(WebFilter.class);
-
-		final Set<Annotation> annotationsToAdd = new HashSet<>();
-
-		if (!annotatedType.isAnnotationPresent(Service.class)) {
-			annotationsToAdd.add(Service.Literal.of(new Class[] {Filter.class}));
-		}
-
-		if(!annotatedType.isAnnotationPresent(HttpWhiteboardContextSelect.class)) {
-			annotationsToAdd.add(HttpWhiteboardContextSelect.Literal.of((String)configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT)));
-		}
-
-		if (!webFilter.description().isEmpty()) {
-			annotationsToAdd.add(ServiceDescription.Literal.of(webFilter.description()));
-		}
-
-		if (!webFilter.filterName().isEmpty()) {
-			annotationsToAdd.add(HttpWhiteboardFilterName.Literal.of(webFilter.filterName()));
-		}
-
-		if (webFilter.servletNames().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardFilterServlet.Literal.of(webFilter.servletNames()));
-		}
-
-		if (webFilter.value().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardFilterPattern.Literal.of(webFilter.value()));
-		}
-		else if (webFilter.urlPatterns().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardFilterPattern.Literal.of(webFilter.urlPatterns()));
-		}
-
-		if (webFilter.dispatcherTypes().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardFilterDispatcher.Literal.of(webFilter.dispatcherTypes()));
-		}
-
-		annotationsToAdd.add(HttpWhiteboardFilterAsyncSupported.Literal.of(webFilter.asyncSupported()));
-
-		if (!annotationsToAdd.isEmpty()) {
-			annotationsToAdd.forEach(pat.configureAnnotatedType()::add);
-		}
-	}
-
-	<X> void processWebListener(
-		@Observes @WithAnnotations(WebListener.class) ProcessAnnotatedType<X> pat) {
-
-		final AnnotatedType<X> annotatedType = pat.getAnnotatedType();
-
-		WebListener webListener = annotatedType.getAnnotation(WebListener.class);
-
-		final Set<Annotation> annotationsToAdd = new HashSet<>();
-
-		if (!annotatedType.isAnnotationPresent(Service.class)) {
-			List<Class<?>> listenerTypes = new ArrayList<>();
-
-			Class<X> javaClass = annotatedType.getJavaClass();
-
-			if (javax.servlet.ServletContextListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.ServletContextListener.class);
-			}
-			if (javax.servlet.ServletContextAttributeListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.ServletContextAttributeListener.class);
-			}
-			if (javax.servlet.ServletRequestListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.ServletRequestListener.class);
-			}
-			if (javax.servlet.ServletRequestAttributeListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.ServletRequestAttributeListener.class);
-			}
-			if (javax.servlet.http.HttpSessionListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.http.HttpSessionListener.class);
-			}
-			if (javax.servlet.http.HttpSessionAttributeListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.http.HttpSessionAttributeListener.class);
-			}
-			if (javax.servlet.http.HttpSessionIdListener.class.isAssignableFrom(javaClass)) {
-				listenerTypes.add(javax.servlet.http.HttpSessionIdListener.class);
-			}
-
-			annotationsToAdd.add(Service.Literal.of(listenerTypes.toArray(new Class<?>[0])));
-		}
-
-		if(!annotatedType.isAnnotationPresent(HttpWhiteboardContextSelect.class)) {
-			annotationsToAdd.add(HttpWhiteboardContextSelect.Literal.of((String)configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT)));
-		}
-
-		annotationsToAdd.add(HttpWhiteboardListener.Literal.INSTANCE);
-
-		if (!webListener.value().isEmpty()) {
-			annotationsToAdd.add(ServiceDescription.Literal.of(webListener.value()));
-		}
-
-		if (!annotationsToAdd.isEmpty()) {
-			annotationsToAdd.forEach(pat.configureAnnotatedType()::add);
-		}
-	}
-
-	<X> void processWebServlet(
-		@Observes @WithAnnotations(WebServlet.class) ProcessAnnotatedType<X> pat) {
-
-		final AnnotatedType<X> annotatedType = pat.getAnnotatedType();
-
-		WebServlet webServlet = annotatedType.getAnnotation(WebServlet.class);
-
-		final Set<Annotation> annotationsToAdd = new HashSet<>();
-
-		if (!annotatedType.isAnnotationPresent(Service.class)) {
-			annotationsToAdd.add(Service.Literal.of(new Class[] {Servlet.class}));
-		}
-
-		if(!annotatedType.isAnnotationPresent(HttpWhiteboardContextSelect.class)) {
-			annotationsToAdd.add(HttpWhiteboardContextSelect.Literal.of((String)configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT)));
-		}
-
-		if (!webServlet.name().isEmpty()) {
-			annotationsToAdd.add(HttpWhiteboardServletName.Literal.of(webServlet.name()));
-		}
-
-		if (webServlet.value().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardServletPattern.Literal.of(webServlet.value()));
-		}
-		else if (webServlet.urlPatterns().length > 0) {
-			annotationsToAdd.add(HttpWhiteboardServletPattern.Literal.of(webServlet.urlPatterns()));
-		}
-
-		annotationsToAdd.add(ServiceRanking.Literal.of(webServlet.loadOnStartup()));
-
-		// TODO Howto: INIT PARAMS ???
-
-		annotationsToAdd.add(HttpWhiteboardServletAsyncSupported.Literal.of(webServlet.asyncSupported()));
-
-		if (!webServlet.description().isEmpty()) {
-			annotationsToAdd.add(ServiceDescription.Literal.of(webServlet.description()));
-		}
-
-		MultipartConfig multipartConfig = annotatedType.getAnnotation(MultipartConfig.class);
-
-		if (multipartConfig != null) {
-			annotationsToAdd.add(HttpWhiteboardServletMultipart.Literal.of(true, multipartConfig.fileSizeThreshold(), multipartConfig.location(), multipartConfig.maxFileSize(), multipartConfig.maxRequestSize()));
-		}
-
-		// TODO HowTo: ServletSecurity ???
-
-		if (!annotationsToAdd.isEmpty()) {
-			annotationsToAdd.forEach(pat.configureAnnotatedType()::add);
-		}
-	}
-
-	void afterDeploymentValidation(
-		@Observes @Priority(LIBRARY_AFTER + 800)
-		AfterDeploymentValidation adv, BeanManager beanManager) {
-
-		beanManager.getEvent().fireAsync(new Ready());
-	}
-
-	void ready(
-		@ObservesAsync Ready ready, BeanManager beanManager, BundleContext bundleContext) {
-
-		Dictionary<String, Object> properties = new Hashtable<>();
-
-		properties.put(SERVICE_DESCRIPTION, "Aries CDI - HTTP Portable Extension for Weld");
-		properties.put(SERVICE_VENDOR, "Apache Software Foundation");
-		properties.put(HTTP_WHITEBOARD_CONTEXT_SELECT, configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT));
-		properties.put(HTTP_WHITEBOARD_LISTENER, Boolean.TRUE.toString());
-		properties.put(SERVICE_RANKING, Integer.MAX_VALUE - 100);
-
-		AnnotatedType<WeldInitialListener> annotatedType = beanManager.createAnnotatedType(WeldInitialListener.class);
-		InjectionTargetFactory<WeldInitialListener> injectionTargetFactory = beanManager.getInjectionTargetFactory(annotatedType);
-		Bean<WeldInitialListener> bean = beanManager.createBean(beanManager.createBeanAttributes(annotatedType), WeldInitialListener.class, injectionTargetFactory);
-
-		WeldInitialListener initialListener = bean.create(beanManager.createCreationalContext(bean));
-
-		_listenerRegistration = bundleContext.registerService(
-			LISTENER_CLASSES, new ListenerWrapper<>(initialListener), properties);
-	}
-
-	void beforeShutdown(@Observes BeforeShutdown bs) {
-		if (_listenerRegistration != null && !destroyed.get()) {
-			try {
-				_listenerRegistration.unregister();
-			}
-			catch (IllegalStateException ise) {
-				// the service was already unregistered.
-			}
-		}
-	}
-
-	private static final String[] LISTENER_CLASSES = new String[] {
-			ServletContextListener.class.getName(),
-			ServletRequestListener.class.getName(),
-			HttpSessionListener.class.getName()
-	};
-
-	private volatile ServiceRegistration<?> _listenerRegistration;
-	private final AtomicBoolean destroyed = new AtomicBoolean(false);
-
-	public static class Ready {}
-
-	private class ListenerWrapper<T extends HttpSessionListener & ServletContextListener & ServletRequestListener>
-		implements HttpSessionListener, ServletContextListener, ServletRequestListener {
-
-		private final T delegate;
-
-		public ListenerWrapper(T delegate) {
-			this.delegate = delegate;
-		}
-
-		@Override
-		public void contextDestroyed(ServletContextEvent sce) {
-			try {
-				delegate.contextDestroyed(sce);
-			}
-			finally {
-				destroyed.set(true);
-			}
-		}
-
-		@Override
-		public void contextInitialized(ServletContextEvent sce) {
-			delegate.contextInitialized(sce);
-		}
-
-		@Override
-		public void requestDestroyed(ServletRequestEvent sre) {
-			delegate.requestDestroyed(sre);
-		}
-
-		@Override
-		public void requestInitialized(ServletRequestEvent sre) {
-			delegate.requestInitialized(sre);
-		}
-
-		@Override
-		public void sessionCreated(HttpSessionEvent se) {
-			delegate.sessionCreated(se);
-		}
-
-		@Override
-		public void sessionDestroyed(HttpSessionEvent se) {
-			delegate.sessionDestroyed(se);
-		}
-
-	}
-
-}
diff --git a/cdi-extension-http-weld/LICENSE b/cdi-extension-servlet-common/LICENSE
similarity index 100%
copy from cdi-extension-http-weld/LICENSE
copy to cdi-extension-servlet-common/LICENSE
diff --git a/cdi-extension-http-weld/NOTICE b/cdi-extension-servlet-common/NOTICE
similarity index 100%
copy from cdi-extension-http-weld/NOTICE
copy to cdi-extension-servlet-common/NOTICE
diff --git a/cdi-extension-http-owb/pom.xml b/cdi-extension-servlet-common/pom.xml
similarity index 90%
copy from cdi-extension-http-owb/pom.xml
copy to cdi-extension-servlet-common/pom.xml
index 701d3d2..23fb934 100644
--- a/cdi-extension-http-owb/pom.xml
+++ b/cdi-extension-servlet-common/pom.xml
@@ -26,10 +26,10 @@
 		<relativePath>..</relativePath>
 	</parent>
 
-	<artifactId>org.apache.aries.cdi.extension.http.owb</artifactId>
-	<name>Apache Aries CDI - Http Extension for OpenWebBeans</name>
+	<artifactId>org.apache.aries.cdi.extension.servlet.common</artifactId>
+	<name>Apache Aries CDI - Servlet Extension Common</name>
 	<description>
-		Provides support to CDI bundles for http servlet scopes; @RequestScoped,
+		Provides common code support to CDI bundles for http servlet scopes; @RequestScoped,
 		@SessionScoped and @ConversationScoped.
 	</description>
 
@@ -84,11 +84,6 @@
 			<artifactId>geronimo-jcdi_2.0_spec</artifactId>
 		</dependency>
 		<dependency>
-			<groupId>org.apache.openwebbeans</groupId>
-			<artifactId>openwebbeans-web</artifactId>
-			<version>${owb.version}</version>
-		</dependency>
-		<dependency>
 			<groupId>org.osgi</groupId>
 			<artifactId>org.osgi.namespace.extender</artifactId>
 		</dependency>
diff --git a/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/WebFilterProcessor.java b/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/WebFilterProcessor.java
new file mode 100644
index 0000000..5318efe
--- /dev/null
+++ b/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/WebFilterProcessor.java
@@ -0,0 +1,97 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.aries.cdi.extension.servlet.common;
+
+import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.servlet.Filter;
+import javax.servlet.annotation.WebFilter;
+
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardContextSelect;
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterAsyncSupported;
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterDispatcher;
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterName;
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterPattern;
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardFilterServlet;
+import org.apache.aries.cdi.extra.propertytypes.ServiceDescription;
+import org.apache.aries.cdi.spi.configuration.Configuration;
+import org.osgi.service.cdi.annotations.Service;
+
+public class WebFilterProcessor {
+
+	/**
+	 * Call this method from an observer defined as:
+	 * <pre>
+	 * &lt;X&gt; void webFilter(@Observes @WithAnnotations(WebFilter.class) ProcessAnnotatedType&lt;X&gt; pat) {
+	 *   new WebFilterProcessor().process(configuration, pat);
+	 * }
+	 * </pre>
+	 * @param <X>
+	 * @param pat
+	 */
+	public <X> void process(
+		Configuration configuration, ProcessAnnotatedType<X> pat) {
+
+		final AnnotatedType<X> annotatedType = pat.getAnnotatedType();
+
+		WebFilter webFilter = annotatedType.getAnnotation(WebFilter.class);
+
+		final Set<Annotation> annotationsToAdd = new HashSet<>();
+
+		if (!annotatedType.isAnnotationPresent(Service.class)) {
+			annotationsToAdd.add(Service.Literal.of(new Class[] {Filter.class}));
+		}
+
+		if(!annotatedType.isAnnotationPresent(HttpWhiteboardContextSelect.class)) {
+			annotationsToAdd.add(HttpWhiteboardContextSelect.Literal.of((String)configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT)));
+		}
+
+		if (!webFilter.description().isEmpty()) {
+			annotationsToAdd.add(ServiceDescription.Literal.of(webFilter.description()));
+		}
+
+		if (!webFilter.filterName().isEmpty()) {
+			annotationsToAdd.add(HttpWhiteboardFilterName.Literal.of(webFilter.filterName()));
+		}
+
+		if (webFilter.servletNames().length > 0) {
+			annotationsToAdd.add(HttpWhiteboardFilterServlet.Literal.of(webFilter.servletNames()));
+		}
+
+		if (webFilter.value().length > 0) {
+			annotationsToAdd.add(HttpWhiteboardFilterPattern.Literal.of(webFilter.value()));
+		}
+		else if (webFilter.urlPatterns().length > 0) {
+			annotationsToAdd.add(HttpWhiteboardFilterPattern.Literal.of(webFilter.urlPatterns()));
+		}
+
+		if (webFilter.dispatcherTypes().length > 0) {
+			annotationsToAdd.add(HttpWhiteboardFilterDispatcher.Literal.of(webFilter.dispatcherTypes()));
+		}
+
+		annotationsToAdd.add(HttpWhiteboardFilterAsyncSupported.Literal.of(webFilter.asyncSupported()));
+
+		if (!annotationsToAdd.isEmpty()) {
+			annotationsToAdd.forEach(pat.configureAnnotatedType()::add);
+		}
+	}
+
+}
diff --git a/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/WebListenerProcessor.java b/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/WebListenerProcessor.java
new file mode 100644
index 0000000..c175a39
--- /dev/null
+++ b/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/WebListenerProcessor.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.aries.cdi.extension.servlet.common;
+
+import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.servlet.annotation.WebListener;
+
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardContextSelect;
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardListener;
+import org.apache.aries.cdi.extra.propertytypes.ServiceDescription;
+import org.apache.aries.cdi.spi.configuration.Configuration;
+import org.osgi.service.cdi.annotations.Service;
+
+public class WebListenerProcessor {
+
+	/**
+	 * Call this method from an observer defined as:
+	 * <pre>
+	 * &lt;X&gt; void webListener(@Observes @WithAnnotations(WebListener.class) ProcessAnnotatedType&lt;X&gt; pat) {
+	 *   new WebListenerProcessor().process(configuration, pat);
+	 * }
+	 * </pre>
+	 * @param <X>
+	 * @param pat
+	 */
+	public <X> void process(
+		Configuration configuration, ProcessAnnotatedType<X> pat) {
+
+		final AnnotatedType<X> annotatedType = pat.getAnnotatedType();
+
+		WebListener webListener = annotatedType.getAnnotation(WebListener.class);
+
+		final Set<Annotation> annotationsToAdd = new HashSet<>();
+
+		if (!annotatedType.isAnnotationPresent(Service.class)) {
+			List<Class<?>> listenerTypes = new ArrayList<>();
+
+			Class<X> javaClass = annotatedType.getJavaClass();
+
+			if (javax.servlet.ServletContextListener.class.isAssignableFrom(javaClass)) {
+				listenerTypes.add(javax.servlet.ServletContextListener.class);
+			}
+			if (javax.servlet.ServletContextAttributeListener.class.isAssignableFrom(javaClass)) {
+				listenerTypes.add(javax.servlet.ServletContextAttributeListener.class);
+			}
+			if (javax.servlet.ServletRequestListener.class.isAssignableFrom(javaClass)) {
+				listenerTypes.add(javax.servlet.ServletRequestListener.class);
+			}
+			if (javax.servlet.ServletRequestAttributeListener.class.isAssignableFrom(javaClass)) {
+				listenerTypes.add(javax.servlet.ServletRequestAttributeListener.class);
+			}
+			if (javax.servlet.http.HttpSessionListener.class.isAssignableFrom(javaClass)) {
+				listenerTypes.add(javax.servlet.http.HttpSessionListener.class);
+			}
+			if (javax.servlet.http.HttpSessionAttributeListener.class.isAssignableFrom(javaClass)) {
+				listenerTypes.add(javax.servlet.http.HttpSessionAttributeListener.class);
+			}
+			if (javax.servlet.http.HttpSessionIdListener.class.isAssignableFrom(javaClass)) {
+				listenerTypes.add(javax.servlet.http.HttpSessionIdListener.class);
+			}
+
+			annotationsToAdd.add(Service.Literal.of(listenerTypes.toArray(new Class<?>[0])));
+		}
+
+		if(!annotatedType.isAnnotationPresent(HttpWhiteboardContextSelect.class)) {
+			annotationsToAdd.add(HttpWhiteboardContextSelect.Literal.of((String)configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT)));
+		}
+
+		annotationsToAdd.add(HttpWhiteboardListener.Literal.INSTANCE);
+
+		if (!webListener.value().isEmpty()) {
+			annotationsToAdd.add(ServiceDescription.Literal.of(webListener.value()));
+		}
+
+		if (!annotationsToAdd.isEmpty()) {
+			annotationsToAdd.forEach(pat.configureAnnotatedType()::add);
+		}
+	}
+
+}
diff --git a/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/WebServletProcessor.java b/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/WebServletProcessor.java
new file mode 100644
index 0000000..3b6e7e2
--- /dev/null
+++ b/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/WebServletProcessor.java
@@ -0,0 +1,102 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.aries.cdi.extension.servlet.common;
+
+import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.servlet.Servlet;
+import javax.servlet.annotation.MultipartConfig;
+import javax.servlet.annotation.WebServlet;
+
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardContextSelect;
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletAsyncSupported;
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletMultipart;
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletName;
+import org.apache.aries.cdi.extra.propertytypes.HttpWhiteboardServletPattern;
+import org.apache.aries.cdi.extra.propertytypes.ServiceDescription;
+import org.apache.aries.cdi.extra.propertytypes.ServiceRanking;
+import org.apache.aries.cdi.spi.configuration.Configuration;
+import org.osgi.service.cdi.annotations.Service;
+
+public class WebServletProcessor {
+
+	/**
+	 * Call this method from an observer defined as:
+	 * <pre>
+	 * &lt;X&gt; void webServlet(@Observes @WithAnnotations(WebServlet.class) ProcessAnnotatedType&lt;X&gt; pat) {
+	 *   new WebServletProcessor().process(configuration, pat);
+	 * }
+	 * </pre>
+	 * @param <X>
+	 * @param pat
+	 */
+	public <X> void process(
+		Configuration configuration, ProcessAnnotatedType<X> pat) {
+
+		final AnnotatedType<X> annotatedType = pat.getAnnotatedType();
+
+		WebServlet webServlet = annotatedType.getAnnotation(WebServlet.class);
+
+		final Set<Annotation> annotationsToAdd = new HashSet<>();
+
+		if (!annotatedType.isAnnotationPresent(Service.class)) {
+			annotationsToAdd.add(Service.Literal.of(new Class[] {Servlet.class}));
+		}
+
+		if(!annotatedType.isAnnotationPresent(HttpWhiteboardContextSelect.class)) {
+			annotationsToAdd.add(HttpWhiteboardContextSelect.Literal.of((String)configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT)));
+		}
+
+		if (!webServlet.name().isEmpty()) {
+			annotationsToAdd.add(HttpWhiteboardServletName.Literal.of(webServlet.name()));
+		}
+
+		if (webServlet.value().length > 0) {
+			annotationsToAdd.add(HttpWhiteboardServletPattern.Literal.of(webServlet.value()));
+		}
+		else if (webServlet.urlPatterns().length > 0) {
+			annotationsToAdd.add(HttpWhiteboardServletPattern.Literal.of(webServlet.urlPatterns()));
+		}
+
+		annotationsToAdd.add(ServiceRanking.Literal.of(webServlet.loadOnStartup()));
+
+		// TODO Howto: INIT PARAMS ???
+
+		annotationsToAdd.add(HttpWhiteboardServletAsyncSupported.Literal.of(webServlet.asyncSupported()));
+
+		if (!webServlet.description().isEmpty()) {
+			annotationsToAdd.add(ServiceDescription.Literal.of(webServlet.description()));
+		}
+
+		MultipartConfig multipartConfig = annotatedType.getAnnotation(MultipartConfig.class);
+
+		if (multipartConfig != null) {
+			annotationsToAdd.add(HttpWhiteboardServletMultipart.Literal.of(true, multipartConfig.fileSizeThreshold(), multipartConfig.location(), multipartConfig.maxFileSize(), multipartConfig.maxRequestSize()));
+		}
+
+		// TODO HowTo: ServletSecurity ???
+
+		if (!annotationsToAdd.isEmpty()) {
+			annotationsToAdd.forEach(pat.configureAnnotatedType()::add);
+		}
+	}
+
+}
diff --git a/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/package-info.java b/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/package-info.java
new file mode 100644
index 0000000..f5a7e4f
--- /dev/null
+++ b/cdi-extension-servlet-common/src/main/java/org/apache/aries/cdi/extension/servlet/common/package-info.java
@@ -0,0 +1,17 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@org.osgi.annotation.bundle.Export
+@org.osgi.annotation.versioning.Version("1.0.0")
+package org.apache.aries.cdi.extension.servlet.common;
diff --git a/cdi-extension-http-owb/LICENSE b/cdi-extension-servlet-owb/LICENSE
similarity index 100%
rename from cdi-extension-http-owb/LICENSE
rename to cdi-extension-servlet-owb/LICENSE
diff --git a/cdi-extension-http-owb/NOTICE b/cdi-extension-servlet-owb/NOTICE
similarity index 100%
rename from cdi-extension-http-owb/NOTICE
rename to cdi-extension-servlet-owb/NOTICE
diff --git a/cdi-extension-http-owb/pom.xml b/cdi-extension-servlet-owb/pom.xml
similarity index 91%
rename from cdi-extension-http-owb/pom.xml
rename to cdi-extension-servlet-owb/pom.xml
index 701d3d2..4a709f0 100644
--- a/cdi-extension-http-owb/pom.xml
+++ b/cdi-extension-servlet-owb/pom.xml
@@ -26,8 +26,8 @@
 		<relativePath>..</relativePath>
 	</parent>
 
-	<artifactId>org.apache.aries.cdi.extension.http.owb</artifactId>
-	<name>Apache Aries CDI - Http Extension for OpenWebBeans</name>
+	<artifactId>org.apache.aries.cdi.extension.servlet.owb</artifactId>
+	<name>Apache Aries CDI - Servlet Extension for OpenWebBeans</name>
 	<description>
 		Provides support to CDI bundles for http servlet scopes; @RequestScoped,
 		@SessionScoped and @ConversationScoped.
@@ -59,6 +59,11 @@
 	<dependencies>
 		<dependency>
 			<groupId>org.apache.aries.cdi</groupId>
+			<artifactId>org.apache.aries.cdi.extension.servlet.common</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.aries.cdi</groupId>
 			<artifactId>org.apache.aries.cdi.extra</artifactId>
 			<version>${project.version}</version>
 		</dependency>
diff --git a/cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/OWBServletExtension.java b/cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/OWBServletExtension.java
new file mode 100644
index 0000000..5dec26d
--- /dev/null
+++ b/cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/OWBServletExtension.java
@@ -0,0 +1,188 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.aries.cdi.extension.servlet.owb;
+
+import static java.util.Collections.list;
+import static java.util.Optional.ofNullable;
+import static javax.interceptor.Interceptor.Priority.LIBRARY_AFTER;
+import static org.osgi.framework.Constants.SERVICE_DESCRIPTION;
+import static org.osgi.framework.Constants.SERVICE_RANKING;
+import static org.osgi.framework.Constants.SERVICE_VENDOR;
+import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
+import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Proxy;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.annotation.Priority;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.BeforeShutdown;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.inject.spi.WithAnnotations;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.annotation.WebListener;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpSessionListener;
+
+import org.apache.aries.cdi.extension.servlet.common.WebFilterProcessor;
+import org.apache.aries.cdi.extension.servlet.common.WebListenerProcessor;
+import org.apache.aries.cdi.extension.servlet.common.WebServletProcessor;
+import org.apache.aries.cdi.spi.configuration.Configuration;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.spi.ContainerLifecycle;
+import org.apache.webbeans.web.lifecycle.test.MockServletContext;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+@SuppressWarnings("serial")
+public class OWBServletExtension extends ServletContextEvent implements Extension {
+
+	private final BundleContext bundleContext;
+	private final ServletContext proxyContext;
+	private volatile ServletContext delegateContext;
+	volatile Configuration configuration;
+
+	public OWBServletExtension(Bundle bundle) {
+		super(new MockServletContext());
+
+		this.bundleContext = bundle.getBundleContext();
+
+		// ensure we can switch the impl and keep ServletContextBean working with an updated context
+		this.proxyContext = ServletContext.class.cast(Proxy.newProxyInstance(ServletContext.class.getClassLoader(),
+				new Class<?>[]{ServletContext.class},
+				(proxy, method, args) -> {
+					try {
+						return method.invoke(ofNullable(delegateContext).orElseGet(OWBServletExtension.super::getServletContext), args);
+					}
+					catch (final InvocationTargetException ite) {
+						throw ite.getTargetException();
+					}
+				}));
+	}
+
+	public void setDelegate(final ServletContext delegateContext) {
+		this.delegateContext = delegateContext;
+	}
+
+	public ServletContext getOriginal() {
+		return super.getServletContext();
+	}
+
+	@Override
+	public ServletContext getServletContext() {
+		return proxyContext;
+	}
+
+	void setConfiguration(@Observes Configuration configuration) {
+		this.configuration = configuration;
+	}
+
+	<X> void webFilter(@Observes @WithAnnotations(WebFilter.class) ProcessAnnotatedType<X> pat) {
+		new WebFilterProcessor().process(configuration, pat);
+	}
+
+	<X> void webListener(@Observes @WithAnnotations(WebListener.class) ProcessAnnotatedType<X> pat) {
+		new WebListenerProcessor().process(configuration, pat);
+	}
+
+	<X> void webServlet(@Observes @WithAnnotations(WebServlet.class) ProcessAnnotatedType<X> pat) {
+		new WebServletProcessor().process(configuration, pat);
+	}
+
+	void afterDeploymentValidation(
+		@Observes @Priority(LIBRARY_AFTER + 800)
+		AfterDeploymentValidation adv, BeanManager beanManager) {
+
+		Dictionary<String, Object> properties = new Hashtable<>();
+		properties.put(SERVICE_DESCRIPTION, "Aries CDI - HTTP Portable Extension for OpenWebBeans");
+		properties.put(SERVICE_VENDOR, "Apache Software Foundation");
+		properties.put(HTTP_WHITEBOARD_CONTEXT_SELECT, configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT));
+		properties.put(HTTP_WHITEBOARD_LISTENER, Boolean.TRUE.toString());
+		properties.put(SERVICE_RANKING, Integer.MAX_VALUE - 100);
+
+		_listenerRegistration = bundleContext.registerService(
+			LISTENER_CLASSES, new CdiListener(WebBeansContext.currentInstance()), properties);
+	}
+
+	void beforeShutdown(@Observes BeforeShutdown bs) {
+		if (_listenerRegistration != null && !destroyed.get()) {
+			try {
+				_listenerRegistration.unregister();
+			}
+			catch (IllegalStateException ise) {
+				// the service was already unregistered.
+			}
+		}
+	}
+
+	private static final String[] LISTENER_CLASSES = new String[] {
+		ServletContextListener.class.getName(),
+		ServletRequestListener.class.getName(),
+		HttpSessionListener.class.getName()
+	};
+
+	private volatile ServiceRegistration<?> _listenerRegistration;
+	private final AtomicBoolean destroyed = new AtomicBoolean(false);
+
+	private class CdiListener extends org.apache.webbeans.servlet.WebBeansConfigurationListener {
+		private final WebBeansContext webBeansContext;
+
+		private CdiListener(final WebBeansContext webBeansContext) {
+			this.webBeansContext = webBeansContext;
+		}
+
+		@Override
+		public void contextInitialized(ServletContextEvent event) {
+			ServletContext realSC = event.getServletContext();
+
+			// update the sce to have the real one in CDI
+			setDelegate(realSC);
+
+			// propagate attributes from the temporary sc
+			list(getOriginal().getAttributeNames()).forEach(
+				attr -> realSC.setAttribute(attr, getOriginal().getAttribute(attr)));
+
+			realSC.setAttribute(BundleContext.class.getName(), bundleContext);
+			realSC.setAttribute(WebBeansContext.class.getName(), webBeansContext);
+
+			// already started in the activator so let's skip it, just ensure it is skipped if re-called
+			event.getServletContext().setAttribute(getClass().getName(), true);
+			if (lifeCycle == null) {
+				lifeCycle = webBeansContext.getService(ContainerLifecycle.class);
+			}
+		}
+
+		@Override
+		public void contextDestroyed(ServletContextEvent sce) {
+			try {
+				super.contextDestroyed(sce);
+			}
+			finally {
+				destroyed.set(true);
+			}
+		}
+	}
+}
diff --git a/cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/HttpActivator.java b/cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/ServletActivator.java
similarity index 93%
rename from cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/HttpActivator.java
rename to cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/ServletActivator.java
index 7bddc93..0466644 100644
--- a/cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/HttpActivator.java
+++ b/cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/ServletActivator.java
@@ -12,7 +12,7 @@
  * limitations under the License.
  */
 
-package org.apache.aries.cdi.extension.http;
+package org.apache.aries.cdi.extension.servlet.owb;
 
 import static org.osgi.framework.Constants.BUNDLE_ACTIVATOR;
 import static org.osgi.framework.Constants.SERVICE_DESCRIPTION;
@@ -36,7 +36,7 @@ import org.osgi.framework.ServiceRegistration;
 	name = BUNDLE_ACTIVATOR,
 	value = "${@class}"
 )
-public class HttpActivator implements BundleActivator {
+public class ServletActivator implements BundleActivator {
 
 	@Override
 	public void start(BundleContext context) throws Exception {
@@ -58,7 +58,7 @@ public class HttpActivator implements BundleActivator {
 			org.apache.webbeans.web.context.WebConversationService.class.getName());
 
 		_serviceRegistration = context.registerService(
-			Extension.class, new HttpExtensionFactory(), properties);
+			Extension.class, new ServletExtensionFactory(), properties);
 	}
 
 	@Override
diff --git a/cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/HttpExtensionFactory.java b/cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/ServletExtensionFactory.java
similarity index 84%
rename from cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/HttpExtensionFactory.java
rename to cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/ServletExtensionFactory.java
index 906b898..6dddfad 100644
--- a/cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/HttpExtensionFactory.java
+++ b/cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/ServletExtensionFactory.java
@@ -12,7 +12,7 @@
  * limitations under the License.
  */
 
-package org.apache.aries.cdi.extension.http;
+package org.apache.aries.cdi.extension.servlet.owb;
 
 import javax.enterprise.inject.spi.Extension;
 
@@ -20,13 +20,13 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.PrototypeServiceFactory;
 import org.osgi.framework.ServiceRegistration;
 
-public class HttpExtensionFactory implements PrototypeServiceFactory<Extension> {
+public class ServletExtensionFactory implements PrototypeServiceFactory<Extension> {
 
 	@Override
 	public Extension getService(
 		Bundle bundle, ServiceRegistration<Extension> registration) {
 
-		return new HttpExtension(bundle);
+		return new OWBServletExtension(bundle);
 	}
 
 	@Override
diff --git a/cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/package-info.java b/cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/package-info.java
similarity index 96%
rename from cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/package-info.java
rename to cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/package-info.java
index 2f1bf4f..cfccabf 100644
--- a/cdi-extension-http-owb/src/main/java/org/apache/aries/cdi/extension/http/package-info.java
+++ b/cdi-extension-servlet-owb/src/main/java/org/apache/aries/cdi/extension/servlet/owb/package-info.java
@@ -36,7 +36,7 @@
 	version = "1.0.0"
 )
 @org.osgi.service.cdi.annotations.RequireCDIImplementation
-package org.apache.aries.cdi.extension.http;
+package org.apache.aries.cdi.extension.servlet.owb;
 
 import static org.osgi.namespace.implementation.ImplementationNamespace.IMPLEMENTATION_NAMESPACE;
 import static org.osgi.namespace.service.ServiceNamespace.SERVICE_NAMESPACE;
diff --git a/cdi-extension-http-weld/LICENSE b/cdi-extension-servlet-weld/LICENSE
similarity index 100%
rename from cdi-extension-http-weld/LICENSE
rename to cdi-extension-servlet-weld/LICENSE
diff --git a/cdi-extension-http-weld/NOTICE b/cdi-extension-servlet-weld/NOTICE
similarity index 100%
rename from cdi-extension-http-weld/NOTICE
rename to cdi-extension-servlet-weld/NOTICE
diff --git a/cdi-extension-http-weld/pom.xml b/cdi-extension-servlet-weld/pom.xml
similarity index 93%
rename from cdi-extension-http-weld/pom.xml
rename to cdi-extension-servlet-weld/pom.xml
index fecf888..b3ed01e 100644
--- a/cdi-extension-http-weld/pom.xml
+++ b/cdi-extension-servlet-weld/pom.xml
@@ -26,8 +26,8 @@
 		<relativePath>..</relativePath>
 	</parent>
 
-	<artifactId>org.apache.aries.cdi.extension.http.weld</artifactId>
-	<name>Apache Aries CDI - Http Extension for Weld</name>
+	<artifactId>org.apache.aries.cdi.extension.servlet.weld</artifactId>
+	<name>Apache Aries CDI - Servlet Extension for Weld</name>
 	<description>
 		Provides support to CDI bundles for http servlet scopes; @RequestScoped,
 		@SessionScoped and @ConversationScoped.
@@ -59,6 +59,11 @@
 	<dependencies>
 		<dependency>
 			<groupId>org.apache.aries.cdi</groupId>
+			<artifactId>org.apache.aries.cdi.extension.servlet.common</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.aries.cdi</groupId>
 			<artifactId>org.apache.aries.cdi.extra</artifactId>
 			<version>${project.version}</version>
 		</dependency>
diff --git a/cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/HttpActivator.java b/cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/ServletActivator.java
similarity index 91%
rename from cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/HttpActivator.java
rename to cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/ServletActivator.java
index 901f932..6d3cb18 100644
--- a/cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/HttpActivator.java
+++ b/cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/ServletActivator.java
@@ -12,7 +12,7 @@
  * limitations under the License.
  */
 
-package org.apache.aries.cdi.extension.http;
+package org.apache.aries.cdi.extension.servlet.weld;
 
 import static org.osgi.framework.Constants.BUNDLE_ACTIVATOR;
 import static org.osgi.framework.Constants.SERVICE_DESCRIPTION;
@@ -33,7 +33,7 @@ import org.osgi.framework.ServiceRegistration;
 	name = BUNDLE_ACTIVATOR,
 	value = "${@class}"
 )
-public class HttpActivator implements BundleActivator {
+public class ServletActivator implements BundleActivator {
 
 	@Override
 	public void start(BundleContext context) throws Exception {
@@ -44,7 +44,7 @@ public class HttpActivator implements BundleActivator {
 		properties.put(SERVICE_VENDOR, "Apache Software Foundation");
 
 		_serviceRegistration = context.registerService(
-			Extension.class, new HttpExtensionFactory(), properties);
+			Extension.class, new ServletExtensionFactory(), properties);
 	}
 
 	@Override
diff --git a/cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/HttpExtensionFactory.java b/cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/ServletExtensionFactory.java
similarity index 84%
rename from cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/HttpExtensionFactory.java
rename to cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/ServletExtensionFactory.java
index ff6a784..2cad1ea 100644
--- a/cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/HttpExtensionFactory.java
+++ b/cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/ServletExtensionFactory.java
@@ -12,7 +12,7 @@
  * limitations under the License.
  */
 
-package org.apache.aries.cdi.extension.http;
+package org.apache.aries.cdi.extension.servlet.weld;
 
 import javax.enterprise.inject.spi.Extension;
 
@@ -20,13 +20,13 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.PrototypeServiceFactory;
 import org.osgi.framework.ServiceRegistration;
 
-public class HttpExtensionFactory implements PrototypeServiceFactory<Extension> {
+public class ServletExtensionFactory implements PrototypeServiceFactory<Extension> {
 
 	@Override
 	public Extension getService(
 		Bundle bundle, ServiceRegistration<Extension> registration) {
 
-		return new HttpExtension();
+		return new WeldServletExtension(bundle);
 	}
 
 	@Override
diff --git a/cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/WeldServletExtension.java b/cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/WeldServletExtension.java
new file mode 100644
index 0000000..c1c1e8d
--- /dev/null
+++ b/cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/WeldServletExtension.java
@@ -0,0 +1,180 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.aries.cdi.extension.servlet.weld;
+
+import static javax.interceptor.Interceptor.Priority.LIBRARY_AFTER;
+import static org.osgi.framework.Constants.SERVICE_DESCRIPTION;
+import static org.osgi.framework.Constants.SERVICE_RANKING;
+import static org.osgi.framework.Constants.SERVICE_VENDOR;
+import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
+import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.annotation.Priority;
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.ObservesAsync;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.BeforeShutdown;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.InjectionTargetFactory;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.inject.spi.WithAnnotations;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.annotation.WebListener;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import org.apache.aries.cdi.extension.servlet.common.WebFilterProcessor;
+import org.apache.aries.cdi.extension.servlet.common.WebListenerProcessor;
+import org.apache.aries.cdi.extension.servlet.common.WebServletProcessor;
+import org.apache.aries.cdi.spi.configuration.Configuration;
+import org.jboss.weld.module.web.servlet.WeldInitialListener;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class WeldServletExtension implements Extension {
+
+	private final BundleContext bundleContext;
+	volatile Configuration configuration;
+
+	public WeldServletExtension(Bundle bundle) {
+		this.bundleContext = bundle.getBundleContext();
+	}
+
+	void setConfiguration(@Observes Configuration configuration) {
+		this.configuration = configuration;
+	}
+
+	<X> void webFilter(@Observes @WithAnnotations(WebFilter.class) ProcessAnnotatedType<X> pat) {
+		new WebFilterProcessor().process(configuration, pat);
+	}
+
+	<X> void webListener(@Observes @WithAnnotations(WebListener.class) ProcessAnnotatedType<X> pat) {
+		new WebListenerProcessor().process(configuration, pat);
+	}
+
+	<X> void webServlet(@Observes @WithAnnotations(WebServlet.class) ProcessAnnotatedType<X> pat) {
+		new WebServletProcessor().process(configuration, pat);
+	}
+
+	void afterDeploymentValidation(
+		@Observes @Priority(LIBRARY_AFTER + 800)
+		AfterDeploymentValidation adv, BeanManager beanManager) {
+
+		beanManager.getEvent().fireAsync(new Ready());
+	}
+
+	void ready(
+		@ObservesAsync Ready ready, BeanManager beanManager) {
+
+		Dictionary<String, Object> properties = new Hashtable<>();
+
+		properties.put(SERVICE_DESCRIPTION, "Aries CDI - HTTP Portable Extension for Weld");
+		properties.put(SERVICE_VENDOR, "Apache Software Foundation");
+		properties.put(HTTP_WHITEBOARD_CONTEXT_SELECT, configuration.get(HTTP_WHITEBOARD_CONTEXT_SELECT));
+		properties.put(HTTP_WHITEBOARD_LISTENER, Boolean.TRUE.toString());
+		properties.put(SERVICE_RANKING, Integer.MAX_VALUE - 100);
+
+		AnnotatedType<WeldInitialListener> annotatedType = beanManager.createAnnotatedType(WeldInitialListener.class);
+		InjectionTargetFactory<WeldInitialListener> injectionTargetFactory = beanManager.getInjectionTargetFactory(annotatedType);
+		Bean<WeldInitialListener> bean = beanManager.createBean(beanManager.createBeanAttributes(annotatedType), WeldInitialListener.class, injectionTargetFactory);
+
+		WeldInitialListener initialListener = bean.create(beanManager.createCreationalContext(bean));
+
+		_listenerRegistration = bundleContext.registerService(
+			LISTENER_CLASSES, new ListenerWrapper<>(initialListener), properties);
+	}
+
+	void beforeShutdown(@Observes BeforeShutdown bs) {
+		if (_listenerRegistration != null && !destroyed.get()) {
+			try {
+				_listenerRegistration.unregister();
+			}
+			catch (IllegalStateException ise) {
+				// the service was already unregistered.
+			}
+		}
+	}
+
+	private static final String[] LISTENER_CLASSES = new String[] {
+		ServletContextListener.class.getName(),
+		ServletRequestListener.class.getName(),
+		HttpSessionListener.class.getName()
+	};
+
+	private volatile ServiceRegistration<?> _listenerRegistration;
+	private final AtomicBoolean destroyed = new AtomicBoolean(false);
+
+	public static class Ready {}
+
+	private class ListenerWrapper<T extends HttpSessionListener & ServletContextListener & ServletRequestListener>
+		implements HttpSessionListener, ServletContextListener, ServletRequestListener {
+
+		private final T delegate;
+
+		public ListenerWrapper(T delegate) {
+			this.delegate = delegate;
+		}
+
+		@Override
+		public void contextDestroyed(ServletContextEvent sce) {
+			try {
+				delegate.contextDestroyed(sce);
+			}
+			finally {
+				destroyed.set(true);
+			}
+		}
+
+		@Override
+		public void contextInitialized(ServletContextEvent sce) {
+			delegate.contextInitialized(sce);
+		}
+
+		@Override
+		public void requestDestroyed(ServletRequestEvent sre) {
+			delegate.requestDestroyed(sre);
+		}
+
+		@Override
+		public void requestInitialized(ServletRequestEvent sre) {
+			delegate.requestInitialized(sre);
+		}
+
+		@Override
+		public void sessionCreated(HttpSessionEvent se) {
+			delegate.sessionCreated(se);
+		}
+
+		@Override
+		public void sessionDestroyed(HttpSessionEvent se) {
+			delegate.sessionDestroyed(se);
+		}
+
+	}
+
+}
diff --git a/cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/package-info.java b/cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/package-info.java
similarity index 96%
rename from cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/package-info.java
rename to cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/package-info.java
index 2f1bf4f..32590be 100644
--- a/cdi-extension-http-weld/src/main/java/org/apache/aries/cdi/extension/http/package-info.java
+++ b/cdi-extension-servlet-weld/src/main/java/org/apache/aries/cdi/extension/servlet/weld/package-info.java
@@ -36,7 +36,7 @@
 	version = "1.0.0"
 )
 @org.osgi.service.cdi.annotations.RequireCDIImplementation
-package org.apache.aries.cdi.extension.http;
+package org.apache.aries.cdi.extension.servlet.weld;
 
 import static org.osgi.namespace.implementation.ImplementationNamespace.IMPLEMENTATION_NAMESPACE;
 import static org.osgi.namespace.service.ServiceNamespace.SERVICE_NAMESPACE;
diff --git a/cdi-itests/owb-itest.bndrun b/cdi-itests/owb-itest.bndrun
index 96b6624..63ebf39 100644
--- a/cdi-itests/owb-itest.bndrun
+++ b/cdi-itests/owb-itest.bndrun
@@ -26,10 +26,11 @@
 	openwebbeans-spi;version='[2.0.13,2.0.14)',\
 	openwebbeans-web;version='[2.0.13,2.0.14)',\
 	org.apache.aries.cdi.extender;version='[1.1.0,1.1.1)',\
-	org.apache.aries.cdi.extension.http.owb;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.extension.jndi;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.extension.mp-config;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.extension.mp-metrics;version='[1.1.0,1.1.1)',\
+	org.apache.aries.cdi.extension.servlet.common;version='[1.1.0,1.1.1)',\
+	org.apache.aries.cdi.extension.servlet.owb;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.extra;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.itests;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.owb;version='[1.1.0,1.1.1)',\
diff --git a/cdi-itests/weld-itest.bndrun b/cdi-itests/weld-itest.bndrun
index 169a2f7..bf3f0c8 100644
--- a/cdi-itests/weld-itest.bndrun
+++ b/cdi-itests/weld-itest.bndrun
@@ -27,10 +27,11 @@
 	javax.transaction-api;version='[1.2.0,1.2.1)',\
 	jboss-classfilewriter;version='[1.2.3,1.2.4)',\
 	org.apache.aries.cdi.extender;version='[1.1.0,1.1.1)',\
-	org.apache.aries.cdi.extension.http.weld;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.extension.jndi;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.extension.mp-config;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.extension.mp-metrics;version='[1.1.0,1.1.1)',\
+	org.apache.aries.cdi.extension.servlet.common;version='[1.1.0,1.1.1)',\
+	org.apache.aries.cdi.extension.servlet.weld;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.extra;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.itests;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.spi;version='[1.1.0,1.1.1)',\
diff --git a/pom.xml b/pom.xml
index 914be62..cd09b52 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,9 +72,10 @@
 		<module>cdi-spi</module>
 		<module>cdi-extender</module>
 		<module>cdi-extension-el-jsp</module>
-		<module>cdi-extension-http-owb</module>
-		<module>cdi-extension-http-weld</module>
 		<module>cdi-extension-jndi</module>
+		<module>cdi-extension-servlet-common</module>
+		<module>cdi-extension-servlet-owb</module>
+		<module>cdi-extension-servlet-weld</module>
 		<module>cdi-extension-mp-config</module>
 		<module>cdi-extension-mp-metrics</module>
 		<module>cdi-owb</module>