]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 7 Nov 2020 18:11:12 +0000 (19:11 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 7 Nov 2020 18:27:57 +0000 (19:27 +0100)
- re-added $stackInstance and others from refactured core framework
- updated core framework

Signed-off-by: Roland Häder <roland@mxchange.org>
application/hub/classes/decoder/class_BaseDecoder.php
application/hub/classes/dht/class_BaseDht.php
application/hub/classes/filter/class_BaseHubFilter.php
application/hub/classes/handler/class_BaseHubHandler.php
application/hub/classes/handler/package/class_NetworkPackageHandler.php
application/hub/classes/package/assembler/class_PackageAssembler.php
application/hub/classes/source/class_BaseUrlSource.php
application/hub/classes/source/units/class_TestUnitSource.php
core

index 676c091c4026d33c996ca8d4f9d78e22658bdb94..73c986855d21816ea5044b5539082a46ead6ab87 100644 (file)
@@ -6,6 +6,9 @@ namespace Org\Shipsimu\Hub\Decoder;
 use Org\Shipsimu\Hub\Generic\BaseHubSystem;
 use Org\Shipsimu\Hub\Network\Delivery\Deliverable;
 
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Stacker\Stackable;
+
 /**
  * A general Decoder class
  *
@@ -34,6 +37,11 @@ abstract class BaseDecoder extends BaseHubSystem {
         */
        private $packageHandlerInstance = NULL;
 
+       /**
+        * Instance of the stacker
+        */
+       private $stackInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -64,4 +72,23 @@ abstract class BaseDecoder extends BaseHubSystem {
                return $this->packageHandlerInstance;
        }
 
+       /**
+        * Setter for stacker instance
+        *
+        * @param       $stackInstance  An instance of an stacker
+        * @return      void
+        */
+       protected final function setStackInstance (Stackable $stackInstance) {
+               $this->stackInstance = $stackInstance;
+       }
+
+       /**
+        * Getter for stacker instance
+        *
+        * @return      $stackInstance  An instance of an stacker
+        */
+       public final function getStackInstance () {
+               return $this->stackInstance;
+       }
+
 }
index 5bbf61d7af19d967673143d40a8a66c5401721b1..8dea3537a4d365b3d96a096cc6df3d8a320046a1 100644 (file)
@@ -12,6 +12,7 @@ use Org\Shipsimu\Hub\Helper\Dht\HelpableDht;
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Result\Search\SearchableResult;
+use Org\Mxchange\CoreFramework\Stacker\Stackable;
 
 /**
  * A general DHT class
@@ -36,16 +37,21 @@ use Org\Mxchange\CoreFramework\Result\Search\SearchableResult;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseDht extends BaseHubSystem implements Distributable {
+       /**
+        * Stacker name for "INSERT" node data
+        */
+       const STACKER_NAME_INSERT_NODE        = 'dht_insert_node';
+       const STACKER_NAME_PENDING_PUBLISHING = 'dht_pending_publish';
+
        /**
         * "Cached" instance of a publish helper
         */
        private $publishHelperInstance = NULL;
 
        /**
-        * Stacker name for "INSERT" node data
+        * Instance of the stacker
         */
-       const STACKER_NAME_INSERT_NODE        = 'dht_insert_node';
-       const STACKER_NAME_PENDING_PUBLISHING = 'dht_pending_publish';
+       private $stackInstance = NULL;
 
        /**
         * Protected constructor
@@ -70,6 +76,25 @@ abstract class BaseDht extends BaseHubSystem implements Distributable {
                DhtStateFactory::createDhtStateInstanceByName('init', $this);
        }
 
+       /**
+        * Setter for stacker instance
+        *
+        * @param       $stackInstance  An instance of an stacker
+        * @return      void
+        */
+       protected final function setStackInstance (Stackable $stackInstance) {
+               $this->stackInstance = $stackInstance;
+       }
+
+       /**
+        * Getter for stacker instance
+        *
+        * @return      $stackInstance  An instance of an stacker
+        */
+       public final function getStackInstance () {
+               return $this->stackInstance;
+       }
+
        /**
         * Initializes all stackers
         *
index 614b069a32d511f54b33f548180ebd944000ebdb..cd740b93f7dc4342ca116d53c065ae2a85f32030 100644 (file)
@@ -63,11 +63,11 @@ abstract class BaseHubFilter extends BaseFilter {
         *
         * @param       $messageType            Type of message
         * @param       $messageInstance        An instance of a DeliverableMessage class
-        * @param       $packageInstance        An instance of a Receivable class
+        * @param       $handlerInstance        An instance of a Receivable class
         * @return      void
         * @todo        Exceptions from renderXmlContent() are currently unhandled
         */
