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/05 21:11:40 UTC

[aries-cdi] branch master updated: mp-metrics

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 da2f9bb  mp-metrics
     new d2ae874  Merge pull request #22 from rotty3000/mp-metrics
da2f9bb is described below

commit da2f9bbd1881f80dd912e1ab749d949730ebceb0
Author: Raymond Augé <ro...@apache.org>
AuthorDate: Wed Dec 4 16:53:27 2019 -0500

    mp-metrics
    
    Signed-off-by: Raymond Augé <ro...@apache.org>
---
 cdi-bom/pom.xml                                    |   6 +
 cdi-extension-mp-metrics/pom.xml                   | 211 +++++++++++++++++++++
 .../cdi/extension/mp/metrics/StubExtension.java    | 159 ++++++++++++++++
 .../cdi/extension/mp/metrics/StubJsonProvider.java |  12 ++
 .../cdi/extension/mp/metrics/package-info.java     |  39 ++++
 cdi-itests/base-itest.bndrun                       |   3 +-
 cdi-itests/bnd.bnd                                 |   3 +-
 cdi-itests/bnd/tb22.bnd                            |  13 ++
 cdi-itests/owb-itest.bndrun                        |  10 +
 cdi-itests/pom.xml                                 |  34 +++-
 .../aries/cdi/test/cases/AbstractTestCase.java     |   6 +
 .../aries/cdi/test/cases/MpMetricsTests.java       | 167 ++++++++++++++++
 .../java/org/apache/aries/cdi/test/tb22/A.java     |  45 +++++
 .../resources/OSGI-INF/configurator/config.json    |   9 +
 cdi-itests/weld-itest.bndrun                       |  10 +
 pom.xml                                            |  16 ++
 16 files changed, 734 insertions(+), 9 deletions(-)

diff --git a/cdi-bom/pom.xml b/cdi-bom/pom.xml
index 489acb7..0692ee8 100644
--- a/cdi-bom/pom.xml
+++ b/cdi-bom/pom.xml
@@ -77,6 +77,12 @@
 			</dependency>
 			<dependency>
 				<groupId>org.apache.aries.cdi</groupId>
+				<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.extra</artifactId>
 				<version>${project.version}</version>
 				<scope>compile</scope>
