com.xebialabs.deployit.hostsession
Interface HostSession

All Known Implementing Classes:
AbstractHostSession, CifsTelnetHostSession, LocalHostSession, SshScpHostSession, SshSftpHostSession, SshSudoHostSession

public interface HostSession

A session on a host (local or remote) on which to manipulate files and execute commands.


Method Summary
 void close()
          Closes the host session.
 HostFile copyToTemporaryFile(java.io.File localFile)
          Copies a local file to a temporary file on the host.
 HostFile copyToTemporaryFile(org.springframework.core.io.Resource resource)
          Copies a resource to a temporary file on the host.
 int execute(CommandExecutionCallbackHandler handler, java.util.Map<java.lang.String,java.lang.String> inputResponse, java.lang.String... commandLine)
          Executes a command and responds to any output with the provided responses.
 int execute(CommandExecutionCallbackHandler handler, java.lang.String... commandLine)
          Executes a command with its arguments.
 HostFile getFile(HostFile parent, java.lang.String child)
          Creates a reference to a file in a directory on the host.
 HostFile getFile(java.lang.String hostPath)
          Creates a reference to a file on the host.
 OperatingSystemFamily getHostOperatingSystem()
          Return the OS family of the host.
 HostFile getTempFile(java.lang.String nameTemplate)
          Creates a reference to a temporary file on the host.
 HostFile getTempFile(java.lang.String prefix, java.lang.String suffix)
          Creates a reference to a temporary file on the host.
 CommandExecution startExecute(java.lang.String... commandLine)
          Starts the execution of a command and gives the caller full control over the execution.
 

Method Detail

getHostOperatingSystem

OperatingSystemFamily getHostOperatingSystem()
Return the OS family of the host.

Returns:
the OS family

close

void close()
Closes the host session. Destroys any temporary files that may have been created on the host. Never throws an exception, not even a RuntimeException


getFile

HostFile getFile(java.lang.String hostPath)
                 throws RuntimeIOException
Creates a reference to a file on the host.

Parameters:
hostPath - the path of the host
Returns:
a reference to the file
Throws:
RuntimeIOException - if an I/O error occurs

getFile

HostFile getFile(HostFile parent,
                 java.lang.String child)
                 throws RuntimeIOException
Creates a reference to a file in a directory on the host.

Parameters:
parent - the reference to the directory on the host
child - the name of the file in the directory
Returns:
a reference to the file in the directory
Throws:
RuntimeIOException - if an I/O error occurs

getTempFile

HostFile getTempFile(java.lang.String nameTemplate)
                     throws RuntimeIOException
Creates a reference to a temporary file on the host. This file has a unique name and will be automatically removed when this session is closed. N.B.: The file is not actually created until a put method is invoked.

Parameters:
nameTemplate - the template on which to base the name of the temporary file. May be null.
Returns:
a reference to the temporary file on the host
Throws:
RuntimeIOException - if an I/O error occurs

getTempFile

HostFile getTempFile(java.lang.String prefix,
                     java.lang.String suffix)
                     throws RuntimeIOException
Creates a reference to a temporary file on the host. This file has a unique name and will be automatically removed when this session is closed. N.B.: The file is not actually created until a put method is invoked.

Parameters:
prefix - the prefix string to be used in generating the file's name; must be at least three characters long
suffix - the suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used
Returns:
a reference to the temporary file on the host
Throws:
RuntimeIOException - if an I/O error occurs

execute

int execute(CommandExecutionCallbackHandler handler,
            java.lang.String... commandLine)
            throws RuntimeIOException
Executes a command with its arguments.

Parameters:
handler - the callback handler that will be invoked when the executed command generated output.
commandLine - the command line to execute. The first element is the command, the other elements are its arguments.
Returns:
the exit value of the executed command. Is 0 on succesfull execution.
Throws:
RuntimeIOException - if an I/O error occurs

execute

int execute(CommandExecutionCallbackHandler handler,
            java.util.Map<java.lang.String,java.lang.String> inputResponse,
            java.lang.String... commandLine)
Executes a command and responds to any output with the provided responses.

Parameters:
handler - the callback handler that will be invoked when the executed command generated output.
inputResponse - expected output and the response to send
commandLine - the command line to execute. The first element is the command, the other elements are its arguments.
Returns:
the exit value of the executed command. Is 0 on succesfull execution.
Throws:
RuntimeIOException - if an I/O error occurs

startExecute

CommandExecution startExecute(java.lang.String... commandLine)
Starts the execution of a command and gives the caller full control over the execution.

Parameters:
commandLine - the command line to execute. The first element is the command, the other elements are its arguments.
Returns:
an object representing the executing command or null if this is not supported by the host session.
Throws:
RuntimeIOException - if an I/O error occurs

copyToTemporaryFile

HostFile copyToTemporaryFile(java.io.File localFile)
                             throws RuntimeIOException
Copies a local file to a temporary file on the host.

Parameters:
localFile - the local file to copy
Returns:
the path of the temporary file on the host.
Throws:
RuntimeIOException

copyToTemporaryFile

HostFile copyToTemporaryFile(org.springframework.core.io.Resource resource)
                             throws RuntimeIOException
Copies a resource to a temporary file on the host.

Parameters:
resource - the resource to copy
Returns:
the path of the temporary file on the host.
Throws:
RuntimeIOException


Copyright © 2010. All Rights Reserved.