The Meta-Environment API

toolbus
Class ToolInstanceManager

java.lang.Object
  extended by toolbus.ToolInstanceManager

public class ToolInstanceManager
extends java.lang.Object

This class manages all the tool instances.

Author:
Arnold Lankamp

Field Summary
private  toolbus.util.collections.ConcurrentHashMap<aterm.ATerm,ToolInstance> activeTools
           
private  toolbus.util.collections.ConcurrentHashSet<ToolInstance> dynamiclyConnectedTools
           
private  toolbus.util.collections.ConcurrentHashMap<aterm.ATerm,ToolInstance> pendingTools
           
 
Constructor Summary
ToolInstanceManager()
          Default constructor.
 
Method Summary
 ToolInstance activateDynamiclyConnectedTool(java.lang.String toolName)
          Activates and returns a tool instance of the given type.
 ToolInstance activatePendingTool(aterm.ATerm toolKey)
          Attempts to activate the tool instance associated with the given key.
 void addDynamiclyConnectedTool(ToolInstance toolInstance)
          Adds a connect tool instance to the collection.
 void addPendingTool(ToolInstance toolInstance)
          Adds a tool instance to the list of which the tool application is currently being started.
 ToolInstance get(aterm.ATerm toolKey)
          Returns the tool with the given id, if it's present in the collection.
 ToolInstance getPendingTool(aterm.ATerm toolKey)
          Returns the tool with the given key, if it's present in the pending tool collection.
private  ToolInstance getReadyDynamiclyConnectedTool(java.lang.String toolName)
          Attempts to locate a dynamicly connected tool instance that is ready to be processed by the 'connect atom'.
 void killExecutedToolsNow()
          Kills all known executed tools immidiately.
 int numberOfConnectedTools()
          Counts the number of connected tools that are registered with this tool instance manager.
 void printQueueTerms()
          Prints all currently queued values, events and requests.
 void remove(aterm.ATerm toolKey)
          Removes the tool instance that is associated with the given id from the collection.
 void removeDynamiclyConnectedTool(ToolInstance toolInstance)
          Removes the given tool instance from the dynamicly connected tools list (if present).
 void removePendingTool(aterm.ATerm toolKey)
          Removes the given tool instance from the pending tools list (if present).
 void showStatus()
           
 void shutDown(aterm.ATerm message)
          Notifies all tools that the ToolBus was shut down, by sending a terminate(\) message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activeTools

private final toolbus.util.collections.ConcurrentHashMap<aterm.ATerm,ToolInstance> activeTools

pendingTools

private final toolbus.util.collections.ConcurrentHashMap<aterm.ATerm,ToolInstance> pendingTools

dynamiclyConnectedTools

private final toolbus.util.collections.ConcurrentHashSet<ToolInstance> dynamiclyConnectedTools
Constructor Detail

ToolInstanceManager

public ToolInstanceManager()
Default constructor.

Method Detail

get

public ToolInstance get(aterm.ATerm toolKey)
Returns the tool with the given id, if it's present in the collection.

Parameters:
toolKey - The key of the tool we want to retrieve.
Returns:
The tool instance associated with the given id.

remove

public void remove(aterm.ATerm toolKey)
Removes the tool instance that is associated with the given id from the collection.

Parameters:
toolKey - The key of the tool instance that we want to remove.

addDynamiclyConnectedTool

public void addDynamiclyConnectedTool(ToolInstance toolInstance)
Adds a connect tool instance to the collection. Connected tools are tools that are connected but are not being used by any process yet.

Parameters:
toolInstance - The pending tool instance we want to add.

activateDynamiclyConnectedTool

public ToolInstance activateDynamiclyConnectedTool(java.lang.String toolName)
Activates and returns a tool instance of the given type. This method moves the found tool instance from the dynamicly connected collection to the active collection.

Parameters:
toolName - The name identifying the type of the tool instance.
Returns:
The tool instance that was activated; if none is found NULL will be returned.

getReadyDynamiclyConnectedTool

private ToolInstance getReadyDynamiclyConnectedTool(java.lang.String toolName)
Attempts to locate a dynamicly connected tool instance that is ready to be processed by the 'connect atom'.

Parameters:
toolName - The name of the tool.
Returns:
The located tool instance (if present); if none is found NULL will be returned.

removeDynamiclyConnectedTool

public void removeDynamiclyConnectedTool(ToolInstance toolInstance)
Removes the given tool instance from the dynamicly connected tools list (if present).

Parameters:
toolInstance - The tool instance that needs to be removed.

addPendingTool

public void addPendingTool(ToolInstance toolInstance)
Adds a tool instance to the list of which the tool application is currently being started.

Parameters:
toolInstance - The tool instance we want to add.

getPendingTool

public ToolInstance getPendingTool(aterm.ATerm toolKey)
Returns the tool with the given key, if it's present in the pending tool collection.

Parameters:
toolKey - The key of the tool we want to retrieve.
Returns:
The tool instance associated with the given id.

activatePendingTool

public ToolInstance activatePendingTool(aterm.ATerm toolKey)
Attempts to activate the tool instance associated with the given key. If the tool instance associated with the given key is ready / connected, it will moved it to the activated collection.

Parameters:
toolKey - The key of the tool that has connected.
Returns:
The tool instance that was activated; if the tool instance associated with the given key is not connected / ready, NULL will be returned.

removePendingTool

public void removePendingTool(aterm.ATerm toolKey)
Removes the given tool instance from the pending tools list (if present).

Parameters:
toolKey - The key that is associated with the tool instance that needs to be removed.

shutDown

public void shutDown(aterm.ATerm message)
Notifies all tools that the ToolBus was shut down, by sending a terminate(\) message.

Parameters:
message - The message that will be encapsulated in the terminate message.

killExecutedToolsNow

public void killExecutedToolsNow()
Kills all known executed tools immidiately.


numberOfConnectedTools

public int numberOfConnectedTools()
Counts the number of connected tools that are registered with this tool instance manager.

Returns:
The number of connected tools that are registered with this tool instance manager.

printQueueTerms

public void printQueueTerms()
Prints all currently queued values, events and requests.


showStatus

public void showStatus()

The Meta-Environment API