diff --git a/cdi-extension-mp-metrics/pom.xml b/cdi-extension-mp-metrics/pom.xml
new file mode 100644
index 0000000..39b00c2
--- /dev/null
+++ b/cdi-extension-mp-metrics/pom.xml
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/**
+ * 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.
+ */
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>org.apache.aries.cdi</groupId>
+		<artifactId>org.apache.aries.cdi</artifactId>
+		<version>1.1.0-SNAPSHOT</version>
+		<relativePath>..</relativePath>
+	</parent>
+
+	<properties>
+		<mp.metrics.version>1.1.1</mp.metrics.version>
+		<byte.buddy.version>1.10.3</byte.buddy.version>
+	</properties>
+
+	<artifactId>org.apache.aries.cdi.extension.mp-metrics</artifactId>
+	<name>Apache Aries CDI - MicroProfile Metrics ${mp.metrics.version} Using Apache Geronimo</name>
+	<description>Apache Aries CDI - MicroProfile Metrics ${mp.metrics.version} Using Apache Geronimo</description>
+
+	<licenses>
+		<license>
+			<name>ASL 2.0</name>
+			<url>https://www.apache.org/licenses/LICENSE-2.0</url>
+		</license>
+	</licenses>
+
+	<scm>
+		<connection>scm:git:git@github.com:apache/aries-cdi.git</connection>
+		<developerConnection>scm:git:git@github.com:apache/aries-cdi.git</developerConnection>
+		<tag>HEAD</tag>
+		<url>https://github.com/apache/aries-cdi</url>
+	</scm>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>biz.aQute.bnd</groupId>
+				<artifactId>bnd-maven-plugin</artifactId>
+				<configuration>
+					<bnd><![CDATA[
+						Export-Package: org.eclipse.microprofile.metrics.*
+						-includepackage: org.apache.geronimo.microprofile.metrics.*
+						-cdiannotations:
+						-noclassforname: true
+						-fixupmessages: "Split package...";is:=ignore
+					]]></bnd>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>net.bytebuddy</groupId>
+				<artifactId>byte-buddy-maven-plugin</artifactId>
+				<version>${byte.buddy.version}</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>transform</goal>
+						</goals>
+					</execution>
+				</executions>
+				<configuration>
+					<transformations>
+						<transformation>
+							<plugin>org.apache.aries.cdi.build.tools.AddExtensionRequirement</plugin>
+							<arguments>
+								<argument>
+									<index>1</index>
+									<value>eclipse.microprofile.metrics</value>
+								</argument>
+								<argument>
+									<index>2</index>
+									<value>${mp.metrics.version}</value>
+								</argument>
+								<argument>
+									<index>3</index>
+									<value>org.eclipse.microprofile.metrics.annotation.*</value>
+								</argument>
+							</arguments>
+						</transformation>
+					</transformations>
+				</configuration>
+				<dependencies>
+					<dependency>
+						<groupId>org.osgi</groupId>
+						<artifactId>osgi.annotation</artifactId>
+						<version>7.0.0</version>
+					</dependency>
+					<dependency>
+						<groupId>org.apache.aries.cdi</groupId>
+						<artifactId>org.apache.aries.cdi.build.tools</artifactId>
+						<version>${project.version}</version>
+					</dependency>
+				</dependencies>
+			</plugin>
+		</plugins>
+	</build>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.aries.cdi</groupId>
+			<artifactId>org.apache.aries.cdi.extra</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.aries.cdi</groupId>
+			<artifactId>org.apache.aries.cdi.spi</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>biz.aQute.bnd</groupId>
+			<artifactId>biz.aQute.bnd.annotation</artifactId>
+			<version>${bnd.version}</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-annotation_1.3_spec</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-atinject_1.0_spec</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-interceptor_1.2_spec</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-jaxrs_2.1_spec</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-jcdi_2.0_spec</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-jsonb_1.0_spec</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-json_1.1_spec</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.johnzon</groupId>
+			<artifactId>johnzon-core</artifactId>
+			<version>1.2.2</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.johnzon</groupId>
+			<artifactId>johnzon-jsonb</artifactId>
+			<version>1.2.2</version>
+		</dependency>
+		<dependency>
+			<groupId>org.eclipse.microprofile.metrics</groupId>
+			<artifactId>microprofile-metrics-api</artifactId>
+			<version>${mp.metrics.version}</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo</groupId>
+			<artifactId>geronimo-metrics</artifactId>
+			<version>1.0.3</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.namespace.service</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.service.cdi</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.service.jaxrs</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>osgi.annotation</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>osgi.core</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.aries.jax.rs</groupId>
+			<artifactId>org.apache.aries.jax.rs.whiteboard</artifactId>
+			<version>1.0.6</version>
+			<scope>runtime</scope>
+		</dependency>
+	</dependencies>
+
+</project>
\ No newline at end of file
diff --git a/cdi-extension-mp-metrics/src/main/java/org/apache/aries/cdi/extension/mp/metrics/StubExtension.java b/cdi-extension-mp-metrics/src/main/java/org/apache/aries/cdi/extension/mp/metrics/StubExtension.java
new file mode 100644
index 0000000..4604d99
--- /dev/null
+++ b/cdi-extension-mp-metrics/src/main/java/org/apache/aries/cdi/extension/mp/metrics/StubExtension.java
@@ -0,0 +1,159 @@
+/**
+ * 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.mp.metrics;
+
+import static javax.interceptor.Interceptor.Priority.LIBRARY_AFTER;
+import static javax.interceptor.Interceptor.Priority.LIBRARY_BEFORE;
+import static org.apache.aries.cdi.extension.mp.metrics.StubExtension.EXTENSION_NAME;
+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.cdi.CDIConstants.CDI_EXTENSION_PROPERTY;
+import static org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_APPLICATION_SELECT;
+import static org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_EXTENSION;
+import static org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_EXTENSION_SELECT;
+import static org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_MEDIA_TYPE;
+import static org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_NAME;
+import static org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_RESOURCE;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import javax.annotation.Priority;
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.ObservesAsync;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+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.ws.rs.core.MediaType;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+import org.apache.aries.cdi.spi.configuration.Configuration;
+import org.apache.geronimo.microprofile.metrics.cdi.CountedInterceptor;
+import org.apache.geronimo.microprofile.metrics.cdi.MeteredInterceptor;
+import org.apache.geronimo.microprofile.metrics.cdi.MetricsExtension;
+import org.apache.geronimo.microprofile.metrics.cdi.TimedInterceptor;
+import org.apache.geronimo.microprofile.metrics.jaxrs.CdiMetricsEndpoints;
+import org.apache.johnzon.jaxrs.jsonb.jaxrs.JsonbJaxrsProvider;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import aQute.bnd.annotation.spi.ServiceProvider;
+
+@ServiceProvider(
+	attribute = {
+		CDI_EXTENSION_PROPERTY + "=" + EXTENSION_NAME,
+		"service.scope=prototype",
+		"service.vendor=Apache Software Foundation",
+		"version:Version=1.1.1"
+	},
+	effective = "active",
+	uses = Extension.class,
+	value = Extension.class
+)
+public class StubExtension extends MetricsExtension {
+
+	public final static String EXTENSION_NAME = "eclipse.microprofile.metrics";
+
+	private volatile Configuration configuration;
+
+	void getConfiguration(@Observes Configuration configuration) {
+		this.configuration = configuration;
+	}
+
+	void addExtensionBeans(
+		@Priority(LIBRARY_BEFORE + 800)
+		@Observes final AfterBeanDiscovery abd, final BeanManager bm) {
+
+		abd.addBean().beanClass(CountedInterceptor.class).createWith(c -> new CountedInterceptor());
+		abd.addBean().beanClass(MeteredInterceptor.class).createWith(c -> new MeteredInterceptor());
+		abd.addBean().beanClass(TimedInterceptor.class).createWith(c -> new TimedInterceptor());
+		abd.addBean().beanClass(CdiMetricsEndpoints.class).createWith(c -> new CdiMetricsEndpoints());
+	}
+
+	void registerMetricsEndpoint(
+		@Observes @Priority(LIBRARY_AFTER + 800)
+		AfterDeploymentValidation adv, BeanManager beanManager) {
+
+		beanManager.getEvent().fireAsync(new Ready());
+	}
+
+	void registerMetricsEndpoint0(
+		@ObservesAsync Ready ready, BeanManager beanManager, BundleContext bundleContext) {
+		Dictionary<String, Object> properties = new Hashtable<>();
+
+		properties.put(SERVICE_DESCRIPTION, "Aries CDI - MP Metrics JSON Provider");
+		properties.put(SERVICE_VENDOR, "Apache Software Foundation");
+		properties.put(JAX_RS_APPLICATION_SELECT, configuration.get(JAX_RS_APPLICATION_SELECT));
+		properties.put(JAX_RS_EXTENSION, Boolean.TRUE.toString());
+		properties.put(JAX_RS_MEDIA_TYPE, MediaType.APPLICATION_JSON);
+		properties.put(JAX_RS_NAME, "metrics.json.provider");
+		properties.put(SERVICE_RANKING, Integer.MAX_VALUE - 100);
+
+		JsonbJaxrsProvider<?> johnzonProvider = new JsonbJaxrsProvider<>();
+
+		_jsonProviderRegistration = bundleContext.registerService(
+			new String[] {MessageBodyReader.class.getName(), MessageBodyWriter.class.getName()}, johnzonProvider, properties);
+
+		properties = new Hashtable<>();
+
+		properties.put(SERVICE_DESCRIPTION, "Aries CDI - MP Metrics Portable Extension Endpoint");
+		properties.put(SERVICE_VENDOR, "Apache Software Foundation");
+		properties.put(JAX_RS_APPLICATION_SELECT, configuration.get(JAX_RS_APPLICATION_SELECT));
+		properties.put(JAX_RS_RESOURCE, Boolean.TRUE.toString());
+		properties.put(JAX_RS_EXTENSION_SELECT, "(osgi.jaxrs.name=metrics.json.provider)");
+		properties.put(SERVICE_RANKING, Integer.MAX_VALUE - 100);
+
+		AnnotatedType<CdiMetricsEndpoints> annotatedType = beanManager.createAnnotatedType(CdiMetricsEndpoints.class);
+		InjectionTargetFactory<CdiMetricsEndpoints> injectionTargetFactory = beanManager.getInjectionTargetFactory(annotatedType);
+		Bean<CdiMetricsEndpoints> bean = beanManager.createBean(beanManager.createBeanAttributes(annotatedType), CdiMetricsEndpoints.class, injectionTargetFactory);
+
+		CdiMetricsEndpoints cdiMetricsEndpoints = bean.create(beanManager.createCreationalContext(bean));
+
+		_endpointRegistration = bundleContext.registerService(
+			CdiMetricsEndpoints.class, cdiMetricsEndpoints, properties);
+	}
+
+	void unregisterMetricsEndpoint(@Observes BeforeShutdown bs) {
+		if (_endpointRegistration != null) {
+			try {
+				_endpointRegistration.unregister();
+			}
+			catch (IllegalStateException ise) {
+				// the service was already unregistered.
+			}
+		}
+		if (_jsonProviderRegistration != null) {
+			try {
+				_jsonProviderRegistration.unregister();
+			}
+			catch (IllegalStateException ise) {
+				// the service was already unregistered.
+			}
+		}
+	}
+
+	public static class Ready {}
+
+	private volatile ServiceRegistration<?> _jsonProviderRegistration;
+	private volatile ServiceRegistration<?> _endpointRegistration;
+
+}
diff --git a/cdi-extension-mp-metrics/src/main/java/org/apache/aries/cdi/extension/mp/metrics/StubJsonProvider.java b/cdi-extension-mp-metrics/src/main/java/org/apache/aries/cdi/extension/mp/metrics/StubJsonProvider.java
new file mode 100644
index 0000000..73d3a68
--- /dev/null
+++ b/cdi-extension-mp-metrics/src/main/java/org/apache/aries/cdi/extension/mp/metrics/StubJsonProvider.java
@@ -0,0 +1,12 @@
+package org.apache.aries.cdi.extension.mp.metrics;
+
+import javax.json.spi.JsonProvider;
+
+import org.apache.johnzon.core.JsonProviderImpl;
+
+import aQute.bnd.annotation.spi.ServiceProvider;
+
+@ServiceProvider(JsonProvider.class)
+@SuppressWarnings("serial")
+public class StubJsonProvider extends JsonProviderImpl {
+}
diff --git a/cdi-extension-mp-metrics/src/main/java/org/apache/aries/cdi/extension/mp/metrics/package-info.java b/cdi-extension-mp-metrics/src/main/java/org/apache/aries/cdi/extension/mp/metrics/package-info.java
new file mode 100644
index 0000000..9303ff8
--- /dev/null
+++ b/cdi-extension-mp-metrics/src/main/java/org/apache/aries/cdi/extension/mp/metrics/package-info.java
@@ -0,0 +1,39 @@
+/**
+ * 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.
+ */
+
+@Capability(
+	attribute = "objectClass:List<String>=javax.enterprise.inject.spi.Extension",
+	namespace = SERVICE_NAMESPACE
+)
+@Capability(
+	namespace = CDI_EXTENSION_PROPERTY,
+	name = EXTENSION_NAME,
+	uses= {
+		javax.annotation.Priority.class,
+		javax.enterprise.event.Observes.class,
+		javax.enterprise.inject.spi.Extension.class
+	},
+	version = "1.1.1" // TODO ?maybe read this from pom property?
+)
+@RequireCDIExtender
+@RequireJaxrsWhiteboard
+package org.apache.aries.cdi.extension.mp.metrics;
+
+import static org.apache.aries.cdi.extension.mp.metrics.StubExtension.EXTENSION_NAME;
+import static org.osgi.namespace.service.ServiceNamespace.SERVICE_NAMESPACE;
+import static org.osgi.service.cdi.CDIConstants.CDI_EXTENSION_PROPERTY;
+
+import org.osgi.annotation.bundle.Capability;
+import org.osgi.service.cdi.annotations.RequireCDIExtender;
+import org.osgi.service.jaxrs.whiteboard.annotations.RequireJaxrsWhiteboard;
diff --git a/cdi-itests/base-itest.bndrun b/cdi-itests/base-itest.bndrun
index 78a73c8..5f50527 100644
--- a/cdi-itests/base-itest.bndrun
+++ b/cdi-itests/base-itest.bndrun
@@ -22,7 +22,8 @@
 	osgi.console=,\
 	tck.config.test.javaconfig.converter.stringvalues=foo,\
 	test.property.a=blah,\
