]> git.mxchange.org Git - hub.git/commitdiff
Introduced NodeObjectFactory to encapsulate (and ease) a lot calls.
authorRoland Haeder <roland@mxchange.org>
Mon, 17 Mar 2014 21:49:16 +0000 (22:49 +0100)
committerRoland Haeder <roland@mxchange.org>
Mon, 17 Mar 2014 21:49:16 +0000 (22:49 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
32 files changed:
application/hub/exceptions/factory/.htaccess [new file with mode: 0644]
application/hub/exceptions/factory/class_FactoryRequiredParameterException.php [new file with mode: 0644]
application/hub/main/commands/console/class_HubConsoleMainCommand.php
application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php
application/hub/main/discovery/socket/class_PackageSocketDiscovery.php
application/hub/main/factories/node/.htaccess [new file with mode: 0644]
application/hub/main/factories/node/class_NodeObjectFactory.php [new file with mode: 0644]
application/hub/main/filter/bootstrap/node/class_NodeBootstrapExtraBootstrappingFilter.php
application/hub/main/filter/bootstrap/node/class_NodeBootstrapGenerateNodeIdFilter.php
application/hub/main/filter/bootstrap/node/class_NodeBootstrapGeneratePrivateKeyFilter.php
application/hub/main/filter/bootstrap/node/class_NodeBootstrapGenerateSessionIdFilter.php
application/hub/main/filter/bootstrap/node/class_NodeBootstrapListenerPoolFilter.php
application/hub/main/filter/node/class_NodeInitializationFilter.php
application/hub/main/filter/node/class_NodeWelcomeTeaserFilter.php
application/hub/main/filter/shutdown/node/class_NodeShutdownFlushNodeListFilter.php
application/hub/main/filter/shutdown/node/class_NodeShutdownNodeFilter.php
application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php
application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php
application/hub/main/handler/class_BaseDataHandler.php
application/hub/main/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php
application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php
application/hub/main/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php
application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php
application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php
application/hub/main/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php
application/hub/main/handler/network/class_BaseRawDataHandler.php
application/hub/main/states/dht/virgin/class_DhtVirginState.php
application/hub/main/tasks/node/announcement/class_NodeAnnouncementTask.php
application/hub/main/tasks/node/listener/class_NodeSocketListenerTask.php
application/hub/main/tasks/node/self_connect/class_NodeSelfConnectTask.php
application/hub/main/tools/class_HubTools.php
core

diff --git a/application/hub/exceptions/factory/.htaccess b/application/hub/exceptions/factory/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/exceptions/factory/class_FactoryRequiredParameterException.php b/application/hub/exceptions/factory/class_FactoryRequiredParameterException.php
new file mode 100644 (file)
index 0000000..6f0cdc6
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * This exception is thrown if not all required parameter are given.
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class FactoryRequiredParameterException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $factoryInstance        An instance of an ObjectFactory class
+        * @param       $code                           Error code
+        * @return      void
+        */
+       public function __construct (ObjectFactory $factoryInstance, $code) {
+               // Construct the message
+               $message = sprintf('[%s:%d] This factory requires all/some parameters to be set.',
+                       $factoryInstance->__toString(),
+                       $this->getLine()
+               );
+
+               // Call parent exception constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
index 339ebe71e4c796568eff2613ad86399812b2ef85..fc8cfa24391a73153fed1d9c4214618372307feb 100644 (file)
@@ -72,7 +72,7 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable {
                self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.');
 
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Add some node-specific filters, e.g. announcement
                $nodeInstance->addExtraNodeFilters();
index 4e540ac9b4bf827bfd94a5a01df3a2fcbd42afcc..8c3a8a5e3f8bb81606988f39f95e3ba6f60b8c3a 100644 (file)
@@ -136,7 +136,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
         */
        private function prepareLocalDataSetInstance () {
                // Get node/request instances
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
                $requestInstance = ApplicationHelper::getSelfInstance()->getRequestInstance();
 
                // Get a dataset instance
@@ -183,7 +183,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
                        $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
 
                        // Get node instance
-                       $nodeInstance = Registry::getRegistry()->getInstance('node');
+                       $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                        // Get ip:port combination and "explode" it
                        $ipPort = $nodeInstance->getAddressPortArray();
@@ -238,7 +238,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
                assert($this->isLocalNodeRegistered());
 
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Get search criteria
                $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
@@ -416,7 +416,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
                $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID);
 
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Add all array elements
                $nodeInstance->addArrayToDataSet($dataSetInstance, $nodeData);
index f3a647f16b4fef7f0dcbcd121d0d0669f41b95cf..125b68f2d9904bd02927cbdf5cf53853c413d5aa 100644 (file)
@@ -63,7 +63,7 @@ class PackageSocketDiscovery extends BaseNodeDiscovery implements DiscoverableSo
                 * Get the listener pool instance, we need to lookup the matching
                 * listener->poolInstance chain there.
                 */
-               $poolInstance = Registry::getRegistry()->getInstance('node')->getListenerPoolInstance();
+               $poolInstance = NodeObjectFactory::createNodeInstance()->getListenerPoolInstance();
 
                // Init listener instance
                $listenerInstance = NULL;
diff --git a/application/hub/main/factories/node/.htaccess b/application/hub/main/factories/node/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/factories/node/class_NodeObjectFactory.php b/application/hub/main/factories/node/class_NodeObjectFactory.php
new file mode 100644 (file)
index 0000000..79af60d
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+/**
+ * A factory class for nodes
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeObjectFactory extends ObjectFactory {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Returns a singleton (registry-based) NodeHelper instance
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      $nodeInstance           An instance of a NodeHelper class
+        * @throws      FactoryRequiredParameterException       If not all parameters are set and no instance 'node' is set.
+        */
+       public static final function createNodeInstance (Requestable $requestInstance = NULL, Responseable $responseInstance = NULL) {
+               // If there is no handler?
+               if (Registry::getRegistry()->instanceExists('node')) {
+                       // Get handler from registry
+                       $nodeInstance = NodeObjectFactory::createNodeInstance();
+               } elseif (($requestInstance instanceof Requestable) && ($responseInstance instanceof Responseable)) {
+                       // Get the node instance
+                       $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
+
+                       // Get a registry
+                       $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+                       // Set the app instance
+                       $nodeInstance->setApplicationInstance($applicationInstance);
+
+                       // Add node-specific filters
+                       $nodeInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
+
+                       // Add it to the registry
+                       Registry::getRegistry()->addInstance('node', $nodeInstance);
+               } else {
+                       // Throw an exception here
+                       throw new FactoryRequiredParameterException(new NodeObjectFactory(), self::EXCEPTION_FACTORY_REQUIRE_PARAMETER);
+               }
+
+               // Return the instance
+               return $nodeInstance;
+       }
+}
+
+// [EOF]
+?>
index 5ab2352ba2bdfa32c09c945d5856da9bbad9d383..cee02f27eff37df56086f6db052349f41edcaf8d 100644 (file)
@@ -55,7 +55,7 @@ class NodeBootstrapExtraBootstrappingFilter extends BaseNodeFilter implements Fi
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Do some extra bootstrapping steps
                $nodeInstance->doBootstrapping();
index 0617584798750c1e435c8e87847b8e55f06f2260..5c31c17ba35ad9ebcf4588dfaf556e50c8bffe9c 100644 (file)
@@ -55,7 +55,7 @@ class NodeBootstrapGenerateNodeIdFilter extends BaseNodeFilter implements Filter
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                /*
                 * Acquire a hub-id. This step generates on first launch a new one and
index 77587bbccd60dad6e7f0f60d7320d0e6dce566fb..f7f3c392d45cdfc4130bbc64eb26fee46f3c2d1a 100644 (file)
@@ -55,7 +55,7 @@ class NodeBootstrapGeneratePrivateKeyFilter extends BaseNodeFilter implements Fi
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                /*
                 * Generate the private key. This will be stored along with the other
index 197f6bbd8bbcd2754fd658b1d6a4d6e304c0959e..63a4ed98de041614325889cbc0798383706a3d37 100644 (file)
@@ -55,7 +55,7 @@ class NodeBootstrapGenerateSessionIdFilter extends BaseNodeFilter implements Fil
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                /*
                 * Generate the session id which will only be stored in RAM and kept for
index e93f8d7e1be8189d0f4c1d8f8eb0a6941f0dd7f9..a6a81669f55809ba451d3f8a0f2eb8daf6f9ced3 100644 (file)
@@ -55,7 +55,7 @@ class NodeBootstrapListenerPoolFilter extends BaseNodeFilter implements Filterab
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Now do something
                $nodeInstance->initializeListenerPool();
index 3d9f694a880b0a257f05c45db41b5b54a5281108..3070e8547946e74abe5303f034eb8df9d5a170f3 100644 (file)
@@ -72,16 +72,7 @@ class NodeInitializationFilter extends BaseNodeFilter implements Filterable {
                // And try to instance it
                try {
                        // Get an instance
-                       $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
-
-                       // Get a registry
-                       $applicationInstance = Registry::getRegistry()->getInstance('app');
-
-                       // Set the app instance
-                       $nodeInstance->setApplicationInstance($applicationInstance);
-
-                       // Add node-specific filters
-                       $nodeInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
+                       $nodeInstance = NodeObjectFactory::createNodeInstance($requestInstance, $responseInstance);
                } catch (ClassNotFoundException $e) {
                        // This exception means, the node mode is invalid.
                        // @TODO Can we rewrite this to app_exit() ?
index 267dda36c7aed590eba70e1e046a409ad19eb765..26c55436e580098aa5782dfbeefb1f203d67b281 100644 (file)
@@ -56,7 +56,7 @@ class NodeWelcomeTeaserFilter extends BaseNodeFilter implements Filterable {
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Now output the teaser
                $nodeInstance->outputConsoleTeaser();
index f5416359314a2bddc7bd67387b8549b2790a66ab..61067437cb19419652a3e47f22bef329cf6bdaee 100644 (file)
@@ -56,7 +56,7 @@ class NodeShutdownFlushNodeListFilter extends BaseNodeFilter implements Filterab
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Now do something
                $this->partialStub('Please implement this step.');
index 4f285a936e124fff2544201cebff0253fd396056..d7e7de8dcaaa3b4b86c9b4aac54cc944fb26167a 100644 (file)
@@ -57,7 +57,7 @@ class NodeShutdownNodeFilter extends BaseNodeFilter implements Filterable {
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Shutdown the node. This should be the last line
                $nodeInstance->doShutdown();
index d66cf8339660ca307fdd0a6573fd48a3bf3fdf56..b393f5b107a3eb1acfce22d06d8efd0b75bb2e68 100644 (file)
@@ -56,7 +56,7 @@ class NodeTaskHandlerInitializerFilter extends BaseNodeFilter implements Filtera
         */
        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');
index 122df05213723aafa878935eb67c72577f7a9184..bf70056504ef163075482bcd7d5701837aa09dde 100644 (file)
@@ -80,7 +80,7 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha
                $handlerInstance->registerTask('dht_bootstrap', $taskInstance);
 
                // Get the node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Change state
                $nodeInstance->getStateInstance()->nodeAnnouncementSuccessful();
@@ -108,7 +108,7 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha
         */
        protected function initMessageConfigurationData (array $messageData) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Get an array of all accepted object types
                $objectList = $nodeInstance->getListFromAcceptedObjectTypes();
index 6e80fd2ac65d5ea270314c57cfaf9ebcb86ab475..902c66783d62bdaa6d5e243f7088b18966bfe475 100644 (file)
@@ -108,7 +108,7 @@ abstract class BaseDataHandler extends BaseHandler {
                $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData));
 
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Load descriptor XML
                $helperInstance->loadDescriptorXml($nodeInstance);
@@ -149,7 +149,7 @@ abstract class BaseDataHandler extends BaseHandler {
                $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData));
 
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Load descriptor XML
                $helperInstance->loadDescriptorXml($nodeInstance);
