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

	<context:property-placeholder location="classpath:org/springframework/integration/sftp/config/sftp.properties"/>

	<channel id="requestChannel">
		<queue/>
	</channel>

	<beans:bean id="pattern" class="java.util.regex.Pattern" factory-method="compile">
		<beans:constructor-arg value="."/>
	</beans:bean>

	<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
		<beans:property name="host" value="localhost"/>
		<beans:property name="knownHostsResource"
						value="#{ new org.springframework.core.io.ByteArrayResource('local, foo.com, bar.foo'.bytes)}"/>
		<beans:property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftp_rsa"/>
		<beans:property name="privateKeyPassphrase" value="ghj"/>
		<beans:property name="password" value="hello"/>
		<beans:property name="port" value="2222"/>
		<beans:property name="user" value="oleg"/>
	</beans:bean>

	<sftp:inbound-channel-adapter id="sftpAdapterAutoCreate"
								  session-factory="sftpSessionFactory"
								  channel="requestChannel"
								  filename-regex="f[o]+\.txt"
								  remote-directory-expression="'/foo'"
								  local-directory="file:local-test-dir"
								  auto-create-local-directory="false"
								  remote-file-separator="."
								  local-filename-generator-expression="#this.toUpperCase() + '.a'"
								  temporary-file-suffix=".bar"
								  comparator="comparator"
								  local-filter="acceptAllFilter"
								  max-fetch-size="42"
								  delete-remote-files="${delete.remote.files}"
								  auto-startup="false"
								  preserve-timestamp="true"
								  remote-file-metadata-store="metadataStore"
								  metadata-store-prefix="testPrefix">
		<poller fixed-rate="1000">
			<transactional synchronization-factory="syncFactory"/>
		</poller>
	</sftp:inbound-channel-adapter>

	<beans:bean id="metadataStore" class="org.springframework.integration.metadata.SimpleMetadataStore"/>

	<beans:bean id="acceptAllFilter" class="org.springframework.integration.file.filters.AcceptAllFileListFilter"/>

	<transaction-synchronization-factory id="syncFactory">
		<after-commit expression="'foo'" channel="successChannel"/>
		<after-rollback expression="'bar'" channel="failureChannel"/>
	</transaction-synchronization-factory>

	<channel id="successChannel"/>

	<channel id="failureChannel"/>

	<beans:bean id="comparator" class="org.mockito.Mockito" factory-method="mock">
		<beans:constructor-arg value="java.util.Comparator" type="java.lang.Class"/>
	</beans:bean>

	<sftp:inbound-channel-adapter id="sftpAdapter"
								  channel="requestChannel"
								  session-factory="sftpSessionFactory"
								  filter="filter"
								  remote-directory="/foo"
								  auto-startup="false"
								  local-directory="file:local-test-dir"
								  auto-create-local-directory="true"
								  delete-remote-files="false">
		<poller fixed-rate="1000"/>
	</sftp:inbound-channel-adapter>

	<sftp:inbound-channel-adapter id="sftpAdapterWithPattern"
								  session-factory="sftpSessionFactory"
								  channel="requestChannel"
								  filename-pattern="pattern"
								  remote-directory="/foo"
								  auto-startup="false"
								  local-directory="file:local-test-dir"
								  auto-create-local-directory="false"
								  delete-remote-files="false">
		<poller fixed-rate="1000"/>
	</sftp:inbound-channel-adapter>

	<sftp:inbound-channel-adapter id="sftpAdapterNoLocalDir"
								  session-factory="sftpSessionFactory"
								  channel="requestChannel"
								  filename-pattern="pattern"
								  remote-directory="/foo"
								  local-directory="file:foo"
								  auto-startup="false"
								  auto-create-local-directory="true"
								  delete-remote-files="false">
		<poller fixed-rate="1000"/>
	</sftp:inbound-channel-adapter>

	<beans:bean id="filter" class="org.springframework.integration.sftp.filters.SftpRegexPatternFileListFilter">
		<beans:constructor-arg value="."/>
	</beans:bean>

	<sftp:inbound-channel-adapter id="autoChannel"
								  session-factory="sftpSessionFactory"
								  filter="filter"
								  remote-directory="/foo"
								  local-directory="file:foo"
								  auto-startup="false"
								  auto-create-local-directory="false"
								  delete-remote-files="false">
		<poller fixed-rate="1000"/>
	</sftp:inbound-channel-adapter>

	<bridge input-channel="autoChannel" output-channel="nullChannel"/>

	<beans:bean id="transactionManager" class="org.springframework.integration.transaction.PseudoTransactionManager"/>

</beans:beans>