-	test.property.b=
+	test.property.b=,\
+	org.apache.felix.http.host=localhost
 
 -resolve.effective: resolve, active
 
diff --git a/cdi-itests/bnd.bnd b/cdi-itests/bnd.bnd
index cf366ef..570c7c3 100644
--- a/cdi-itests/bnd.bnd
+++ b/cdi-itests/bnd.bnd
@@ -63,7 +63,8 @@ p = org.apache.aries.cdi.test
 	tb18.jar,\
 	tb19.jar,\
 	tb20.jar,\
-	tb21.jar
+	tb21.jar,\
+	tb22.jar
 
 # Don't forget that we had to coax the `maven-jar-plugin` NOT to include the `sub-bundle` packages in
 # the root bundle:
diff --git a/cdi-itests/bnd/tb22.bnd b/cdi-itests/bnd/tb22.bnd
new file mode 100644
index 0000000..1ec52c6
--- /dev/null
+++ b/cdi-itests/bnd/tb22.bnd
@@ -0,0 +1,13 @@
+#    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.
+
+Export-Package: ${p}.tb22.*;-split-package:=first
diff --git a/cdi-itests/owb-itest.bndrun b/cdi-itests/owb-itest.bndrun
index 36f751d..d219c54 100644
--- a/cdi-itests/owb-itest.bndrun
+++ b/cdi-itests/owb-itest.bndrun
@@ -28,16 +28,19 @@
 	org.apache.aries.cdi.extender;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.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)',\
 	org.apache.aries.cdi.spi;version='[1.1.0,1.1.1)',\
+	org.apache.aries.jax.rs.whiteboard;version='[1.0.6,1.0.7)',\
 	org.apache.aries.jndi.api;version='[1.1.0,1.1.1)',\
 	org.apache.aries.jndi.core;version='[1.0.2,1.0.3)',\
 	org.apache.aries.spifly.dynamic.framework.extension;version='[1.2.3,1.2.4)',\
 	org.apache.aries.util;version='[1.0.0,1.0.1)',\
 	org.apache.commons.logging;version='[1.2.0,1.2.1)',\
 	org.apache.felix.configadmin;version='[1.9.10,1.9.11)',\
+	org.apache.felix.configurator;version='[1.0.10,1.0.11)',\
 	org.apache.felix.converter;version='[1.0.12,1.0.13)',\
 	org.apache.felix.gogo.command;version='[1.1.0,1.1.1)',\
 	org.apache.felix.gogo.runtime;version='[1.1.2,1.1.3)',\
@@ -48,12 +51,19 @@
 	org.apache.geronimo.specs.geronimo-atinject_1.0_spec;version='[1.1.0,1.1.1)',\
 	org.apache.geronimo.specs.geronimo-el_2.2_spec;version='[1.1.0,1.1.1)',\
 	org.apache.geronimo.specs.geronimo-interceptor_1.2_spec;version='[1.1.0,1.1.1)',\
