PTP
Release 5.0

org.eclipse.ptp.remote.core.server
Class AbstractRemoteServerRunner

java.lang.Object
  extended by org.eclipse.core.runtime.PlatformObject
      extended by org.eclipse.core.internal.jobs.InternalJob
          extended by org.eclipse.core.runtime.jobs.Job
              extended by org.eclipse.ptp.remote.core.server.AbstractRemoteServerRunner
All Implemented Interfaces:
java.lang.Comparable, org.eclipse.core.runtime.IAdaptable

public abstract class AbstractRemoteServerRunner
extends org.eclipse.core.runtime.jobs.Job

Since:
5.0

Nested Class Summary
static class AbstractRemoteServerRunner.ServerState
           
 
Field Summary
 
Fields inherited from class org.eclipse.core.runtime.jobs.Job
ASYNC_FINISH, BUILD, DECORATE, INTERACTIVE, LONG, NONE, RUNNING, SHORT, SLEEPING, WAITING
 
Fields inherited from class org.eclipse.core.internal.jobs.InternalJob
manager
 
Constructor Summary
AbstractRemoteServerRunner(java.lang.String name)
           
 
Method Summary
protected abstract  void doServerFinished(org.eclipse.core.runtime.IProgressMonitor monitor)
          Called on termination of the server process
protected abstract  boolean doServerStarted(org.eclipse.core.runtime.IProgressMonitor monitor)
          Called once the server starts
protected abstract  boolean doServerStarting(org.eclipse.core.runtime.IProgressMonitor monitor)
          Called just prior to the server starting
protected  boolean doVerifyServerRunningFromStderr(java.lang.String output)
          Called with each line of stderr from the server.
protected  boolean doVerifyServerRunningFromStdout(java.lang.String output)
          Called with each line of stdout from the server.
 java.util.Map<java.lang.String,java.lang.String> getEnv()
           
 java.io.InputStream getErrorStream()
          Get the error stream of the remote process.
 java.io.InputStream getInputStream()
          Get the input stream of the remote process.
 java.lang.String getLaunchCommand()
          Get the launch command for this server
 java.io.OutputStream getOutputStream()
          Get the output stream of the remote process.
 java.lang.String getPayload()
          Get the payload.
 IRemoteConnection getRemoteConnection()
          Get the remote connection used to launch the server
 AbstractRemoteServerRunner.ServerState getServerState()
          Get the current state of the server.
 java.lang.String getUnpackCommand()
          Get the unpack command for this server
 java.lang.String getVariable(java.lang.String name)
          Get the value of a variable that will be expanded in the launch command
 java.lang.String getVerifyLaunchCommand()
           
 java.lang.String getVerifyLaunchFailMessage()
           
 java.lang.String getVerifyLaunchPattern()
           
 java.lang.String getVerifyUnpackCommand()
           
 java.lang.String getVerifyUnpackFailMessage()
           
 java.lang.String getVerifyUnpackPattern()
           
 java.lang.String getWorkingDir()
          Get the working directory.
