]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php
Register the task handler after it has been created as some tasks may need it
[hub.git] / application / hub / main / filter / task / node / class_NodeTaskHandlerInitializerFilter.php
index d66cf8339660ca307fdd0a6573fd48a3bf3fdf56..abc35dc35ab6f938f233f07366867b6651bbae7c 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -51,16 +51,19 @@ class NodeTaskHandlerInitializerFilter extends BaseNodeFilter implements Filtera
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
-        * @throws      FilterChainException    If we need to interrupt the filter chain
+        * @throws      FilterChainException    If the filter chain needs to be interrupted
         * @todo        Maybe some more tasks needs to be added?
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Get a new task handler instance
                $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class');
 
+               // Put the task handler in registry
+               Registry::getRegistry()->addInstance('task_handler', $handlerInstance);
+
                // Prepare a package-tags initialization task for the listeners
                $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_tags_init_task_class');
 
@@ -142,8 +145,12 @@ class NodeTaskHandlerInitializerFilter extends BaseNodeFilter implements Filtera
                // Register it
                $handlerInstance->registerTask('ping', $taskInstance);
 
-               // Put the task handler in registry
-               Registry::getRegistry()->addInstance('task_handler', $handlerInstance);
+               /*
+                * Allow extra node-depending tasks, e.g. the bootstrapper node needs
+                * booting its DHT. DHTs are decentralized and are working on
+                * peer-to-peer basis.
+                */
+               $nodeInstance->addExtraTasks($handlerInstance);
        }
 }