+	org.apache.geronimo.specs.geronimo-jaxrs_2.1_spec;version='[1.1.0,1.1.1)',\
 	org.apache.geronimo.specs.geronimo-jcdi_2.0_spec;version='[1.1.0,1.1.1)',\
+	org.apache.geronimo.specs.geronimo-json_1.1_spec;version='[1.3.0,1.3.1)',\
+	org.apache.geronimo.specs.geronimo-jsonb_1.0_spec;version='[1.2.0,1.2.1)',\
 	org.apache.httpcomponents.httpclient;version='[4.5.3,4.5.4)',\
 	org.apache.httpcomponents.httpcore;version='[4.4.6,4.4.7)',\
+	org.apache.johnzon.core;version='[1.2.2,1.2.3)',\
+	org.apache.johnzon.jsonb;version='[1.2.2,1.2.3)',\
+	org.apache.johnzon.mapper;version='[1.2.2,1.2.3)',\
 	org.apache.xbean.asm7-shaded;version='[4.13.0,4.13.1)',\
 	org.apache.xbean.bundleutils;version='[4.15.0,4.15.1)',\
 	org.apache.xbean.finder-shaded;version='[4.13.0,4.13.1)',\
 	org.osgi.service.cdi;version='[1.0.0,1.0.1)',\
