Repository: cxf Updated Branches: refs/heads/master fd77d3f33 -> 30fab03d7
[CXF-7164] Remove soap package as the code also supports REST Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/30fab03d Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/30fab03d Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/30fab03d Branch: refs/heads/master Commit: 30fab03d70e5655130e6a1ab3081f3563c40cd48 Parents: fd77d3f Author: Christian Schneider <[email protected]> Authored: Tue Dec 6 14:58:54 2016 +0100 Committer: Christian Schneider <[email protected]> Committed: Tue Dec 6 14:58:54 2016 +0100 ---------------------------------------------------------------------- .../cxf/tracing/brave/CxfClientRequest.java | 49 ++++++++ .../cxf/tracing/brave/CxfServerRequest.java | 48 ++++++++ .../cxf/tracing/brave/HttpResponse200.java | 28 +++++ .../apache/cxf/tracing/brave/ParsedMessage.java | 121 +++++++++++++++++++ .../apache/cxf/tracing/brave/TraceFeature.java | 50 ++++++++ .../cxf/tracing/brave/TraceInInterceptor.java | 58 +++++++++ .../cxf/tracing/brave/TraceOutInterceptor.java | 57 +++++++++ .../brave/soap/CxfHttpClientRequest.java | 49 -------- .../tracing/brave/soap/CxfServerRequest.java | 48 -------- .../cxf/tracing/brave/soap/HttpResponse200.java | 28 ----- .../cxf/tracing/brave/soap/ParsedMessage.java | 121 ------------------- .../cxf/tracing/brave/soap/TraceFeature.java | 50 -------- .../tracing/brave/soap/TraceInInterceptor.java | 58 --------- .../tracing/brave/soap/TraceOutInterceptor.java | 57 --------- .../cxf/tracing/brave/BraveTraceTest.java | 99 +++++++++++++++ .../tracing/brave/LoggingSpanNameProvider.java | 31 +++++ .../org/apache/cxf/tracing/brave/MyService.java | 26 ++++ .../apache/cxf/tracing/brave/MyServiceImpl.java | 28 +++++ .../cxf/tracing/brave/soap/BraveTraceTest.java | 99 --------------- .../brave/soap/LoggingSpanNameProvider.java | 31 ----- .../cxf/tracing/brave/soap/MyService.java | 26 ---- .../cxf/tracing/brave/soap/MyServiceImpl.java | 28 ----- 22 files changed, 595 insertions(+), 595 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/CxfClientRequest.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/CxfClientRequest.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/CxfClientRequest.java new file mode 100644 index 0000000..3b5eff0 --- /dev/null +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/CxfClientRequest.java @@ -0,0 +1,49 @@ +/** + * 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.brave; + +import java.net.URI; + +import com.github.kristofa.brave.http.HttpClientRequest; +import org.apache.cxf.message.Message; + +public class CxfClientRequest implements HttpClientRequest { + + private ParsedMessage message; + + public CxfClientRequest(Message message) { + this.message = new ParsedMessage(message); + } + + @Override + public URI getUri() { + return message.getUri(); + } + + @Override + public String getHttpMethod() { + return message.getHttpMethod(); + } + + @Override + public void addHeader(String header, String value) { + message.addHeader(header, value); + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/CxfServerRequest.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/CxfServerRequest.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/CxfServerRequest.java new file mode 100644 index 0000000..c2335f6 --- /dev/null +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/CxfServerRequest.java @@ -0,0 +1,48 @@ +/** + * 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.brave; + +import java.net.URI; + +import com.github.kristofa.brave.http.HttpServerRequest; + +public class CxfServerRequest implements HttpServerRequest { + + private ParsedMessage message; + + public CxfServerRequest(ParsedMessage message) { + this.message = message; + } + + @Override + public URI getUri() { + return message.getUri(); + } + + @Override + public String getHttpMethod() { + return message.getHttpMethod(); + } + + @Override + public String getHttpHeaderValue(String headerName) { + return message.getHeaders().get(headerName); + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/HttpResponse200.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/HttpResponse200.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/HttpResponse200.java new file mode 100644 index 0000000..820188b --- /dev/null +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/HttpResponse200.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.cxf.tracing.brave; + +import com.github.kristofa.brave.http.HttpResponse; + +final class HttpResponse200 implements HttpResponse { + @Override + public int getHttpStatusCode() { + return 200; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/ParsedMessage.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/ParsedMessage.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/ParsedMessage.java new file mode 100644 index 0000000..d4cfa1c --- /dev/null +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/ParsedMessage.java @@ -0,0 +1,121 @@ +/** + * 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.brave; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.cxf.helpers.CastUtils; +import org.apache.cxf.message.Message; +import org.apache.cxf.message.MessageUtils; + +public class ParsedMessage { + + private Message message; + + public ParsedMessage(Message message) { + this.message = message; + } + + String safeGet(String key) { + if (!message.containsKey(key)) { + return null; + } + Object value = message.get(key); + return (value instanceof String) ? value.toString() : null; + } + + public String getUriSt() { + String uri = safeGet(Message.REQUEST_URL); + if (uri == null) { + String address = safeGet(Message.ENDPOINT_ADDRESS); + uri = safeGet(Message.REQUEST_URI); + if (uri != null && uri.startsWith("/")) { + if (address != null && !address.startsWith(uri)) { + if (address.endsWith("/") && address.length() > 1) { + address = address.substring(0, address.length()); + } + uri = address + uri; + } + } else { + uri = address; + } + } + String query = safeGet(Message.QUERY_STRING); + if (query != null) { + return uri + "?" + query; + } else { + return uri; + } + } + + public URI getUri() { + try { + String uriSt = getUriSt(); + return uriSt != null ? new URI(uriSt) : new URI(""); + } catch (URISyntaxException e) { + throw new RuntimeException(e.getMessage(), e); + } + } + + Message getEffectiveMessage() { + boolean isRequestor = MessageUtils.isRequestor(message); + boolean isOutbound = MessageUtils.isOutbound(message); + if (isRequestor) { + return isOutbound ? message : message.getExchange().getOutMessage(); + } else { + return isOutbound ? message.getExchange().getInMessage() : message; + } + } + + Map<String, String> getHeaders() { + Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS)); + Map<String, String> result = new HashMap<>(); + if (headers == null) { + return result; + } + for (Map.Entry<String, List<String>> entry : headers.entrySet()) { + if (entry.getValue().size() == 1) { + result.put(entry.getKey(), entry.getValue().get(0)); + } else { + String[] valueAr = entry.getValue().toArray(new String[] {}); + result.put(entry.getKey(), valueAr.toString()); + } + } + return result; + } + + void addHeader(String key, String value) { + Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS)); + if (headers == null) { + headers = new HashMap<String, List<String>>(); + message.put(Message.PROTOCOL_HEADERS, headers); + } + headers.put(key, Arrays.asList(value)); + } + + public String getHttpMethod() { + ParsedMessage eMessage = new ParsedMessage(getEffectiveMessage()); + return eMessage.safeGet(Message.HTTP_REQUEST_METHOD); + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceFeature.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceFeature.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceFeature.java new file mode 100644 index 0000000..45c82b8 --- /dev/null +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceFeature.java @@ -0,0 +1,50 @@ +/** + * 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.brave; + +import com.github.kristofa.brave.Brave; +import com.github.kristofa.brave.http.DefaultSpanNameProvider; +import org.apache.cxf.Bus; +import org.apache.cxf.annotations.Provider; +import org.apache.cxf.annotations.Provider.Type; +import org.apache.cxf.common.injection.NoJSR250Annotations; +import org.apache.cxf.feature.AbstractFeature; +import org.apache.cxf.interceptor.InterceptorProvider; + +@NoJSR250Annotations +@Provider(value = Type.Feature) +public class TraceFeature extends AbstractFeature { + private TraceInInterceptor in; + private TraceOutInterceptor out; + + public TraceFeature(Brave brave) { + DefaultSpanNameProvider nameProvider = new DefaultSpanNameProvider(); + in = new TraceInInterceptor(brave, nameProvider); + out = new TraceOutInterceptor(brave, nameProvider); + } + + @Override + protected void initializeProvider(InterceptorProvider provider, Bus bus) { + provider.getInInterceptors().add(in); + provider.getInFaultInterceptors().add(in); + + provider.getOutInterceptors().add(out); + provider.getOutFaultInterceptors().add(out); + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceInInterceptor.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceInInterceptor.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceInInterceptor.java new file mode 100644 index 0000000..655ab40 --- /dev/null +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceInInterceptor.java @@ -0,0 +1,58 @@ +/** + * 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.brave; + +import com.github.kristofa.brave.Brave; +import com.github.kristofa.brave.http.HttpClientResponseAdapter; +import com.github.kristofa.brave.http.HttpServerRequestAdapter; +import com.github.kristofa.brave.http.SpanNameProvider; +import org.apache.cxf.common.injection.NoJSR250Annotations; +import org.apache.cxf.interceptor.Fault; +import org.apache.cxf.message.Message; +import org.apache.cxf.message.MessageUtils; +import org.apache.cxf.phase.AbstractPhaseInterceptor; +import org.apache.cxf.phase.Phase; + +/** + * + */ +@NoJSR250Annotations +public class TraceInInterceptor extends AbstractPhaseInterceptor<Message> { + + private Brave brave; + private SpanNameProvider spanNameProvider; + + public TraceInInterceptor(Brave brave, SpanNameProvider spanNameProvider) { + super(Phase.PRE_INVOKE); + this.brave = brave; + this.spanNameProvider = spanNameProvider; + } + + public void handleMessage(Message cxfMessage) throws Fault { + ParsedMessage message = new ParsedMessage(cxfMessage); + if (MessageUtils.isRequestor(cxfMessage)) { + brave.clientResponseInterceptor().handle(new HttpClientResponseAdapter(new HttpResponse200())); + } else { + HttpServerRequestAdapter adapter = + new HttpServerRequestAdapter(new CxfServerRequest(message), spanNameProvider); + brave.serverRequestInterceptor().handle(adapter); + } + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceOutInterceptor.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceOutInterceptor.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceOutInterceptor.java new file mode 100644 index 0000000..ca7b7a2 --- /dev/null +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/TraceOutInterceptor.java @@ -0,0 +1,57 @@ +/** + * 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.brave; + +import com.github.kristofa.brave.Brave; +import com.github.kristofa.brave.http.HttpClientRequest; +import com.github.kristofa.brave.http.HttpClientRequestAdapter; +import com.github.kristofa.brave.http.HttpServerResponseAdapter; +import com.github.kristofa.brave.http.SpanNameProvider; +import org.apache.cxf.common.injection.NoJSR250Annotations; +import org.apache.cxf.interceptor.Fault; +import org.apache.cxf.message.Message; +import org.apache.cxf.message.MessageUtils; +import org.apache.cxf.phase.AbstractPhaseInterceptor; +import org.apache.cxf.phase.Phase; + +/** + * + */ +@NoJSR250Annotations +public class TraceOutInterceptor extends AbstractPhaseInterceptor<Message> { + + private Brave brave; + private SpanNameProvider spanNameProvider; + + public TraceOutInterceptor(Brave brave, SpanNameProvider spanNameProvider) { + super(Phase.PRE_PROTOCOL); + this.brave = brave; + this.spanNameProvider = spanNameProvider; + } + + public void handleMessage(Message message) throws Fault { + if (MessageUtils.isRequestor(message)) { + final HttpClientRequest req = new CxfClientRequest(message); + brave.clientRequestInterceptor().handle(new HttpClientRequestAdapter(req, spanNameProvider)); + } else { + brave.serverResponseInterceptor().handle(new HttpServerResponseAdapter(new HttpResponse200())); + } + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java deleted file mode 100644 index 78a40fd..0000000 --- a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java +++ /dev/null @@ -1,49 +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.tracing.brave.soap; - -import java.net.URI; - -import com.github.kristofa.brave.http.HttpClientRequest; -import org.apache.cxf.message.Message; - -public class CxfHttpClientRequest implements HttpClientRequest { - - private ParsedMessage message; - - public CxfHttpClientRequest(Message message) { - this.message = new ParsedMessage(message); - } - - @Override - public URI getUri() { - return message.getUri(); - } - - @Override - public String getHttpMethod() { - return message.getHttpMethod(); - } - - @Override - public void addHeader(String header, String value) { - message.addHeader(header, value); - } - -} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java deleted file mode 100644 index fcc8797..0000000 --- a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java +++ /dev/null @@ -1,48 +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.tracing.brave.soap; - -import java.net.URI; - -import com.github.kristofa.brave.http.HttpServerRequest; - -public class CxfServerRequest implements HttpServerRequest { - - private ParsedMessage message; - - public CxfServerRequest(ParsedMessage message) { - this.message = message; - } - - @Override - public URI getUri() { - return message.getUri(); - } - - @Override - public String getHttpMethod() { - return message.getHttpMethod(); - } - - @Override - public String getHttpHeaderValue(String headerName) { - return message.getHeaders().get(headerName); - } - -} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java deleted file mode 100644 index f50dbde..0000000 --- a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java +++ /dev/null @@ -1,28 +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.tracing.brave.soap; - -import com.github.kristofa.brave.http.HttpResponse; - -final class HttpResponse200 implements HttpResponse { - @Override - public int getHttpStatusCode() { - return 200; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java deleted file mode 100644 index 8967375..0000000 --- a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java +++ /dev/null @@ -1,121 +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.tracing.brave.soap; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.cxf.helpers.CastUtils; -import org.apache.cxf.message.Message; -import org.apache.cxf.message.MessageUtils; - -public class ParsedMessage { - - private Message message; - - public ParsedMessage(Message message) { - this.message = message; - } - - String safeGet(String key) { - if (!message.containsKey(key)) { - return null; - } - Object value = message.get(key); - return (value instanceof String) ? value.toString() : null; - } - - public String getUriSt() { - String uri = safeGet(Message.REQUEST_URL); - if (uri == null) { - String address = safeGet(Message.ENDPOINT_ADDRESS); - uri = safeGet(Message.REQUEST_URI); - if (uri != null && uri.startsWith("/")) { - if (address != null && !address.startsWith(uri)) { - if (address.endsWith("/") && address.length() > 1) { - address = address.substring(0, address.length()); - } - uri = address + uri; - } - } else { - uri = address; - } - } - String query = safeGet(Message.QUERY_STRING); - if (query != null) { - return uri + "?" + query; - } else { - return uri; - } - } - - public URI getUri() { - try { - String uriSt = getUriSt(); - return uriSt != null ? new URI(uriSt) : new URI(""); - } catch (URISyntaxException e) { - throw new RuntimeException(e.getMessage(), e); - } - } - - Message getEffectiveMessage() { - boolean isRequestor = MessageUtils.isRequestor(message); - boolean isOutbound = MessageUtils.isOutbound(message); - if (isRequestor) { - return isOutbound ? message : message.getExchange().getOutMessage(); - } else { - return isOutbound ? message.getExchange().getInMessage() : message; - } - } - - Map<String, String> getHeaders() { - Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS)); - Map<String, String> result = new HashMap<>(); - if (headers == null) { - return result; - } - for (Map.Entry<String, List<String>> entry : headers.entrySet()) { - if (entry.getValue().size() == 1) { - result.put(entry.getKey(), entry.getValue().get(0)); - } else { - String[] valueAr = entry.getValue().toArray(new String[] {}); - result.put(entry.getKey(), valueAr.toString()); - } - } - return result; - } - - void addHeader(String key, String value) { - Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS)); - if (headers == null) { - headers = new HashMap<String, List<String>>(); - message.put(Message.PROTOCOL_HEADERS, headers); - } - headers.put(key, Arrays.asList(value)); - } - - public String getHttpMethod() { - ParsedMessage eMessage = new ParsedMessage(getEffectiveMessage()); - return eMessage.safeGet(Message.HTTP_REQUEST_METHOD); - } -} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java deleted file mode 100644 index fbaca07..0000000 --- a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java +++ /dev/null @@ -1,50 +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.tracing.brave.soap; - -import com.github.kristofa.brave.Brave; -import com.github.kristofa.brave.http.DefaultSpanNameProvider; -import org.apache.cxf.Bus; -import org.apache.cxf.annotations.Provider; -import org.apache.cxf.annotations.Provider.Type; -import org.apache.cxf.common.injection.NoJSR250Annotations; -import org.apache.cxf.feature.AbstractFeature; -import org.apache.cxf.interceptor.InterceptorProvider; - -@NoJSR250Annotations -@Provider(value = Type.Feature) -public class TraceFeature extends AbstractFeature { - private TraceInInterceptor in; - private TraceOutInterceptor out; - - public TraceFeature(Brave brave) { - DefaultSpanNameProvider nameProvider = new DefaultSpanNameProvider(); - in = new TraceInInterceptor(brave, nameProvider); - out = new TraceOutInterceptor(brave, nameProvider); - } - - @Override - protected void initializeProvider(InterceptorProvider provider, Bus bus) { - provider.getInInterceptors().add(in); - provider.getInFaultInterceptors().add(in); - - provider.getOutInterceptors().add(out); - provider.getOutFaultInterceptors().add(out); - } -} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java deleted file mode 100644 index 4b84eb3..0000000 --- a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java +++ /dev/null @@ -1,58 +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.tracing.brave.soap; - -import com.github.kristofa.brave.Brave; -import com.github.kristofa.brave.http.HttpClientResponseAdapter; -import com.github.kristofa.brave.http.HttpServerRequestAdapter; -import com.github.kristofa.brave.http.SpanNameProvider; -import org.apache.cxf.common.injection.NoJSR250Annotations; -import org.apache.cxf.interceptor.Fault; -import org.apache.cxf.message.Message; -import org.apache.cxf.message.MessageUtils; -import org.apache.cxf.phase.AbstractPhaseInterceptor; -import org.apache.cxf.phase.Phase; - -/** - * - */ -@NoJSR250Annotations -public class TraceInInterceptor extends AbstractPhaseInterceptor<Message> { - - private Brave brave; - private SpanNameProvider spanNameProvider; - - public TraceInInterceptor(Brave brave, SpanNameProvider spanNameProvider) { - super(Phase.PRE_INVOKE); - this.brave = brave; - this.spanNameProvider = spanNameProvider; - } - - public void handleMessage(Message cxfMessage) throws Fault { - ParsedMessage message = new ParsedMessage(cxfMessage); - if (MessageUtils.isRequestor(cxfMessage)) { - brave.clientResponseInterceptor().handle(new HttpClientResponseAdapter(new HttpResponse200())); - } else { - HttpServerRequestAdapter adapter = - new HttpServerRequestAdapter(new CxfServerRequest(message), spanNameProvider); - brave.serverRequestInterceptor().handle(adapter); - } - } - -} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java deleted file mode 100644 index 17f76d0..0000000 --- a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java +++ /dev/null @@ -1,57 +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.tracing.brave.soap; - -import com.github.kristofa.brave.Brave; -import com.github.kristofa.brave.http.HttpClientRequest; -import com.github.kristofa.brave.http.HttpClientRequestAdapter; -import com.github.kristofa.brave.http.HttpServerResponseAdapter; -import com.github.kristofa.brave.http.SpanNameProvider; -import org.apache.cxf.common.injection.NoJSR250Annotations; -import org.apache.cxf.interceptor.Fault; -import org.apache.cxf.message.Message; -import org.apache.cxf.message.MessageUtils; -import org.apache.cxf.phase.AbstractPhaseInterceptor; -import org.apache.cxf.phase.Phase; - -/** - * - */ -@NoJSR250Annotations -public class TraceOutInterceptor extends AbstractPhaseInterceptor<Message> { - - private Brave brave; - private SpanNameProvider spanNameProvider; - - public TraceOutInterceptor(Brave brave, SpanNameProvider spanNameProvider) { - super(Phase.PRE_PROTOCOL); - this.brave = brave; - this.spanNameProvider = spanNameProvider; - } - - public void handleMessage(Message message) throws Fault { - if (MessageUtils.isRequestor(message)) { - final HttpClientRequest req = new CxfHttpClientRequest(message); - brave.clientRequestInterceptor().handle(new HttpClientRequestAdapter(req, spanNameProvider)); - } else { - brave.serverResponseInterceptor().handle(new HttpServerResponseAdapter(new HttpResponse200())); - } - } - -} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/BraveTraceTest.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/BraveTraceTest.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/BraveTraceTest.java new file mode 100644 index 0000000..fdaa0a5 --- /dev/null +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/BraveTraceTest.java @@ -0,0 +1,99 @@ +/** + * 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.brave; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.github.kristofa.brave.Brave; +import org.apache.cxf.endpoint.Server; +import org.apache.cxf.ext.logging.LoggingFeature; +import org.apache.cxf.feature.Feature; +import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; +import org.apache.cxf.jaxws.JaxWsServerFactoryBean; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import zipkin.Span; +import zipkin.reporter.Reporter; + +public class BraveTraceTest { + + private static final String ADDRESS = "http://localhost:8182"; + private Server server; + private TraceFeature logging; + private Localreporter localReporter; + + @Before + public void startServer() { + localReporter = new Localreporter(); + logging = createLoggingFeature(localReporter); + server = createServer(logging); + } + + @Test + public void testMyService() { + MyService myService = createProxy(logging); + myService.echo("test"); + for (Span span : localReporter.spans) { + System.out.println(span); + } + Assert.assertEquals(2, localReporter.spans.size()); + + } + + @After + public void stopServer() { + server.destroy(); + } + + private static Server createServer(Feature logging) { + JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); + factory.setAddress(ADDRESS); + factory.setServiceBean(new MyServiceImpl()); + factory.setFeatures(Arrays.asList(logging)); + return factory.create(); + } + + private static MyService createProxy(Feature trace) { + JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); + factory.setServiceClass(MyService.class); + factory.setAddress(ADDRESS); + factory.setFeatures(Arrays.asList(trace, new LoggingFeature())); + return (MyService)factory.create(); + } + + private static TraceFeature createLoggingFeature(Reporter<Span> reporter) { + Brave brave = new Brave.Builder("myservice").reporter(reporter).build(); + return new TraceFeature(brave); + } + + static final class Localreporter implements Reporter<Span> { + List<Span> spans = new ArrayList<Span>(); + + @Override + public void report(Span span) { + spans.add(span); + } + + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/LoggingSpanNameProvider.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/LoggingSpanNameProvider.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/LoggingSpanNameProvider.java new file mode 100644 index 0000000..5751e2c --- /dev/null +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/LoggingSpanNameProvider.java @@ -0,0 +1,31 @@ +/** + * 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.brave; + +import com.github.kristofa.brave.http.HttpRequest; +import com.github.kristofa.brave.http.SpanNameProvider; + +public class LoggingSpanNameProvider implements SpanNameProvider { + + @Override + public String spanName(HttpRequest request) { + return (request instanceof SpanNameProvider) ? ((SpanNameProvider)request).spanName(request) : ""; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/MyService.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/MyService.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/MyService.java new file mode 100644 index 0000000..77dc709 --- /dev/null +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/MyService.java @@ -0,0 +1,26 @@ +/** + * 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.brave; + +import javax.jws.WebService; + +@WebService +public interface MyService { + String echo(String msg); +} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/MyServiceImpl.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/MyServiceImpl.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/MyServiceImpl.java new file mode 100644 index 0000000..594e8c7 --- /dev/null +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/MyServiceImpl.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.cxf.tracing.brave; + +public class MyServiceImpl implements MyService { + + @Override + public String echo(String msg) { + return msg; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java deleted file mode 100644 index 5bac5f7..0000000 --- a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java +++ /dev/null @@ -1,99 +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.tracing.brave.soap; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.github.kristofa.brave.Brave; -import org.apache.cxf.endpoint.Server; -import org.apache.cxf.ext.logging.LoggingFeature; -import org.apache.cxf.feature.Feature; -import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; -import org.apache.cxf.jaxws.JaxWsServerFactoryBean; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import zipkin.Span; -import zipkin.reporter.Reporter; - -public class BraveTraceTest { - - private static final String ADDRESS = "http://localhost:8182"; - private Server server; - private TraceFeature logging; - private Localreporter localReporter; - - @Before - public void startServer() { - localReporter = new Localreporter(); - logging = createLoggingFeature(localReporter); - server = createServer(logging); - } - - @Test - public void testMyService() { - MyService myService = createProxy(logging); - myService.echo("test"); - for (Span span : localReporter.spans) { - System.out.println(span); - } - Assert.assertEquals(2, localReporter.spans.size()); - - } - - @After - public void stopServer() { - server.destroy(); - } - - private static Server createServer(Feature logging) { - JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); - factory.setAddress(ADDRESS); - factory.setServiceBean(new MyServiceImpl()); - factory.setFeatures(Arrays.asList(logging)); - return factory.create(); - } - - private static MyService createProxy(Feature trace) { - JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); - factory.setServiceClass(MyService.class); - factory.setAddress(ADDRESS); - factory.setFeatures(Arrays.asList(trace, new LoggingFeature())); - return (MyService)factory.create(); - } - - private static TraceFeature createLoggingFeature(Reporter<Span> reporter) { - Brave brave = new Brave.Builder("myservice").reporter(reporter).build(); - return new TraceFeature(brave); - } - - static final class Localreporter implements Reporter<Span> { - List<Span> spans = new ArrayList<Span>(); - - @Override - public void report(Span span) { - spans.add(span); - } - - } - -} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java deleted file mode 100644 index 86fa25a..0000000 --- a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java +++ /dev/null @@ -1,31 +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.tracing.brave.soap; - -import com.github.kristofa.brave.http.HttpRequest; -import com.github.kristofa.brave.http.SpanNameProvider; - -public class LoggingSpanNameProvider implements SpanNameProvider { - - @Override - public String spanName(HttpRequest request) { - return (request instanceof SpanNameProvider) ? ((SpanNameProvider)request).spanName(request) : ""; - } - -} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java deleted file mode 100644 index 2001164..0000000 --- a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java +++ /dev/null @@ -1,26 +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.tracing.brave.soap; - -import javax.jws.WebService; - -@WebService -public interface MyService { - String echo(String msg); -} http://git-wip-us.apache.org/repos/asf/cxf/blob/30fab03d/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java ---------------------------------------------------------------------- diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java deleted file mode 100644 index e9f901a..0000000 --- a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java +++ /dev/null @@ -1,28 +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.tracing.brave.soap; - -public class MyServiceImpl implements MyService { - - @Override - public String echo(String msg) { - return msg; - } - -}
