com.xebialabs.deployit.hostsession.common
Class AbstractHostSession

java.lang.Object
  extended by com.xebialabs.deployit.hostsession.common.AbstractHostSession
All Implemented Interfaces:
HostSession
Direct Known Subclasses:
CifsTelnetHostSession, LocalHostSession, SshScpHostSession, SshSftpHostSession, SshSudoHostSession

public abstract class AbstractHostSession
extends java.lang.Object
implements HostSession

Abstract base class with common methods used by actual implementations of HostSession.


Field Summary
static long MAX_TEMP_RETRIES
           
 
Constructor Summary
AbstractHostSession(OperatingSystemFamily os, java.lang.String temporaryDirectoryPath)
           
 
Method Summary
 void cleanupTemporaryFiles()
           
 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.
protected  HostFile createSessionTempDirectory(HostFile systemTempDirectory, java.lang.String name)
           
 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.
protected  HostFile getTemporaryDirectory()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.xebialabs.deployit.hostsession.HostSession
execute, execute, getFile, getFile, getTempFile, startExecute
 

Field Detail

MAX_TEMP_RETRIES

public static final long MAX_TEMP_RETRIES
See Also:
Constant Field Values
Constructor Detail

AbstractHostSession

public AbstractHostSession(OperatingSystemFamily os,
                           java.lang.String temporaryDirectoryPath)
Method Detail

getHostOperatingSystem

public OperatingSystemFamily getHostOperatingSystem()
Description copied from interface: HostSession
Return the OS family of the host.

Specified by:
getHostOperatingSystem in interface HostSession
Returns:
the OS family

close

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

Specified by:
close in interface HostSession

getTemporaryDirectory

protected HostFile getTemporaryDirectory()
                                  throws RuntimeIOException
Throws:
RuntimeIOException

createSessionTempDirectory

protected HostFile createSessionTempDirectory(HostFile systemTempDirectory,
                                              java.lang.String name)

cleanupTemporaryFiles

public void cleanupTemporaryFiles()

getTempFile

public HostFile getTempFile(java.lang.String nameTemplate)
                     throws RuntimeIOException
Description copied from interface: HostSession
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.

Specified by:
getTempFile in interface HostSession
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

copyToTemporaryFile

public HostFile copyToTemporaryFile(java.io.File localFile)
                             throws RuntimeIOException
Description copied from interface: HostSession
Copies a local file to a temporary file on the host.

Specified by:
copyToTemporaryFile in interface HostSession
Parameters:
localFile - the local file to copy
Returns:
the path of the temporary file on the host.
Throws:
RuntimeIOException

copyToTemporaryFile

public HostFile copyToTemporaryFile(org.springframework.core.io.Resource resource)
                             throws RuntimeIOException
Description copied from interface: HostSession
Copies a resource to a temporary file on the host.

Specified by:
copyToTemporaryFile in interface HostSession
Parameters:
resource - the resource to copy
Returns:
the path of the temporary file on the host.
Throws:
RuntimeIOException


Copyright © 2010. All Rights Reserved.