index ebbfe9d00daf192d347cf95d54b28131aa396d43..b313071bbb3548f2427a7c66280ad80c2f11696b 100644 (file)
@@ -90,7 +90,7 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
         */
        public function handleMessageData (array $messageData, Receivable $packageInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Is this node accepting announcements?
                if (!$nodeInstance->isAcceptingAnnouncements()) {
index e29b8b3fa0c2ece2996837c52a5017f605bb11cb..59bc4de0b61f1aa1ca091bae9c3bd6cb76ddd889 100644 (file)
@@ -93,7 +93,7 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements
         */
        public function handleMessageData (array $messageData, Receivable $packageInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Has this node attempted to announce itself?
                if (!$nodeInstance->ifNodeIsAnnouncing()) {
index a6a80b2e86023013355e8f77da50d08baa9a1cd5..bcd471d6d8135ce7a945b870140bb208a6c7d7e0 100644 (file)
@@ -77,7 +77,7 @@ class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler impleme
         */
        public function handleMessageData (array $messageData, Receivable $packageInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Has this node attempted to announce itself?
                if (!$nodeInstance->ifNodeHasAnnouncementCompleted()) {
index 686d3be82cda348e15c3d283cbd0d7829ff23fa4..b29e3c7c18ddc17f81e32f6da7f2df81a636af70 100644 (file)
@@ -90,7 +90,7 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl
         */
        public function handleMessageData (array $messageData, Receivable $packageInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Is this node accepting DHT bootstrap requests?
                if (!$nodeInstance->isAcceptingDhtBootstrap()) {
index 88ddd2ae39c34cd3b300b6483852377633b8e717..81d6aad3e0964256cab92f861357d69d2e374228 100644 (file)
@@ -72,7 +72,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha
         */
        public function handleMessageData (array $messageData, Receivable $packageInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Is this node accepting announcements?
                if (!$nodeInstance->isAcceptingNodeListRequests()) {
index 635a77e4b0147e0736e6cc04a0d5d21e89093122..76e3f902aef3133bddb0799a1c4ec1c5bdaad766 100644 (file)
@@ -62,7 +62,7 @@ class NodeMessageSelfConnectHandler extends BaseMessageHandler implements Handle
                        self::createDebugInstance(__CLASS__)->debugOutput('SELF-CONNECT[' . __METHOD__ . ':' . __LINE__ . ']: Have connected to myself, both node and session id are equal!');
 
                        // Get node instance ...
-                       $nodeInstance = Registry::getRegistry()->getInstance('node');
+                       $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                        // ... and change state
                        $nodeInstance->getStateInstance()->nodeHasSelfConnected();
index 93fdb3acf034354c7039b32fbabbe287cda62f20..d1c5e1c8d271cad4492f2cac8c03ee5d44c5bbc0 100644 (file)
@@ -148,7 +148,7 @@ class BaseRawDataHandler extends BaseHandler {
         */
        protected function ifRecipientMatchesOwnAddress (array $packageData) {
                // Construct own address first
-               $ownAddress = Registry::getRegistry()->getInstance('node')->getAddressPort();
+               $ownAddress = NodeObjectFactory::createNodeInstance()->getAddressPort();
 
                // Does it match?
                $matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
index 90da00503c7f61c48d430db76f42ee0a3c00eb85..9f0a1a2719cd060ebc07f1a3b8a035362e01933c 100644 (file)
@@ -52,7 +52,7 @@ class DhtVirginState extends BaseDhtState implements Stateable {
                $stateInstance->setDhtInstance($dhtInstance);
 
                // Get node instance and enable DHT bootstrap requests
-               Registry::getRegistry()->getInstance('node')->enableAcceptDhtBootstrap();
+               NodeObjectFactory::createNodeInstance()->enableAcceptDhtBootstrap();
 
                // Return the prepared instance
                return $stateInstance;
index 6250208202f6fb3db3414071ae1f35af1c13d855..386439a196632b3bc0617acbf5b57d309fbf61f4 100644 (file)
@@ -63,7 +63,7 @@ class NodeAnnouncementTask extends BaseTask implements Taskable, Visitable {
         */
        public function executeTask () {
                // Get the node instance and announce us
-               Registry::getRegistry()->getInstance('node')->announceToUpperNodes($this);
+               NodeObjectFactory::createNodeInstance()->announceToUpperNodes($this);
        }
 }
 
index 668514d8051fc91847973401a1fe0dfe53c19f22..1fba9629cb5ea1a4ff8c0a8d1ce01a5aed9c280e 100644 (file)
@@ -53,7 +53,7 @@ class NodeSocketListenerTask extends BaseTask implements Taskable, Visitable {
         */
        public function accept (Visitor $visitorInstance) {
                // Get the node instance from registry
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Visit the pool listener task
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('LISTENER-TASK[' . __METHOD__ . ':' . __LINE__ . ']: Going to visit object ' . $nodeInstance->getListenerPoolInstance()->__toString() . ' ...');
index 9feeedfb2884251b860898c317d8f11333c458c4..74133b6a01ab2e04f44741899465b64d25109a9a 100644 (file)
@@ -63,7 +63,7 @@ class NodeSelfConnectTask extends BaseTask implements Taskable, Visitable {
         */
        public function executeTask () {
                // Get the node instance and try it
-               Registry::getRegistry()->getInstance('node')->doSelfConnection($this);
+               NodeObjectFactory::createNodeInstance()->doSelfConnection($this);
        }
 }
 
index 710bb21d5da90993321479d545ffc0226136cb91..122ce3a185b82c11a3eadaabd2211f85bcfd9979 100644 (file)
@@ -105,7 +105,7 @@ class HubTools extends BaseHubSystem {
                        $recipientIpPort = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_IP] . ':' . $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT];
                } else {
                        // Get the instance, this might throw a NPE
-                       $nodeInstance = Registry::getRegistry()->getInstance('node');
+                       $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                        // Is the session id the same?
                        if ($nodeInstance->getSessionId() == $sessionId) {
diff --git a/core b/core
index 1ccbc488f607a0b1f42a4edd5cf5823b7294f337..932873c41ad866ed0745ceb78e8c9323ada0c31b 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 1ccbc488f607a0b1f42a4edd5cf5823b7294f337
+Subproject commit 932873c41ad866ed0745ceb78e8c9323ada0c31b