Index: trunk/workflow/inc/local/classes/class.wf_workitem.php
===================================================================
--- trunk/workflow/inc/local/classes/class.wf_workitem.php	(revision 795)
+++ trunk/workflow/inc/local/classes/class.wf_workitem.php	(revision 2591)
@@ -29,5 +29,5 @@
 	public function wf_workitem()
 	{
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$this->processID = (int) $GLOBALS['workflow']['wf_runtime']->activity->getProcessId();
 	}
Index: trunk/workflow/inc/local/classes/class.wf_role.php
===================================================================
--- trunk/workflow/inc/local/classes/class.wf_role.php	(revision 1048)
+++ trunk/workflow/inc/local/classes/class.wf_role.php	(revision 2591)
@@ -57,7 +57,7 @@
 			$this->processID = (int) $GLOBALS['workflow']['job']['processID'];
 
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
-		$this->roleManager = CreateObject('workflow.workflow_rolemanager');
-		$this->activityManager = CreateObject('workflow.workflow_activitymanager');
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
+		$this->roleManager = Factory::getInstance('workflow_rolemanager');
+		$this->activityManager = Factory::getInstance('workflow_activitymanager');
 	}
 
@@ -186,5 +186,5 @@
 			$users = array((int) $users);
 		$roleID = $this->roleManager->get_role_id($this->processID, $roleName);
-		$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$ldap = Factory::getInstance('WorkflowLDAP');
 		foreach ($users as $user)
 		{
@@ -212,5 +212,5 @@
 		$users = $this->roleManager->list_mapped_users($this->processID, false, array('wf_role_name' => $roleName));
 
-		$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$ldap = Factory::getInstance('WorkflowLDAP');
 		$output = array();
 		foreach ($users as $id => $login)
@@ -367,5 +367,5 @@
 
 		/* get the roles */
-		$userGroups = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserGroups($userID);
+		$userGroups = Factory::getInstance('WorkflowLDAP')->getUserGroups($userID);
 		$query = 'SELECT DISTINCT role.wf_role_id, role.wf_name, role.wf_description FROM egw_wf_roles role, egw_wf_user_roles user_role WHERE (user_role.wf_role_id = role.wf_role_id) AND (role.wf_p_id = ?) AND (role.wf_role_id = ANY (?))';
 		$query .= ' AND (((user_role.wf_user = ?) AND (user_role.wf_account_type = ?))';
Index: trunk/workflow/inc/local/classes/class.wf_instance.php
===================================================================
--- trunk/workflow/inc/local/classes/class.wf_instance.php	(revision 1385)
+++ trunk/workflow/inc/local/classes/class.wf_instance.php	(revision 2591)
@@ -77,5 +77,5 @@
 	{
 		$instanceID = (int) $instanceID;
-		$instance = CreateObject('workflow.workflow_instance');
+		$instance = Factory::getInstance('workflow_instance');
 		if (!$instance->getInstance($instanceID))
 			return false;
@@ -92,5 +92,5 @@
 	{
 		/* load the DB */
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 
 		/* load the process ID from the runtime */
@@ -118,5 +118,5 @@
 		$instance = $this->getInstanceObject($instanceID);
 
-		$runActivity = CreateObject('workflow.run_activity');
+		$runActivity = Factory::getInstance('run_activity');
 
 		ob_start();
@@ -423,6 +423,5 @@
 
 		/* load the required instance (for the required user) */
-		require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'GUI' . SEP . 'GUI.php';
-		$GUI = new GUI($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$GUI = &Factory::newInstance('GUI');
 		$userInstance = $GUI->gui_list_user_instances($userID, 0, -1, '', '', "(ga.wf_is_interactive = 'y') AND (gia.wf_activity_id = {$activityID}) AND (gia.wf_instance_id = {$instanceID})", false, $this->processID, true, false, true, false, false, false);
 		$userInstance = $userInstance['data'];
@@ -456,9 +455,6 @@
 		if ($userID !== '*')
 		{
-			require_once dirname(__FILE__) . '/class.wf_role.php';
-			require_once dirname(__FILE__) . '/class.wf_engine.php';
-
-			$wfRole = new wf_role();
-			$engine = new wf_engine();
+			$wfRole = Factory::getInstance('wf_role');
+			$engine = Factory::getInstance('wf_engine');
 			/* get information about the activity */
 			if (($activityInfo = $engine->getActivityInformationByID($activityID)) === false)
@@ -529,6 +525,5 @@
 
 		/* try to get the role id */
-		require_once dirname(__FILE__) . '/class.wf_role.php';
-		$wfRole = new wf_role();
+		$wfRole = Factory::getInstance('wf_role');
 		if (($roleID = $wfRole->getRoleIdByName($roleName)) === false)
 			return false;
Index: trunk/workflow/inc/local/classes/class.wf_engine.php
===================================================================
--- trunk/workflow/inc/local/classes/class.wf_engine.php	(revision 795)
+++ trunk/workflow/inc/local/classes/class.wf_engine.php	(revision 2591)
@@ -68,5 +68,5 @@
 		$flagObject[0] = is_null($this->processManager);
 		if ($flagObject[0])
-			$this->processManager = CreateObject('workflow.workflow_processmanager');
+			$this->processManager = Factory::getInstance('workflow_processmanager');
 
 		$output = array();
@@ -90,6 +90,5 @@
 	function continueInstance($activityID, $instanceID)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		return $WFInstance->continueInstance($activityID, $instanceID);
 	}
@@ -104,6 +103,5 @@
 	function abortInstance($instanceID)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		return $WFInstance->abort($instanceID);
 	}
@@ -119,6 +117,5 @@
 	function setInstanceName($instanceID, $name)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		return $WFInstance->setName($instanceID, $name);
 	}
@@ -134,6 +131,5 @@
 	function setInstancePriority($instanceID, $priority)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		return $WFInstance->setPriority($instanceID, $priority);
 	}
@@ -149,6 +145,5 @@
 	function getIdleInstances($numberOfDays, $activities = null)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		return $WFInstance->getIdle($numberOfDays, $activities);
 	}
