]> git.mxchange.org Git - hub.git/commitdiff
Fixed a lot broken stuff:
authorRoland Haeder <roland@mxchange.org>
Mon, 30 Mar 2015 00:03:10 +0000 (02:03 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 30 Mar 2015 00:03:10 +0000 (02:03 +0200)
- All handler (expanding BaseHandler) and task classes no longer extends
  BaseHubSystem which caused missing setters and getters. Yes, it is stupid
  to set a log instances as this way these classes are interlocked more
  tighter. Better is to have them more indepently from each other.

Signed-off-by: Roland Haeder <roland@mxchange.org>
26 files changed:
application/hub/config.php
application/hub/interfaces/listener/class_Listenable.php
application/hub/interfaces/package/class_Receivable.php
application/hub/main/class_BaseHubSystem.php
application/hub/main/decoder/package/class_PackageDecoder.php
application/hub/main/factories/decoder/.htaccess [new file with mode: 0644]
application/hub/main/factories/decoder/class_DecoderFactory.php [new file with mode: 0644]
application/hub/main/factories/states/node/class_NodeStateFactory.php
application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php
application/hub/main/handler/chunks/class_ChunkHandler.php
application/hub/main/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php
application/hub/main/handler/protocol/class_BaseProtocolHandler.php
application/hub/main/listener/class_BaseListener.php
application/hub/main/listener/class_BaseListenerDecorator.php
application/hub/main/package/class_NetworkPackage.php
application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php
application/hub/main/states/node/active/class_NodeActiveState.php
application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php
application/hub/main/states/node/announced/class_NodeAnnouncingState.php
application/hub/main/states/node/init/class_NodeInitState.php
application/hub/main/states/node/seniors/class_NodeReachableState.php
application/hub/main/states/node/virgin/class_NodeVirginState.php
application/hub/main/tasks/network/class_NetworkPackageReaderTask.php
application/hub/main/tasks/network/class_NetworkPackageWriterTask.php
application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php
application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php

index 97ff9a483149934713e6b428661bbfbee17158cc..cad249e11e55931ef26ae596aff8c036a78eb81d 100644 (file)
@@ -126,11 +126,11 @@ $cfg->setConfigEntry('dht_publish_entry_helper_class', 'DhtPublishEntryHelper');
 // CFG: DEFAULT-CONSOLE-COMMAND
 $cfg->setConfigEntry('default_console_command', 'main');
 
-// CFG: DEFAULT-HUBCONSOLE-COMMAND
-$cfg->setConfigEntry('default_hubconsole_command', 'main');
+// CFG: DEFAULT-HUB-CONSOLE-COMMAND
+$cfg->setConfigEntry('default_hub_console_command', 'main');
 
-// CFG: HUBCONSOLE-CMD-MAIN-RESOLVER-CLASS
-$cfg->setConfigEntry('hubconsole_cmd_main_resolver_class', 'HubConsoleCommandResolver');
+// CFG: HUB-CONSOLE-CMD-MAIN-RESOLVER-CLASS
+$cfg->setConfigEntry('hub_console_cmd_main_resolver_class', 'HubConsoleCommandResolver');
 
 // CFG: NETWORK-STATE-RESOLVER-CLASS
 $cfg->setConfigEntry('network_state_resolver_class', 'NetworkStateResolver');
@@ -918,7 +918,7 @@ $cfg->setConfigEntry('miner_default_mode', 'chash');
 $cfg->setConfigEntry('miner_buffer_stacker_class', 'FiFoStacker');
 
 // CFG: HUBCONSOLE-CMD-CRUNCHER-RESOLVER-CLASS
-$cfg->setConfigEntry('hubconsole_cmd_miner_resolver_class', 'HubConsoleCommandResolver');
+$cfg->setConfigEntry('hub_console_cmd_miner_resolver_class', 'HubConsoleCommandResolver');
 
 // CFG: MINER-PHP-REQUIREMENTS-FILTER
 $cfg->setConfigEntry('miner_php_requirements_filter', 'MinerPhpRequirementsFilter');
index cf561ef0badf57f891547c920a572940a7ebaafc..d453324ebfa09473683a43b2defc0194bebdd945 100644 (file)
@@ -48,10 +48,9 @@ interface Listenable extends FrameworkInterface {
         * Monitors incoming raw data from the handler and transfers it to the
         * given receiver instance.
         *
-        * @param       $receiverInstance       An instance of a Receivable class
         * @return      void
         */
-       function monitorIncomingRawData (Receivable $receiverInstance);
+       function monitorIncomingRawData ();
 
        /**
         * Getter for listen address
index f35f28a412966dac0b1e061ebf85d35a94fe65e6..126247bdfca788190e0dbea614096152d71ae0f2 100644 (file)
@@ -25,10 +25,9 @@ interface Receivable extends FrameworkInterface {
        /**
         * Checks whether new raw data from the socket has arrived
         *
-        * @param       $poolInstance   An instance of a PoolableListener class
         * @return      $hasArrived             Whether raw package data has arrived at a socket
         */
-       function isNewRawDataPending (PoolableListener $poolInstance);
+       function isNewRawDataPending ();
 
        /**
         * Handles the incoming decoded raw data. This method does not "convert" the
index 885abc5d08b959e66b8611b317fd8cfba71a7e14..0dc699244990176f7b9f3964ccffc67880594869 100644 (file)
@@ -94,11 +94,6 @@ class BaseHubSystem extends BaseFrameworkSystem {
         */
        private $fragmenterInstance = NULL;
 
-       /**
-        * Decoder instance
-        */
-       private $decoderInstance = NULL;
-
        /**
         * Assembler instance
         */
@@ -315,29 +310,10 @@ class BaseHubSystem extends BaseFrameworkSystem {
                return $this->fragmenterInstance;
        }
 
-       /**
-        * Setter for decoder instance
-        *
-        * @param       $decoderInstance        A Decodeable instance
-        * @return      void
-        */
-       protected final function setDecoderInstance (Decodeable $decoderInstance) {
-               $this->decoderInstance = $decoderInstance;
-       }
-
-       /**
-        * Getter for decoder instance
-        *
-        * @return      $decoderInstance        A Decodeable instance
-        */
-       protected final function getDecoderInstance () {
-               return $this->decoderInstance;
-       }
-
        /**
         * Setter for assembler instance
         *
-        * @param       $assemblerInstance      A Decodeable instance
+        * @param       $assemblerInstance      An instance of an Assembler class
         * @return      void
         */
        protected final function setAssemblerInstance (Assembler $assemblerInstance) {
@@ -347,7 +323,7 @@ class BaseHubSystem extends BaseFrameworkSystem {
        /**
         * Getter for assembler instance
         *
-        * @return      $assemblerInstance      A Decodeable instance
+        * @return      $assemblerInstance      An instance of an Assembler class
         */
        protected final function getAssemblerInstance () {
                return $this->assemblerInstance;
@@ -366,7 +342,7 @@ class BaseHubSystem extends BaseFrameworkSystem {
        /**
         * Getter for info instance
         *
-        * @return      $infoInstance   A Decodeable instance
+        * @return      $infoInstance   An instance of a ShareableInfo class
         */
        public final function getInfoInstance () {
                return $this->infoInstance;
@@ -541,36 +517,6 @@ class BaseHubSystem extends BaseFrameworkSystem {
                socket_clear_error($socketResource);
        }
 
-       /**
-        * Checks whether the final (last) chunk is valid
-        *
-        * @param       $chunks         An array with chunks and (hopefully) a valid final chunk
-        * @return      $isValid        Whether the final (last) chunk is valid
-        */
-       protected function isValidFinalChunk (array $chunks) {
-               // Default is all fine
-               $isValid = TRUE;
-
-               // Split the (possible) EOP chunk
-               $chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunks[count($chunks) - 1]);
-
-               // Make sure chunks with only 3 elements are parsed (for details see ChunkHandler)
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('eopChunk=' . $chunks[count($chunks) - 1] . ',chunkSplits=' . print_r($chunkSplits, TRUE));
-               assert(count($chunkSplits) == 3);
-
-               // Validate final chunk
-               if (substr($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], 0, strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER)) != PackageFragmenter::END_OF_PACKAGE_IDENTIFIER) {
-                       // Not fine
-                       $isValid = FALSE;
-               } elseif (substr_count($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], PackageFragmenter::CHUNK_HASH_SEPARATOR) != 1) {
-                       // CHUNK_HASH_SEPARATOR shall only be found once
-                       $isValid = FALSE;
-               }
-
-               // Return status
-               return $isValid;
-       }
-
        /**
         * Translates socket error codes into our own internal names which can be
         * used for call-backs.
index 12884af7dee0aea449b2999ae37249b6148a0470..49ba434c5c5f37bbfc97d7ef9a35b99e59bc91a7 100644 (file)
@@ -21,7 +21,7 @@
  * 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 PackageDecoder extends BaseDecoder implements Decodeable {
+class PackageDecoder extends BaseDecoder implements Decodeable, Registerable {
        /**
         * Name for stacker for received packages
         */
diff --git a/application/hub/main/factories/decoder/.htaccess b/application/hub/main/factories/decoder/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/factories/decoder/class_DecoderFactory.php b/application/hub/main/factories/decoder/class_DecoderFactory.php
new file mode 100644 (file)
index 0000000..7125c6a
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+/**
+ * A factory class for Decodeable objects
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 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 DecoderFactory extends ObjectFactory {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Returns a singleton (registry-based) Decodeable instance
+        *
+        * @return      $decoderInstance        An instance of a Decodeable class
+        */
+       public static final function createPackageDecoderInstance () {
+               // If there is no handler?
+               if (Registry::getRegistry()->instanceExists('package_decoder')) {
+                       // Get handler from registry
+                       $decoderInstance = Registry::getRegistry()->getInstance('package_decoder');
+               } else {
+                       // Get a chunk handler instance
+                       $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance();
+
+                       // Get the handler instance
+                       $decoderInstance = self::createObjectByConfiguredName('package_decoder_class', array($handlerInstance));
+
+                       // Add it to the registry
+                       Registry::getRegistry()->addInstance('package_decoder', $decoderInstance);
+               }
+
+               // Return the instance
+               return $decoderInstance;
+       }
+}
+
+// [EOF]
+?>
index eee1246a8acd20dcb54e605d433578a10296a9d8..46212da4f391acaaafc7a230570845bf45ea278a 100644 (file)
@@ -37,13 +37,19 @@ class NodeStateFactory extends ObjectFactory {
         * given node instance.
         *
         * @param       $stateName              Name of the state
-        * @param       $nodeInstance   A NodeHelper class instance
+        * @param       $nodeInstance   An instance of a NodeHelper class (optional)
         * @return      $stateInstance  A Stateable class instance
         */
-       public static final function createNodeStateInstanceByName ($stateName, NodeHelper $nodeInstance) {
+       public static final function createNodeStateInstanceByName ($stateName, NodeHelper $nodeInstance = NULL) {
                // Then construct the class' configuraton entry
                $className = 'node_' . $stateName . '_state_class';
 
+               // Is the node instance set?
+               if (is_null($nodeInstance)) {
+                       // Get node instance from registry
+                       $nodeInstance = NodeObjectFactory::createNodeInstance();
+               } // END - if
+
                // Get a class from that configuration entry
                $stateInstance = self::createObjectByConfiguredName($className, array($nodeInstance));
 
index bb5ab1ac4d3c98db9d573104d9809a5814676b47..6b12e416951a2645c522f7fd79efbbd9f1e743a0 100644 (file)
@@ -77,7 +77,7 @@ class NodeTaskHandlerInitializerFilter extends BaseNodeFilter implements Filtera
                $handlerInstance->registerTask('network_package_writer', $taskInstance);
 
                // Generate package reader task
-               $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_reader_task_class', array($nodeInstance->getListenerPoolInstance()));
+               $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_reader_task_class');
 
                // Network package reader, needs to be delayed a little
                $handlerInstance->registerTask('network_package_reader', $taskInstance);
index 2c0e5a47bf5e2e1d593ee8a2a28ef3b003a3fa70..180805cdd1739465ad02f1925fe38fa6e951d785 100644 (file)
@@ -62,6 +62,11 @@ class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable
         */
        private $rawPackageData = '';
 
+       /**
+        * Fragmenter instance, needs to be set here again
+        */
+       private $fragmenterInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -76,6 +81,12 @@ class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable
 
                // Initialize handler
                $this->initHandler();
+
+               // Get a fragmenter instance for later verification of serial numbers (e.g. if all are received)
+               $fragmenterInstance = FragmenterFactory::createFragmenterInstance('package');
+
+               // Set it in this handler
+               $this->fragmenterInstance = $fragmenterInstance;
        }
 
        /**
@@ -106,12 +117,6 @@ class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable
                // ... and set it in this handler
                $handlerInstance->setCryptoInstance($cryptoInstance);
 
-               // Get a fragmenter instance for later verification of serial numbers (e.g. if all are received)
-               $fragmenterInstance = FragmenterFactory::createFragmenterInstance('package');
-
-               // Set it in this handler
-               $handlerInstance->setFragmenterInstance($fragmenterInstance);
-
                // Return the prepared instance
                return $handlerInstance;
        }
@@ -292,12 +297,12 @@ class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable
                $finalHash = $this->generateFinalHash(implode('', $this->finalPackageChunks['content']));
 
                // Reset the serial number generator
-               $this->getFragmenterInstance()->resetSerialNumber($finalHash);
+               $this->fragmenterInstance->resetSerialNumber($finalHash);
 
                // "Walk" through all (content) chunks
                foreach ($this->finalPackageChunks['content'] as $serialNumber => $content) {
                        // Get next serial number
-                       $nextSerial = $this->getFragmenterInstance()->getNextHexSerialNumber($finalHash);
+                       $nextSerial = $this->fragmenterInstance->getNextHexSerialNumber($finalHash);
 
                        // Debug output
                        //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber=' . $serialNumber . ',nextSerial=' . $nextSerial);
@@ -395,6 +400,36 @@ class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable
                assert($finalHash == $this->eopChunk[0]);
        }
 
+       /**
+        * Checks whether the final (last) chunk is valid
+        *
+        * @param       $chunks         An array with chunks and (hopefully) a valid final chunk
+        * @return      $isValid        Whether the final (last) chunk is valid
+        */
+       private function isValidFinalChunk (array $chunks) {
+               // Default is all fine
+               $isValid = TRUE;
+
+               // Split the (possible) EOP chunk
+               $chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunks[count($chunks) - 1]);
+
+               // Make sure chunks with only 3 elements are parsed (for details see ChunkHandler)
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('eopChunk=' . $chunks[count($chunks) - 1] . ',chunkSplits=' . print_r($chunkSplits, TRUE));
+               assert(count($chunkSplits) == 3);
+
+               // Validate final chunk
+               if (substr($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], 0, strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER)) != PackageFragmenter::END_OF_PACKAGE_IDENTIFIER) {
+                       // Not fine
+                       $isValid = FALSE;
+               } elseif (substr_count($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], PackageFragmenter::CHUNK_HASH_SEPARATOR) != 1) {
+                       // CHUNK_HASH_SEPARATOR shall only be found once
+                       $isValid = FALSE;
+               }
+
+               // Return status
+               return $isValid;
+       }
+
        /**
         * Adds all chunks if the last one verifies as a 'final chunk'.
         *
index 584c8daff9b4edce7c279a1d098db20e919f308b..e1ac210a247e0863b7b87b8e3f46c6a33a6dc8c1 100644 (file)
@@ -56,14 +56,14 @@ class NodeMessageSelfConnectHandler extends BaseMessageHandler implements Handle
         * @return      void
         */
        public function handleMessageData (array $messageData, Receivable $packageInstance) {
+               // Get node instance
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
                // Are node id and session id the same?
-               if (($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_NODE_ID] == $this->getNodeId()) && ($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_SESSION_ID] == $this->getSessionId())) {
+               if (($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_NODE_ID] == $nodeInstance->getNodeId()) && ($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_SESSION_ID] == $nodeInstance->getSessionId())) {
                        // Both are equal
                        self::createDebugInstance(__CLASS__)->debugOutput('SELF-CONNECT[' . __METHOD__ . ':' . __LINE__ . ']: Have connected to myself, both node and session id are equal!');
 
-                       // Get node instance ...
-                       $nodeInstance = NodeObjectFactory::createNodeInstance();
-
                        // ... and change state
                        $nodeInstance->getStateInstance()->nodeHasSelfConnected();
                } else {
index 5b058572979d4dfe6d705001cb81e41eec5a474f..d769cde79c5fc77f4082a7a76cdfc01f17cb1b01 100644 (file)
@@ -27,6 +27,11 @@ class BaseProtocolHandler extends BaseHandler {
         */
        private $universalNodeLocatorData = array();
 
+       /**
+        * Name of used protocol
+        */
+       private $protocolName = 'invalid';
+
        /**
         * Protected constructor
         *
@@ -38,6 +43,25 @@ class BaseProtocolHandler extends BaseHandler {
                parent::__construct($className);
        }
 
+       /**
+        * Getter for protocol name
+        *
+        * @return      $protocolName   Name of used protocol
+        */
+       public final function getProtocolName () {
+               return $this->protocolName;
+       }
+
+       /**
+        * Setter for protocol name
+        *
+        * @param       $protocolName   Name of used protocol
+        * @return      void
+        */
+       protected final function setProtocolName ($protocolName) {
+               $this->protocolName = $protocolName;
+       }
+
        /**
         * Setter for UNL data array to satify HandleableProtocol
         *
index 81d105416fea3fc18175e00313d960251a7a19b1..037f62d8009a21c52e12a40705064a30035a5e19 100644 (file)
@@ -280,12 +280,11 @@ class BaseListener extends BaseHubSystem implements Visitable {
         * given receiver instance. This method should not be called, please call
         * the decorator's version instead to separator node/client traffic.
         *
-        * @param       $receiverInstance       An instance of a Receivable class
         * @return      void
         * @throws      UnsupportedOperatorException    If this method is called by a mistake
         */
-       public function monitorIncomingRawData (Receivable $receiverInstance) {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__, $receiverInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+       public function monitorIncomingRawData () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 }
 
index 54bb578bb4a4ea0d772ac0500f824faccffeb400..ab44d2d6f5a7274080fc78d6b6d65e4d6e670693 100644 (file)
@@ -111,10 +111,9 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable {
         * Monitors incoming raw data from the handler and transfers it to the
         * given receiver instance.
         *
-        * @param       $receiverInstance       An instance of a Receivable class
         * @return      void
         */
-       public function monitorIncomingRawData (Receivable $receiverInstance) {
+       public function monitorIncomingRawData () {
                // Get the handler instance
                $handlerInstance = $this->getListenerInstance()->getHandlerInstance();
 
@@ -135,6 +134,9 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable {
                        return;
                } // END - if
 
+               // Get receiver (network package) instance
+               $receiverInstance = NetworkPackageFactory::createNetworkPackageInstance();
+
                /*
                 * We have some pending decoded data. The receiver instance is an
                 * abstract network package (which can be received and sent out) so
index 90ee53fcf0aa2167832cd1288e1b85844d69015b..72667ee5d0b883488174c3a8c50ada7002b00d2c 100644 (file)
@@ -288,7 +288,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                $packageInstance->initStacks();
 
                // Get a visitor instance for speeding up things and set it
-               $visitorInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_monitor_visitor_class', array($packageInstance));
+               $visitorInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_monitor_visitor_class');
                $packageInstance->setVisitorInstance($visitorInstance);
 
                // Get crypto instance and set it, too
@@ -299,6 +299,15 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                $assemblerInstance = PackageAssemblerFactory::createAssemblerInstance($packageInstance);
                $packageInstance->setAssemblerInstance($assemblerInstance);
 
+               // Get node instance
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // Get pool instance from node
+               $poolInstance = $nodeInstance->getListenerPoolInstance();
+
+               // And set it here
+               $packageInstance->setListenerPoolInstance($poolInstance);
+
                // Return the prepared instance
                return $packageInstance;
        }
@@ -950,12 +959,11 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
        /**
         * Checks whether new raw package data has arrived at a socket
         *
-        * @param       $poolInstance   An instance of a PoolableListener class
         * @return      $hasArrived             Whether new raw package data has arrived for processing
         */
-       public function isNewRawDataPending (PoolableListener $poolInstance) {
+       public function isNewRawDataPending () {
                // Visit the pool. This monitors the pool for incoming raw data.
-               $poolInstance->accept($this->getVisitorInstance());
+               $this->getListenerPoolInstance()->accept($this->getVisitorInstance());
 
                // Check for new data arrival
                $hasArrived = $this->isRawDataPending();
index 6a24b12db1c42ff8f8af67290a1640b67dbbd5df..2a73ee25505c894f3dcc17e780f81a4d375d5586 100644 (file)
@@ -32,7 +32,7 @@ class HubConsoleControllerResolver extends BaseControllerResolver implements Con
                parent::__construct(__CLASS__);
 
                // Set prefix to "HubConsole"
-               $this->setClassPrefix('HubConsole');
+               $this->setClassPrefix('hub_console');
        }
 
        /**
index 646e9fe68fef89b603d9ca02334976aedee72144..0352ff754aabdccfe2052083fcb83ae30c7d578e 100644 (file)
@@ -38,18 +38,14 @@ class NodeActiveState extends BaseNodeState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $nodeInstance   An instance of a NodeHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public static final function createNodeActiveState (NodeHelper $nodeInstance) {
+       public static final function createNodeActiveState () {
                // Get new instance
                $stateInstance = new NodeActiveState();
 
-               // Enable isActive flag in node instance
-               $nodeInstance->enableIsActive();
-
-               // Set the node instance
-               $stateInstance->setNodeInstance($nodeInstance);
+               // Get node instance and set 'active' flag
+               NodeObjectFactory::createNodeInstance()->enableIsActive();
 
                // Return the prepared instance
                return $stateInstance;
@@ -62,7 +58,7 @@ class NodeActiveState extends BaseNodeState implements Stateable {
         */
        public function nodeAnnouncingToUpperHubs () {
                // Create the new state instance
-               NodeStateFactory::createNodeStateInstanceByName('announcing', $this->getNodeInstance());
+               NodeStateFactory::createNodeStateInstanceByName('announcing');
        }
 
        /**
@@ -76,7 +72,7 @@ class NodeActiveState extends BaseNodeState implements Stateable {
         */
        public function nodeHasSelfConnected () {
                // Create the new state instance
-               NodeStateFactory::createNodeStateInstanceByName('reachable', $this->getNodeInstance());
+               NodeStateFactory::createNodeStateInstanceByName('reachable');
        }
 }
 
index ed200ec26044d7ba1e3aece7886126aec5e86b9d..f9fdba626ac3c296218addafb493436d6359df04 100644 (file)
@@ -38,16 +38,12 @@ class NodeAnnouncementCompletedState extends BaseNodeState implements Stateable
        /**
         * Creates an instance of this class
         *
-        * @param       $nodeInstance   An instance of a NodeHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public static final function createNodeAnnouncementCompletedState (NodeHelper $nodeInstance) {
+       public static final function createNodeAnnouncementCompletedState () {
                // Get new instance
                $stateInstance = new NodeAnnouncementCompletedState();
 
-               // Set the node instance
-               $stateInstance->setNodeInstance($nodeInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
index 0b65b629ae6e54a974c891f004ccff8807ad1c48..d8b114eaa80e0c9594cb234a8c29890593ed1f81 100644 (file)
@@ -38,16 +38,12 @@ class NodeAnnouncingState extends BaseNodeState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $nodeInstance   An instance of a NodeHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public static final function createNodeAnnouncingState (NodeHelper $nodeInstance) {
+       public static final function createNodeAnnouncingState () {
                // Get new instance
                $stateInstance = new NodeAnnouncingState();
 
-               // Set the node instance
-               $stateInstance->setNodeInstance($nodeInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
@@ -60,7 +56,7 @@ class NodeAnnouncingState extends BaseNodeState implements Stateable {
         */
        public function nodeAnnouncementSuccessful () {
                // The node's announcement was successful
-               NodeStateFactory::createNodeStateInstanceByName('announcement_completed', $this->getNodeInstance());
+               NodeStateFactory::createNodeStateInstanceByName('announcement_completed');
        }
 }
 
index 49f27a3c3d5d1a31b203ac0bbe417f6c2a74e622..6f4014f17a421d3b91de0dc14625a54778731b74 100644 (file)
@@ -38,16 +38,12 @@ class NodeInitState extends BaseNodeState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $nodeInstance   An instance of a NodeHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public static final function createNodeInitState (NodeHelper $nodeInstance) {
+       public static final function createNodeInitState () {
                // Get new instance
                $stateInstance = new NodeInitState();
 
-               // Set the node instance
-               $stateInstance->setNodeInstance($nodeInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
@@ -61,7 +57,7 @@ class NodeInitState extends BaseNodeState implements Stateable {
         */
        public function nodeGeneratedSessionId () {
                // Create the new state instance
-               NodeStateFactory::createNodeStateInstanceByName('virgin', $this->getNodeInstance());
+               NodeStateFactory::createNodeStateInstanceByName('virgin');
        }
 }
 
index 68a35fed2ce161166bd167f6d022fee7ef35d9ea..4241988774d756ed214742cf10ed29c7871f795f 100644 (file)
@@ -38,19 +38,12 @@ class NodeReachableState extends BaseNodeState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $nodeInstance   An instance of a NodeHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public final static function createNodeReachableState (NodeHelper $nodeInstance) {
+       public final static function createNodeReachableState () {
                // Get new instance
                $stateInstance = new NodeReachableState();
 
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-STATE: Has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
-
-               // Set the node instance
-               $stateInstance->setNodeInstance($nodeInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
@@ -62,7 +55,7 @@ class NodeReachableState extends BaseNodeState implements Stateable {
         */
        public function nodeAnnouncingToUpperHubs () {
                // Create the new state instance
-               NodeStateFactory::createNodeStateInstanceByName('announcing', $this->getNodeInstance());
+               NodeStateFactory::createNodeStateInstanceByName('announcing');
        }
 }
 
index adc1e708a846a797691d332e77152738ac0c0696..2d83f58e15952e0da5b796ce2704dc490a70b4f0 100644 (file)
@@ -38,16 +38,12 @@ class NodeVirginState extends BaseNodeState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $nodeInstance   An instance of a NodeHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public static final function createNodeVirginState (NodeHelper $nodeInstance) {
+       public static final function createNodeVirginState () {
                // Get new instance
                $stateInstance = new NodeVirginState();
 
-               // Set the node instance
-               $stateInstance->setNodeInstance($nodeInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
@@ -62,7 +58,7 @@ class NodeVirginState extends BaseNodeState implements Stateable {
         */
        public function nodeIsActivated () {
                // Create the new state instance
-               NodeStateFactory::createNodeStateInstanceByName('active', $this->getNodeInstance());
+               NodeStateFactory::createNodeStateInstanceByName('active');
        }
 
 }
index 79e625e0376b0cf73689f72d4a8d6cc234f310c5..e1ffb5afe60af30c2e87a91ea7bb98a8c6e32ffc 100644 (file)
@@ -35,22 +35,12 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable {
        /**
         * Creates an instance of this class
         *
-        * @param       $poolInstance   An instance of a PoolableListener class
         * @return      $taskInstance   An instance of a Taskable/Visitable class
         */
-       public static final function createNetworkPackageReaderTask (PoolableListener $poolInstance) {
+       public static final function createNetworkPackageReaderTask () {
                // Get new instance
                $taskInstance = new NetworkPackageReaderTask();
 
-               // Set the listener instance here
-               $taskInstance->setListenerPoolInstance($poolInstance);
-
-               // Get a singleton network package instance
-               $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
-
-               // And set it in this task
-               $taskInstance->setPackageInstance($packageInstance);
-
                // Return the prepared instance
                return $taskInstance;
        }
@@ -74,7 +64,7 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable {
         */
        public function executeTask () {
                // "Cache" package instance
-               $packageInstance = $this->getPackageInstance();
+               $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
 
                // Do we have something to handle?
                if ($packageInstance->isProcessedMessagePending()) {
@@ -105,7 +95,7 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable {
                         * Some raw data contained multiple messages which where now splitted.
                         */
                        $packageInstance->handleMultipleMessages();
-               } elseif ($packageInstance->isNewRawDataPending($this->getListenerPoolInstance())) {
+               } elseif ($packageInstance->isNewRawDataPending()) {
                        // Raw, decoded data has been received
                        $packageInstance->handleIncomingDecodedData();
                } elseif ($packageInstance->ifAssemblerHasPendingDataLeft()) {
index 871a4f97be0d1b4e714f45a44840b46c76134072..fabc92819d0f83dcc554757efb1c2e47a6876af1 100644 (file)
@@ -41,12 +41,6 @@ class NetworkPackageWriterTask extends BaseTask implements Taskable, Visitable {
                // Get new instance
                $taskInstance = new NetworkPackageWriterTask();
 
-               // Get a singleton network package instance
-               $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
-
-               // And set it in this task
-               $taskInstance->setPackageInstance($packageInstance);
-
                // Return the prepared instance
                return $taskInstance;
        }
@@ -70,7 +64,7 @@ class NetworkPackageWriterTask extends BaseTask implements Taskable, Visitable {
         */
        public function executeTask () {
                // "Cache" package instance
-               $packageInstance = $this->getPackageInstance();
+               $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
 
                // Do we have something to deliver?
                if ($packageInstance->isEncodedDataPending()) {
index be17beb142076d2165c108b702f99f7cc47e1665..767996e3b9692c009dac2bd7edc1ee356f70fbd2 100644 (file)
@@ -41,15 +41,6 @@ class NodePackageDecoderTask extends BaseTask implements Taskable, Visitable {
                // Get new instance
                $taskInstance = new NodePackageDecoderTask();
 
-               // Get a chunk handler instance
-               $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance();
-
-               // Get a decoder instance
-               $decoderInstance = ObjectFactory::createObjectByConfiguredName('package_decoder_class', array($handlerInstance));
-
-               // ... and also set the decoder instance here
-               $taskInstance->setDecoderInstance($decoderInstance);
-
                // Return the prepared instance
                return $taskInstance;
        }
@@ -71,8 +62,8 @@ class NodePackageDecoderTask extends BaseTask implements Taskable, Visitable {
         * @return      void
         */
        public function executeTask () {
-               // "Cache" decoder instance
-               $decoderInstance = $this->getDecoderInstance();
+               // Get a decoder instance
+               $decoderInstance = DecoderFactory::createPackageDecoderInstance();
 
                // Check if the stacker has some entries left
                if ($decoderInstance->ifUnhandledRawPackageDataLeft()) {
index 286d77ed581ec507d600db11771fdeea5c7fe7fd..630360f5ebfb1920b886754e1d8edc8f32a15da9 100644 (file)
@@ -41,13 +41,10 @@ class RawDataPoolMonitorVisitor extends BaseVisitor implements PoolVisitor, List
         * @param       $receiverInstance       An instance of a Receivable class
         * @return      $visitorInstance        An instance of a Visitorable class
         */
-       public final static function createRawDataPoolMonitorVisitor (Receivable $receiverInstance) {
+       public final static function createRawDataPoolMonitorVisitor () {
                // Get new instance
                $visitorInstance = new RawDataPoolMonitorVisitor();
 
-               // Set the receiver instance
-               $visitorInstance->setReceiverInstance($receiverInstance);
-
                // Return the prepared instance
                return $visitorInstance;
        }
@@ -87,7 +84,7 @@ class RawDataPoolMonitorVisitor extends BaseVisitor implements PoolVisitor, List
        public function visitDecorator (BaseDecorator $decoratorInstance) {
                // Do monitor here
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - CALLED!');
-               $decoratorInstance->monitorIncomingRawData($this->getReceiverInstance());
+               $decoratorInstance->monitorIncomingRawData();
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - FINISH');
        }
 }