+	org.osgi.service.jaxrs;version='[1.0.0,1.0.1)',\
 	org.osgi.util.function;version='[1.1.0,1.1.1)',\
 	org.osgi.util.promise;version='[1.1.0,1.1.1)'
diff --git a/cdi-itests/pom.xml b/cdi-itests/pom.xml
index 4321005..c59681a 100644
--- a/cdi-itests/pom.xml
+++ b/cdi-itests/pom.xml
@@ -68,6 +68,10 @@
 			<artifactId>org.apache.aries.cdi.extension.mp-config</artifactId>
 		</dependency>
 		<dependency>
+			<groupId>org.apache.aries.cdi</groupId>
+			<artifactId>org.apache.aries.cdi.extension.mp-metrics</artifactId>
+		</dependency>
+		<dependency>
 			<groupId>org.apache.felix</groupId>
 			<artifactId>org.apache.felix.http.servlet-api</artifactId>
 		</dependency>
@@ -85,6 +89,10 @@
 		</dependency>
 		<dependency>
 			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-jaxrs_2.1_spec</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
 			<artifactId>geronimo-jcdi_2.0_spec</artifactId>
 		</dependency>
 		<dependency>
@@ -106,6 +114,11 @@
 		</dependency>
 		<dependency>
 			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.service.configurator</artifactId>
+			<version>1.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
 			<artifactId>org.osgi.service.jaxrs</artifactId>
 		</dependency>
 		<dependency>
@@ -136,12 +149,6 @@
 			<scope>runtime</scope>
 		</dependency>
 		<dependency>
-			<groupId>org.apache.openwebbeans</groupId>
-			<artifactId>openwebbeans-web</artifactId>
-			<version>${owb.version}</version>
-			<scope>runtime</scope>
-		</dependency>
-		<dependency>
 			<groupId>org.apache.aries.cdi</groupId>
 			<artifactId>org.apache.aries.cdi.weld</artifactId>
 			<scope>runtime</scope>
