*/
private void populateWithSessionTools(List tools, Context context,
RunData data, boolean usePerm)
{
// Get the PoolService to fetch object instances from
PoolService pool = (PoolService)
TurbineServices.getInstance().getService(PoolService.SERVICE_NAME);
// Get the current user
User user = data.getUser();
// Iterate the tools
Iterator it = tools.iterator();
while (it.hasNext())
{
ToolData toolData = (ToolData)it.next();
try
{
// ensure that tool is created only once for a user
// by synchronizing against the user object
synchronized (user)
{
// first try and fetch the tool from the user's
// hashtable
Object tool = usePerm
? user.getPerm(toolData.toolClassName)
: user.getTemp(toolData.toolClassName);
if (tool == null)
{
// if not there, an instance must be fetched from
// the pool
tool = pool.getInstance(toolData.toolClass);
if (tool instanceof ApplicationTool)
{
// session tools are init'd with the User object
((ApplicationTool)tool).init(user);
}