From: Roland Häder <roland@mxchange.org>
Date: Sun, 21 Mar 2010 00:28:56 +0000 (+0000)
Subject: Removed some dublicate instances to avoid confusion
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=22079aa7f39f3cbdf0eb62980b4a36810451eea6;p=hub.git

Removed some dublicate instances to avoid confusion
---

diff --git a/application/hub/interfaces/connectors/class_Connectable.php b/application/hub/interfaces/connectors/class_Connectable.php
index e4270e036..bd6e7c4a1 100644
--- a/application/hub/interfaces/connectors/class_Connectable.php
+++ b/application/hub/interfaces/connectors/class_Connectable.php
@@ -23,13 +23,13 @@
  */
 interface Connectable extends FrameworkInterface {
 	/**
-	 * Processes all pending queries. This method should be called by the
+	 * Handles all pending queries. This method should be called by the
 	 * ActiveTaskVisitor class and should use an iterator on all pending
 	 * queries.
 	 *
 	 * @return	void
 	 */
-	function processAllPendingQueries ();
+	function handlePendingQueries ();
 }
 
 // [EOF]
diff --git a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php
index 2d35cae8a..88dd5c3f2 100644
--- a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php
+++ b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php
@@ -85,16 +85,27 @@ class LocalQueryConnector extends BaseQueryConnector implements Connectable, Vis
 	}
 
 	/**
-	 * Processes all pending queries. This method should be called by the
+	 * Handles all pending queries. This method should be called by the
 	 * ActiveTaskVisitor class and should use an iterator on all pending
 	 * queries.
 	 *
 	 * @return	void
 	 */
-	public function processAllPendingQueries () {
-		$this->partialStub('Please implement this method.');
+	public function handlePendingQueries () {
+		// Should we rewind?
+		if (!$this->getIteratorInstance()->valid()) {
+			// Rewind to the beginning for next loop
+			$this->getIteratorInstance()->rewind();
+		} // END - if
+
+		// Try to execute the task
+		$this->handleCurrentQuery();
+
+		// Go to next entry
+		$this->getIteratorInstance()->next();
 	}
 }
 
 // [EOF]
 ?>
+
diff --git a/application/hub/main/handler/tasks/class_TaskHandler.php b/application/hub/main/handler/tasks/class_TaskHandler.php
index 9799fb06d..a1ecf3016 100644
--- a/application/hub/main/handler/tasks/class_TaskHandler.php
+++ b/application/hub/main/handler/tasks/class_TaskHandler.php
@@ -25,16 +25,6 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
 	// Exception constants
 	const EXCEPTION_TASK_IS_INVALID = 0xb00;
 
-	/**
-	 * A task list instance
-	 */
-	private $listInstance = null;
-
-	/**
-	 * Instance for iterator
-	 */
-	private $iteratorInstance = null;
-
 	/**
 	 * Visitor instance for all tasks while they are active
 	 */
@@ -50,10 +40,10 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
 		parent::__construct(__CLASS__);
 
 		// Init the task list
-		$this->listInstance = ObjectFactory::createObjectByConfiguredName('task_list_class');
+		$this->setListInstance(ObjectFactory::createObjectByConfiguredName('task_list_class'));
 
 		// Get default instance
-		$this->iteratorInstance = $this->listInstance->getIterator();
+		$this->setIteratorInstance($this->getListInstance()->getIterator());
 
 		// Init visitor instance for faster loop
 		$this->visitorInstance = ObjectFactory::createObjectByConfiguredName('active_task_visitor_class');
@@ -88,13 +78,13 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
 		$updateTask = false;
 
 		// Is the current task valid?
