I am using SSH Maverich Library for making SFTP Call and i encapsulated maverick objects and pooled connections objects using apache commons pool.
I implemented commons pool Factory method to create object.
How do I close the transport layer connection while idle object is eligible for eviction?
P.S.destroyObject in Factory is not working. Apache commons pool version: 1.6
SshClient.disconnect and SftpClient.quit has to invoked to close the transport channels.
The below points has solved my problem.
1.The most important thing when using mavericks with apache commons pool is invoking proper life cycle method.
2.Encapsulation of SshClient and SftpClient into Object that is under the pool. SshClient and SftpClient has to be the instance member of the object that is under the pool.So that destroyObject method of BaseKeyedObjectPoolableFactory is implemented with objects quit and disconnect.
class SFTPConnection{
private SshClient sshClient;
private SftpClient sftpClient;
------
public void destroyObject(){
sshClient.disconnect();
sftpClient.quit()
}
class SFTPConnectionFactory extends BaseKeyedObjectPoolableFactory{
----
public void destroyObject(Object Key,Object arg){
SFTPConnection sftpConnection = (SFTPConnection)arg;
sftpConnection.destroyObject():
}
}