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] Updating the papckage with jaxrs specific classes
Date Fri, 05 Jun 2015 13:00:29 GMT
Repository: cxf
Updated Branches:
  refs/heads/master f5655d81e -> 23c0c7309


[CXF-6360] Updating the papckage with jaxrs specific classes


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

Branch: refs/heads/master
Commit: 23c0c73092caf223e621617200a55f1613bbef0d
Parents: f5655d8
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Jun 5 14:00:10 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Jun 5 14:00:10 2015 +0100

----------------------------------------------------------------------
 .../tracing/htrace/HTraceContextProvider.java   |  42 ------
 .../cxf/jaxrs/tracing/htrace/HTraceFeature.java |  71 ----------
 .../jaxrs/tracing/htrace/HTraceProvider.java    | 139 -------------------
 .../htrace/jaxrs/HTraceContextProvider.java     |  42 ++++++
 .../cxf/tracing/htrace/jaxrs/HTraceFeature.java |  71 ++++++++++
 .../tracing/htrace/jaxrs/HTraceProvider.java    | 139 +++++++++++++++++++
 .../htrace/HTraceTracingCustomHeadersTest.java  |   3 +-
 .../jaxrs/tracing/htrace/HTraceTracingTest.java |   3 +-
 8 files changed, 256 insertions(+), 254 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/23c0c730/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java
