org.aitools.programd.util
Class ManagedProcesses

java.lang.Object
  extended by org.aitools.programd.util.ManagedProcesses

public class ManagedProcesses
extends java.lang.Object

Controls processes that run in separate threads and need to be shut down before the bot exits.


Field Summary
private  Core core
          The Core to which this is attached.
private  java.util.Map<java.lang.String,ManagedProcess> registry
          The registry of all processes.
 
Constructor Summary
ManagedProcesses(Core coreToUse)
          Creates a ManagedProcesses object.
 
Method Summary
 ManagedProcess get(java.lang.String name)
          Returns a given process.
 void shutdownAll()
          Shuts down all registered processes.
 void start(ManagedProcess process, java.lang.String name)
          Adds a process to the registry and starts it.
 java.util.Collection<ManagedProcess> values()
          Returns an iterator on the registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

core

private Core core
The Core to which this is attached.


registry

private java.util.Map<java.lang.String,ManagedProcess> registry
The registry of all processes.

Constructor Detail

ManagedProcesses

public ManagedProcesses(Core coreToUse)
Creates a ManagedProcesses object.

Parameters:
coreToUse - the Core to which to attach this
Method Detail

start

public void start(ManagedProcess process,
                  java.lang.String name)
Adds a process to the registry and starts it.

Parameters:
process - the process to add
name - a name by which its thread will be identified

values

public java.util.Collection<ManagedProcess> values()
Returns an iterator on the registry.

Returns:
an iterator on the registry

get

public ManagedProcess get(java.lang.String name)
Returns a given process.

Parameters:
name - the name of the process
Returns:
the process assigned to the name

shutdownAll

public void shutdownAll()
Shuts down all registered processes.