-       protected function genericProcessMessage ($messageType, DeliverableMessage $messageInstance, Receivable $packageInstance) {
+       protected function genericProcessMessage ($messageType, DeliverableMessage $messageInstance, Receivable $handlerInstance) {
                // Get a template instance from the factory
                $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance(sprintf('node_%s_template_class', $messageType));
 
@@ -124,7 +124,7 @@ abstract class BaseHubFilter extends BaseFilter {
                );
 
                // Push the processed message back on stack
-               $packageInstance->getStackInstance()->pushNamed(NetworkPackageHandler::STACKER_NAME_PROCESSED_MESSAGE, $messageArray);
+               $handlerInstance->getStackInstance()->pushNamed(NetworkPackageHandler::STACKER_NAME_PROCESSED_MESSAGE, $messageArray);
        }
 
 }
index 9d7a6a607c43a9e9c4aadc77fafdb69c40bcaabf..d87e3e39aa93f0b71a07f5c5861557072b7134a2 100644 (file)
@@ -17,6 +17,7 @@ use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
 use Org\Mxchange\CoreFramework\Handler\BaseHandler;
 use Org\Mxchange\CoreFramework\Handler\Handleable;
 use Org\Mxchange\CoreFramework\Registry\Register;
+use Org\Mxchange\CoreFramework\Stacker\Stackable;
 
 /**
  * A general hub handler
@@ -76,6 +77,11 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte
         */
        private $registryInstance = NULL;
 
+       /**
+        * Instance of the stacker
+        */
+       private $stackInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -306,4 +312,23 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte
                return $this->registryInstance;
        }
 
+       /**
+        * Setter for stacker instance
+        *
+        * @param       $stackInstance  An instance of an stacker
+        * @return      void
+        */
+       protected final function setStackInstance (Stackable $stackInstance) {
+               $this->stackInstance = $stackInstance;
+       }
+
+       /**
+        * Getter for stacker instance
+        *
+        * @return      $stackInstance  An instance of an stacker
+        */
+       public final function getStackInstance () {
+               return $this->stackInstance;
+       }
+
 }
index 8c6388360b8acbce88129b694e3805b2b287a3e1..f5c1038484d1338c076a68a1b078f23e4d7bd972 100644 (file)
@@ -314,6 +314,11 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        private $compressorInstance = NULL;
 
+       /**
+        * Visitor handler instance
+        */
+       private $visitorInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -334,14 +339,14 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         * Creates an instance of this class
         *
         * @param       $compressorInstance             A Compressor instance for compressing the content
-        * @return      $packageInstance                An instance of a Deliverable class
+        * @return      $handlerInstance                An instance of a Deliverable class
         */
        public static final function createNetworkPackageHandler (Compressor $compressorInstance) {
                // Get new instance
-               $packageInstance = new NetworkPackageHandler();
+               $handlerInstance = new NetworkPackageHandler();
 
                // Now set the compressor instance
-               $packageInstance->setCompressorInstance($compressorInstance);
+               $handlerInstance->setCompressorInstance($compressorInstance);
 
                /*
                 * We need to initialize a stack here for our packages even for those
@@ -351,38 +356,38 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $stackInstance = ObjectFactory::createObjectByConfiguredName('network_package_stacker_class');
 
                // At last, set it in this class
-               $packageInstance->setStackInstance($stackInstance);
+               $handlerInstance->setStackInstance($stackInstance);
 
                // Init all stacker
-               $packageInstance->initStacks();
+               $handlerInstance->initStacks();
 
                // Get a visitor instance for speeding up things and set it
                $visitorInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_monitor_visitor_class');
-               $packageInstance->setVisitorInstance($visitorInstance);
+               $handlerInstance->setVisitorInstance($visitorInstance);
 
                // Get crypto instance and set it, too
                $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
-               $packageInstance->setCryptoInstance($cryptoInstance);
+               $handlerInstance->setCryptoInstance($cryptoInstance);
 
                // Get a singleton package assembler instance from factory and set it here, too
-               $assemblerInstance = PackageAssemblerFactory::createAssemblerInstance($packageInstance);
-               $packageInstance->setAssemblerInstance($assemblerInstance);
+               $assemblerInstance = PackageAssemblerFactory::createAssemblerInstance($handlerInstance);
+               $handlerInstance->setAssemblerInstance($assemblerInstance);
 
                // Get node instance
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Creating node instance ...');
                $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Set it locally
-               $packageInstance->setNodeInstance($nodeInstance);
+               $handlerInstance->setNodeInstance($nodeInstance);
 
                // Get pool instance from node
                $poolInstance = $nodeInstance->getListenerPoolInstance();
 
                // And set it here
-               $packageInstance->setListenerPoolInstance($poolInstance);
+               $handlerInstance->setListenerPoolInstance($poolInstance);
 
                // Return the prepared instance
-               return $packageInstance;
+               return $handlerInstance;
        }
 
        /**
@@ -404,6 +409,25 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                return $this->compressorInstance;
        }
 
+       /**
+        * Setter for visitor instance
+        *
+        * @param       $visitorInstance        A Visitor instance
+        * @return      void
+        */
+       protected final function setVisitorInstance (Visitor $visitorInstance) {
+               $this->visitorInstance = $visitorInstance;
+       }
+
+       /**
+        * Getter for visitor instance
+        *
+        * @return      $visitorInstance        A Visitor instance
+        */
+       protected final function getVisitorInstance () {
+               return $this->visitorInstance;
+       }
+
        /**
         * Initialize all stackers
         *
index 256b72d6db7981c152d97d21269ad8bbe907ec8b..34cda4532c4b7ba42edce2b84801ea2765959d13 100644 (file)
@@ -18,6 +18,7 @@ use Org\Shipsimu\Hub\Network\Receive\Receivable;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
+use Org\Mxchange\CoreFramework\Stacker\Stackable;
 use Org\Mxchange\CoreFramework\Visitor\Visitable;
 use Org\Mxchange\CoreFramework\Visitor\Visitor;
 
@@ -73,6 +74,11 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable,
         */
        private $packageHandlerInstance = NULL;
 
+       /**
+        * Instance of the stacker
+        */
+       private $stackInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -150,6 +156,25 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable,
                return $this->packageHandlerInstance;
        }
 
