<blueprint
	xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
	xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0"
	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-cm/v1.1.0
		http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd

		http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0
		http://aries.apache.org/schemas/blueprint-ext/blueprint-ext-1.1.xsd
">

  <!-- Configuration properties -->
  <cm:property-placeholder id="properties" persistent-id="org.opennms.netmgt.sampler.persister" update-strategy="none">
    <cm:default-properties>
      <cm:property name="brokerName" value="persisterBroker"/>

      <!-- Simple localhost broker with no network connections -->
      <!-- <cm:property name="brokerUri" value="vm://localhost?broker.brokerName=${brokerName}&amp;broker.persistent=false" /> -->

      <!-- Broker configured via XML file -->
      <!-- <cm:property name="brokerUri" value="vm://localhost?brokerConfig=xbean:etc/activemq.xml" /> -->

      <!-- VM broker with a network connection back to OpenNMS -->
      <cm:property name="brokerUri" value="vm:(broker:(network:static:tcp://127.0.0.1:61616)?brokerName=${brokerName}&amp;persistent=false&amp;useJmx=false)" />

    </cm:default-properties>
  </cm:property-placeholder>

  <!-- Camel (un)marshalling DataFormats -->
  <bean id="jaxbXml" class="org.opennms.netmgt.api.sample.DataFormatUtils" factory-method="jaxbXml"/>

  <!-- Wire in a dispatcher that will route SampleSet messages into the Camel context -->
  <bean id="activemqDispatcher" class="org.opennms.netmgt.api.sample.support.DefaultSampleSetDispatcher">
    <argument value="direct:sendSampleSet"/>
  </bean>

  <service ref="activemqDispatcher" interface="org.opennms.netmgt.api.sample.SampleSetDispatcher">
    <service-properties>
      <entry key="impl" value="activemq"/>
    </service-properties>
  </service>

  <camelContext id="activemqDispatcherCamelContext" xmlns="http://camel.apache.org/schema/blueprint">

    <!-- Send SampleSets over ActiveMQ -->
    <route id="sendSampleSet">
      <from uri="direct:sendSampleSet" />
      <convertBodyTo type="org.opennms.netmgt.api.sample.SampleSet" />
      <marshal ref="jaxbXml" />
      <to uri="activemq:sampleSet?disableReplyTo=true" />
    </route>

  </camelContext>

  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="${brokerUri}" />
  </bean>

</blueprint>
