<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:beans="http://www.springframework.org/schema/beans"
	xmlns:groovy="http://www.springframework.org/schema/integration/groovy"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd
		http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
		http://www.springframework.org/schema/integration/groovy https://www.springframework.org/schema/integration/groovy/spring-integration-groovy.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">

	<service-activator input-channel="referencedScriptInput">
		<groovy:script location="org/springframework/integration/groovy/config/GroovyServiceActivatorTests.groovy"
					   customizer="groovyCustomizer">
			<groovy:variable name="foo" value="foo"/>
			<groovy:variable name="bar" value="bar"/>
			<groovy:variable name="date" ref="date"/>
		</groovy:script>
	</service-activator>


	<service-activator input-channel="withScriptVariableGenerator">
		<groovy:script location="org/springframework/integration/groovy/config/GroovyServiceActivatorTests.groovy"
					   script-variable-generator="scriptVarSource" customizer="groovyCustomizer"/>
	</service-activator>

	<beans:bean id="groovyCustomizer"
			class="org.springframework.integration.groovy.config.GroovyServiceActivatorTests.MyGroovyCustomizer"/>

	<beans:bean id="scriptVarSource"
		class="org.springframework.integration.groovy.config.GroovyServiceActivatorTests.SampleScriptVariSource"/>

	<service-activator input-channel="inlineScriptInput">
		<groovy:script customizer="groovyCustomizer" variables="date-ref=date">
			<![CDATA[
				return "inline-$payload : ${date.format('dd.MM.yyyy')}"
			]]>
		</groovy:script>
	</service-activator>

	<service-activator input-channel="scriptWithoutVariablesInput">
		<groovy:script>
			<![CDATA[
				return "withoutVariables-$payload : ${date.format('dd.MM.yyyy')}"
			]]>
		</groovy:script>
	</service-activator>

	<beans:bean id="date" class="java.util.Date" scope="prototype">
		<aop:scoped-proxy/>
	</beans:bean>

	<service-activator input-channel="invalidInlineScript">
        <groovy:script>
            <![CDATA[
                  //import org.springframework.integration.handler.ReplyRequiredException

                  if (payload in ReplyRequiredException) return 'OK'
                  throw payload
                ]]>
        </groovy:script>
    </service-activator>

	<beans:bean id="invoked" class="java.util.concurrent.atomic.AtomicBoolean"/>

	<outbound-channel-adapter id="outboundChannelAdapterWithGroovy">
		<groovy:script>
			invoked.set(true)
		</groovy:script>
	</outbound-channel-adapter>

</beans:beans>