+       /**
+        * Setter for stacker instance
+        *
+        * @param       $stackInstance  An instance of an stacker
+        * @return      void
+        */
+       protected final function setStackInstance (Stackable $stackInstance) {
+               $this->stackInstance = $stackInstance;
+       }
+
+       /**
+        * Getter for stacker instance
+        *
+        * @return      $stackInstance  An instance of an stacker
+        */
+       public final function getStackInstance () {
+               return $this->stackInstance;
+       }
+
        /**
         * Checks whether the input buffer (stacker to be more preceise) is empty.
         *
index 0fe5a8d25959c3315058fdf1eb1d65c045d1f00b..3026f5ece69cb9a22c5515c63a1fc198b92151da 100644 (file)
@@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Crawler\Source\BaseSource;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Factory\Stack\FileStackFactory;
+use Org\Mxchange\CoreFramework\Stacker\Stackable;
 
 /**
  * A general URL source class
@@ -39,6 +40,11 @@ abstract class BaseUrlSource extends BaseSource {
        const CRAWL_JOB_ARRAY_DEPTH          = 'start_depth';
        const CRAWL_JOB_ARRAY_EXTERNAL_DEPTH = 'external_depth';
 
+       /**
+        * Instance of the stacker
+        */
+       private $stackInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -50,6 +56,25 @@ abstract class BaseUrlSource extends BaseSource {
                parent::__construct($className);
        }
 
+       /**
+        * Setter for stacker instance
+        *
+        * @param       $stackInstance  An instance of an stacker
+        * @return      void
+        */
+       protected final function setStackInstance (Stackable $stackInstance) {
+               $this->stackInstance = $stackInstance;
+       }
+
+       /**
+        * Getter for stacker instance
+        *
+        * @return      $stackInstance  An instance of an stacker
+        */
+       public final function getStackInstance () {
+               return $this->stackInstance;
+       }
+
        /**
         * Initalizes this source
         *
index 93f716eceb05e22b7a8add723326c5f5b7dff490..a3cfa070905d3e6265472cb19b89fa0181f6cd21 100644 (file)
@@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Crawler\Source\BaseSource;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 
@@ -33,6 +34,11 @@ use Org\Mxchange\CoreFramework\Registry\Registerable;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class TestUnitSource extends BaseSource implements UnitSource, Registerable {
+       /**
+        * Instance of a RNG
+        */
+       private $rngInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -64,6 +70,25 @@ class TestUnitSource extends BaseSource implements UnitSource, Registerable {
                return $sourceInstance;
        }
 
+       /**
+        * Setter for RNG instance
+        *
+        * @param       $rngInstance    An instance of a random number generator (RNG)
+        * @return      void
+        */
+       protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
+               $this->rngInstance = $rngInstance;
+       }
+
+       /**
+        * Getter for RNG instance
+        *
+        * @return      $rngInstance    An instance of a random number generator (RNG)
+        */
+       public final function getRngInstance () {
+               return $this->rngInstance;
+       }
+
        /**
         * Generates an encrypted random message
         *
@@ -83,6 +108,3 @@ class TestUnitSource extends BaseSource implements UnitSource, Registerable {
                return $encryptedMessage;
        }
 }
-
-// [EOF]
-?>
diff --git a/core b/core
index a1dfd448376c05e2a5ee2af1538c2e38f42983e4..c2e22b6c3806033f8a1935010cf875c1f243fa4a 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit a1dfd448376c05e2a5ee2af1538c2e38f42983e4
+Subproject commit c2e22b6c3806033f8a1935010cf875c1f243fa4a