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

	<cm:property-placeholder id="syslogHandlerDefaultProperties" persistent-id="org.opennms.netmgt.syslog.handler.default" update-strategy="none">
		<cm:default-properties>
			<cm:property name="brokerUri" value="vm://localhost?create=false" />
		</cm:default-properties>
	</cm:property-placeholder>

	<bean id="syslogConnectionHandlerDefault" class="org.opennms.netmgt.syslogd.SyslogConnectionHandlerDefaultImpl"/>

	<!-- Don't register this as a service: we're only using it internally -->
	<!--
	<service interface="org.opennms.netmgt.syslogd.SyslogConnectionHandler" ref="syslogConnectionHandlerDefault"/>
	-->

	<!-- Camel Event marshalling processor -->
	<bean id="unmarshaller" class="org.opennms.core.camel.JaxbUtilsUnmarshalProcessor">
		<argument value="org.opennms.netmgt.syslogd.SyslogConnection" />
	</bean>

	<reference id="syslogdConfig" interface="org.opennms.netmgt.config.SyslogdConfig" />
	
	<bean id="syslogdConfigProcessor" class="org.opennms.netmgt.syslogd.SyslogdConfigProcessor">
		<argument ref="syslogdConfig"/>
	</bean>

	<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
		<!-- TODO: HZN-490 Add configurable ActiveMQ URI -->
		<property name="brokerURL" value="${brokerUri}" />
		<!-- TODO: HZN-490 Add configurable authentication -->
		<!--
		<property name="userName" value="karaf" />
		<property name="password" value="karaf" />
		-->
	</bean>

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

		<route id="receiveSyslogConnection">
			<from uri="activemq:broadcastSyslog"/>
			<process ref="unmarshaller"/>
			<!-- Update the SyslogdConfig on the message to the local config value -->
			<bean ref="syslogdConfigProcessor"/>
			<to uri="seda:syslogHandler"/>
		</route>

		<route id="syslogHandler">
			<from uri="seda:syslogHandler"/>
			<!-- 
				Pass the message to the default handler which will convert it into
				an event and broadcast the event.
			-->
			<bean ref="syslogConnectionHandlerDefault"/>
		</route>
	</camelContext>

</blueprint>
