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:
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(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(String output)
          Called with each line of stderr from the server.
protected  boolean doVerifyServerRunningFromStdout(String output)
          Called with each line of stdout from the server.
 Map<String,String> getEnv()
           
 InputStream getErrorStream()
          Get the error stream of the remote process.
 InputStream getInputStream()
          Get the input stream of the remote process.
 String getLaunchCommand()
          Get the launch command for this server
 OutputStream getOutputStream()
          Get the output stream of the remote process.
 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.
 String getUnpackCommand()
          Get the unpack command for this server
 String getVariable(String name)
          Get the value of a variable that will be expanded in the launch command
 String getVerifyLaunchCommand()
           
 String getVerifyLaunchFailMessage()
           
 String getVerifyLaunchPattern()
           
 String getVerifyUnpackCommand()
           
 String getVerifyUnpackFailMessage()
           
 String getVerifyUnpackPattern()
           
 String getWorkingDir()
          Get the working directory.
protected  org.eclipse.core.runtime.IStatus run(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void setBundleId(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(String env)
          Set the environment prior to launching the server.
 void setLaunchCommand(String command)
          Set the command used to launch the server
 void setPayload(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(String command)
          Set the command used to unpack the payload
 void setVariable(String name, String value)
          Set the value of a variable that will be expended in the launch command
 void setVerifyLaunchCommand(String verifyCommand)
           
 void setVerifyLaunchFailMessage(String verifyFailMessage)
           
 void setVerifyLaunchPattern(String verifyPattern)
           
 void setVerifyUnpackCommand(String verifyCommand)
           
 void setVerifyUnpackFailMessage(String verifyFailMessage)
           
 void setVerifyUnpackPattern(String verifyPattern)
           
 void setWorkDir(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(String name)
Method Detail

getEnv

public Map<String,String> getEnv()

getErrorStream

public 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 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 String getLaunchCommand()
Get the launch command for this server

Returns:
launch command

getOutputStream

public 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 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 String getUnpackCommand()
Get the unpack command for this server

Returns:
unpack command

getVariable

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

Parameters:
name - variable name

getVerifyLaunchCommand

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

getVerifyLaunchFailMessage

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

getVerifyLaunchPattern

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

getVerifyUnpackCommand

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

getVerifyUnpackFailMessage

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

getVerifyUnpackPattern

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

getWorkingDir

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

Returns:
working directory

setBundleId

public void setBundleId(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(String env)
Set the environment prior to launching the server.

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

setLaunchCommand

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

Parameters:
command - launch command

setPayload

public void setPayload(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(String command)
Set the command used to unpack the payload

Parameters:
command - unpack command

setVariable

public void setVariable(String name,
                        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(String verifyCommand)
Parameters:
verifyCommand - the new verify command
Since:
5.0 Sets the verify command.

setVerifyLaunchFailMessage

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

setVerifyLaunchPattern

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

setVerifyUnpackCommand

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

setVerifyUnpackFailMessage

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

setVerifyUnpackPattern

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

setWorkDir

public void setWorkDir(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 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:
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(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(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.