Index: trunk/workflow/inc/engine/src/API/Process.php
===================================================================
--- trunk/workflow/inc/engine/src/API/Process.php	(revision 795)
+++ trunk/workflow/inc/engine/src/API/Process.php	(revision 2591)
@@ -48,8 +48,8 @@
 	 * @access public
 	 */
-	function Process(&$db) 
+	function Process() 
 	{
 		$this->child_name = 'Process';
-		parent::Base($db);
+		parent::Base();
 	}
 
Index: trunk/workflow/inc/engine/src/API/activities/View.php
===================================================================
--- trunk/workflow/inc/engine/src/API/activities/View.php	(revision 795)
+++ trunk/workflow/inc/engine/src/API/activities/View.php	(revision 2591)
@@ -16,7 +16,7 @@
 	 * @access public
 	 */	
-	function View(&$db)
+	function View()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'View';
 	}
Index: trunk/workflow/inc/engine/src/API/activities/Split.php
===================================================================
--- trunk/workflow/inc/engine/src/API/activities/Split.php	(revision 795)
+++ trunk/workflow/inc/engine/src/API/activities/Split.php	(revision 2591)
@@ -15,7 +15,7 @@
 	 * @access public
 	 */
-	function Split(&$db)
+	function Split()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'Split';
 	}
Index: trunk/workflow/inc/engine/src/API/activities/Activity.php
===================================================================
--- trunk/workflow/inc/engine/src/API/activities/Activity.php	(revision 795)
+++ trunk/workflow/inc/engine/src/API/activities/Activity.php	(revision 2591)
@@ -16,7 +16,7 @@
 	 * @access public
 	 */
-	function Activity(&$db)
+	function Activity()
 	{
-		parent::Base($db);
+		parent::Base();
 		$this->child_name = 'Activity';
 	}
Index: trunk/workflow/inc/engine/src/API/activities/Start.php
===================================================================
--- trunk/workflow/inc/engine/src/API/activities/Start.php	(revision 795)
+++ trunk/workflow/inc/engine/src/API/activities/Start.php	(revision 2591)
@@ -15,7 +15,7 @@
 	 * @access public
 	 */
-	function Start(&$db)
+	function Start()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'Start';
 	}
Index: trunk/workflow/inc/engine/src/API/activities/SwitchActivity.php
===================================================================
--- trunk/workflow/inc/engine/src/API/activities/SwitchActivity.php	(revision 795)
+++ trunk/workflow/inc/engine/src/API/activities/SwitchActivity.php	(revision 2591)
@@ -16,7 +16,7 @@
 	 * @access public
 	 */
-	function SwitchActivity(&$db)
+	function SwitchActivity()
 	{
-	   parent::Base($db);
+	   parent::Base();
 	   $this->child_name = 'Switch';
 	}
Index: trunk/workflow/inc/engine/src/API/activities/Join.php
===================================================================
--- trunk/workflow/inc/engine/src/API/activities/Join.php	(revision 795)
+++ trunk/workflow/inc/engine/src/API/activities/Join.php	(revision 2591)
@@ -15,7 +15,7 @@
 	 * @access public
 	 */
-	function Join(&$db)
+	function Join()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'Join';
 	}
Index: trunk/workflow/inc/engine/src/API/activities/End.php
===================================================================
--- trunk/workflow/inc/engine/src/API/activities/End.php	(revision 795)
+++ trunk/workflow/inc/engine/src/API/activities/End.php	(revision 2591)
@@ -15,7 +15,7 @@
 	 * @access public
 	 */
-	function End(&$db)
+	function End()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'End';
 	}
Index: trunk/workflow/inc/engine/src/API/activities/Standalone.php
===================================================================
--- trunk/workflow/inc/engine/src/API/activities/Standalone.php	(revision 795)
+++ trunk/workflow/inc/engine/src/API/activities/Standalone.php	(revision 2591)
@@ -15,7 +15,7 @@
 	 * @access public
 	 */
