INT-1614 renamed DefaultSftpSession to SftpSession and renamed SimpleSftpSessionFactory to DefaultSftpSessionFactory

This commit is contained in:
Mark Fisher
2010-11-19 18:52:15 -05:00
parent ff85df9e99
commit b91a17ed01
7 changed files with 20 additions and 21 deletions

View File

@@ -23,14 +23,13 @@ import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Factory for creating {@link SftpSession} instances. There are lots of ways to construct a
* {@link SftpSession} instance, and not all of them are obvious. This factory should help.
* Factory for creating {@link SftpSession} instances.
*
* @author Josh Long
* @author Mario Gray
* @since 2.0
*/
public class SimpleSftpSessionFactory implements SessionFactory {
public class DefaultSftpSessionFactory implements SessionFactory {
private volatile String host;
@@ -86,7 +85,7 @@ public class SimpleSftpSessionFactory implements SessionFactory {
if (privateKey != null){
privateKeyToPass = privateKey.getFile().getAbsolutePath();
}
DefaultSftpSession session = new DefaultSftpSession(
SftpSession session = new SftpSession(
this.user, this.host, this.password, this.port, this.knownHosts, null, privateKeyToPass, this.privateKeyPassphrase);
session.connect();
return session;

View File

@@ -40,7 +40,7 @@ import com.jcraft.jsch.UserInfo;
* @author Mark Fisher
* @since 2.0
*/
public class DefaultSftpSession implements Session {
public class SftpSession implements Session {
private final Log logger = LogFactory.getLog(this.getClass());
@@ -78,7 +78,7 @@ public class DefaultSftpSession implements Session {
* to surmount that, we need the private key passphrase. Specify that here.
* @throws Exception thrown if any of a myriad of scenarios plays out
*/
public DefaultSftpSession(String userName, String hostName, String userPassword, int port, String knownHostsFile,
public SftpSession(String userName, String hostName, String userPassword, int port, String knownHostsFile,
InputStream knownHostsInputStream, String privateKey, String pvKeyPassPhrase) throws Exception {
JSch jSch = new JSch();
@@ -120,15 +120,6 @@ public class DefaultSftpSession implements Session {
}
}
public void close() {
if (jschSession.isConnected()) {
jschSession.disconnect();
if (channel.isConnected()) {
channel.disconnect();
}
}
}
public boolean mkdir(String path) {
try {
channel.mkdir(path);
@@ -191,6 +182,15 @@ public class DefaultSftpSession implements Session {
}
}
public void close() {
if (jschSession.isConnected()) {
jschSession.disconnect();
if (channel.isConnected()) {
channel.disconnect();
}
}
}
/**
* this is a simple, optimistic implementation of this interface. It simply returns in the positive where possible

View File

@@ -20,7 +20,7 @@
<channel id="requestChannel"/>
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SimpleSftpSessionFactory">
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<beans:property name="host" value="loclahost"/>
<beans:property name="knownHosts" value="local, foo.com, bar.foo"/>
<beans:property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftpTest"/>

View File

@@ -26,7 +26,7 @@
<beans:constructor-arg value="."/>
</beans:bean>
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SimpleSftpSessionFactory">
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<beans:property name="host" value="loclahost"/>
<beans:property name="knownHosts" value="local, foo.com, bar.foo"/>
<beans:property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftpTest"/>

View File

@@ -20,7 +20,7 @@
<channel id="inboundFilesChannel"/>
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SimpleSftpSessionFactory">
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<beans:property name="host" value="loclahost"/>
<beans:property name="knownHosts" value="local, foo.com, bar.foo"/>
<beans:property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftpTest"/>

View File

@@ -8,7 +8,7 @@
http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp-2.0.xsd">
<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SimpleSftpSessionFactory">
<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="localhost"/>
<property name="knownHosts" value="local, foo.com, bar.foo"/>
<property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftpTest"/>

View File

@@ -32,7 +32,7 @@ import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.file.FileNameGenerator;
import org.springframework.integration.file.remote.session.CachingSessionFactory;
import org.springframework.integration.sftp.outbound.SftpSendingMessageHandler;
import org.springframework.integration.sftp.session.SimpleSftpSessionFactory;
import org.springframework.integration.sftp.session.DefaultSftpSessionFactory;
import org.springframework.integration.test.util.TestUtils;
/**
@@ -58,7 +58,7 @@ public class OutboundChannelAdapaterParserTests {
assertNotNull(TestUtils.getPropertyValue(handler, "temporaryBufferFolder"));
assertNotNull(TestUtils.getPropertyValue(handler, "temporaryBufferFolderFile"));
CachingSessionFactory sessionFactory = (CachingSessionFactory) TestUtils.getPropertyValue(handler, "sessionFactory");
SimpleSftpSessionFactory clientFactory = (SimpleSftpSessionFactory) TestUtils.getPropertyValue(sessionFactory, "sessionFactory");
DefaultSftpSessionFactory clientFactory = (DefaultSftpSessionFactory) TestUtils.getPropertyValue(sessionFactory, "sessionFactory");
assertEquals("localhost", TestUtils.getPropertyValue(clientFactory, "host"));
assertEquals(2222, TestUtils.getPropertyValue(clientFactory, "port"));
}