Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

abbot.script
Class ForkedStepRunner  view ForkedStepRunner download ForkedStepRunner.java

java.lang.Object
  extended byabbot.script.StepRunner
      extended byabbot.script.ForkedStepRunner
All Implemented Interfaces:
abbot.i18n.Resources, abbot.editor.i18n.Resources

public class ForkedStepRunner
extends StepRunner

A StepRunner that runs the step in a separate VM. Behavior should be indistinguishable from the base StepRunner.


Nested Class Summary
(package private)  class ForkedStepRunner.ForkedError
          An exception that for all purposes looks like another exception.
(package private)  class ForkedStepRunner.ForkedFailure
          An exception that for all purposes looks like another exception.
protected static class ForkedStepRunner.SlaveProcess
          When actually within the separate VM, this is what gets run.
 
Nested classes inherited from class abbot.editor.i18n.Resources
abbot.editor.i18n.Resources.ResourceLoader
 
Field Summary
private  java.net.Socket connection
           
(package private)  int LAUNCH_TIMEOUT
           
private  java.lang.Process process
           
private static java.net.ServerSocket serverSocket
           
(package private)  int TERMINATE_TIMEOUT
           
 
Fields inherited from class abbot.script.StepRunner
 
Fields inherited from interface abbot.editor.i18n.Resources
bundle, STRINGS_BUNDLE
 
Constructor Summary
ForkedStepRunner()
           
 
Method Summary
(package private) static Step decodeStep(Sequence root, java.lang.String code)
           
(package private) static java.lang.String encodeStep(Sequence root, Step step)
          Encode the given step into a set of indices.
(package private)  java.lang.Process fork(java.lang.String vmargs)
          Launch a new process, using this class as the main class.
(package private)  java.lang.Process fork(java.lang.String vmargs, java.lang.String[] cmdArgs)
           
private  java.lang.Process forkProcess(java.lang.String vmargs)
           
static void main(java.lang.String[] args)
          Provide means to control execution and feedback of a script in a separate process.
private static java.lang.String readMessage(java.net.Socket connection)
           
private  StepEvent receiveEvent(Script script)
          Receive a serialized event on the connection and convert it back into a real event, setting the given step's exception/error if necessary.
 void runStep(Step step)
          Running the step in a separate VM should be indistinguishable from running a regular script.
private  void sendScript(Script script)
           
private  void trackScript(Script script)
           
private static void writeMessage(java.net.Socket connection, java.lang.String msg)
           
 
Methods inherited from class abbot.script.StepRunner
addStepListener, clearErrors, fireStepEnd, fireStepError, fireStepEvent, fireStepFailure, fireStepProgress, fireStepStart, getError, getStopOnError, getStopOnFailure, launch, removeStepListener, run, setError, setStopOnError, setStopOnFailure, stop, stopped, terminate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAUNCH_TIMEOUT

int LAUNCH_TIMEOUT

TERMINATE_TIMEOUT

int TERMINATE_TIMEOUT

serverSocket

private static java.net.ServerSocket serverSocket

process

private java.lang.Process process

connection

private java.net.Socket connection
Constructor Detail

ForkedStepRunner

public ForkedStepRunner()
Method Detail

fork

java.lang.Process fork(java.lang.String vmargs,
                       java.lang.String[] cmdArgs)
                 throws java.io.IOException

fork

java.lang.Process fork(java.lang.String vmargs)
                 throws java.net.UnknownHostException,
                        java.io.IOException
Launch a new process, using this class as the main class.


runStep

public void runStep(Step step)
Running the step in a separate VM should be indistinguishable from running a regular script. When running as master, nothing actually runs locally. We just fork a subprocess and run the script in that, reporting back its progress as if it were running locally.

Overrides:
runStep in class StepRunner

forkProcess

private java.lang.Process forkProcess(java.lang.String vmargs)
                               throws java.lang.Throwable

sendScript

private void sendScript(Script script)
                 throws java.io.IOException

trackScript

private void trackScript(Script script)
                  throws java.io.IOException

decodeStep

static Step decodeStep(Sequence root,
                       java.lang.String code)

encodeStep

static java.lang.String encodeStep(Sequence root,
                                   Step step)
Encode the given step into a set of indices.


receiveEvent

private StepEvent receiveEvent(Script script)
                        throws java.io.IOException
Receive a serialized event on the connection and convert it back into a real event, setting the given step's exception/error if necessary.


writeMessage

private static void writeMessage(java.net.Socket connection,
                                 java.lang.String msg)
                          throws java.io.IOException

readMessage

private static java.lang.String readMessage(java.net.Socket connection)
                                     throws java.io.IOException

main

public static void main(java.lang.String[] args)
Provide means to control execution and feedback of a script in a separate process.