From: Roland Haeder Date: Mon, 30 Mar 2015 00:03:10 +0000 (+0200) Subject: Fixed a lot broken stuff: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4f0fa8c72f17f708d6fd4aa66258395b390cbe93;p=hub.git Fixed a lot broken stuff: - 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 --- diff --git a/application/hub/config.php b/application/hub/config.php index 97ff9a483..cad249e11 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -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'); diff --git a/application/hub/interfaces/listener/class_Listenable.php b/application/hub/interfaces/listener/class_Listenable.php index cf561ef0b..d453324eb 100644 --- a/application/hub/interfaces/listener/class_Listenable.php +++ b/application/hub/interfaces/listener/class_Listenable.php @@ -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 diff --git a/application/hub/interfaces/package/class_Receivable.php b/application/hub/interfaces/package/class_Receivable.php index f35f28a41..126247bdf 100644 --- a/application/hub/interfaces/package/class_Receivable.php +++ b/application/hub/interfaces/package/class_Receivable.php @@ -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 diff --git a/application/hub/main/class_BaseHubSystem.php b/application/hub/main/class_BaseHubSystem.php index 885abc5d0..0dc699244 100644 --- a/application/hub/main/class_BaseHubSystem.php +++ b/application/hub/main/class_BaseHubSystem.php @@ -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. diff --git a/application/hub/main/decoder/package/class_PackageDecoder.php b/application/hub/main/decoder/package/class_PackageDecoder.php index 12884af7d..49ba434c5 100644 --- a/application/hub/main/decoder/package/class_PackageDecoder.php +++ b/application/hub/main/decoder/package/class_PackageDecoder.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -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 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/factories/decoder/.htaccess @@ -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 index 000000000..7125c6a9f --- /dev/null +++ b/application/hub/main/factories/decoder/class_DecoderFactory.php @@ -0,0 +1,62 @@ + + * @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 . + */ +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] +?> diff --git a/application/hub/main/factories/states/node/class_NodeStateFactory.php b/application/hub/main/factories/states/node/class_NodeStateFactory.php index eee1246a8..46212da4f 100644 --- a/application/hub/main/factories/states/node/class_NodeStateFactory.php +++ b/application/hub/main/factories/states/node/class_NodeStateFactory.php @@ -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)); diff --git a/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php b/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php index bb5ab1ac4..6b12e4169 100644 --- a/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php +++ b/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php @@ -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); diff --git a/application/hub/main/handler/chunks/class_ChunkHandler.php b/application/hub/main/handler/chunks/class_ChunkHandler.php index 2c0e5a47b..180805cdd 100644 --- a/application/hub/main/handler/chunks/class_ChunkHandler.php +++ b/application/hub/main/handler/chunks/class_ChunkHandler.php @@ -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'. * diff --git a/application/hub/main/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php b/application/hub/main/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php index 584c8daff..e1ac210a2 100644 --- a/application/hub/main/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php +++ b/application/hub/main/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php @@ -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 { diff --git a/application/hub/main/handler/protocol/class_BaseProtocolHandler.php b/application/hub/main/handler/protocol/class_BaseProtocolHandler.php index 5b0585729..d769cde79 100644 --- a/application/hub/main/handler/protocol/class_BaseProtocolHandler.php +++ b/application/hub/main/handler/protocol/class_BaseProtocolHandler.php @@ -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 * diff --git a/application/hub/main/listener/class_BaseListener.php b/application/hub/main/listener/class_BaseListener.php index 81d105416..037f62d80 100644 --- a/application/hub/main/listener/class_BaseListener.php +++ b/application/hub/main/listener/class_BaseListener.php @@ -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); } } diff --git a/application/hub/main/listener/class_BaseListenerDecorator.php b/application/hub/main/listener/class_BaseListenerDecorator.php index 54bb578bb..ab44d2d6f 100644 --- a/application/hub/main/listener/class_BaseListenerDecorator.php +++ b/application/hub/main/listener/class_BaseListenerDecorator.php @@ -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 diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php index 90ee53fcf..72667ee5d 100644 --- a/application/hub/main/package/class_NetworkPackage.php +++ b/application/hub/main/package/class_NetworkPackage.php @@ -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(); diff --git a/application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php b/application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php index 6a24b12db..2a73ee255 100644 --- a/application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php +++ b/application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php @@ -32,7 +32,7 @@ class HubConsoleControllerResolver extends BaseControllerResolver implements Con parent::__construct(__CLASS__); // Set prefix to "HubConsole" - $this->setClassPrefix('HubConsole'); + $this->setClassPrefix('hub_console'); } /** diff --git a/application/hub/main/states/node/active/class_NodeActiveState.php b/application/hub/main/states/node/active/class_NodeActiveState.php index 646e9fe68..0352ff754 100644 --- a/application/hub/main/states/node/active/class_NodeActiveState.php +++ b/application/hub/main/states/node/active/class_NodeActiveState.php @@ -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'); } } diff --git a/application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php b/application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php index ed200ec26..f9fdba626 100644 --- a/application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php +++ b/application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php @@ -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; } diff --git a/application/hub/main/states/node/announced/class_NodeAnnouncingState.php b/application/hub/main/states/node/announced/class_NodeAnnouncingState.php index 0b65b629a..d8b114eaa 100644 --- a/application/hub/main/states/node/announced/class_NodeAnnouncingState.php +++ b/application/hub/main/states/node/announced/class_NodeAnnouncingState.php @@ -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'); } } diff --git a/application/hub/main/states/node/init/class_NodeInitState.php b/application/hub/main/states/node/init/class_NodeInitState.php index 49f27a3c3..6f4014f17 100644 --- a/application/hub/main/states/node/init/class_NodeInitState.php +++ b/application/hub/main/states/node/init/class_NodeInitState.php @@ -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'); } } diff --git a/application/hub/main/states/node/seniors/class_NodeReachableState.php b/application/hub/main/states/node/seniors/class_NodeReachableState.php index 68a35fed2..424198877 100644 --- a/application/hub/main/states/node/seniors/class_NodeReachableState.php +++ b/application/hub/main/states/node/seniors/class_NodeReachableState.php @@ -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'); } } diff --git a/application/hub/main/states/node/virgin/class_NodeVirginState.php b/application/hub/main/states/node/virgin/class_NodeVirginState.php index adc1e708a..2d83f58e1 100644 --- a/application/hub/main/states/node/virgin/class_NodeVirginState.php +++ b/application/hub/main/states/node/virgin/class_NodeVirginState.php @@ -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'); } } diff --git a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php b/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php index 79e625e03..e1ffb5afe 100644 --- a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php +++ b/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php @@ -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()) { diff --git a/application/hub/main/tasks/network/class_NetworkPackageWriterTask.php b/application/hub/main/tasks/network/class_NetworkPackageWriterTask.php index 871a4f97b..fabc92819 100644 --- a/application/hub/main/tasks/network/class_NetworkPackageWriterTask.php +++ b/application/hub/main/tasks/network/class_NetworkPackageWriterTask.php @@ -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()) { diff --git a/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php b/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php index be17beb14..767996e3b 100644 --- a/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php +++ b/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php @@ -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()) { diff --git a/application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php b/application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php index 286d77ed5..630360f5e 100644 --- a/application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php +++ b/application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php @@ -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'); } }