Repository: cxf Updated Branches: refs/heads/master 09c7f359e -> d649aed45
CXF-6360: Integration with Apache HTrace. Evolving sample application with HBase support. Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d649aed4 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d649aed4 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d649aed4 Branch: refs/heads/master Commit: d649aed452bb668ec575bd140c7a085e12b4b255 Parents: 09c7f35 Author: reta <[email protected]> Authored: Sun Jul 26 21:53:21 2015 -0400 Committer: reta <[email protected]> Committed: Sun Jul 26 21:53:21 2015 -0400 ---------------------------------------------------------------------- .../tracing/server/CatalogApplication.java | 62 ++++++++++++++++++++ .../java/demo/jaxrs/tracing/server/Server.java | 34 +---------- 2 files changed, 65 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/d649aed4/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java new file mode 100644 index 0000000..0b15241 --- /dev/null +++ b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java @@ -0,0 +1,62 @@ +/** + * 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 demo.jaxrs.tracing.server; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider; +import org.apache.cxf.tracing.htrace.jaxrs.HTraceFeature; +import org.apache.htrace.HTraceConfiguration; +import org.apache.htrace.impl.AlwaysSampler; + +import demo.jaxrs.tracing.conf.TracingConfiguration; + +@ApplicationPath("/") +public class CatalogApplication extends Application { + @Override + public Set<Object> getSingletons() { + try { + return new HashSet<Object>( + Arrays.asList( + new Catalog(), + new HTraceFeature(HTraceConfiguration.fromMap(getTracingProperties())), + new JsrJsonpProvider() + ) + ); + } catch (final IOException ex) { + throw new RuntimeException("Failed to initaliaze JAX-RS application", ex); + } + } + + private static Map<String, String> getTracingProperties() { + final Map<String, String> properties = new HashMap<String, String>(); + properties.put("span.receiver", TracingConfiguration.SPAN_RECEIVER.getName()); + properties.put("sampler", AlwaysSampler.class.getName()); + return properties; + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/d649aed4/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Server.java ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Server.java b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Server.java index 15ad5bd..407300b 100644 --- a/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Server.java +++ b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Server.java @@ -19,34 +19,11 @@ package demo.jaxrs.tracing.server; -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.lang.StringUtils; -import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider; import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; -import org.apache.cxf.tracing.htrace.jaxrs.HTraceFeature; -import org.apache.htrace.HTraceConfiguration; -import org.apache.htrace.impl.AlwaysSampler; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; -import demo.jaxrs.tracing.conf.TracingConfiguration; - public class Server { - public static class TracingFeature extends HTraceFeature { - public TracingFeature() { - super(HTraceConfiguration.fromMap(getTracingProperties())); - } - - private static Map<String, String> getTracingProperties() { - final Map<String, String> properties = new HashMap<String, String>(); - properties.put("span.receiver", TracingConfiguration.SPAN_RECEIVER.getName()); - properties.put("sampler", AlwaysSampler.class.getName()); - return properties; - } - } - protected Server() throws Exception { org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(9000); @@ -56,14 +33,9 @@ public class Server { context.setContextPath("/"); context.addServlet(servletHolder, "/*"); - servletHolder.setInitParameter("jaxrs.serviceClasses", Catalog.class.getName()); - servletHolder.setInitParameter("jaxrs.features", TracingFeature.class.getName()); - servletHolder.setInitParameter("jaxrs.providers", StringUtils.join( - new String[] { - JsrJsonpProvider.class.getName() - }, ",") - ); - + servletHolder.setInitParameter("javax.ws.rs.Application", + CatalogApplication.class.getName()); + server.setHandler(context); server.start(); server.join();