@@ -175,6 +170,5 @@
 	function getInstancesByName($name)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		$preOutput = $WFInstance->getByName($name);
 		$output = array();
@@ -197,6 +191,5 @@
 	function getChildInstances($instanceID = null, $activityID = null)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		$preOutput = $WFInstance->getChildren($instanceID, $activityID);
 		$output = array();
@@ -217,6 +210,5 @@
 	function getInstanceProperties($instanceID)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		return $WFInstance->getProperties($instanceID);
 	}
@@ -231,6 +223,5 @@
 	function getChildInstanceProperties($instanceID)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		return $WFInstance->getProperties($instanceID);
 	}
@@ -247,5 +238,5 @@
 		$flagObject[0] = is_null($this->acl);
 		if ($flagObject[0])
-			$this->acl = CreateObject('workflow.workflow_acl');
+			$this->acl = Factory::getInstance('workflow_acl');
 
 		$output = $this->acl->getUserPermissions($type, $uid);
@@ -268,5 +259,5 @@
 		$flagObject[0] = is_null($this->acl);
 		if ($flagObject[0])
-			$this->acl = CreateObject('workflow.workflow_acl');
+			$this->acl = Factory::getInstance('workflow_acl');
 
 		$output = $this->acl->getUserGroupPermissions($type, $uid);
@@ -291,5 +282,5 @@
 		/* build the SQL query */
 		$query = "SELECT wf_activity_id, wf_name, wf_normalized_name, wf_type, wf_description FROM egw_wf_activities WHERE (wf_activity_id = ?) AND (wf_p_id = ?)";
-		$db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$resultSet = $db->query($query, array($activityID, $processID));
 
@@ -319,5 +310,5 @@
 		/* build the SQL query */
 		$query = "SELECT wf_activity_id, wf_name, wf_normalized_name, wf_type, wf_description FROM egw_wf_activities WHERE (wf_name = ?) AND (wf_p_id = ?)";
-		$db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$resultSet = $db->query($query, array($activityName, $processID));
 
@@ -346,6 +337,5 @@
 	function getUserInstances($users, $activities = null, $status = null)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		return $WFInstance->getByUser($users, $activities, $status);
 	}
@@ -360,6 +350,5 @@
 	function setInstanceProperty($instanceID, $nameProperty, $value)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		return $WFInstance->setProperty($instanceID, $nameProperty, $value);
 	}
@@ -377,6 +366,5 @@
 	function checkUserAccessToInstance($userID, $instanceID, $activityID, $writeAccess = true)
 	{
-		require_once 'class.wf_instance.php';
-		$WFInstance = new wf_instance();
+		$WFInstance = &Factory::getInstance('wf_instance');
 		return $WFInstance->checkUserAccess($userID, $instanceID, $activityID, $writeAccess);
 	}
