org.apache.tools.ant.taskdefs.optional.sshClass AbstractSshMessage
- java.lang.Object
- org.apache.tools.ant.taskdefs.optional.ssh.AbstractSshMessage
- Direct Known Subclasses:
- ScpFromMessage, ScpToMessage
public abstract class AbstractSshMessage extends java.lang.Object
Abstract class for ssh upload and download
Constructor Summary
Constructors Constructor and Description AbstractSshMessage(boolean verbose, boolean compressed, com.jcraft.jsch.Session session)
Constructor for AbstractSshMessageAbstractSshMessage(boolean verbose, com.jcraft.jsch.Session session)
Constructor for AbstractSshMessageAbstractSshMessage(com.jcraft.jsch.Session session)
Constructor for AbstractSshMessage
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract void
execute()
Carry out the transfer.protected boolean
getCompressed()
Is the compressed attribute set.protected com.jcraft.jsch.SftpProgressMonitor
getProgressMonitor()
Get the progress monitor.protected boolean
getVerbose()
Is the verbose attribute set.protected void
log(java.lang.String message)
Log a message to the log listener.protected void
logStats(long timeStarted, long timeEnded, long totalLength)
Log transfer stats to the log listener.protected com.jcraft.jsch.Channel
openExecChannel(java.lang.String command)
Open an ssh channel.protected com.jcraft.jsch.ChannelSftp
openSftpChannel()
Open an ssh sftp channel.protected void
sendAck(java.io.OutputStream out)
Send an ack.void
setLogListener(LogListener aListener)
Set a log listener.protected int
trackProgress(long filesize, long totalLength, int percentTransmitted)
Track progress every 10% if 100kb < filesize < 1Mb.protected void
waitForAck(java.io.InputStream in)
Reads the response, throws a BuildException if the response indicates an error.
Constructor Detail
AbstractSshMessage
public AbstractSshMessage(com.jcraft.jsch.Session session)Constructor for AbstractSshMessage
- Parameters:
session
- the ssh session to use
AbstractSshMessage
public AbstractSshMessage(boolean verbose, com.jcraft.jsch.Session session)Constructor for AbstractSshMessage
- Parameters:
verbose
- if true do verbose loggingsession
- the ssh session to use- Since:
- Ant 1.6.2
AbstractSshMessage
public AbstractSshMessage(boolean verbose, boolean compressed, com.jcraft.jsch.Session session)Constructor for AbstractSshMessage
- Parameters:
verbose
- if true do verbose loggingcompressed
- if true use compressionsession
- the ssh session to use- Since:
- Ant 1.9.8
Method Detail
openExecChannel
protected com.jcraft.jsch.Channel openExecChannel(java.lang.String command) throws com.jcraft.jsch.JSchExceptionOpen an ssh channel.
- Parameters:
command
- the command to use- Returns:
- the channel
- Throws:
com.jcraft.jsch.JSchException
- on error
openSftpChannel
protected com.jcraft.jsch.ChannelSftp openSftpChannel() throws com.jcraft.jsch.JSchExceptionOpen an ssh sftp channel.
- Returns:
- the channel
- Throws:
com.jcraft.jsch.JSchException
- on error
sendAck
protected void sendAck(java.io.OutputStream out) throws java.io.IOExceptionSend an ack.
- Parameters:
out
- the output stream to use- Throws:
java.io.IOException
- on error
waitForAck
protected void waitForAck(java.io.InputStream in) throws java.io.IOException, BuildExceptionReads the response, throws a BuildException if the response indicates an error.
- Parameters:
in
- the input stream to use- Throws:
java.io.IOException
- on I/O errorBuildException
- on other errors
execute
public abstract void execute() throws java.io.IOException, com.jcraft.jsch.JSchExceptionCarry out the transfer.
- Throws:
java.io.IOException
- on I/O errorscom.jcraft.jsch.JSchException
- on ssh errors
setLogListener
public void setLogListener(LogListener aListener)Set a log listener.
- Parameters:
aListener
- the log listener
log
protected void log(java.lang.String message)Log a message to the log listener.
- Parameters:
message
- the message to log
logStats
protected void logStats(long timeStarted, long timeEnded, long totalLength)Log transfer stats to the log listener.
- Parameters:
timeStarted
- the time startedtimeEnded
- the finishing timetotalLength
- the total length
getVerbose
protected final boolean getVerbose()Is the verbose attribute set.
- Returns:
- true if the verbose attribute is set
- Since:
- Ant 1.6.2
getCompressed
protected final boolean getCompressed()Is the compressed attribute set.
- Returns:
- true if the compressed attribute is set
- Since:
- Ant 1.9.8
trackProgress
protected final int trackProgress(long filesize, long totalLength, int percentTransmitted)Track progress every 10% if 100kb < filesize < 1Mb. For larger files track progress for every percent transmitted.
- Parameters:
filesize
- the size of the file been transmittedtotalLength
- the total transmission sizepercentTransmitted
- the current percent transmitted- Returns:
- the percent that the file is of the total
getProgressMonitor
protected com.jcraft.jsch.SftpProgressMonitor getProgressMonitor()Get the progress monitor.
- Returns:
- the progress monitor.