LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.misc
Class LyProcessViewer

java.lang.Object
  extended by java.lang.Thread
      extended by leon.misc.LyProcessViewer
All Implemented Interfaces:
java.lang.Runnable

public final class LyProcessViewer
extends java.lang.Thread

This class is used to execute an external process, capture its output and redirect it to the standard console. If a script is used, all commands that require a user input (pause, etc.) will block the process.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static java.lang.String __VERSION
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LyProcessViewer(LyEnvironment environment, java.lang.String[] commands, boolean waiting)
          Constructor.
LyProcessViewer(LyEnvironment environment, java.lang.String[] commands, boolean waiting, int refreshRate)
          Constructor.
LyProcessViewer(LyEnvironment environment, java.lang.String[] commands, boolean waiting, int refreshRate, java.lang.String errorMessage)
          Constructor.
LyProcessViewer(LyEnvironment environment, java.lang.String[] commands, boolean waiting, int refreshRate, java.lang.String errorMessage, boolean raiseError)
          Constructor.
LyProcessViewer(LyEnvironment environment, java.lang.String script, boolean waiting)
          Constructor.
LyProcessViewer(LyEnvironment environment, java.lang.String script, boolean waiting, int refreshRate)
          Constructor.
LyProcessViewer(LyEnvironment environment, java.lang.String script, boolean waiting, int refreshRate, java.lang.String errorMessage)
          Constructor.
LyProcessViewer(LyEnvironment environment, java.lang.String script, boolean waiting, int refreshRate, java.lang.String errorMessage, boolean raiseError)
          Constructor.
 
Method Summary
 void abort()
          Abort the current process.
 LyEnvironment getEnvironment()
          Gets process viewer environment.
 java.lang.Process getProcess()
          Gets the process corresponding to command execution when used as console.
 int getReturnCode()
          Gets the process returnCode.
 boolean isRunning()
          Checks if the process viewer is still running or not.
 void printConsole()
          Displays process output to standard output.
 void run()
          Waits for process completion and redirect its outputs to standard output.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values
Constructor Detail

LyProcessViewer

public LyProcessViewer(LyEnvironment environment,
                       java.lang.String script,
                       boolean waiting,
                       int refreshRate)
Constructor. Sets the current environment, waiting status and refreshRate with the given values. Creates the current process from the given Script then run() or start() it depentding on the waiting status. The result is sent to the standard output.

Parameters:
environment - the environment of the command
script - system script which should be executed.
waiting - indicates whether the call is waiting for process completion
refreshRate - refresh rate.

LyProcessViewer

public LyProcessViewer(LyEnvironment environment,
                       java.lang.String[] commands,
                       boolean waiting,
                       int refreshRate)
Constructor. Sets the current environment, waiting status and refreshRate with the given values. Creates the current process from the given Script then run() or start() it depentding on the waiting status. The result is sent to the standard output.

Parameters:
environment - the environment of the command
commands - command list which should be executed.
waiting - indicates whether the call is waiting for process completion
refreshRate - refresh rate.

LyProcessViewer

public LyProcessViewer(LyEnvironment environment,
                       java.lang.String script,
                       boolean waiting,
                       int refreshRate,
                       java.lang.String errorMessage)
Constructor. Sets the current environment, waiting status and refreshRate with the given values. Creates the current process from the given Script then run() or start() it depentding on the waiting status. The result is sent to the standard output.

Parameters:
environment - the environment of the command
script - system script which should be executed.
waiting - indicates whether the call is waiting for process completion
refreshRate - refresh rate.
errorMessage - The error message to show if the process fails.

LyProcessViewer

public LyProcessViewer(LyEnvironment environment,
                       java.lang.String[] commands,
                       boolean waiting,
                       int refreshRate,
                       java.lang.String errorMessage)
Constructor. Sets the current environment, waiting status and refreshRate with the given values. Creates the current process from the given Script then run() or start() it depentding on the waiting status. The result is sent to the standard output.

Parameters:
environment - the environment of the command
commands - command list which should be executed.
waiting - indicates whether the call is waiting for process completion
refreshRate - refresh rate.
errorMessage - The error message to show if the process fails.

LyProcessViewer

public LyProcessViewer(LyEnvironment environment,
                       java.lang.String[] commands,
                       boolean waiting,
                       int refreshRate,
                       java.lang.String errorMessage,
                       boolean raiseError)
Constructor. Sets the current environment, waiting status and refreshRate with the given values. Creates the current process from the given Script then run() or start() it depentding on the waiting status. The result is sent to the standard output.

Parameters:
environment - the environment of the command
commands - command list which should be executed.
waiting - indicates whether the call is waiting for process completion
refreshRate - refresh rate.
errorMessage - The error message to show if the process fails.
raiseError - if true, raise errors to the user

LyProcessViewer

public LyProcessViewer(LyEnvironment environment,
                       java.lang.String script,
                       boolean waiting,
                       int refreshRate,
                       java.lang.String errorMessage,
                       boolean raiseError)
Constructor. Sets the current environment, waiting status and refreshRate with the given values. Creates the current process from the given Script then run() or start() it depentding on the waiting status. The result is sent to the standard output.

Parameters:
environment - the environment of the command
script - system script which should be executed.
waiting - indicates whether the call is waiting for process completion
refreshRate - refresh rate.
errorMessage - The error message to show if the process fails.
raiseError - if true, raise errors to the user

LyProcessViewer

public LyProcessViewer(LyEnvironment environment,
                       java.lang.String script,
                       boolean waiting)
Constructor.
Calls LyProcessViewer(environment, script, waiting, 500) in order to set the refresh rate to 500ms.

Parameters:
environment - the environment of the command
script - system script which should be executed.
waiting - indicates whether the call is waiting for process completion

LyProcessViewer

public LyProcessViewer(LyEnvironment environment,
                       java.lang.String[] commands,
                       boolean waiting)
Constructor.
Calls LyProcessViewer(environment, script, waiting, 500) in order to set the refresh rate to 500ms.

Parameters:
environment - the environment of the command
commands - command list which should be executed.
waiting - indicates whether the call is waiting for process completion
Method Detail

run

public void run()
Waits for process completion and redirect its outputs to standard output.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

printConsole

public void printConsole()
Displays process output to standard output.


abort

public void abort()
Abort the current process.


getReturnCode

public int getReturnCode()
Gets the process returnCode.

Returns:
0 if process still running

isRunning

public boolean isRunning()
Checks if the process viewer is still running or not.

Returns:
true if the process is still running, false otherwise

getEnvironment

public LyEnvironment getEnvironment()
Gets process viewer environment.

Returns:
the environment

getProcess

public java.lang.Process getProcess()
Gets the process corresponding to command execution when used as console.

Returns:
the process

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com