-	function Standalone(&$db)
+	function Standalone()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'Standalone';
 	}
Index: trunk/workflow/inc/engine/src/API/Instance.php
===================================================================
--- trunk/workflow/inc/engine/src/API/Instance.php	(revision 795)
+++ trunk/workflow/inc/engine/src/API/Instance.php	(revision 2591)
@@ -1,5 +1,4 @@
 <?php
 require_once (GALAXIA_LIBRARY.SEP.'src'.SEP.'common'.SEP.'Base.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'common' . SEP . 'WfSecurity.php');
 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php');
 
@@ -141,8 +140,8 @@
 
   var $activityID = null;
-  function Instance($db) 
+  function Instance() 
   {
     $this->child_name = 'Instance';
-    parent::Base($db);
+    parent::Base();
   }
 
@@ -1171,5 +1170,5 @@
     
     //lock rows and ensure access is granted
-    if (!(isset($this->security))) $this->security =& new WfSecurity($this->db); 
+    if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity');
     if (!($this->security->checkUserAction($activityId,$this->instanceId,'complete')))
     {
@@ -1551,5 +1550,5 @@
     {
       //we check rights for this user on the next activity
-      if (!(isset($this->security))) $this->security =& new WfSecurity($this->db); 
+      if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity');
       if ($this->security->checkUserAccess($the_next_user,$activityId))
       {
@@ -1560,5 +1559,5 @@
     {
       // then check to see if there is a default user
-      $activity_manager =& new ActivityManager($this->db);
+      $activity_manager = &Factory::newInstance('ActivityManager');
       //get_default_user will give us '*' if there is no default_user or if the default user has no role
       //mapped anymore
Index: trunk/workflow/inc/engine/src/API/BaseActivity.php
===================================================================
--- trunk/workflow/inc/engine/src/API/BaseActivity.php	(revision 795)
+++ trunk/workflow/inc/engine/src/API/BaseActivity.php	(revision 2591)
@@ -97,9 +97,9 @@
    * @access public
    */
-  function BaseActivity(&$db)
+  function BaseActivity()
   {
     $this->type='base';
     $this->child_name = 'BaseActivity';
-    parent::Base($db);
+    parent::Base();
   }
 
@@ -122,41 +122,42 @@
     if(!$result || !$result->numRows() ) return false;
     $res = $result->fetchRow();
+
     switch($res['wf_type']) {
       case 'start':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Start.php');
-        $act = new Start($this->db);  
-        break;
+        $act = &Factory::newInstance('Start');
+        break;
+
       case 'end':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'End.php');
-        $act = new End($this->db);
-        break;
+        $act = &Factory::newInstance('End');
+        break;
+
       case 'join':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Join.php');
-        $act = new Join($this->db);
-        break;
+        $act = &Factory::newInstance('Join');
+        break;
+
       case 'split':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Split.php');
-        $act = new Split($this->db);
-        break;
+        $act = &Factory::newInstance('Split');
+        break;
+
       case 'standalone':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Standalone.php');
-        $act = new Standalone($this->db);
-        break;
+        $act = &Factory::newInstance('Standalone');
+        break;
+
       case 'view':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'View.php');
-        $act = new View($this->db);
-        break;
+        $act = &Factory::newInstance('View');
+        break;
+
       case 'switch':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'SwitchActivity.php');
-        $act = new SwitchActivity($this->db);
-        break;
+        $act = &Factory::newInstance('SwitchActivity');
+        break;
+
       case 'activity':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Activity.php');
-        $act = new Activity($this->db);
-        break;
+        $act = &Factory::newInstance('Activity');
+        break;
+
       default:
         trigger_error('Unknown activity type:'.$res['wf_type'],E_USER_WARNING);
     }
-    
+
     $act->setName($res['wf_name']);
     $act->setProcessId($res['wf_p_id']);
