<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
">

	<bean id="queueNameFactory" class="org.opennms.core.camel.JmsQueueNameFactory">
		<argument value="Trapd"/>
		<argument value="BroadcastTrap"/>
	</bean>

	<cm:property-placeholder id="trapHandlerMinionProperties" persistent-id="org.opennms.netmgt.trapd.handler.minion" update-strategy="none">
		<cm:default-properties>
			<cm:property name="queueName">
				<bean factory-ref="queueNameFactory" factory-method="getName"/>
			</cm:property>
		</cm:default-properties>
	</cm:property-placeholder>

	<bean id="trapdNotificationHandlerCamel" class="org.opennms.netmgt.trapd.TrapNotificationHandlerCamelImpl">
		<argument value="seda:handleMessage" />
	</bean>

	<service interface="org.opennms.netmgt.trapd.TrapNotificationHandler" ref="trapdNotificationHandlerCamel" />

	<!-- ActiveMQ component provided by minion-core -->
	<reference id="queuingservice" interface="org.apache.camel.Component" filter="(alias=opennms.broker)"/>

	<camelContext id="trapdNotificationHandlerMinion" xmlns="http://camel.apache.org/schema/blueprint">
		<propertyPlaceholder id="properties" location="blueprint:trapHandlerMinionProperties" />

		<route id="trapdHandlerMinion">
			<from uri="seda:handleMessage" />
			<convertBodyTo type="org.opennms.netmgt.snmp.TrapNotification" />
			<!-- TODO: Use marshalling instead of serialization when transmitting object? -->
			<!-- Broadcast message over ActiveMQ -->
			<to uri="queuingservice:{{queueName}}?disableReplyTo=true" />
		</route>
	</camelContext>

</blueprint>