@@ -154,6 +161,12 @@
 		</dependency>
 		<dependency>
 			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.configurator</artifactId>
+			<version>1.0.10</version>
+			<scope>runtime</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
 			<artifactId>org.apache.felix.http.jetty</artifactId>
 			<scope>runtime</scope>
 		</dependency>
@@ -163,6 +176,12 @@
 			<version>4.4.6</version>
 			<scope>runtime</scope>
 		</dependency>
+		<dependency>
+			<groupId>org.apache.openwebbeans</groupId>
+			<artifactId>openwebbeans-web</artifactId>
+			<version>${owb.version}</version>
+			<scope>runtime</scope>
+		</dependency>
 	</dependencies>
 
 	<dependencyManagement>
@@ -198,7 +217,8 @@
 				<artifactId>maven-jar-plugin</artifactId>
 				<configuration>
 					<includes>
-						<include>META-INF/*</include>
+						<include>META-INF/**</include>
+						<include>OSGI-INF/**</include>
 						<include>org/apache/aries/cdi/test/cases/*</include>
 						<include>org/apache/aries/cdi/test/interfaces/*</include>
 						<include>*.jar</include>
diff --git a/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java b/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java
index 25414dd..085644c 100644
--- a/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java
+++ b/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java
@@ -55,6 +55,7 @@ import org.osgi.namespace.service.ServiceNamespace;
 import org.osgi.service.cdi.CDIConstants;
 import org.osgi.service.cdi.runtime.CDIComponentRuntime;
 import org.osgi.service.cdi.runtime.dto.ContainerDTO;
+import org.osgi.service.configurator.annotations.RequireConfigurator;
 import org.osgi.util.promise.PromiseFactory;
 import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
@@ -76,6 +77,11 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer;
 	namespace = CDI_EXTENSION_PROPERTY,
 	name = "eclipse.microprofile.config"
 )
+@Requirement(
+	namespace = CDI_EXTENSION_PROPERTY,
+	name = "eclipse.microprofile.metrics"
+)
+@RequireConfigurator
 public abstract class AbstractTestCase {
 
 	@Rule
diff --git a/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/MpMetricsTests.java b/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/MpMetricsTests.java
new file mode 100644
index 0000000..d47801c
--- /dev/null
+++ b/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/MpMetricsTests.java
@@ -0,0 +1,167 @@
+/**
+ * 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.test.cases;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+
+import org.apache.aries.cdi.test.interfaces.Pojo;
+import org.assertj.core.api.Assertions;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.runtime.HttpServiceRuntime;
+import org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime;
+import org.osgi.service.jaxrs.runtime.JaxrsServiceRuntimeConstants;
+import org.osgi.service.jaxrs.runtime.dto.ResourceDTO;
+import org.osgi.service.jaxrs.runtime.dto.ResourceMethodInfoDTO;
+import org.osgi.service.jaxrs.runtime.dto.RuntimeDTO;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class MpMetricsTests extends SlimTestCase {
+
+	@Test
+	public void testMetrics() throws Exception {
+		Bundle tb2Bundle = installBundle("tb22.jar", false);
+
+		tb2Bundle.start();
+
+		ServiceTracker<Pojo, Pojo> st = new ServiceTracker<Pojo, Pojo>(
+			bundleContext, Pojo.class, null);
+		st.open(true);
+
+		try {
+			Pojo pojo = st.waitForService(timeout);
+			assertNotNull(pojo);
+
+			WebTarget webTarget = cb.build().target(getEndpoint()).path("/metrics/application");
+
+			Response response = webTarget.request().get();
+
+			assertEquals(response.readEntity(String.class),200, response.getStatus());
+
+			String result = response.readEntity(String.class);
+
+			assertEquals("{\"org.apache.aries.cdi.test.tb22.A.applicationCount\":0}", result);
+
+			Assertions.assertThat(pojo.foo("Count: ")).isEqualTo("Count: 1");
+
+			response = webTarget.request().get();
+
+			assertEquals(200, response.getStatus());
+
+			result = response.readEntity(String.class);
+
+			assertEquals("{\"org.apache.aries.cdi.test.tb22.A.applicationCount\":1}", result);
+		}
+		finally {
+			st.close();
+			tb2Bundle.uninstall();
+		}
+	}
+
+	private String getEndpoint() {
+		Object endpointsObj = jsrReference.getProperty(
+			JaxrsServiceRuntimeConstants.JAX_RS_SERVICE_ENDPOINT);
+
+		if (endpointsObj instanceof String) {
+			return String.valueOf(endpointsObj);
+		}
+		else if (endpointsObj instanceof String[]) {
+			return ((String[])endpointsObj)[0];
+		}
+		else if (endpointsObj instanceof Collection) {
+			return String.valueOf(((Collection<?>)endpointsObj).iterator().next());
+		}
+
+		return null;
+	}
+
+	private ResourceDTO waitFor(String path) throws InterruptedException {
+		return waitFor(path, 20);
+	}
+
+	private ResourceDTO waitFor(String path, int intervals) throws InterruptedException {
+		for (int j = intervals; j > 0; j--) {
+			RuntimeDTO runtimeDTO = jsr.getRuntimeDTO();
+
+			for (ResourceDTO curResourceDTO : runtimeDTO.defaultApplication.resourceDTOs) {
+				for (ResourceMethodInfoDTO rmid : curResourceDTO.resourceMethods) {
+					if (path.equals(rmid.path)) {
+						return curResourceDTO;
+					}
+				}
+			}
+
+			Thread.sleep(50);
+		}
+
+		assertTrue(String.format("%s not found in time", path), false);
+
+		return null;
+	}
+
+	@Before
+	@Override
+	public void setUp() throws Exception {
+		hsrTracker = new ServiceTracker<>(bundleContext, HttpServiceRuntime.class, null);
+
+		hsrTracker.open();
+
+		hsr = hsrTracker.waitForService(timeout);
+
+		jsrTracker = new ServiceTracker<>(bundleContext, JaxrsServiceRuntime.class, null);
+
+		jsrTracker.open();
+
+		jsr = jsrTracker.waitForService(timeout);
+
+		jsrReference = jsrTracker.getServiceReference();
+
+		cbTracker = new ServiceTracker<>(bundleContext, ClientBuilder.class, null);
+
+		cbTracker.open();
+
+		cb = cbTracker.waitForService(timeout);
+
+		assertNotNull(cb);
+	}
+
+	@After
+	@Override
+	public void tearDown() throws Exception {
+		hsrTracker.close();
+		jsrTracker.close();
+		cbTracker.close();
+	}
+
+	private ServiceTracker<HttpServiceRuntime, HttpServiceRuntime> hsrTracker = new ServiceTracker<>(bundleContext, HttpServiceRuntime.class, null);
+	private HttpServiceRuntime hsr;
+	private ClientBuilder cb;
+	private ServiceTracker<ClientBuilder, ClientBuilder> cbTracker;
+	private JaxrsServiceRuntime jsr;
+	private ServiceReference<JaxrsServiceRuntime> jsrReference;
+	private ServiceTracker<JaxrsServiceRuntime, JaxrsServiceRuntime> jsrTracker;
+
+}
diff --git a/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb22/A.java b/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb22/A.java
new file mode 100644
index 0000000..3ab1e2e
--- /dev/null
+++ b/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb22/A.java
@@ -0,0 +1,45 @@
+/**
+ * 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.test.tb22;
+
+import javax.inject.Inject;
+
+import org.apache.aries.cdi.test.interfaces.Pojo;
+import org.eclipse.microprofile.metrics.Counter;
+import org.eclipse.microprofile.metrics.annotation.Metric;
+import org.osgi.service.cdi.annotations.Bean;
+import org.osgi.service.cdi.annotations.Service;
+
+@Bean
+@Service
+public class A implements Pojo {
+
+	@Override
+	public String foo(String input) {
+		count.inc();
+		return input + count.getCount();
+	}
+
+	@Override
+	public int getCount() {
+		count.inc();
+		return (int)count.getCount();
+	}
+
+	@Inject
+	@Metric(name = "applicationCount")
+	Counter count;
+
+}
diff --git a/cdi-itests/src/main/resources/OSGI-INF/configurator/config.json b/cdi-itests/src/main/resources/OSGI-INF/configurator/config.json
new file mode 100644
index 0000000..cc606ae
--- /dev/null
+++ b/cdi-itests/src/main/resources/OSGI-INF/configurator/config.json
@@ -0,0 +1,9 @@
+{
+	":configurator:resource-version" : 1,
+
+	"org.apache.aries.jax.rs.whiteboard.default": {
+		"osgi.http.whiteboard.context.select": "(osgi.http.whiteboard.context.name=default)",
+		"osgi.jaxrs.extension.select": "(osgi.jaxrs.name=metrics.json.provider)",
+		"default.web": false
+	}
+}
\ No newline at end of file
diff --git a/cdi-itests/weld-itest.bndrun b/cdi-itests/weld-itest.bndrun
index dd36c60..2f42ebe 100644
--- a/cdi-itests/weld-itest.bndrun
+++ b/cdi-itests/weld-itest.bndrun
@@ -37,16 +37,19 @@
 	org.apache.aries.cdi.extension.http;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.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)',\
 	org.apache.aries.cdi.weld;version='[1.1.0,1.1.1)',\
+	org.apache.aries.jax.rs.whiteboard;version='[1.0.6,1.0.7)',\
 	org.apache.aries.jndi.api;version='[1.1.0,1.1.1)',\
 	org.apache.aries.jndi.core;version='[1.0.2,1.0.3)',\
 	org.apache.aries.spifly.dynamic.framework.extension;version='[1.2.3,1.2.4)',\
 	org.apache.aries.util;version='[1.0.0,1.0.1)',\
 	org.apache.commons.logging;version='[1.2.0,1.2.1)',\
 	org.apache.felix.configadmin;version='[1.9.10,1.9.11)',\
+	org.apache.felix.configurator;version='[1.0.10,1.0.11)',\
 	org.apache.felix.converter;version='[1.0.12,1.0.13)',\
 	org.apache.felix.gogo.command;version='[1.1.0,1.1.1)',\
 	org.apache.felix.gogo.runtime;version='[1.1.2,1.1.3)',\
@@ -57,11 +60,18 @@
 	org.apache.geronimo.specs.geronimo-atinject_1.0_spec;version='[1.1.0,1.1.1)',\
 	org.apache.geronimo.specs.geronimo-el_2.2_spec;version='[1.1.0,1.1.1)',\
 	org.apache.geronimo.specs.geronimo-interceptor_1.2_spec;version='[1.1.0,1.1.1)',\
+	org.apache.geronimo.specs.geronimo-jaxrs_2.1_spec;version='[1.1.0,1.1.1)',\
 	org.apache.geronimo.specs.geronimo-jcdi_2.0_spec;version='[1.1.0,1.1.1)',\
+	org.apache.geronimo.specs.geronimo-json_1.1_spec;version='[1.3.0,1.3.1)',\
+	org.apache.geronimo.specs.geronimo-jsonb_1.0_spec;version='[1.2.0,1.2.1)',\
 	org.apache.httpcomponents.httpclient;version='[4.5.3,4.5.4)',\
 	org.apache.httpcomponents.httpcore;version='[4.4.6,4.4.7)',\
+	org.apache.johnzon.core;version='[1.2.2,1.2.3)',\
+	org.apache.johnzon.jsonb;version='[1.2.2,1.2.3)',\
+	org.apache.johnzon.mapper;version='[1.2.2,1.2.3)',\
 	org.jboss.logging.jboss-logging;version='[3.3.2,3.3.3)',\
 	org.jboss.weld.osgi-bundle;version='[3.0.5,3.0.6)',\
 	org.osgi.service.cdi;version='[1.0.0,1.0.1)',\
+	org.osgi.service.jaxrs;version='[1.0.0,1.0.1)',\
 	org.osgi.util.function;version='[1.1.0,1.1.1)',\
 	org.osgi.util.promise;version='[1.1.0,1.1.1)'
diff --git a/pom.xml b/pom.xml
index 05065be..bb02d94 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,6 +66,7 @@
 		<module>cdi-extension-http</module>
 		<module>cdi-extension-jndi</module>
 		<module>cdi-extension-mp-config</module>
+		<module>cdi-extension-mp-metrics</module>
 		<module>cdi-owb</module>
 		<module>cdi-weld</module>
 		<module>cdi-bom</module>
@@ -113,10 +114,25 @@
 			</dependency>
 			<dependency>
 				<groupId>org.apache.geronimo.specs</groupId>
+				<artifactId>geronimo-jaxrs_2.1_spec</artifactId>
+				<version>1.1</version>
+			</dependency>
+			<dependency>
+				<groupId>org.apache.geronimo.specs</groupId>
 				<artifactId>geronimo-jcdi_2.0_spec</artifactId>
 				<version>1.1</version>
 			</dependency>
 			<dependency>
+				<groupId>org.apache.geronimo.specs</groupId>
+				<artifactId>geronimo-json_1.1_spec</artifactId>
+				<version>1.3</version>
+			</dependency>
+			<dependency>
+				<groupId>org.apache.geronimo.specs</groupId>
+				<artifactId>geronimo-jsonb_1.0_spec</artifactId>
+				<version>1.2</version>
+			</dependency>
+			<dependency>
 				<groupId>org.osgi</groupId>
 				<artifactId>org.osgi.namespace.extender</artifactId>
 				<version>1.0.1</version>