|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.phoenix_int.aserver.PHXRunShare
public class PHXRunShare
This class handles runshare capabilities for any component which needs it. It can create temp directorys, deal w/ auto-copy and auto-delete of important files, return errors and block until it is safe to run. It also handles providing monitors for stdout and stderr as well as for monitoring started processes.
This class can only handle one single process running at a time. If you need to run multiple processes, use multiple instances of this class. You can use this same object over and over by calling lock() and unlock() multiple times.
| Nested Class Summary | |
|---|---|
class |
PHXRunShare.RunInfo
Data structure used to hold info about a currently running command |
| Field Summary | |
|---|---|
static int |
DEL_AUTO
|
static int |
DEL_FALSE
|
static int |
DEL_TRUE
|
static int |
MODE_ERROR
|
static int |
MODE_NONE
|
static int |
MODE_SHARE
|
static int |
MODE_WAIT
|
| Constructor Summary | |
|---|---|
PHXRunShare(java.lang.String baseDir,
java.lang.String wrapperID)
|
|
| Method Summary | |
|---|---|
void |
addFileToCopy(java.lang.String file)
|
void |
addRunDirChangedListener(com.phoenix_int.aserver.IPHXRunDirChangedListener rdl)
Adds a listener which will receive events when the run directory is changed. |
void |
addTraceListener(com.phoenix_int.aserver.trace.IPHXTraceListener listener)
Adds a listener to trace events |
void |
cleanTempDir()
cleans up the temporary run directory if one has been created. |
void |
finalize()
|
boolean |
getAutoChangeDir()
Gets the "AutoChangeDir" flag |
int |
getAutoDelete()
Gets the auto-delete mode |
java.lang.String |
getBaseDirectory()
Gets the base dir which was passed in to the constructor. |
java.util.Map |
getDictionary()
|
java.lang.String |
getDirectory()
Returns the current directory being used by the runshare system. |
boolean |
getIgnoreErrors()
Gets the "IgnoreErrors" flag |
int |
getMode()
Gets the runshare mode |
java.lang.Object |
getMonitor(java.lang.String m)
Returns any available monitors by name. |
java.lang.String |
getShell()
Gets the shell used to execute commands. |
java.lang.String |
getWrapperID()
Returns the wrapper ID being used for locking. |
void |
halt()
halts any running process |
java.lang.String[] |
listMonitorableFiles()
Lists available "monitors". |
PHXProcessInfo[] |
listProcesses()
Lists any running processes |
void |
lock()
Causes the run-share mode to be implemented. |
void |
removeRunDirChangedListener(com.phoenix_int.aserver.IPHXRunDirChangedListener rdl)
Removes a listener for run directory changed events. |
void |
removeTraceListener(com.phoenix_int.aserver.trace.IPHXTraceListener listener)
Removes a listener from trace events |
int |
run(java.lang.String cmd)
Runs a command. |
int |
run(java.lang.String cmd,
boolean ignoreErrors,
boolean autoChangeDir,
java.lang.String shell)
Runs a command. |
int |
run(java.lang.String cmd,
boolean ignoreErrors,
java.lang.String autoChangeDir,
java.lang.String shell)
Runs a command. |
void |
setAutoChangeDir(boolean flag)
Sets the "AutoChangeDir" flag. |
void |
setAutoDelete(int autoDelete)
Sets the auto-delete mode for runshare mode MODE_SHARE. |
PHXRunShare |
setDictionary(java.util.Map dict)
|
void |
setDirectTransfer(boolean flag)
Set whehter or not this runShare is involved in direct transfer of files |
void |
setFilesToCopy(java.lang.String files)
Sets the files which need to be copied when runshare mode is MODE_SHARE. |
void |
setIgnoreErrors(boolean flag)
Sets the "IgnoreErrors" flag. |
void |
setMode(int mode)
Sets the runshare mode. |
void |
setRunReplacer(com.phoenix_int.aserver.util.PHXRunReplacer replacer)
Sets the run replacer object which is used to transform $VAR type specifications before running commands |
void |
setShell(java.lang.String shell)
Sets the shell used to execute commands. |
void |
unlock()
Unlocks the runshare mechanisms. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MODE_NONE
public static final int MODE_ERROR
public static final int MODE_WAIT
public static final int MODE_SHARE
public static final int DEL_AUTO
public static final int DEL_FALSE
public static final int DEL_TRUE
| Constructor Detail |
|---|
public PHXRunShare(java.lang.String baseDir,
java.lang.String wrapperID)
baseDir - The directory on disk where the files
associated w/ this component are located.wrapperID - A unique ID which identifies this component.
This is used to synchronize runshare access across multiple
instances of the same component. Typically the full path
on disk to the component's main file is used for this ID.| Method Detail |
|---|
public void finalize()
finalize in class java.lang.Objectpublic java.lang.String getWrapperID()
public PHXRunShare setDictionary(java.util.Map dict)
public java.util.Map getDictionary()
public void setRunReplacer(com.phoenix_int.aserver.util.PHXRunReplacer replacer)
public void addRunDirChangedListener(com.phoenix_int.aserver.IPHXRunDirChangedListener rdl)
public void removeRunDirChangedListener(com.phoenix_int.aserver.IPHXRunDirChangedListener rdl)
public java.lang.String getBaseDirectory()
public java.lang.String getDirectory()
public void lock()
throws java.io.IOException
Once in "locked" mode, calling lock() again has no effect.
java.io.IOExceptionpublic void unlock()
Calling unlock() when not in "locked" mode has no effect.
public void setDirectTransfer(boolean flag)
flag - boolean flag
public void cleanTempDir()
throws java.io.IOException
java.io.IOExceptionpublic void setMode(int mode)
public int getMode()
public void addFileToCopy(java.lang.String file)
public void setFilesToCopy(java.lang.String files)
public void setAutoDelete(int autoDelete)
public int getAutoDelete()
public void setIgnoreErrors(boolean flag)
flag - true to ignore errorspublic boolean getIgnoreErrors()
public void setAutoChangeDir(boolean flag)
flag - false to not change folders.public boolean getAutoChangeDir()
public void setShell(java.lang.String shell)
shell - The shell used to invoke the run commandpublic java.lang.String getShell()
public int run(java.lang.String cmd)
throws java.lang.Exception
This function will not return until the sub-process has finished. It will collect stdout and stderr and provide progress monitors.
cmd - The command to run.
java.lang.Exception
public int run(java.lang.String cmd,
boolean ignoreErrors,
boolean autoChangeDir,
java.lang.String shell)
throws java.lang.Exception
This function will not return until the sub-process has finished. It will collect stdout and stderr and provide progress monitors.
cmd - The command to run.ignoreErrors - By default this code will throw
an exception if the spawned process returns a non-zero
errorlevel. Occasionally a program will return an errorlevel
even if it succeeds. This option allows you to igore the
errorlevel.autoChangeDir - Whether to change the current working
directory to the run directory (see getDirectory) before
running the code. True by default.shell - On UNIX you can specify which shell to use
to launch the program. By default "sh" is used.
java.lang.Exception
public int run(java.lang.String cmd,
boolean ignoreErrors,
java.lang.String autoChangeDir,
java.lang.String shell)
throws java.lang.Exception
This function will not return until the sub-process has finished. It will collect stdout and stderr and provide progress monitors.
cmd - The command to run.ignoreErrors - By default this code will throw
an exception if the spawned process returns a non-zero
errorlevel. Occasionally a program will return an errorlevel
even if it succeeds. This option allows you to igore the
errorlevel.autoChangeDir - If non-empty, the directory will be
changed to this before running the program.shell - On UNIX you can specify which shell to use
to launch the program. By default "sh" is used.
java.lang.Exceptionpublic void halt()
public PHXProcessInfo[] listProcesses()
throws java.io.IOException
listProcesses in interface IPHXMonitorablejava.io.IOException - If there was a problem
reading information about running processes
public java.lang.String[] listMonitorableFiles()
throws java.io.IOException
listMonitorableFiles in interface IPHXMonitorablejava.io.IOException
public java.lang.Object getMonitor(java.lang.String m)
throws PHXNoSuchObjectException
getMonitor in interface IPHXMonitorablePHXNoSuchObjectExceptionpublic void addTraceListener(com.phoenix_int.aserver.trace.IPHXTraceListener listener)
addTraceListener in interface com.phoenix_int.aserver.trace.IPHXTraceGeneratorlistener - the listenerpublic void removeTraceListener(com.phoenix_int.aserver.trace.IPHXTraceListener listener)
removeTraceListener in interface com.phoenix_int.aserver.trace.IPHXTraceGeneratorlistener - the listener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||