Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::acs::commandcenter::engine::NativeCommand Class Reference

List of all members.

Public Member Functions

 NativeCommand (String command, boolean foreground)
 NativeCommand (String command, boolean foreground, long maxExecutionTime)
 NativeCommand (String command, boolean foreground, long maxExecutionTime, String endMark)
 NativeCommand (String command, boolean foreground, long maxExecutionTime, String endMark, long interval, long delay)
void setThreadFactory (ThreadFactory threads)
void addListener (NativeCommand.Listener po)
void removeListener (NativeCommand.Listener po)
String getStatus ()
Integer getExitValue ()
Throwable getLatestException ()
void send (String text)
void run ()

Static Public Attributes

final String NEW = "new"
final String RUNNING = "running"
final String TERMINATED = "terminated"
final String CANNOTRUN = "unable to run"
final String TIMEOUT = "timed out"
final long NO_TIMEOUT = -1
long DEFAULT_WATCHER_INTERVAL = 1000
long DEFAULT_WATCHER_DELAY = 500

Protected Member Functions

void changeStatus (String newStatus)
void fireStatusChanged (String oldStatus, String newStatus)
void fireOutputWritten (InputStream sourceStream, String additionalOutput)

Protected Attributes

OutputStreamWriter stdin
Vector< NativeCommand.Listenerlisteners = new Vector<NativeCommand.Listener>()
String command
Process process
long interval
long delay
long maxExecutionTime
String status
boolean foreground
String endMark
Throwable latestException
Integer exitValue = null
Logger log
ThreadFactory threadFactoryDefault
ThreadFactory threadFactory = threadFactoryDefault

Static Protected Attributes

Timer watchers

Detailed Description

Describes and encapsulates a native command. A native command triggers a process, and provides various bells and whistles around the pure process object as provided by the Java Runtime.

The native command can be run a) within its own thread (as it implements Runnable), or b) directly via a call to its run() method.

Author:
mschilli


Constructor & Destructor Documentation

alma::acs::commandcenter::engine::NativeCommand::NativeCommand String  command,
boolean  foreground
[inline]
 

alma::acs::commandcenter::engine::NativeCommand::NativeCommand String  command,
boolean  foreground,
long  maxExecutionTime
[inline]
 

alma::acs::commandcenter::engine::NativeCommand::NativeCommand String  command,
boolean  foreground,
long  maxExecutionTime,
String  endMark
[inline]
 

alma::acs::commandcenter::engine::NativeCommand::NativeCommand String  command,
boolean  foreground,
long  maxExecutionTime,
String  endMark,
long  interval,
long  delay
[inline]
 


Member Function Documentation

void alma::acs::commandcenter::engine::NativeCommand::addListener NativeCommand.Listener  po  )  [inline]
 

void alma::acs::commandcenter::engine::NativeCommand::changeStatus String  newStatus  )  [inline, protected]
 

void alma::acs::commandcenter::engine::NativeCommand::fireOutputWritten InputStream  sourceStream,
String  additionalOutput
[inline, protected]
 

void alma::acs::commandcenter::engine::NativeCommand::fireStatusChanged String  oldStatus,
String  newStatus
[inline, protected]
 

Integer alma::acs::commandcenter::engine::NativeCommand::getExitValue  )  [inline]
 

Returns:
null if no exit value due to ungraceful process death

Throwable alma::acs::commandcenter::engine::NativeCommand::getLatestException  )  [inline]
 

Returns the most recent occured error. Note that the internal exception cache is reset by this method, thus it can only be called once for each error.

Returns:

String alma::acs::commandcenter::engine::NativeCommand::getStatus  )  [inline]
 

void alma::acs::commandcenter::engine::NativeCommand::removeListener NativeCommand.Listener  po  )  [inline]
 

void alma::acs::commandcenter::engine::NativeCommand::run  )  [inline]
 

We use four delegates:

  1. One to start a process
  2. One to watch its progress
  3. Two to read its output (out and err)

The delegates give feedback to the main thread by provoking InterruptedExceptions on it.

void alma::acs::commandcenter::engine::NativeCommand::send String  text  )  [inline]
 

Writes the given text to the STDIN of the process.

Parameters:
text the input to send to the process

void alma::acs::commandcenter::engine::NativeCommand::setThreadFactory ThreadFactory  threads  )  [inline]
 

This class executes various actions concurrently. With this setter, clients can control the threads to be used.

Parameters:
threads - null for default


Member Data Documentation

final String alma::acs::commandcenter::engine::NativeCommand::CANNOTRUN = "unable to run" [static]
 

String alma::acs::commandcenter::engine::NativeCommand::command [protected]
 

long alma::acs::commandcenter::engine::NativeCommand::DEFAULT_WATCHER_DELAY = 500 [static]
 

long alma::acs::commandcenter::engine::NativeCommand::DEFAULT_WATCHER_INTERVAL = 1000 [static]
 

long alma::acs::commandcenter::engine::NativeCommand::delay [protected]
 

String alma::acs::commandcenter::engine::NativeCommand::endMark [protected]
 

Integer alma::acs::commandcenter::engine::NativeCommand::exitValue = null [protected]
 

boolean alma::acs::commandcenter::engine::NativeCommand::foreground [protected]
 

long alma::acs::commandcenter::engine::NativeCommand::interval [protected]
 

Throwable alma::acs::commandcenter::engine::NativeCommand::latestException [protected]
 

Vector<NativeCommand.Listener> alma::acs::commandcenter::engine::NativeCommand::listeners = new Vector<NativeCommand.Listener>() [protected]
 

Logger alma::acs::commandcenter::engine::NativeCommand::log [protected]
 

long alma::acs::commandcenter::engine::NativeCommand::maxExecutionTime [protected]
 

final String alma::acs::commandcenter::engine::NativeCommand::NEW = "new" [static]
 

final long alma::acs::commandcenter::engine::NativeCommand::NO_TIMEOUT = -1 [static]
 

Process alma::acs::commandcenter::engine::NativeCommand::process [protected]
 

final String alma::acs::commandcenter::engine::NativeCommand::RUNNING = "running" [static]
 

String alma::acs::commandcenter::engine::NativeCommand::status [protected]
 

OutputStreamWriter alma::acs::commandcenter::engine::NativeCommand::stdin [protected]
 

final String alma::acs::commandcenter::engine::NativeCommand::TERMINATED = "terminated" [static]
 

ThreadFactory alma::acs::commandcenter::engine::NativeCommand::threadFactory = threadFactoryDefault [protected]
 

ThreadFactory alma::acs::commandcenter::engine::NativeCommand::threadFactoryDefault [protected]
 

Initial value:

new ThreadFactory(){ public Thread newThread (Runnable r) { return new Thread(r); } }
The default thread factory for background actions.

final String alma::acs::commandcenter::engine::NativeCommand::TIMEOUT = "timed out" [static]
 

Timer alma::acs::commandcenter::engine::NativeCommand::watchers [static, protected]
 


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:51:30 2009 for ACS Java API by doxygen 1.3.8