org.sakaiproject.component.kernel.tool
Class ToolComponent

java.lang.Object
  extended byorg.sakaiproject.component.kernel.tool.ToolComponent
All Implemented Interfaces:
ToolManager
Direct Known Subclasses:
ActiveToolComponent

public class ToolComponent
extends Object
implements ToolManager

ToolComponent is the standard implementation of the Sakai Tool API.

Version:
$Revision: 4512 $
Author:
University of Michigan, Sakai Software Development Team

Field Summary
protected static String CURRENT_PLACEMENT
          Key in the ThreadLocalManager for binding our current placement.
protected static String CURRENT_TOOL
          Key in the ThreadLocalManager for binding our current tool.
protected  String[] m_stealthToolIds
          tool ids to be stealthed.
protected  ThreadLocalManager m_threadLocalManager
          Dependency: the current manager.
protected  Map m_tools
          The registered tools.
 
Constructor Summary
ToolComponent()
           
 
Method Summary
 void destroy()
          Final cleanup.
 Set findTools(Set categories, Set keywords)
          Find a set of tools that meet the critieria.
 Placement getCurrentPlacement()
          Access the Tool Placement associated with the current request / thread
 Tool getCurrentTool()
          Access the Tool associated with the current request / thread
 Tool getTool(String id)
          Find a tool with this well known id in the registry.
 void init()
          Final initialization, once all dependencies are set.
protected  boolean matchCriteria(Set criteria, Set target)
          Check the target values for a match in the criteria.
 void register(Document toolXml)
          Add tools in this XML DOM to the registry, using the Tool XML schema.
 void register(File toolXmlFile)
          Add tools in this file of Tool XML schema to the registry.
 void register(InputStream toolXmlStream)
          Add tools in this stream of Tool XML schema to the registry.
 void register(Tool tool)
          Add this tool to the registry.
protected  void setCurrentPlacement(Placement placement)
          Establish the Tool associated with the current request / thread
protected  void setCurrentTool(Tool tool)
          Establish the Tool associated with the current request / thread
 void setStealthTools(String toolIds)
          Configuration - set the list of tool ids to be "stealthed".
 void setThreadLocalManager(ThreadLocalManager manager)
          Dependency - set the current manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURRENT_PLACEMENT

protected static final String CURRENT_PLACEMENT
Key in the ThreadLocalManager for binding our current placement.

See Also:
Constant Field Values

CURRENT_TOOL

protected static final String CURRENT_TOOL
Key in the ThreadLocalManager for binding our current tool.

See Also:
Constant Field Values

m_tools

protected Map m_tools
The registered tools.


m_threadLocalManager

protected ThreadLocalManager m_threadLocalManager
Dependency: the current manager.


m_stealthToolIds

protected String[] m_stealthToolIds
tool ids to be stealthed.

Constructor Detail

ToolComponent

public ToolComponent()
Method Detail

setThreadLocalManager

public void setThreadLocalManager(ThreadLocalManager manager)
Dependency - set the current manager.


setStealthTools

public void setStealthTools(String toolIds)
Configuration - set the list of tool ids to be "stealthed". A stealthed tool does not show up in a category list of tools.

Parameters:
toolIds - The comma-separated list of tool ids to be stealthed.

init

public void init()
Final initialization, once all dependencies are set.


destroy

public void destroy()
Final cleanup.


findTools

public Set findTools(Set categories,
                     Set keywords)
Description copied from interface: ToolManager
Find a set of tools that meet the critieria. A tool must have a category in the categories criteria (unless it is empty or null) to be returned. A tool must have a keyword in the keywords criteria (unless it is empty or null) to be returned. If both categories and keywords criteria are specified, the tool must meet both criteria to be returned. If neither criteria are specified, all registered tools are returned.

Specified by:
findTools in interface ToolManager
Parameters:
categories - A Set (String) of category values; if null or empty no category criteria is specified.
keywords - A Set (String) of keyword values; if null or empty no keyword criteria is specified.
Returns:
A Set (Tool) of Tool objects that meet the criteria, or an empty set if none found.

getCurrentPlacement

public Placement getCurrentPlacement()
Description copied from interface: ToolManager
Access the Tool Placement associated with the current request / thread

Specified by:
getCurrentPlacement in interface ToolManager
Returns:
The current Tool Placement, or null if there is none.

getCurrentTool

public Tool getCurrentTool()
Description copied from interface: ToolManager
Access the Tool associated with the current request / thread

Specified by:
getCurrentTool in interface ToolManager
Returns:
The current Tool, or null if there is none.

getTool

public Tool getTool(String id)
Description copied from interface: ToolManager
Find a tool with this well known id in the registry.

Specified by:
getTool in interface ToolManager
Parameters:
id - The tool's well known id.
Returns:
The Tool object that has this id, or null if not found.

matchCriteria

protected boolean matchCriteria(Set criteria,
                                Set target)
Check the target values for a match in the criteria. If criteria is empty or null, the target is a match.

Parameters:
criteria - The set of String values that is the criteria - any one in the target is a match
target - The set of String values to check against the criteria.
Returns:
true if the target meets the criteria, false if not.

register

public void register(Document toolXml)
Description copied from interface: ToolManager
Add tools in this XML DOM to the registry, using the Tool XML schema.

Specified by:
register in interface ToolManager
Parameters:
toolXml - The parsed XML DOM in which tools to be added to the registry are to be found.

register

public void register(File toolXmlFile)
Description copied from interface: ToolManager
Add tools in this file of Tool XML schema to the registry.

Specified by:
register in interface ToolManager
Parameters:
toolXmlFile - The file of Tool schema XML in which tools to be added to the registry are to be found.

register

public void register(InputStream toolXmlStream)
Description copied from interface: ToolManager
Add tools in this stream of Tool XML schema to the registry.

Specified by:
register in interface ToolManager

register

public void register(Tool tool)
Description copied from interface: ToolManager
Add this tool to the registry.

Specified by:
register in interface ToolManager
Parameters:
tool - The Tool to register.

setCurrentPlacement

protected void setCurrentPlacement(Placement placement)
Establish the Tool associated with the current request / thread


setCurrentTool

protected void setCurrentTool(Tool tool)
Establish the Tool associated with the current request / thread