Index: trunk/workflow/inc/local/classes/class.wf_location.php
===================================================================
--- trunk/workflow/inc/local/classes/class.wf_location.php	(revision 2137)
+++ trunk/workflow/inc/local/classes/class.wf_location.php	(revision 2591)
@@ -36,5 +36,5 @@
 	function initialize()
 	{
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID;
 		$this->db->setFetchMode(ADODB_FETCH_ASSOC);
 		$this->cityInfo = array();
Index: trunk/workflow/inc/local/classes/class.JobBase.php
===================================================================
--- trunk/workflow/inc/local/classes/class.JobBase.php	(revision 1437)
+++ trunk/workflow/inc/local/classes/class.JobBase.php	(revision 2591)
@@ -89,9 +89,9 @@
 	{
 		require_once 'common.inc.php';
-		$GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment();
+		Factory::getInstance('WorkflowMacro')->prepareEnvironment();
 		$this->jobID = $jobID;
 		$this->processID = $processID;
 		$this->currentDate = $currentDate;
-		$this->jobManager = &$GLOBALS['workflow']['factory']->getInstance('WorkflowJobManager');
+		$this->jobManager = Factory::getInstance('WorkflowJobManager');
 		$this->testMode = $testMode;
 		$this->maximumExecutionTime = $maximumExecutionTime;
@@ -148,10 +148,8 @@
 	final private function prepareEnvironment()
 	{
-		$GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareProcessEnvironment($this->processID);
-
-		require_once PHPGW_SERVER_ROOT . '/workflow/inc/class.process_factory.inc.php';
+		Factory::getInstance('WorkflowMacro')->prepareProcessEnvironment($this->processID);
 
 		$this->environment = array();
-		$this->environment['factory']  = &new ProcessFactory();
+		$this->environment['factory']  = &Factory::newInstance('ProcessWrapperFactory');
 	}
 
@@ -202,5 +200,5 @@
 	final public function createNewInstance($startActivityId, $instanceName=false, $properties=false, $user=false)
 	{
-		$activityManager = CreateObject('workflow.workflow_activitymanager');
+		$activityManager = Factory::getInstance('workflow_activitymanager');
 		$activity = $activityManager->get_activity($startActivityId);
 
Index: trunk/workflow/inc/local/classes/class.wf_orgchart.php
===================================================================
--- trunk/workflow/inc/local/classes/class.wf_orgchart.php	(revision 2348)
+++ trunk/workflow/inc/local/classes/class.wf_orgchart.php	(revision 2591)
@@ -24,5 +24,5 @@
 	function wf_orgchart()
 	{
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID;
 		$this->db->setFetchMode(ADODB_FETCH_ASSOC);
 	}
Index: trunk/workflow/inc/local/classes/class.wf_ldap.php
===================================================================
--- trunk/workflow/inc/local/classes/class.wf_ldap.php	(revision 1067)
+++ trunk/workflow/inc/local/classes/class.wf_ldap.php	(revision 2591)
@@ -1,4 +1,3 @@
 <?php
-require_once PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'classes' . SEP . 'class.wf_cached_ldap.php';
 
 /**
@@ -41,11 +40,11 @@
 	function wf_ldap()
 	{
-		$tmpLDAP = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$tmpLDAP = Factory::getInstance('WorkflowLDAP');
 		$this->user_context  = $tmpLDAP->getUserContext();
 		$this->group_context = $tmpLDAP->getGroupContext();
 
-		$this->ds = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$this->ds = &Factory::getInstance('WorkflowObjects')->getLDAP();
 
-		$this->cachedLDAP = new wf_cached_ldap();
+		$this->cachedLDAP = &Factory::getInstance('wf_cached_ldap');
 		$this->cachedLDAP->setOperationMode($this->cachedLDAP->OPERATION_MODE_LDAP);
 	}
Index: trunk/workflow/inc/local/classes/class.wf_mail.php
===================================================================
--- trunk/workflow/inc/local/classes/class.wf_mail.php	(revision 795)
+++ trunk/workflow/inc/local/classes/class.wf_mail.php	(revision 2591)
@@ -39,5 +39,5 @@
 		$requiredConfiguration = array('mail_smtp_profile' => false);
 		$configuration = $GLOBALS['workflow']['wf_runtime']->process->getConfigValues($requiredConfiguration);
-		$bo_emailadmin = CreateObject('emailadmin.bo');
+		$bo_emailadmin = Factory::getInstance('bo');
 		$profileData = $bo_emailadmin->getProfile($configuration['mail_smtp_profile']);
 
