Support Tomee JAX-WS (OpenEJB/CXF)
MODIFY
instrumentation/jaxws/jaxws-2.0-cxf-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/CxfInstrumentationModule.java
instrumentation/jaxws/jaxws-2.0-cxf-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/CxfInstrumentationModule.java
@@ -19,6 +19,6 @@ public class CxfInstrumentationModule extends InstrumentationModule {
@Override
public List<TypeInstrumentation> typeInstrumentations() {
- return Collections.singletonList(new EndpointImplTypeInstrumentation());
+ return Collections.singletonList(new JaxWsServerFactoryBeanInstrumentation());
}
}

DELETE
instrumentation/jaxws/jaxws-2.0-cxf-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/EndpointImplTypeInstrumentation.java
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.javaagent.instrumentation.cxf;
-
-import static net.bytebuddy.matcher.ElementMatchers.named;
-import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
-
-import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
-import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
-import net.bytebuddy.asm.Advice;
-import net.bytebuddy.description.type.TypeDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.cxf.jaxws.EndpointImpl;
-
-public class EndpointImplTypeInstrumentation implements TypeInstrumentation {
-
- @Override
- public ElementMatcher<TypeDescription> typeMatcher() {
- return named("org.apache.cxf.jaxws.EndpointImpl");
- }
-
- @Override
- public void transform(TypeTransformer transformer) {
- transformer.applyAdviceToMethod(
- named("getServer").and(takesArgument(0, named(String.class.getName()))),
- EndpointImplTypeInstrumentation.class.getName() + "$GetServerAdvice");
- }
-
- @SuppressWarnings("unused")
- public static class GetServerAdvice {
-
- @Advice.OnMethodEnter(suppress = Throwable.class)
- public static void onEnter(@Advice.This EndpointImpl endpoint) {
- if (endpoint.isPublished()) {
- return;
- }
- endpoint.getInInterceptors().add(new TracingStartInInterceptor());
- endpoint.getInInterceptors().add(new TracingEndInInterceptor());
- endpoint.getOutFaultInterceptors().add(new TracingOutFaultInterceptor());
- }
- }
-}

ADD
instrumentation/jaxws/jaxws-2.0-cxf-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/JaxWsServerFactoryBeanInstrumentation.java
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.javaagent.instrumentation.cxf;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.returns;
+import static net.bytebuddy.matcher.ElementMatchers.takesNoArguments;
+
+import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
+import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
+import net.bytebuddy.asm.Advice;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.Server;
+
+public class JaxWsServerFactoryBeanInstrumentation implements TypeInstrumentation {
+
+ @Override
+ public ElementMatcher<TypeDescription> typeMatcher() {
+ // TODO (trask) add test for Tomee JAX-WS (which is based on OpenEJB/CXF)
+ // in the meantime:
+ // it's important to instrument this underlying class, instead of
+ // org.apache.cxf.jaxws.EndpointImpl, because Tomee JAX-WS (which is based on OpenEJB/CXF) has
+ // it's own copy/variant of that class (org.apache.openejb.server.cxf.CxfEndpoint)
+ return named("org.apache.cxf.jaxws.JaxWsServerFactoryBean");
+ }
+
+ @Override
+ public void transform(TypeTransformer transformer) {
+ transformer.applyAdviceToMethod(
+ named("create")
+ .and(takesNoArguments().and(returns(named("org.apache.cxf.endpoint.Server")))),
+ JaxWsServerFactoryBeanInstrumentation.class.getName() + "$CreateAdvice");
+ }
+
+ @SuppressWarnings("unused")
+ public static class CreateAdvice {
+
+ @Advice.OnMethodExit(suppress = Throwable.class)
+ public static void onEnter(@Advice.Return Server server) {
+ Endpoint endpoint = server.getEndpoint();
+ endpoint.getInInterceptors().add(new TracingStartInInterceptor());
+ endpoint.getInInterceptors().add(new TracingEndInInterceptor());
+ endpoint.getOutFaultInterceptors().add(new TracingOutFaultInterceptor());
+ }
+ }
+}

MODIFY
instrumentation/jaxws/jaxws-2.0-cxf-3.0/library/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/TracingEndInInterceptor.java
instrumentation/jaxws/jaxws-2.0-cxf-3.0/library/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/TracingEndInInterceptor.java
@@ -11,7 +11,7 @@ import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
-public class TracingEndInInterceptor extends AbstractPhaseInterceptor {
+public class TracingEndInInterceptor extends AbstractPhaseInterceptor<Message> {
public TracingEndInInterceptor() {
super(Phase.POST_INVOKE);
}

MODIFY
instrumentation/jaxws/jaxws-2.0-cxf-3.0/library/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/TracingOutFaultInterceptor.java
instrumentation/jaxws/jaxws-2.0-cxf-3.0/library/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/TracingOutFaultInterceptor.java
@@ -11,7 +11,7 @@ import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
-public class TracingOutFaultInterceptor extends AbstractPhaseInterceptor {
+public class TracingOutFaultInterceptor extends AbstractPhaseInterceptor<Message> {
public TracingOutFaultInterceptor() {
super(Phase.SETUP);
}

MODIFY
instrumentation/jaxws/jaxws-2.0-cxf-3.0/library/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/TracingStartInInterceptor.java
instrumentation/jaxws/jaxws-2.0-cxf-3.0/library/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/TracingStartInInterceptor.java
@@ -11,7 +11,7 @@ import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
-public class TracingStartInInterceptor extends AbstractPhaseInterceptor {
+public class TracingStartInInterceptor extends AbstractPhaseInterceptor<Message> {
public TracingStartInInterceptor() {
super(Phase.PRE_INVOKE);

Support Tomee JAX-WS (OpenEJB/CXF) (#3303)