org.javagroup.process
Interface ProcessManager

All Known Implementing Classes:
StandardProcessManager

public abstract interface ProcessManager


Method Summary
 void addProcessEventListener(ProcessEventListener listener)
           
 JProcess createProcess(java.lang.String className)
          Create a process with given args, and additional classpath(s).
 JProcess createProcess(java.lang.String className, java.lang.String[] args)
          Create a process with given args, and additional classpath(s).
 JProcess createProcess(java.lang.String className, java.lang.String[] args, java.net.URL[] classPath)
          Create a process with given args, and additional classpath(s).
 JProcess createProcessFromString(java.lang.String line)
          Creates a process from the information in a given String of the format: " *".
 JProcess createProcessFromString(java.lang.String line, java.net.URL[] classPath)
          Creates a process from the information in a given String of the format: " *".
 void doGarbageCollect()
          Perform garbage collection.
 JProcess getCurrentProcess()
          Return the current process.
 JProcess getProcess(long pid)
          Get a process by process-id.
 java.util.Enumeration getProcesses()
          Get an enumeration of all processes.
 JProcess getProcessFor(java.lang.ClassLoader loader)
          Get the process that a classloader belongs to.
 JProcess getProcessFor(java.lang.ThreadGroup group)
          Get the process that a threadgroup belongs to.
 StandardIO getStandardIOForProcess(JProcess process)
          Set the streams to be used when the Process asks for standard io.
 void kill(long pid)
          Kill a process by pid.
 void removeProcessEventListener(ProcessEventListener listener)
           
 void setStandardIOForProcess(JProcess process, StandardIO stdio)
          Get the streams a process uses for standard io
 

Method Detail

createProcess

public JProcess createProcess(java.lang.String className)
                       throws ProcessCreationException
Create a process with given args, and additional classpath(s).
Parameters:
className - The name of the target class.

createProcess

public JProcess createProcess(java.lang.String className,
                              java.lang.String[] args)
                       throws ProcessCreationException
Create a process with given args, and additional classpath(s).
Parameters:
className - The name of the target class.
args - The arguments to pass to the main(String[]) method.

createProcess

public JProcess createProcess(java.lang.String className,
                              java.lang.String[] args,
                              java.net.URL[] classPath)
                       throws ProcessCreationException
Create a process with given args, and additional classpath(s).
Parameters:
className - The name of the target class.
args - The arguments to pass to the main(String[]) method.
classpath - An array of URLs to search for classes in.

createProcessFromString

public JProcess createProcessFromString(java.lang.String line)
                                 throws ProcessCreationException
Creates a process from the information in a given String of the format: " *".
Parameters:
string - The string to decode process info from.
Returns:
The created JProcess.

createProcessFromString

public JProcess createProcessFromString(java.lang.String line,
                                        java.net.URL[] classPath)
                                 throws ProcessCreationException
Creates a process from the information in a given String of the format: " *".
Parameters:
string - The string to decode process info from.
classpath - Classpaths to search in addition to defaults.
Returns:
The created JProcess.

getProcessFor

public JProcess getProcessFor(java.lang.ThreadGroup group)
Get the process that a threadgroup belongs to.
Parameters:
group - The ThreadGroup to attribute a process to.
Returns:
The process owning the group, or null if none found.

getProcessFor

public JProcess getProcessFor(java.lang.ClassLoader loader)
Get the process that a classloader belongs to.
Parameters:
group - The ThreadGroup to attribute a process to.
Returns:
The process owning the group, or null if none found.

getCurrentProcess

public JProcess getCurrentProcess()
Return the current process.
Returns:
The process making the invocation, or null if none can be determined.

getProcess

public JProcess getProcess(long pid)
Get a process by process-id.
Parameters:
pid - The id-number of the process.
Returns:
The process, or null if no match.

getProcesses

public java.util.Enumeration getProcesses()
Get an enumeration of all processes.
Returns:
Enumeration of all processes.

kill

public void kill(long pid)
Kill a process by pid.
Parameters:
pid - The process-id to kill.

addProcessEventListener

public void addProcessEventListener(ProcessEventListener listener)

removeProcessEventListener

public void removeProcessEventListener(ProcessEventListener listener)

doGarbageCollect

public void doGarbageCollect()
Perform garbage collection. Usually invoked by the garbage collector.

getStandardIOForProcess

public StandardIO getStandardIOForProcess(JProcess process)
Set the streams to be used when the Process asks for standard io.
Parameters:
process - The process to set for.
stdio - The set of IO streams to use as standard io.

setStandardIOForProcess

public void setStandardIOForProcess(JProcess process,
                                    StandardIO stdio)
Get the streams a process uses for standard io
Parameters:
process - The process to get streams for.
Returns:
The set of streams being used as standard io.