--- //c/turbine/jakarta-turbine/src/java/org/apache/turbine/services/pull/TurbinePullService.java	Thu Jun  7 21:27:46 2001
+++ //c/sandbox/turbine/src/java/org/apache/turbine/services/pull/TurbinePullService.java	Fri Jun 15 15:11:46 2001
@@ -77,6 +77,7 @@
 import org.apache.turbine.util.Log;
 import org.apache.turbine.util.RunData;
 import org.apache.turbine.util.ServletUtils;
+import org.apache.turbine.services.factory.FactoryService;
 
 /**
  * <p>
@@ -147,7 +148,7 @@
  *
  * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  * @author <a href="mailto:sean@informage.net">Sean Legassick</a>
- * @version $Id: TurbinePullService.java,v 1.24 2001/06/08 01:27:46 jon Exp $
+ * @version $Id: TurbinePullService.java,v 1.3 2001/06/14 22:58:57 cfelaco Exp $
  */
 public class TurbinePullService extends TurbineBaseService 
     implements PullService
@@ -171,14 +172,22 @@
     {
         String toolName;
         String toolClassName;
-        Class  toolClass;
 
+        /**
+         * @deprecated toolClass is no longer stored in ToolData
+         */
         public ToolData(String toolName, String toolClassName, Class toolClass)
         {
+            this(toolName, toolClassName);
+        }
+
+        public ToolData(String toolName, String toolClassName)
+        {
             this.toolName      = toolName;
             this.toolClassName = toolClassName;
-            this.toolClass     = toolClass;
         }
+
+
     }
 
     /**
@@ -368,17 +377,12 @@
             
             try
             {
-                /* 
-                 * Create an instance of the tool class.
-                 */
-                Class toolClass = Class.forName(toolClassName);
-
                 /*
                  * Add the tool to the list being built.
                  */
-                classes.add(new ToolData(toolName, toolClassName, toolClass));
+                classes.add(new ToolData(toolName, toolClassName));
                 
-                Log.info("Instantiated tool class " + toolClassName
+                Log.info("Setup tool class " + toolClassName
                         + " to add to the context as '$"  + toolName + "'"); 
             }
             catch (Exception e)
@@ -433,13 +437,17 @@
      */
     private void populateWithGlobalTools(Context context)
     {
+        // Use the FactoryService to get instances for much more flexibility
+        FactoryService factoryService = (FactoryService)
+            TurbineServices.getInstance().getService(FactoryService.SERVICE_NAME);
+   
         Iterator it = globalTools.iterator();
         while (it.hasNext())
         {
             ToolData toolData = (ToolData)it.next();
             try
             {
-                Object tool = toolData.toolClass.newInstance();
+                Object tool = factoryService.getInstance(toolData.toolClassName);
                 if (tool instanceof ApplicationTool)
                 {
                     // global tools are init'd with a null data parameter
@@ -476,7 +484,7 @@
             ToolData toolData = (ToolData)it.next();
             try
             {
-                Object tool = pool.getInstance(toolData.toolClass);
+                Object tool = pool.getInstance(toolData.toolClassName);
                 if (tool instanceof ApplicationTool)
                 {
                     // request tools are init'd with a RunData object
@@ -531,7 +539,7 @@
                     {
                         // if not there, an instance must be fetched from
                         // the pool
-                        tool = pool.getInstance(toolData.toolClass);
+                        tool = pool.getInstance(toolData.toolClassName);
                         if (tool instanceof ApplicationTool)
                         {
                             // session tools are init'd with the User object