deleted file mode 100644
index 12abac9..0000000
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.cxf.jaxrs.tracing.htrace;
-
-import javax.ws.rs.ext.Provider;
-
-import org.apache.cxf.jaxrs.ext.ContextProvider;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.tracing.TracerContext;
-import org.apache.cxf.tracing.htrace.HTraceTracerContext;
-import org.apache.htrace.Sampler;
-import org.apache.htrace.impl.NeverSampler;
-
-@Provider
-public class HTraceContextProvider implements ContextProvider< TracerContext > {
-    private Sampler< ? > sampler = NeverSampler.INSTANCE;
-    
-    public HTraceContextProvider(final Sampler< ? > sampler) {
-        this.sampler = sampler;
-    }
-
-    @Override
-    public TracerContext createContext(final Message message) {
-        return new HTraceTracerContext(sampler);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/23c0c730/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java
deleted file mode 100644
index 2b14f99..0000000
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * 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.cxf.jaxrs.tracing.htrace;
-
-import java.util.Arrays;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.feature.AbstractFeature;
-import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
-import org.apache.htrace.HTraceConfiguration;
-import org.apache.htrace.Sampler;
-import org.apache.htrace.SamplerBuilder;
-import org.apache.htrace.SpanReceiver;
-import org.apache.htrace.SpanReceiverBuilder;
-import org.apache.htrace.Trace;
-
-public class HTraceFeature extends AbstractFeature {
-    private HTraceConfiguration configuration;
-    
-    public HTraceFeature() {
-        this(HTraceConfiguration.EMPTY);
-    }
-
-    public HTraceFeature(final HTraceConfiguration configuration) {
-        this.configuration = configuration;
-    }
-
-    @Override
-    public void initialize(final Server server, final Bus bus) {
-        final ServerProviderFactory providerFactory = (ServerProviderFactory)server
-            .getEndpoint()
-            .get(ServerProviderFactory.class.getName());
-
-        final Sampler< ? > sampler = new SamplerBuilder(configuration).build();
-        final SpanReceiver spanReceiver = new SpanReceiverBuilder(configuration).build();
-        
-        if (spanReceiver != null) {
-            Trace.addReceiver(spanReceiver);
-        }
-
-        if (providerFactory != null) {
-            providerFactory.setUserProviders(Arrays.asList(new HTraceProvider(sampler), 
-                new HTraceContextProvider(sampler)));
-        }
-    }
-    
-    public void setConfiguration(final HTraceConfiguration configuration) {
-        this.configuration = configuration;
-    }
-    
-    public HTraceConfiguration getConfiguration() {
-        return configuration;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/23c0c730/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
deleted file mode 100644
index 5514bcc..0000000
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * 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.cxf.jaxrs.tracing.htrace;
-
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-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.core.MultivaluedMap;
-import javax.ws.rs.ext.Provider;
-
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.tracing.TracerHeaders;
-import org.apache.htrace.Sampler;
-import org.apache.htrace.Trace;
-import org.apache.htrace.TraceInfo;
-import org.apache.htrace.TraceScope;
-import org.apache.htrace.Tracer;
-import org.apache.htrace.impl.NeverSampler;
-
-import static org.apache.cxf.tracing.TracerHeaders.DEFAULT_HEADER_SPAN_ID;
-import static org.apache.cxf.tracing.TracerHeaders.DEFAULT_HEADER_TRACE_ID;
-
-@Provider
-public class HTraceProvider implements ContainerRequestFilter, ContainerResponseFilter {

-    private static final Logger LOG = LogUtils.getL7dLogger(HTraceProvider.class);
-    private static final String TRACE_SPAN = "org.apache.cxf.jaxrs.tracing.htrace.span";
-        
-    private final Sampler< ? > sampler;
-    
-    public HTraceProvider() {
-        this(NeverSampler.INSTANCE);
-    }
-
-    public HTraceProvider(final Sampler< ? > sampler) {
-        this.sampler = sampler;
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public void filter(final ContainerRequestContext requestContext) throws IOException {
-        final MultivaluedMap<String, String> headers = requestContext.getHeaders();
-        
-        // Try to extract the Trace Id value from the request header
-        final long traceId = getFirstValueOrDefault(headers, getTraceIdHeader(), 
-            Tracer.DONT_TRACE.traceId);
-        
-        // Try to extract the Span Id value from the request header
-        final long spanId = getFirstValueOrDefault(headers, getSpanIdHeader(), 
-            Tracer.DONT_TRACE.spanId); 
-        
-        if (traceId != Tracer.DONT_TRACE.traceId && spanId != Tracer.DONT_TRACE.spanId)
{
-            requestContext.setProperty(TRACE_SPAN, Trace.startSpan(requestContext.getUriInfo().getPath(),

-                (Sampler< TraceInfo >)sampler, new TraceInfo(traceId, spanId)));
-        }
-    }
-    
-    @Override
-    public void filter(final ContainerRequestContext requestContext,
-            final ContainerResponseContext responseContext) throws IOException {
-        final MultivaluedMap<String, String> headers = requestContext.getHeaders();
-        
-        final String traceIdHeader = getTraceIdHeader();
-        final String spanIdHeader = getSpanIdHeader();
-
-        // Transfer tracing headers into the response headers
-        if (headers.containsKey(traceIdHeader) && headers.containsKey(spanIdHeader))
{
-            responseContext.getHeaders().add(traceIdHeader, headers.getFirst(traceIdHeader));
-            responseContext.getHeaders().add(spanIdHeader, headers.getFirst(spanIdHeader));
-        }
-        
-        final Object value = requestContext.getProperty(TRACE_SPAN);
-        if (value instanceof TraceScope) {
-            final TraceScope span = (TraceScope)value;
-            span.close();
-        }
-    }
-    
-    private static Long getFirstValueOrDefault(final MultivaluedMap<String, String>
headers, 
-            final String header, final long defaultValue) {
-        String value = headers.getFirst(header);
-        if (value != null) {
-            try {
-                return Long.parseLong(value);
-            } catch (NumberFormatException ex) {
-                LOG.log(Level.FINE, String.format("Unable to parse '%s' header value to long
number", header), ex);
-            }
-        }
-        return defaultValue;
-    }
-    
-    private static String getSpanIdHeader() {
-        return getHeaderOrDefault(TracerHeaders.HEADER_SPAN_ID, DEFAULT_HEADER_SPAN_ID);
-    }
-    
-    private static String getTraceIdHeader() {
-        return getHeaderOrDefault(TracerHeaders.HEADER_TRACE_ID, DEFAULT_HEADER_TRACE_ID);
-    }
-
-    private static String getHeaderOrDefault(final String property, final String fallback)
{
-        final Message message = JAXRSUtils.getCurrentMessage();
-        
-        if (message != null) {
-            final Object header = message.getContextualProperty(property);
-            
-            if (header instanceof String) {
-                final String name = (String)header;
-                if (!StringUtils.isEmpty(name)) {
-                    return name;
-                }
-            }
-        }
-        
-        return fallback;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/23c0c730/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceContextProvider.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceContextProvider.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceContextProvider.java
new file mode 100644
index 0000000..453f0d4
--- /dev/null
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceContextProvider.java
@@ -0,0 +1,42 @@
+/**
+ * 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.cxf.tracing.htrace.jaxrs;
+
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.jaxrs.ext.ContextProvider;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.tracing.TracerContext;
+import org.apache.cxf.tracing.htrace.HTraceTracerContext;
+import org.apache.htrace.Sampler;
+import org.apache.htrace.impl.NeverSampler;
+
+@Provider
+public class HTraceContextProvider implements ContextProvider< TracerContext > {
+    private Sampler< ? > sampler = NeverSampler.INSTANCE;
+    
+    public HTraceContextProvider(final Sampler< ? > sampler) {
+        this.sampler = sampler;
+    }
+
+    @Override
+    public TracerContext createContext(final Message message) {
+        return new HTraceTracerContext(sampler);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/23c0c730/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceFeature.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceFeature.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceFeature.java
new file mode 100644
index 0000000..6409846
--- /dev/null
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceFeature.java
@@ -0,0 +1,71 @@
+/**
+ * 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.cxf.tracing.htrace.jaxrs;
+
+import java.util.Arrays;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
+import org.apache.htrace.HTraceConfiguration;
+import org.apache.htrace.Sampler;
+import org.apache.htrace.SamplerBuilder;
+import org.apache.htrace.SpanReceiver;
+import org.apache.htrace.SpanReceiverBuilder;
+import org.apache.htrace.Trace;
+
+public class HTraceFeature extends AbstractFeature {
+    private HTraceConfiguration configuration;
+    
+    public HTraceFeature() {
+        this(HTraceConfiguration.EMPTY);
+    }
+
+    public HTraceFeature(final HTraceConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    @Override
+    public void initialize(final Server server, final Bus bus) {
+        final ServerProviderFactory providerFactory = (ServerProviderFactory)server
+            .getEndpoint()
+            .get(ServerProviderFactory.class.getName());
+
+        final Sampler< ? > sampler = new SamplerBuilder(configuration).build();
+        final SpanReceiver spanReceiver = new SpanReceiverBuilder(configuration).build();
+        
+        if (spanReceiver != null) {
+            Trace.addReceiver(spanReceiver);
+        }
+
+        if (providerFactory != null) {
+            providerFactory.setUserProviders(Arrays.asList(new HTraceProvider(sampler), 
+                new HTraceContextProvider(sampler)));
+        }
+    }
+    
+    public void setConfiguration(final HTraceConfiguration configuration) {
+        this.configuration = configuration;
+    }
+    
+    public HTraceConfiguration getConfiguration() {
+        return configuration;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/23c0c730/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
new file mode 100644
index 0000000..2479157
--- /dev/null
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceProvider.java
@@ -0,0 +1,139 @@
+/**
+ * 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.cxf.tracing.htrace.jaxrs;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+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.core.MultivaluedMap;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.tracing.TracerHeaders;
+import org.apache.htrace.Sampler;
+import org.apache.htrace.Trace;
+import org.apache.htrace.TraceInfo;
+import org.apache.htrace.TraceScope;
+import org.apache.htrace.Tracer;
+import org.apache.htrace.impl.NeverSampler;
+
+import static org.apache.cxf.tracing.TracerHeaders.DEFAULT_HEADER_SPAN_ID;
+import static org.apache.cxf.tracing.TracerHeaders.DEFAULT_HEADER_TRACE_ID;
+
+@Provider
+public class HTraceProvider implements ContainerRequestFilter, ContainerResponseFilter {

+    private static final Logger LOG = LogUtils.getL7dLogger(HTraceProvider.class);
+    private static final String TRACE_SPAN = "org.apache.cxf.jaxrs.tracing.htrace.span";
+        
+    private final Sampler< ? > sampler;
+    
+    public HTraceProvider() {
+        this(NeverSampler.INSTANCE);
+    }
+
+    public HTraceProvider(final Sampler< ? > sampler) {
+        this.sampler = sampler;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void filter(final ContainerRequestContext requestContext) throws IOException {
+        final MultivaluedMap<String, String> headers = requestContext.getHeaders();
+        
+        // Try to extract the Trace Id value from the request header
+        final long traceId = getFirstValueOrDefault(headers, getTraceIdHeader(), 
+            Tracer.DONT_TRACE.traceId);
+        
+        // Try to extract the Span Id value from the request header
+        final long spanId = getFirstValueOrDefault(headers, getSpanIdHeader(), 
+            Tracer.DONT_TRACE.spanId); 
+        
+        if (traceId != Tracer.DONT_TRACE.traceId && spanId != Tracer.DONT_TRACE.spanId)
{
+            requestContext.setProperty(TRACE_SPAN, Trace.startSpan(requestContext.getUriInfo().getPath(),

+                (Sampler< TraceInfo >)sampler, new TraceInfo(traceId, spanId)));
+        }
+    }
+    
+    @Override
+    public void filter(final ContainerRequestContext requestContext,
+            final ContainerResponseContext responseContext) throws IOException {
+        final MultivaluedMap<String, String> headers = requestContext.getHeaders();
+        
+        final String traceIdHeader = getTraceIdHeader();
+        final String spanIdHeader = getSpanIdHeader();
+
+        // Transfer tracing headers into the response headers
+        if (headers.containsKey(traceIdHeader) && headers.containsKey(spanIdHeader))
{
+            responseContext.getHeaders().add(traceIdHeader, headers.getFirst(traceIdHeader));
+            responseContext.getHeaders().add(spanIdHeader, headers.getFirst(spanIdHeader));
+        }
+        
+        final Object value = requestContext.getProperty(TRACE_SPAN);
+        if (value instanceof TraceScope) {
+            final TraceScope span = (TraceScope)value;
+            span.close();
+        }
+    }
+    
+    private static Long getFirstValueOrDefault(final MultivaluedMap<String, String>
headers, 
+            final String header, final long defaultValue) {
+        String value = headers.getFirst(header);
+        if (value != null) {
+            try {
+                return Long.parseLong(value);
+            } catch (NumberFormatException ex) {
+                LOG.log(Level.FINE, String.format("Unable to parse '%s' header value to long
number", header), ex);
+            }
+        }
+        return defaultValue;
+    }
+    
+    private static String getSpanIdHeader() {
+        return getHeaderOrDefault(TracerHeaders.HEADER_SPAN_ID, DEFAULT_HEADER_SPAN_ID);
+    }
+    
+    private static String getTraceIdHeader() {
+        return getHeaderOrDefault(TracerHeaders.HEADER_TRACE_ID, DEFAULT_HEADER_TRACE_ID);
+    }
+
+    private static String getHeaderOrDefault(final String property, final String fallback)
{
+        final Message message = JAXRSUtils.getCurrentMessage();
+        
+        if (message != null) {
+            final Object header = message.getContextualProperty(property);
+            
+            if (header instanceof String) {
+                final String name = (String)header;
+                if (!StringUtils.isEmpty(name)) {
+                    return name;
+                }
+            }
+        }
+        
+        return fallback;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/23c0c730/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingCustomHeadersTest.java
----------------------------------------------------------------------
diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingCustomHeadersTest.java
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingCustomHeadersTest.java
index ab4f7ba..69fb1a2 100644
--- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingCustomHeadersTest.java
+++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingCustomHeadersTest.java
@@ -32,14 +32,15 @@ import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
-import org.apache.cxf.jaxrs.tracing.htrace.HTraceFeature;
 import org.apache.cxf.systest.jaxrs.tracing.BookStore;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.tracing.TracerHeaders;
+import org.apache.cxf.tracing.htrace.jaxrs.HTraceFeature;
 import org.apache.htrace.HTraceConfiguration;
 import org.apache.htrace.impl.AlwaysSampler;
 import org.apache.htrace.impl.StandardOutSpanReceiver;
+
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/cxf/blob/23c0c730/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
----------------------------------------------------------------------
diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
index 588bc4a..68e5c24 100644
--- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
+++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
@@ -32,13 +32,14 @@ import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
-import org.apache.cxf.jaxrs.tracing.htrace.HTraceFeature;
 import org.apache.cxf.systest.jaxrs.tracing.BookStore;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.tracing.TracerHeaders;
+import org.apache.cxf.tracing.htrace.jaxrs.HTraceFeature;
 import org.apache.htrace.HTraceConfiguration;
 import org.apache.htrace.impl.AlwaysSampler;
+
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Ignore;


Mime
View raw message