<?xml version="1.0" encoding="UTF-8"?>
<!-- Configures the Camel Context-->

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <!-- Here is an example route which builds requests to the CreateFromData method of the FlightCustomer BAPI 
  	   to create Flight Customers within an SAP System. The request is sent to SAP via a 
  	   queued RFC endpoint to the BAPI method. -->
<camelContext xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="timer://init?repeatCount=1"/>
	    <to uri="bean:fredRequest"/>
        <log message="${body}" loggingLevel="INFO"/>
        <to uri="sap-qrfc-destination:quickstartDest:QUICKSTARTQUEUE:BAPI_FLCUST_CREATEFROMDATA"/>
	    <to uri="bean:barneyRequest"/>
        <log message="${body}" loggingLevel="INFO"/>
        <to uri="sap-qrfc-destination:quickstartDest:QUICKSTARTQUEUE:BAPI_FLCUST_CREATEFROMDATA"/>
	    <to uri="bean:wilmaRequest"/>
        <log message="${body}" loggingLevel="INFO"/>
        <to uri="sap-qrfc-destination:quickstartDest:QUICKSTARTQUEUE:BAPI_FLCUST_CREATEFROMDATA"/>
	    <to uri="bean:bettyRequest"/>
        <log message="${body}" loggingLevel="INFO"/>
        <to uri="sap-qrfc-destination:quickstartDest:QUICKSTARTQUEUE:BAPI_FLCUST_CREATEFROMDATA"/>
    </route>
</camelContext>

	<!-- Create interceptor to support tRFC processing -->
	<bean id="currentProcessorDefinitionInterceptor"
		class="org.fusesource.camel.component.sap.CurrentProcessorDefinitionInterceptStrategy" />
		
	<!-- Instantiates processor beans which build requests to the CreateFromData method of the FlightCustomer BAPI
	 	 and sets those requests in the body of the exchange's message. -->
	<bean id="fredRequest" class="com.redhat.quickstarts.fuse.sap_qrfc_destination_standalone.CreateFredRequest"/>
	<bean id="barneyRequest" class="com.redhat.quickstarts.fuse.sap_qrfc_destination_standalone.CreateBarneyRequest"/>
	<bean id="wilmaRequest" class="com.redhat.quickstarts.fuse.sap_qrfc_destination_standalone.CreateWilmaRequest"/>
	<bean id="bettyRequest" class="com.redhat.quickstarts.fuse.sap_qrfc_destination_standalone.CreateBettyRequest"/>

	<!-- Configures the Inbound and Outbound SAP Connections -->
	<bean id="sap-configuration"
		class="org.fusesource.camel.component.sap.SapConnectionConfiguration">
		<property name="destinationDataStore">
			<map>
				<entry key="quickstartDest" value-ref="quickstartDestinationData" />
			</map>
		</property>
	</bean>

    <!-- Configures an Outbound SAP Connection -->
    <!-- *** Please enter the connection property values for your environment *** -->
    <bean id="quickstartDestinationData"
        class="org.fusesource.camel.component.sap.model.rfc.impl.DestinationDataImpl">
        <property name="ashost" value="${jco.client.ashost}" />
        <property name="sysnr" value="${jco.client.sysnr}" />
        <property name="client" value="${jco.client.client}" />
        <property name="user" value="${jco.client.user}" />
        <property name="passwd" value="${jco.client.passwd}" />
        <property name="lang" value="${jco.client.lang}" />
    </bean>
</beans>
