org.apache.tools.ant.taskdefs.optional.ssh
Class AbstractSshMessage
java.lang.Object
org.apache.tools.ant.taskdefs.optional.ssh.AbstractSshMessage
public abstract class AbstractSshMessage
extends java.lang.Object
Abstract class for ssh upload and download
abstract void | execute() - Carry out the transfer.
|
protected SftpProgressMonitor | getProgressMonitor() - Get the progress monitor.
|
protected boolean | getVerbose() - Is the verbose attribute set.
|
protected void | log(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 Channel | openExecChannel(String command) - Open an ssh channel.
|
protected ChannelSftp | openSftpChannel() - Open an ssh sftp channel.
|
protected void | sendAck(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 <32filesize <321mb.
|
protected void | waitForAck(InputStream in) - Reads the response, throws a BuildException if the response
indicates an error.
|
AbstractSshMessage
public AbstractSshMessage(Session session)
Constructor for AbstractSshMessage
session
- the ssh session to use
AbstractSshMessage
public AbstractSshMessage(boolean verbose,
Session session)
Constructor for AbstractSshMessage
verbose
- if true do verbose loggingsession
- the ssh session to use
execute
public abstract void execute()
throws IOException,
JSchException
Carry out the transfer.
getProgressMonitor
protected SftpProgressMonitor getProgressMonitor()
Get the progress monitor.
getVerbose
protected final boolean getVerbose()
Is the verbose attribute set.
- true if the verbose attribute is set
log
protected void log(String message)
Log a message to the log listener.
message
- the message to log
logStats
protected void logStats(long timeStarted,
long timeEnded,
long totalLength)
Log transfer stats to the log listener.
timeStarted
- the time startedtimeEnded
- the finishing timetotalLength
- the total length
openExecChannel
protected Channel openExecChannel(String command)
throws JSchException
Open an ssh channel.
command
- the command to use
openSftpChannel
protected ChannelSftp openSftpChannel()
throws JSchException
Open an ssh sftp channel.
sendAck
protected void sendAck(OutputStream out)
throws IOException
Send an ack.
out
- the output stream to use
setLogListener
public void setLogListener(LogListener aListener)
Set a log listener.
aListener
- the log listener
trackProgress
protected final int trackProgress(long filesize,
long totalLength,
int percentTransmitted)
Track progress every 10% if 100kb <32filesize <321mb. For larger
files track progress for every percent transmitted.
filesize
- the size of the file been transmittedtotalLength
- the total transmission sizepercentTransmitted
- the current percent transmitted
- the percent that the file is of the total
waitForAck
protected void waitForAck(InputStream in)
throws IOException,
BuildException
Reads the response, throws a BuildException if the response
indicates an error.
in
- the input stream to use