cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6360] Trying to keep the abstract HTrace code neutral
Date Wed, 12 Aug 2015 13:43:53 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 405059c0c -> 480332043


[CXF-6360] Trying to keep the abstract HTrace code neutral


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/48033204
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/48033204
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/48033204

Branch: refs/heads/master
Commit: 480332043150dcc96843c3eb7c7c660118bfaf74
Parents: 405059c
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Aug 12 14:43:38 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Aug 12 14:43:38 2015 +0100

----------------------------------------------------------------------
 .../tracing/htrace/AbstractHTraceProvider.java  | 27 +++++---------------
 .../tracing/htrace/jaxrs/HTraceProvider.java    | 20 ++++++++++++++-
 2 files changed, 25 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/48033204/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
index fba817b..8f397a7 100644
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
@@ -18,18 +18,14 @@
  */
 package org.apache.cxf.tracing.htrace;
 
-import java.lang.annotation.Annotation;
 import java.util.List;
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javax.ws.rs.container.ResourceInfo;
-import javax.ws.rs.container.Suspended;
-import javax.ws.rs.core.Context;
-
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.tracing.AbstractTracingProvider;
 import org.apache.htrace.Sampler;
 import org.apache.htrace.Trace;
@@ -43,8 +39,7 @@ public abstract class AbstractHTraceProvider extends AbstractTracingProvider
{
     protected static final String TRACE_SPAN = "org.apache.cxf.tracing.htrace.span";
         
     private final Sampler< ? > sampler;
-    @Context private ResourceInfo resourceInfo;
-    
+        
     public AbstractHTraceProvider(final Sampler< ? > sampler) {
         this.sampler = sampler;
     }
@@ -71,7 +66,7 @@ public abstract class AbstractHTraceProvider extends AbstractTracingProvider
{
                 .build());
         }
         
-        // If the JAX-RS resource is using asynchronous processing mode, the trace
+        // If the service resource is using asynchronous processing mode, the trace
         // scope will be closed in another thread and as such should be detached.
         if (isAsyncResponse()) {
             traceScope.detach();
@@ -93,7 +88,7 @@ public abstract class AbstractHTraceProvider extends AbstractTracingProvider
{
         }
         
         if (span != null) {
-            // If the JAX-RS resource is using asynchronous processing mode, the trace
+            // If the service resource is using asynchronous processing mode, the trace
             // scope has been created in another thread and should be re-attached to the
current 
             // one.
             if (span.isDetached()) {
@@ -105,18 +100,8 @@ public abstract class AbstractHTraceProvider extends AbstractTracingProvider
{
         }
     }
     
-    private boolean isAsyncResponse() {
-        if (resourceInfo != null) {
-            for (final Annotation[] annotations: resourceInfo.getResourceMethod().getParameterAnnotations())
{
-                for (final Annotation annotation: annotations) {
-                    if (annotation.annotationType().equals(Suspended.class)) {
-                        return true;
-                    }
-                }
-            }
-        }
-        
-        return false;
+    protected boolean isAsyncResponse() {
+        return !JAXRSUtils.getCurrentMessage().getExchange().isSynchronous();
     }
     
     private static Long getFirstValueOrDefault(final Map<String, List<String>>
headers, 

http://git-wip-us.apache.org/repos/asf/cxf/blob/48033204/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceProvider.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceProvider.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceProvider.java
index 5f0ff2f..9225220 100644
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceProvider.java
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceProvider.java
@@ -19,11 +19,15 @@
 package org.apache.cxf.tracing.htrace.jaxrs;
 
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerRequestFilter;
 import javax.ws.rs.container.ContainerResponseContext;
 import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.container.ResourceInfo;
+import javax.ws.rs.container.Suspended;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.ext.Provider;
 
 import org.apache.cxf.tracing.htrace.AbstractHTraceProvider;
@@ -33,7 +37,9 @@ import org.apache.htrace.impl.NeverSampler;
 
 @Provider
 public class HTraceProvider extends AbstractHTraceProvider 
-    implements ContainerRequestFilter, ContainerResponseFilter { 
+    implements ContainerRequestFilter, ContainerResponseFilter {
+    @Context 
+    private ResourceInfo resourceInfo;
     public HTraceProvider() {
         this(NeverSampler.INSTANCE);
     }
@@ -59,4 +65,16 @@ public class HTraceProvider extends AbstractHTraceProvider
                             responseContext.getHeaders(), 
                             (TraceScope)requestContext.getProperty(TRACE_SPAN));
     }
+    
+    @Override
+    protected boolean isAsyncResponse() {
+        for (final Annotation[] annotations: resourceInfo.getResourceMethod().getParameterAnnotations())
{
+            for (final Annotation annotation: annotations) {
+                if (annotation.annotationType().equals(Suspended.class)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
 }


Mime
View raw message