protected  org.eclipse.core.runtime.IStatus run(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void setBundleId(java.lang.String id)
          Set the id of the bundle containing the remote server file.
 void setContinuous(boolean continuous)
          Set flag to indicate job is continuous or only runs once.
 void setEnv(java.lang.String env)
          Set the environment prior to launching the server.
 void setLaunchCommand(java.lang.String command)
          Set the command used to launch the server
 void setPayload(java.lang.String file)
          Set the name of the payload
 void setRemoteConnection(IRemoteConnection conn)
          Set the connection used to launch the server
protected  void setServerState(AbstractRemoteServerRunner.ServerState state)
          Change the state of the server
 void setUnpackCommand(java.lang.String command)
          Set the command used to unpack the payload
 void setVariable(java.lang.String name, java.lang.String value)
          Set the value of a variable that will be expended in the launch command
 void setVerifyLaunchCommand(java.lang.String verifyCommand)
           
 void setVerifyLaunchFailMessage(java.lang.String verifyFailMessage)
           
 void setVerifyLaunchPattern(java.lang.String verifyPattern)
           
 void setVerifyUnpackCommand(java.lang.String verifyCommand)
           
 void setVerifyUnpackFailMessage(java.lang.String verifyFailMessage)
           
 void setVerifyUnpackPattern(java.lang.String verifyPattern)
           
 void setWorkDir(java.lang.String workDir)
          Set the working directory.
 void startServer(org.eclipse.core.runtime.IProgressMonitor monitor)
          Start the server launch.
protected  void terminateServer()
          Terminate the server
 void waitForServerFinish(org.eclipse.core.runtime.IProgressMonitor monitor)
          Wait for the server to finished.
 void waitForServerStart(int timeout)
          Wait for the server to start up for at most "timeout" ms.
 void waitForServerStart(org.eclipse.core.runtime.IProgressMonitor monitor)
          Wait for the server to start up.
 
Methods inherited from class org.eclipse.core.runtime.jobs.Job
addJobChangeListener, belongsTo, cancel, canceling, done, getJobManager, getName, getPriority, getProperty, getResult, getRule, getState, getThread, isBlocking, isSystem, isUser, join, removeJobChangeListener, schedule, schedule, setName, setPriority, setProgressGroup, setProperty, setRule, setSystem, setThread, setUser, shouldRun, shouldSchedule, sleep, toString, wakeUp, wakeUp, yieldRule
 
Methods inherited from class org.eclipse.core.internal.jobs.InternalJob
compareTo
 
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Constructor Detail

AbstractRemoteServerRunner

public AbstractRemoteServerRunner(java.lang.String name)
Method Detail

getEnv

public java.util.Map<java.lang.String,java.lang.String> getEnv()

getErrorStream

public java.io.InputStream getErrorStream()
Get the error stream of the remote process. This should only be used for non-continuous processes and is only valid for servers in the RUNNING state.

Returns:
InputStream error stream or null if the server has not been started

getInputStream

public java.io.InputStream getInputStream()
Get the input stream of the remote process. This should only be used for non-continuous processes and is only valid for servers in the RUNNING state.

Returns:
InputStream input stream or null if the server has not been started

getLaunchCommand

public java.lang.String getLaunchCommand()
Get the launch command for this server

Returns:
launch command

getOutputStream

public java.io.OutputStream getOutputStream()
Get the output stream of the remote process. This should only be used for non-continuous processes.

Returns:
OutputStream output stream or null if the server has not been started

getPayload

public java.lang.String getPayload()
Get the payload. The payload is copied to the remote system using the supplied connection if it doesn't exist.

Returns:

getRemoteConnection

public IRemoteConnection getRemoteConnection()
Get the remote connection used to launch the server

Returns:
remote connection

getServerState

public AbstractRemoteServerRunner.ServerState getServerState()
Get the current state of the server.

Returns:
server state

getUnpackCommand

public java.lang.String getUnpackCommand()
Get the unpack command for this server

Returns:
unpack command

getVariable

public java.lang.String getVariable(java.lang.String name)
Get the value of a variable that will be expanded in the launch command

Parameters:
name - variable name

getVerifyLaunchCommand

public java.lang.String getVerifyLaunchCommand()
Returns:
the verify launch command
Since:
5.0 Gets the verify launch command.

getVerifyLaunchFailMessage

public java.lang.String getVerifyLaunchFailMessage()
Returns:
the verify launch fail message
Since:
5.0 Gets the verify launch fail message.

getVerifyLaunchPattern

public java.lang.String getVerifyLaunchPattern()
Returns:
the verify launch pattern
Since:
5.0 Gets the verify launch pattern.

getVerifyUnpackCommand

public java.lang.String getVerifyUnpackCommand()
Returns:
the verify unpack command
Since:
5.0 Gets the verify unpack command.

getVerifyUnpackFailMessage

public java.lang.String getVerifyUnpackFailMessage()
Returns:
the verify unpack fail message
Since:
5.0 Gets the verify unpack fail message.

getVerifyUnpackPattern

public java.lang.String getVerifyUnpackPattern()
Returns:
the verify unpack pattern
Since:
5.0 Gets the verify unpack pattern.

getWorkingDir

public java.lang.String getWorkingDir()
Get the working directory. This is the location of the payload.

Returns:
working directory

setBundleId

public void setBundleId(java.lang.String id)
Set the id of the bundle containing the remote server file.

Parameters:
id - bundle id

setContinuous

public void setContinuous(boolean continuous)
Set flag to indicate job is continuous or only runs once.

Parameters:
continuous - true if the job runs continuously

setEnv

public void setEnv(java.lang.String env)
Set the environment prior to launching the server.

Parameters:
env - string containing environment (as returned by "env" command)

setLaunchCommand

public void setLaunchCommand(java.lang.String command)
Set the command used to launch the server

Parameters:
command - launch command

setPayload

public void setPayload(java.lang.String file)
Set the name of the payload

Parameters:
file - payload name

setRemoteConnection

public void setRemoteConnection(IRemoteConnection conn)
Set the connection used to launch the server

Parameters:
conn - remote connection

setUnpackCommand

public void setUnpackCommand(java.lang.String command)
Set the command used to unpack the payload

Parameters:
command - unpack command

setVariable

public void setVariable(java.lang.String name,
                        java.lang.String value)
Set the value of a variable that will be expended in the launch command

Parameters:
name - variable name
value - variable value

setVerifyLaunchCommand

public void setVerifyLaunchCommand(java.lang.String verifyCommand)
Parameters:
verifyCommand - the new verify command
Since:
5.0 Sets the verify command.

setVerifyLaunchFailMessage

public void setVerifyLaunchFailMessage(java.lang.String verifyFailMessage)
Parameters:
verifyFailMessage - the new verify fail message
Since:
5.0 Sets the verify fail message.

setVerifyLaunchPattern

public void setVerifyLaunchPattern(java.lang.String verifyPattern)
Parameters:
verifyPattern - the new verify pattern
Since:
5.0 Sets the verify pattern.

setVerifyUnpackCommand

public void setVerifyUnpackCommand(java.lang.String verifyCommand)
Parameters:
verifyCommand - the new verify command
Since:
5.0 Sets the verify unpack command.

setVerifyUnpackFailMessage

public void setVerifyUnpackFailMessage(java.lang.String verifyFailMessage)
Parameters:
verifyFailMessage - the new verify fail message
Since:
5.0 Sets the verify unpack fail message.

setVerifyUnpackPattern

public void setVerifyUnpackPattern(java.lang.String verifyPattern)
Parameters:
verifyPattern - the new verify pattern
Since:
5.0 Sets the verify unpack pattern.

setWorkDir

public void setWorkDir(java.lang.String workDir)
Set the working directory. This is the location of the payload on the remote system.

Parameters:
workDir - working directory

startServer

public void startServer(org.eclipse.core.runtime.IProgressMonitor monitor)
                 throws java.io.IOException
Start the server launch. Clients should check the server status with getServerState() or use waitForServerStart(int) to determine when the server has actually started.

Parameters:
monitor - progress monitor that can be used to cancel the launch
Throws:
java.io.IOException - if the launch fails

waitForServerFinish

public void waitForServerFinish(org.eclipse.core.runtime.IProgressMonitor monitor)
Wait for the server to finished. Will do nothing if the server is stopped.

Parameters:
monitor - progress monitor to cancel waiting
Since:
5.0

waitForServerStart

public void waitForServerStart(int timeout)
Wait for the server to start up for at most "timeout" ms. Will do nothing if the server is stopped.

Parameters:
timeout - time (in ms) to wait for server startup. A timeout of 0 means wait forever.
Since:
5.0

waitForServerStart

public void waitForServerStart(org.eclipse.core.runtime.IProgressMonitor monitor)
Wait for the server to start up. Will do nothing if the server is stopped.

Parameters:
monitor - progress monitor to cancel waiting
Since:
5.0

doServerFinished

protected abstract void doServerFinished(org.eclipse.core.runtime.IProgressMonitor monitor)
Called on termination of the server process

Since:
5.0

doServerStarted

protected abstract boolean doServerStarted(org.eclipse.core.runtime.IProgressMonitor monitor)
Called once the server starts

Returns:
false if server should be aborted
Since:
5.0

doServerStarting

protected abstract boolean doServerStarting(org.eclipse.core.runtime.IProgressMonitor monitor)
Called just prior to the server starting

Returns:
false if start should be aborted
Since:
5.0

doVerifyServerRunningFromStderr

protected boolean doVerifyServerRunningFromStderr(java.lang.String output)
Called with each line of stderr from the server. Implementers can use this to determine when the server has successfully started.

Parameters:
output - line of stderr output from server
Returns:
true if the server has started

doVerifyServerRunningFromStdout

protected boolean doVerifyServerRunningFromStdout(java.lang.String output)
Called with each line of stdout from the server. Implementers can use this to determine when the server has successfully started.

Parameters:
output - line of stdout output from server
Returns:
true if the server has started

run

protected org.eclipse.core.runtime.IStatus run(org.eclipse.core.runtime.IProgressMonitor monitor)
Specified by:
run in class org.eclipse.core.runtime.jobs.Job

setServerState

protected void setServerState(AbstractRemoteServerRunner.ServerState state)
Change the state of the server

Parameters:
state - new server state

terminateServer

protected void terminateServer()
Terminate the server


PTP
Release 5.0

Copyright (c) 2011 IBM Corporation and others. All Rights Reserved.