-		if (!$this->iteratorInstance->valid()) {
+		if (!$this->getIteratorInstance()->valid()) {
 			// Not valid!
 			throw new InvalidTaskException($this, self::EXCEPTION_TASK_IS_INVALID);
 		} // END - if
 
 		// Get current task
-		$currentTask = $this->iteratorInstance->current();
+		$currentTask = $this->getIteratorInstance()->current();
 
 		// Is the task not yet started?
 		if ($currentTask['task_started'] === false) {
@@ -152,13 +142,13 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
 	 */
 	private function updateTask (array $taskEntry) {
 		// Get the key from current iteration
-		$key = $this->iteratorInstance->key();
+		$key = $this->getIteratorInstance()->key();
 
 		// Get the hash from key
-		$hash = $this->listInstance->getHash($key);
+		$hash = $this->getListInstance()->getHash($key);
 
 		// Update the entry
-		$this->listInstance->updateCurrentEntryByHash($hash, $taskEntry);
+		$this->getListInstance()->updateCurrentEntryByHash($hash, $taskEntry);
 	}
 
 	/**
@@ -169,7 +159,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
 	 */
 	 private function unregisterTask ($taskName) {
 		// Remove the entry
-		$this->listInstance->removeEntry('tasks', $taskName);
+		$this->getListInstance()->removeEntry('tasks', $taskName);
 	 }
 
 	/**
@@ -207,7 +197,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
 		);
 
 		// Add the entry
-		$this->listInstance->addEntry('tasks', $taskEntry);
+		$this->getListInstance()->addEntry('tasks', $taskEntry);
 
 		// Debug message
 		$this->debugOutput('TASK-HANDLER: Task ' . $taskName .
@@ -225,7 +215,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
 	 */
 	public function hasTasksLeft () {
 		// Do we have tasks there?
-		$tasksLeft = (($this->listInstance instanceof Listable) && ($this->listInstance->count() > 0));
+		$tasksLeft = (($this->getListInstance() instanceof Listable) && ($this->getListInstance()->count() > 0));
 
 		// Return result
 		return $tasksLeft;
@@ -241,16 +231,16 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
 	 */
 	public function handleTasks () {
 		// Should we rewind?
-		if (!$this->iteratorInstance->valid()) {
+		if (!$this->getIteratorInstance()->valid()) {
 			// Rewind to the beginning for next loop
-			$this->iteratorInstance->rewind();
+			$this->getIteratorInstance()->rewind();
 		} // END - if
 
 		// Try to execute the task
 		$this->executeCurrentTask();
 
 		// Go to next entry
-		$this->iteratorInstance->next();
+		$this->getIteratorInstance()->next();
 	}
 
 	/**
@@ -261,21 +251,21 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
 	 */
 	public function doShutdown () {
 		// Should we rewind?
-		if (!$this->iteratorInstance->valid()) {
+		if (!$this->getIteratorInstance()->valid()) {
 			// Rewind to the beginning for next loop
-			$this->iteratorInstance->rewind();
+			$this->getIteratorInstance()->rewind();
 		} // END - if
 
 		// Debug message
-		$this->debugOutput('TASK-HANDLER: Shutting down all ' . $this->listInstance->count() . ' tasks...');
+		$this->debugOutput('TASK-HANDLER: Shutting down all ' . $this->getListInstance()->count() . ' tasks...');
 
 		// Remember all tasks that has been shutdown for removal
 		$tasks = array();
 
 		// Shutdown all tasks in once go
-		while ($this->iteratorInstance->valid()) {
+		while ($this->getIteratorInstance()->valid()) {
 			// Get current entry
-			$current = $this->iteratorInstance->current();
+			$current = $this->getIteratorInstance()->current();
 
 			// Output debug message
 			$this->debugOutput('TASK-HANDLER: Shutting down task ' . $current['id'] . ' (taskInstance=' . $current['task_instance']->__toString() . ') ...');
@@ -287,7 +277,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
 			$tasks[] = $current;
 
 			// Advance to next one
-			$this->iteratorInstance->next();
+			$this->getIteratorInstance()->next();
 		} // END - while
 
 
diff --git a/application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php b/application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php
index e352a9a6e..81717d21a 100644
--- a/application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php
+++ b/application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php
@@ -67,7 +67,7 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryConnect
 	 */
 	public function visitQueryConnector (Connectable $connectorInstance) {
 		// Process all pending queries
-		$connectorInstance->processAllPendingQueries();
+		$connectorInstance->handlePendingQueries();
 	}
 
 	/**
@@ -77,9 +77,11 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryConnect
 	 * @return	void
 	 */
 	public function visitPool (Poolable $poolInstance) {
-		// We don't need to visit a pool as an active task because a pool can
-		// never become a task. Instead e.g. by a listener pool we should visit
-		// all listeners one by one
+		/**
+		 * We don't need to visit a pool as an active task because a pool can
+		 * never become a task. Instead e.g. by a listener pool we should visit
+		 * all listeners one by one
+		 */
 	}
 
 	/**