GERONIMO-6651 GERONIMO-6652 osgi bundle - tests to do + spec 1.2 upgrade
diff --git a/geronimo-opentracing-common/pom.xml b/geronimo-opentracing-common/pom.xml
index ce93630..9fe0c60 100644
--- a/geronimo-opentracing-common/pom.xml
+++ b/geronimo-opentracing-common/pom.xml
@@ -35,15 +35,4 @@
<properties>
<geronimo-opentracing.Automatic-Module-Name>org.apache.geronimo.opentracing.common</geronimo-opentracing.Automatic-Module-Name>
</properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>4.0.0</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
</project>
diff --git a/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/config/GeronimoOpenTracingConfig.java b/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/config/GeronimoOpenTracingConfig.java
index 5f5f749..34d18ee 100644
--- a/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/config/GeronimoOpenTracingConfig.java
+++ b/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/config/GeronimoOpenTracingConfig.java
@@ -55,8 +55,7 @@
static GeronimoOpenTracingConfig create() {
try {
- final Iterator<GeronimoOpenTracingConfig> iterator = ServiceLoader.load(GeronimoOpenTracingConfig.class)
- .iterator();
+ final Iterator<GeronimoOpenTracingConfig> iterator = ServiceLoader.load(GeronimoOpenTracingConfig.class).iterator();
if (iterator.hasNext()) {
return new PrefixedConfig(iterator.next());
}
diff --git a/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/server/GeronimoOpenTracingFeature.java b/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/server/GeronimoOpenTracingFeature.java
index 7da58ca..33597b6 100644
--- a/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/server/GeronimoOpenTracingFeature.java
+++ b/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/server/GeronimoOpenTracingFeature.java
@@ -17,8 +17,13 @@
package org.apache.geronimo.microprofile.opentracing.common.microprofile.server;
import static java.util.Optional.ofNullable;
+import static java.util.stream.Collectors.joining;
+import static java.util.stream.Collectors.toList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Optional;
+import java.util.regex.Pattern;
import java.util.stream.Stream;
import javax.ws.rs.HttpMethod;
@@ -40,6 +45,7 @@
private Tracer tracer;
private GeronimoOpenTracingConfig config;
private Container container;
+ private Collection<Pattern> skipPatterns;
public void setTracer(final Tracer tracer) {
this.tracer = tracer;
@@ -64,22 +70,32 @@
if (config == null) {
config = container.lookup(GeronimoOpenTracingConfig.class);
}
+ if (skipPatterns == null) {
+ skipPatterns = ofNullable(config.read("mp.opentracing.server.skip-pattern", null))
+ .map(it -> Stream.of(it.split("\\|")).map(String::trim).filter(p -> !p.isEmpty()).map(Pattern::compile).collect(toList()))
+ .orElseGet(Collections::emptyList);
+ }
final Optional<Traced> traced = ofNullable(ofNullable(resourceInfo.getResourceMethod().getAnnotation(Traced.class))
.orElseGet(() -> resourceInfo.getResourceClass().getAnnotation(Traced.class)));
if (!traced.map(Traced::value).orElse(true)) {
return;
}
+ final String path = Stream.of(
+ ofNullable(resourceInfo.getResourceClass().getAnnotation(Path.class)).map(Path::value).orElse(""),
+ ofNullable(resourceInfo.getResourceMethod().getAnnotation(Path.class)).map(Path::value).orElse(""))
+ .map(it -> it.substring(it.startsWith("/") ? 1 : 0, it.endsWith("/") ? it.length() - 1 : it.length()))
+ .filter(it -> !it.isEmpty())
+ .collect(joining("/", "/", ""));
+ if (skipPatterns.stream().anyMatch(it -> it.matcher(path).matches())) {
+ return;
+ }
final String operationName = traced.map(Traced::operationName).filter(v -> !v.trim().isEmpty()).orElseGet(() -> {
- final boolean usePath = Boolean.parseBoolean(config.read("server.filter.request.operationName.usePath", "false"));
- if (usePath) {
- final String classPath = ofNullable(resourceInfo.getResourceClass().getAnnotation(Path.class)).map(Path::value)
- .orElse("");
- final String methodPath = ofNullable(resourceInfo.getResourceMethod().getAnnotation(Path.class)).map(Path::value)
- .orElse("");
- return getHttpMethod(resourceInfo) + ':' + classPath
- + (!classPath.isEmpty() && !methodPath.isEmpty() && !classPath.endsWith("/") ? "/" : "") + methodPath;
+ if (Boolean.parseBoolean(config.read("server.filter.request.operationName.usePath", "false"))) {
+ return getHttpMethod(resourceInfo) + ':' + getMethodPath(resourceInfo);
+ } else if ("http-path".equals(config.read("mp.opentracing.server.operation-name-provider", null))) {
+ return getMethodPath(resourceInfo);
}
return buildDefaultName(resourceInfo);
});
@@ -92,6 +108,17 @@
Boolean.parseBoolean(config.read("server.filter.request.skipDefaultTags", "false"))));
}
+ private String getMethodPath(final ResourceInfo resourceInfo) {
+ final String classPath = ofNullable(resourceInfo.getResourceClass().getAnnotation(Path.class))
+ .map(Path::value).orElse("");
+ final String methodPath = ofNullable(resourceInfo.getResourceMethod().getAnnotation(Path.class))
+ .map(Path::value).orElse("");
+ return Stream.of(classPath, methodPath)
+ .map(it -> it.substring(it.startsWith("/") ? 1 : 0, it.length() - (it.endsWith("/") ? 1 : 0)))
+ .filter(it -> !it.isEmpty())
+ .collect(joining("/", "/", ""));
+ }
+
private String buildDefaultName(final ResourceInfo resourceInfo) {
return getHttpMethod(resourceInfo) + ':' + resourceInfo.getResourceClass().getName() + "."
+ resourceInfo.getResourceMethod().getName();
diff --git a/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/server/OpenTracingFilter.java b/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/server/OpenTracingFilter.java
index 0504a6f..8de9dd2 100644
--- a/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/server/OpenTracingFilter.java
+++ b/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/server/OpenTracingFilter.java
@@ -4,9 +4,13 @@
import static java.util.stream.Collectors.toList;
import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
@@ -30,6 +34,7 @@
import org.apache.geronimo.microprofile.opentracing.common.spi.Container;
import io.opentracing.Scope;
+import io.opentracing.ScopeManager;
import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.propagation.Format;
@@ -38,7 +43,7 @@
public class OpenTracingFilter implements Filter {
private Tracer tracer;
private GeronimoOpenTracingConfig config;
- private ScopeManagerImpl manager;
+ private ScopeManager manager;
private Container container;
private Collection<Predicate<String>> forcedUrls;
@@ -46,6 +51,7 @@
private List<Predicate<String>> skipUrls;
private boolean skipDefaultTags;
+ private boolean forceStackLog;
public void setTracer(final Tracer tracer) {
this.tracer = tracer;
@@ -55,7 +61,7 @@
this.config = config;
}
- public void setManager(final ScopeManagerImpl manager) {
+ public void setManager(final ScopeManager manager) {
this.manager = manager;
}
@@ -72,12 +78,13 @@
tracer = container.lookup(Tracer.class);
}
if (manager == null) {
- manager = container.lookup(ScopeManagerImpl.class);
+ manager = container.lookup(ScopeManager.class);
}
if (config == null) {
config = container.lookup(GeronimoOpenTracingConfig.class);
}
skipDefaultTags = Boolean.parseBoolean(config.read("filter.forcedTracing.skipDefaultTags", "false"));
+ forceStackLog = Boolean.parseBoolean(config.read("filter.error.forceStackLog", "false"));
forcedUrls = ofNullable(config.read("filter.forcedTracing.urls", null))
.map(String::trim).filter(v -> !v.isEmpty())
.map(v -> toMatchingPredicates(v, "forcedTracing"))
@@ -153,14 +160,13 @@
final Span span = scope.span();
Tags.HTTP_STATUS.set(span,
status == HttpServletResponse.SC_OK ? HttpServletResponse.SC_INTERNAL_SERVER_ERROR : status);
- Tags.ERROR.set(span, true);
- span.log(new HashMap<String, Object>() {
-
- {
- put("event", Tags.ERROR.getKey());
- put("event.object", ex);
- }
- });
+ if (forceStackLog) {
+ Tags.ERROR.set(span, true);
+ final Map<String, Object> logs = new LinkedHashMap<>();
+ logs.put("event", Tags.ERROR.getKey());
+ logs.put("error.object", ex);
+ span.log(logs);
+ }
});
throw ex;
} finally {
@@ -188,7 +194,17 @@
// no-op
}
});
- manager.clear();
+
+ ScopeManager managerImpl = manager;
+ if (!ScopeManagerImpl.class.isInstance(managerImpl) && Proxy.isProxyClass(manager.getClass())) {
+ final InvocationHandler handler = Proxy.getInvocationHandler(manager);
+ if (Container.Unwrappable.class.isInstance(handler)) {
+ managerImpl = ScopeManager.class.cast(Container.Unwrappable.class.cast(handler).unwrap());
+ }
+ }
+ if (ScopeManagerImpl.class.isInstance(managerImpl)) {
+ ScopeManagerImpl.class.cast(managerImpl).clear();
+ }
} else {
scope.close();
}
diff --git a/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/zipkin/ZipkinLogger.java b/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/zipkin/ZipkinLogger.java
index 7acf2e2..ae73637 100644
--- a/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/zipkin/ZipkinLogger.java
+++ b/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/microprofile/zipkin/ZipkinLogger.java
@@ -18,7 +18,6 @@
import java.util.logging.Logger;
-import javax.inject.Inject;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
@@ -31,7 +30,6 @@
private final Logger spanLogger = Logger.getLogger("org.apache.geronimo.opentracing.zipkin");
- @Inject
private GeronimoOpenTracingConfig config;
private Jsonb jsonb;
@@ -53,6 +51,10 @@
wrapAsList = Boolean.parseBoolean(config.read("span.converter.zipkin.logger.wrapAsList", "true"));
}
+ public Jsonb getJsonb() {
+ return jsonb;
+ }
+
public void destroy() {
try {
jsonb.close();
diff --git a/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/spi/Container.java b/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/spi/Container.java
index 6a379f4..991b6f1 100644
--- a/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/spi/Container.java
+++ b/geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/spi/Container.java
@@ -29,4 +29,9 @@
}
return iterator.next();
}
+
+ @FunctionalInterface
+ interface Unwrappable {
+ Object unwrap();
+ }
}
diff --git a/geronimo-opentracing-osgi/pom.xml b/geronimo-opentracing-osgi/pom.xml
new file mode 100644
index 0000000..d5b1fa7
--- /dev/null
+++ b/geronimo-opentracing-osgi/pom.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>geronimo-opentracing-parent</artifactId>
+ <groupId>org.apache.geronimo</groupId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>geronimo-opentracing-osgi</artifactId>
+ <packaging>bundle</packaging>
+ <name>Geronimo OpenTracing :: OSGi</name>
+
+ <properties>
+ <geronimo-opentracing.Automatic-Module-Name>org.apache.geronimo.opentracing.osgi</geronimo-opentracing.Automatic-Module-Name>
+
+ <pax.exam.version>4.12.0</pax.exam.version>
+ <slf4j.version>1.7.25</slf4j.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>6.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>6.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo</groupId>
+ <artifactId>geronimo-opentracing-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit4</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-karaf</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-aether</artifactId>
+ <version>1.6.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${slf4j.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/ConfigAdminOpenTracingConfig.java b/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/ConfigAdminOpenTracingConfig.java
new file mode 100644
index 0000000..fc4bfe9
--- /dev/null
+++ b/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/ConfigAdminOpenTracingConfig.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.geronimo.microprofile.opentracing.osgi;
+
+import static java.util.Optional.ofNullable;
+
+import java.io.IOException;
+
+import org.apache.geronimo.microprofile.opentracing.common.config.GeronimoOpenTracingConfig;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+public class ConfigAdminOpenTracingConfig implements GeronimoOpenTracingConfig {
+ private volatile Configuration delegate;
+
+ public ConfigAdminOpenTracingConfig() {
+ ofNullable(OpenTracingActivator.INSTANCES.get(ConfigurationAdmin.class))
+ .map(ConfigurationAdmin.class::cast)
+ .ifPresent(admin -> {
+ try {
+ delegate = admin.getConfiguration("geronimo.opentracing");
+ } catch (final IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ });
+ }
+
+ @Override
+ public String read(final String value, final String def) {
+ return ofNullable(delegate).map(c -> c.getProperties().get(value)).map(String::valueOf).orElse(def);
+ }
+}
diff --git a/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/OSGiContainer.java b/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/OSGiContainer.java
new file mode 100644
index 0000000..54c4a83
--- /dev/null
+++ b/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/OSGiContainer.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.geronimo.microprofile.opentracing.osgi;
+
+import org.apache.geronimo.microprofile.opentracing.common.spi.Container;
+
+public class OSGiContainer implements Container {
+ @Override
+ public <T> T lookup(final Class<T> type) {
+ return type.cast(OpenTracingActivator.INSTANCES.get(type).getInstance());
+ }
+}
diff --git a/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/OpenTracingActivator.java b/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/OpenTracingActivator.java
new file mode 100644
index 0000000..c143d7a
--- /dev/null
+++ b/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/OpenTracingActivator.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.geronimo.microprofile.opentracing.osgi;
+
+import static java.util.Collections.singletonMap;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.function.BiConsumer;
+
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.container.DynamicFeature;
+
+import org.apache.geronimo.microprofile.opentracing.common.config.GeronimoOpenTracingConfig;
+import org.apache.geronimo.microprofile.opentracing.common.impl.FinishedSpan;
+import org.apache.geronimo.microprofile.opentracing.common.impl.GeronimoTracer;
+import org.apache.geronimo.microprofile.opentracing.common.impl.IdGenerator;
+import org.apache.geronimo.microprofile.opentracing.common.impl.ScopeManagerImpl;
+import org.apache.geronimo.microprofile.opentracing.common.microprofile.client.OpenTracingClientRequestFilter;
+import org.apache.geronimo.microprofile.opentracing.common.microprofile.client.OpenTracingClientResponseFilter;
+import org.apache.geronimo.microprofile.opentracing.common.microprofile.server.GeronimoOpenTracingFeature;
+import org.apache.geronimo.microprofile.opentracing.common.microprofile.zipkin.ZipkinConverter;
+import org.apache.geronimo.microprofile.opentracing.common.microprofile.zipkin.ZipkinLogger;
+import org.apache.geronimo.microprofile.opentracing.common.microprofile.zipkin.ZipkinSpan;
+import org.apache.geronimo.microprofile.opentracing.common.spi.Container;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.service.event.EventConstants;
+import org.osgi.service.event.EventHandler;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+import io.opentracing.ScopeManager;
+import io.opentracing.Tracer;
+
+public class OpenTracingActivator implements BundleActivator {
+ // not sure we can avoid that :(
+ static final Map<Class<?>, Tracked<?>> INSTANCES = new HashMap<>();
+
+ private final Collection<ServiceRegistration<?>> registrations = new ArrayList<>();
+ private ZipkinLogger logger;
+
+ @Override
+ public void start(final BundleContext context) {
+ INSTANCES.put(Container.class, new Tracked<>(context, Container.class, this::register));
+ INSTANCES.put(Tracer.class, new Tracked<>(context, Tracer.class, this::register));
+ INSTANCES.put(GeronimoOpenTracingConfig.class, new Tracked<>(context, GeronimoOpenTracingConfig.class, this::register));
+ INSTANCES.put(ScopeManager.class, new Tracked<>(context, ScopeManager.class, this::register));
+ INSTANCES.put(OpenTracingClientRequestFilter.class, new Tracked<>(context, OpenTracingClientRequestFilter.class, this::register));
+ INSTANCES.put(OpenTracingClientResponseFilter.class, new Tracked<>(context, OpenTracingClientResponseFilter.class, this::register));
+ INSTANCES.put(EventAdmin.class, new Tracked<>(context, EventAdmin.class, this::register));
+ INSTANCES.put(ConfigurationAdmin.class, new Tracked<>(context, ConfigurationAdmin.class, this::register));
+
+ final OSGiContainer container = new OSGiContainer();
+
+ final GeronimoOpenTracingConfig config = new ConfigAdminOpenTracingConfig();
+ final ScopeManager scopeManager = new ScopeManagerImpl();
+
+ final IdGenerator idGenerator = new IdGenerator();
+ idGenerator.setConfig(config);
+ idGenerator.init();
+
+ final GeronimoTracer tracer = new GeronimoTracer();
+ tracer.setConfig(config);
+ tracer.setIdGenerator(idGenerator);
+ tracer.setScopeManager(scopeManager);
+ tracer.setFinishedSpanEvent(span -> container
+ .lookup(EventAdmin.class)
+ .postEvent(new Event("geronimo/microprofile/opentracing/finishedSpan", singletonMap("span", span))));
+ tracer.init();
+
+ final ZipkinConverter zipkinConverter = new ZipkinConverter();
+ zipkinConverter.setConfig(config);
+ zipkinConverter.setIdGenerator(idGenerator);
+ zipkinConverter.setZipkinSpanEvent(span -> container
+ .lookup(EventAdmin.class)
+ .postEvent(new Event("geronimo/microprofile/opentracing/zipkinSpan", singletonMap("span", span))));
+ zipkinConverter.init();
+
+ logger = new ZipkinLogger();
+ logger.setConfig(config);
+ logger.init();
+
+ final OpenTracingClientRequestFilter requestFilter = new OpenTracingClientRequestFilter();
+ requestFilter.setTracer(tracer);
+ requestFilter.setConfig(config);
+ requestFilter.init();
+
+ final OpenTracingClientResponseFilter responseFilter = new OpenTracingClientResponseFilter();
+
+ final GeronimoOpenTracingFeature tracingFeature = new GeronimoOpenTracingFeature();
+ tracingFeature.setConfig(config);
+ tracingFeature.setContainer(container);
+ tracingFeature.setTracer(tracer);
+
+ registrations.add(context.registerService(GeronimoOpenTracingConfig.class, config, new Hashtable<>()));
+ registrations.add(context.registerService(Container.class, container, new Hashtable<>()));
+ registrations.add(context.registerService(IdGenerator.class, idGenerator, new Hashtable<>()));
+ registrations.add(context.registerService(ScopeManager.class, scopeManager, new Hashtable<>()));
+ registrations.add(context.registerService(Tracer.class, tracer, new Hashtable<>()));
+ registrations.add(context.registerService(ClientRequestFilter.class, requestFilter, newJaxRsExtensionProps()));
+ registrations.add(context.registerService(ClientResponseFilter.class, responseFilter, newJaxRsExtensionProps()));
+ registrations.add(context.registerService(DynamicFeature.class, tracingFeature, newJaxRsExtensionProps()));
+ registrations.add(context.registerService(EventHandler.class,
+ event -> zipkinConverter.onEvent(FinishedSpan.class.cast(event.getProperty("span"))),
+ newEventHandlerProps("geronimo/microprofile/opentracing/finishedSpan")));
+ registrations.add(context.registerService(EventHandler.class,
+ event -> logger.onEvent(ZipkinSpan.class.cast(event.getProperty("span"))),
+ newEventHandlerProps("geronimo/microprofile/opentracing/zipkinSpan")));
+ }
+
+ @Override
+ public void stop(final BundleContext context) {
+ INSTANCES.values().forEach(ServiceTracker::close);
+ INSTANCES.clear();
+ registrations.forEach(ServiceRegistration::unregister);
+ logger.destroy();
+ }
+
+ private Dictionary<String, Object> newEventHandlerProps(final String topic) {
+ final Dictionary<String, Object> props = new Hashtable<>();
+ props.put(EventConstants.EVENT_TOPIC, topic);
+ return props;
+ }
+
+ private Dictionary<String, Object> newJaxRsExtensionProps() {
+ final Dictionary<String, Object> props = new Hashtable<>();
+ props.put("osgi.jaxrs.extension", "true");
+ return props;
+ }
+
+ private void register(final Class<?> tClass, final Object t) {
+ final Tracked tracked = INSTANCES.get(tClass);
+ tracked.instance = t;
+ }
+
+ public static class Tracked<T> extends ServiceTracker<T, T> implements ServiceTrackerCustomizer<T, T> {
+ private volatile T instance;
+
+ private Tracked(final BundleContext context, final Class<T> clazz, final BiConsumer<Class<T>, T> onInstance) {
+ super(context, clazz, new ServiceTrackerCustomizer<T, T>() {
+ @Override
+ public T addingService(final ServiceReference<T> reference) {
+ final T service = context.getService(reference);
+ onInstance.accept(clazz, service);
+ return service;
+ }
+
+ @Override
+ public void modifiedService(final ServiceReference<T> reference, final T service) {
+ addingService(reference);
+ }
+
+ @Override
+ public void removedService(final ServiceReference<T> reference, final T service) {
+ addingService(reference);
+ }
+ });
+ }
+
+ T getInstance() {
+ return instance;
+ }
+ }
+}
diff --git a/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/package-info.java b/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/package-info.java
new file mode 100644
index 0000000..5a00bbc
--- /dev/null
+++ b/geronimo-opentracing-osgi/src/main/java/org/apache/geronimo/microprofile/opentracing/osgi/package-info.java
@@ -0,0 +1,17 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.geronimo.microprofile.opentracing.osgi;
diff --git a/geronimo-opentracing-osgi/src/main/resources/META-INF/services/org.apache.geronimo.microprofile.opentracing.common.config.GeronimoOpenTracingConfig b/geronimo-opentracing-osgi/src/main/resources/META-INF/services/org.apache.geronimo.microprofile.opentracing.common.config.GeronimoOpenTracingConfig
new file mode 100644
index 0000000..e79f8cc
--- /dev/null
+++ b/geronimo-opentracing-osgi/src/main/resources/META-INF/services/org.apache.geronimo.microprofile.opentracing.common.config.GeronimoOpenTracingConfig
@@ -0,0 +1 @@
+org.apache.geronimo.microprofile.opentracing.osgi.ConfigAdminOpenTracingConfig
diff --git a/geronimo-opentracing-osgi/src/main/resources/META-INF/services/org.apache.geronimo.microprofile.opentracing.common.spi.Container b/geronimo-opentracing-osgi/src/main/resources/META-INF/services/org.apache.geronimo.microprofile.opentracing.common.spi.Container
new file mode 100644
index 0000000..7ae90bd
--- /dev/null
+++ b/geronimo-opentracing-osgi/src/main/resources/META-INF/services/org.apache.geronimo.microprofile.opentracing.common.spi.Container
@@ -0,0 +1 @@
+org.apache.geronimo.microprofile.opentracing.osgi.OSGiContainer
diff --git a/geronimo-opentracing-osgi/src/test/java/org/apache/geronimo/microprofile/opentracing/osgi/KarafTest.java b/geronimo-opentracing-osgi/src/test/java/org/apache/geronimo/microprofile/opentracing/osgi/KarafTest.java
new file mode 100644
index 0000000..d66ac43
--- /dev/null
+++ b/geronimo-opentracing-osgi/src/test/java/org/apache/geronimo/microprofile/opentracing/osgi/KarafTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.geronimo.microprofile.opentracing.osgi;
+
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.url;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+import static org.testng.Assert.assertNotNull;
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+import javax.inject.Inject;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+import io.opentracing.Tracer;
+
+@Ignore("likely need more love to work")
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class KarafTest {
+ @Inject
+ private Tracer tracer;
+
+ @Configuration
+ public Option[] config() throws MalformedURLException {
+ final String karafVersion = "4.2.1";
+ return options(
+ karafDistributionConfiguration()
+ .frameworkUrl(maven()
+ .groupId("org.apache.karaf")
+ .artifactId("apache-karaf")
+ .version(karafVersion)
+ .type("tar.gz"))
+ .unpackDirectory(new File("target/karaf"))
+ .useDeployFolder(false)
+ .runEmbedded(true),
+ keepRuntimeFolder(),
+ features(url(new File("src/test/resources/features.xml").toURI().toURL().toExternalForm()), "test")
+ );
+ }
+
+ @Test
+ public void ensureServicesAreRegistered() {
+ assertNotNull(tracer);
+ }
+}
diff --git a/geronimo-opentracing-osgi/src/test/java/org/apache/geronimo/microprofile/opentracing/osgi/endpoint/HiWorld.java b/geronimo-opentracing-osgi/src/test/java/org/apache/geronimo/microprofile/opentracing/osgi/endpoint/HiWorld.java
new file mode 100644
index 0000000..946b0ac
--- /dev/null
+++ b/geronimo-opentracing-osgi/src/test/java/org/apache/geronimo/microprofile/opentracing/osgi/endpoint/HiWorld.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.geronimo.microprofile.opentracing.osgi.endpoint;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("hi")
+public class HiWorld {
+ @GET
+ public String get() {
+ return "world";
+ }
+}
diff --git a/geronimo-opentracing-osgi/src/test/resources/features.xml b/geronimo-opentracing-osgi/src/test/resources/features.xml
new file mode 100644
index 0000000..ae0ed22
--- /dev/null
+++ b/geronimo-opentracing-osgi/src/test/resources/features.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<features name="test-1.0.0"
+ xmlns="http://karaf.apache.org/xmlns/features/v1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://karaf.apache.org/xmlns/features/v1.3.0
+ http://karaf.apache.org/xmlns/features/v1.3.0">
+ <repository>mvn:org.ops4j.pax.cdi/pax-cdi-features/1.0.0/xml/features</repository>
+
+ <feature name="test" version="1.0.0" description="Test setup">
+ <feature prerequisite="true">wrap</feature>
+ <feature prerequisite="true">http-whiteboard</feature>
+ <!-- todo placeholders -->
+ <bundle>mvn:org.apache.servicemix.specs:org.apache.servicemix.specs.jaxrs-api-2.1:2.9.1</bundle>
+ <bundle>wrap:mvn:io.opentracing/opentracing-api/0.31.0</bundle>
+ <bundle>mvn:http://repo.apache.maven.org/maven2/!org.eclipse.microprofile.opentracing:microprofile-opentracing-api:1.1</bundle>
+ <bundle start="true">mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.1</bundle>
+ </feature>
+</features>
diff --git a/geronimo-opentracing/pom.xml b/geronimo-opentracing/pom.xml
index 0bcbfda..89e175a 100644
--- a/geronimo-opentracing/pom.xml
+++ b/geronimo-opentracing/pom.xml
@@ -45,6 +45,12 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.geronimo</groupId>
<artifactId>geronimo-opentracing-common</artifactId>
<version>${project.version}</version>
@@ -61,7 +67,7 @@
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
- <version>2.0.5</version>
+ <version>2.0.7</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -73,7 +79,7 @@
<dependency>
<groupId>org.apache.meecrowave</groupId>
<artifactId>meecrowave-arquillian</artifactId>
- <version>1.2.1</version>
+ <version>1.2.3</version>
<scope>test</scope>
<exclusions>
<exclusion>
@@ -85,7 +91,7 @@
<dependency>
<groupId>org.eclipse.microprofile.opentracing</groupId>
<artifactId>microprofile-opentracing-tck</artifactId>
- <version>1.1</version>
+ <version>1.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
@@ -110,6 +116,12 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.config</groupId>
+ <artifactId>geronimo-config-impl</artifactId>
+ <version>1.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/geronimo-opentracing/src/main/java/org/apache/geronimo/microprofile/opentracing/microprofile/cdi/OpenTracingExtension.java b/geronimo-opentracing/src/main/java/org/apache/geronimo/microprofile/opentracing/microprofile/cdi/OpenTracingExtension.java
index f9c1e0d..dfd4e1d 100644
--- a/geronimo-opentracing/src/main/java/org/apache/geronimo/microprofile/opentracing/microprofile/cdi/OpenTracingExtension.java
+++ b/geronimo-opentracing/src/main/java/org/apache/geronimo/microprofile/opentracing/microprofile/cdi/OpenTracingExtension.java
@@ -36,11 +36,16 @@
import javax.ws.rs.Path;
import org.apache.geronimo.microprofile.opentracing.common.config.GeronimoOpenTracingConfig;
+import org.apache.geronimo.microprofile.opentracing.common.impl.IdGenerator;
+import org.apache.geronimo.microprofile.opentracing.common.microprofile.client.OpenTracingClientRequestFilter;
+import org.apache.geronimo.microprofile.opentracing.common.microprofile.client.OpenTracingClientResponseFilter;
import org.apache.geronimo.microprofile.opentracing.common.microprofile.thread.OpenTracingExecutorService;
import org.apache.geronimo.microprofile.opentracing.microprofile.zipkin.CdiZipkinConverter;
import org.apache.geronimo.microprofile.opentracing.microprofile.zipkin.CdiZipkinLogger;
import org.eclipse.microprofile.opentracing.Traced;
+import io.opentracing.ScopeManager;
+
public class OpenTracingExtension implements Extension {
private GeronimoOpenTracingConfig config;
@@ -54,6 +59,41 @@
useZipkinLogger = useZipkin && Boolean.parseBoolean(config.read("span.converter.zipkin.logger.active", "true"));
}
+ void vetoDefaultConfigIfScanned(@Observes final ProcessAnnotatedType<GeronimoOpenTracingConfig> config) {
+ if (config.getAnnotatedType().getJavaClass().getName()
+ .equals("org.apache.geronimo.microprofile.opentracing.common.config.DefaultOpenTracingConfig")) {
+ config.veto();
+ }
+ }
+
+ void vetoDefaultScopeManagerIfScanned(@Observes final ProcessAnnotatedType<ScopeManager> manager) {
+ if (manager.getAnnotatedType().getJavaClass().getName()
+ .equals("org.apache.geronimo.microprofile.opentracing.common.impl.ScopeManagerImpl")) {
+ manager.veto();
+ }
+ }
+
+ void vetoDefaultIdGeneratorIfScanned(@Observes final ProcessAnnotatedType<IdGenerator> generator) {
+ if (generator.getAnnotatedType().getJavaClass().getName()
+ .equals("org.apache.geronimo.microprofile.opentracing.common.impl.IdGenerator")) {
+ generator.veto();
+ }
+ }
+
+ void vetoClientRequestTracingIfScanned(@Observes final ProcessAnnotatedType<OpenTracingClientRequestFilter> clientFilter) {
+ if (clientFilter.getAnnotatedType().getJavaClass().getName()
+ .equals("org.apache.geronimo.microprofile.opentracing.common.microprofile.client.OpenTracingClientRequestFilter")) {
+ clientFilter.veto();
+ }
+ }
+
+ void vetoClientResponseTracingIfScanned(@Observes final ProcessAnnotatedType<OpenTracingClientResponseFilter> clientFilter) {
+ if (clientFilter.getAnnotatedType().getJavaClass().getName()
+ .equals("org.apache.geronimo.microprofile.opentracing.common.microprofile.client.OpenTracingClientResponseFilter")) {
+ clientFilter.veto();
+ }
+ }
+
void zipkinConverterToggle(@Observes final ProcessAnnotatedType<CdiZipkinConverter> onZipkinConverter) {
if (!useZipkin) {
onZipkinConverter.veto();
diff --git a/geronimo-opentracing/src/main/java/org/apache/geronimo/microprofile/opentracing/microprofile/cdi/TracedInterceptor.java b/geronimo-opentracing/src/main/java/org/apache/geronimo/microprofile/opentracing/microprofile/cdi/TracedInterceptor.java
index 80d3f1a..917946f 100644
--- a/geronimo-opentracing/src/main/java/org/apache/geronimo/microprofile/opentracing/microprofile/cdi/TracedInterceptor.java
+++ b/geronimo-opentracing/src/main/java/org/apache/geronimo/microprofile/opentracing/microprofile/cdi/TracedInterceptor.java
@@ -16,10 +16,14 @@
*/
package org.apache.geronimo.microprofile.opentracing.microprofile.cdi;
+import static java.util.Collections.singletonMap;
import static java.util.Objects.requireNonNull;
import java.io.Serializable;
import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -37,7 +41,9 @@
import org.eclipse.microprofile.opentracing.Traced;
import io.opentracing.Scope;
+import io.opentracing.Span;
import io.opentracing.Tracer;
+import io.opentracing.tag.Tags;
@Traced
@Interceptor
@@ -81,8 +87,24 @@
if (parent != null) {
spanBuilder.asChildOf(parent.span());
}
- try (final Scope scope = spanBuilder.startActive(true)) {
+ Scope scope = null;
+ try {
+ scope = spanBuilder.startActive(true);
return context.proceed();
+ } catch (final RuntimeException re) {
+ if (scope != null) {
+ final Span span = scope.span();
+ Tags.ERROR.set(span, true);
+ final Map<String, Object> logs = new LinkedHashMap<>();
+ logs.put("event", Tags.ERROR.getKey());
+ logs.put("error.object", re);
+ span.log(logs);
+ }
+ throw re;
+ } finally {
+ if (scope != null) {
+ scope.close();
+ }
}
}
diff --git a/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/CxfCdiWorkaround.java b/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/CxfCdiWorkaround.java
deleted file mode 100644
index d43eec7..0000000
--- a/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/CxfCdiWorkaround.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.apache.geronimo.microprofile.opentracing.tck.setup;
-
-import static java.util.stream.Collectors.toMap;
-
-import java.lang.reflect.Field;
-import java.util.Map;
-
-import javax.enterprise.context.ApplicationScoped;
-
-import org.apache.cxf.cdi.extension.JAXRSServerFactoryCustomizationExtension;
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
-import org.apache.cxf.message.Message;
-
-@ApplicationScoped
-public class CxfCdiWorkaround implements JAXRSServerFactoryCustomizationExtension {
- @Override
- public void customize(final JAXRSServerFactoryBean bean) {
- final Map<Class<?>, ResourceProvider> providers = getProviders(bean);
- final Map<Class<?>, ResourceProvider> workaround = providers.entrySet().stream()
- .collect(toMap(Map.Entry::getKey, e -> new WorkaroundProvider(e.getValue())));
- providers.clear();
- providers.putAll(workaround);
- }
-
- private Map<Class<?>, ResourceProvider> getProviders(final JAXRSServerFactoryBean bean) {
- try {
- final Field f = JAXRSServerFactoryBean.class.getDeclaredField("resourceProviders");
- f.setAccessible(true);
- return (Map<Class<?>, ResourceProvider>) f.get(bean);
- } catch (final Exception e) {
- throw new IllegalStateException(e);
- }
- }
-
- private static class WorkaroundProvider implements ResourceProvider {
- private final ResourceProvider delegate;
-
- private WorkaroundProvider(final ResourceProvider value) {
- this.delegate = value;
- }
-
- @Override
- public Object getInstance(final Message m) {
- return delegate.getInstance(m);
- }
-
- @Override
- public void releaseInstance(final Message m, final Object o) {
- // no-op: don't release otherwise we are not thread safe for @Dependent, this leaks but ok in *this* context
- }
-
- @Override
- public Class<?> getResourceClass() {
- return delegate.getResourceClass();
- }
-
- @Override
- public boolean isSingleton() {
- return true;
- }
- }
-}
diff --git a/geronimo-opentracing/src/test/resources/tck-dev.xml b/geronimo-opentracing/src/test/resources/tck-dev.xml
index d79e780..98e5909 100644
--- a/geronimo-opentracing/src/test/resources/tck-dev.xml
+++ b/geronimo-opentracing/src/test/resources/tck-dev.xml
@@ -16,11 +16,10 @@
limitations under the License.
-->
<suite name="microprofile-opentracing-TCK" verbose="2" configfailurepolicy="continue">
- <test name="microprofile-opentracing 1.0 TCK">
+ <test name="microprofile-opentracing TCK">
<classes>
- <class name="org.eclipse.microprofile.opentracing.tck.OpentracingClientTests">
+ <class name="org.eclipse.microprofile.opentracing.tck.OpenTracingHTTPPathNameTests">
<methods>
- <include name="testMultithreadedNestedSpans"/>
</methods>
</class>
</classes>
diff --git a/pom.xml b/pom.xml
index 6a5f53e..32d243f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,7 +45,7 @@
<dependency>
<groupId>org.eclipse.microprofile.opentracing</groupId>
<artifactId>microprofile-opentracing-api</artifactId>
- <version>1.1</version>
+ <version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -92,11 +92,18 @@
<modules>
<module>geronimo-opentracing-common</module>
<module>geronimo-opentracing</module>
+ <module>geronimo-opentracing-osgi</module>
</modules>
<build>
<plugins>
<plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>4.1.0</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>