<?xml version="1.0" encoding="UTF-8"?>
<!--
  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.
-->
<!-- START SNIPPET: blueprint -->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:cxf="http://cxf.apache.org/blueprint/core"
       xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"

       xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                           http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.6.0 https://aries.apache.org/schemas/blueprint-ext/blueprint-ext-1.6.xsd
                           http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
                           http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd">

    <type-converters>
        <bean class="demo.jaxrs.tracing.server.AsyncReporterConverter" />
    </type-converters>
    
    <bean id="sender" class="zipkin2.reporter.okhttp3.OkHttpSender" factory-method="create" destroy-method="close">
        <argument index="0" value="http://localhost:9411/api/v2/spans" />
    </bean>
    
    <bean id="reporter" class="zipkin2.reporter.AsyncReporter" factory-method="create" destroy-method="close">
        <argument index="0" ref="sender" />
    </bean>
    
    <bean id="tracing" class="demo.jaxrs.tracing.server.CatalogTracingFactory" factory-method="create">
        <argument index="0" value="catalog-service" />
        <argument index="1" ref="reporter" />
    </bean>
  
    <!-- JAXRS providers -->
    <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider" />

    <bean id="braveFeature" class="org.apache.cxf.tracing.brave.jaxrs.BraveFeature">
        <argument index="0" ref="tracing" />
    </bean>
    
    <!-- Application resources -->
    <bean id="catalogResource" class="demo.jaxrs.tracing.server.Catalog" />

    <!-- CXF BraveFeature -->  
    <cxf:bus>
        <cxf:features>
            <cxf:logging />
        </cxf:features>
    </cxf:bus>

    <jaxrs:server id="catalogServer" address="/">
        <jaxrs:serviceBeans>
            <ref component-id="catalogResource" />
        </jaxrs:serviceBeans>
        <jaxrs:providers>
            <ref component-id="jsonProvider" />
            <ref component-id="braveFeature" />
        </jaxrs:providers>
    </jaxrs:server>
</blueprint>
<!-- END SNIPPET: blueprint -->
