]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 10 Jul 2022 10:01:12 +0000 (12:01 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 10 Jul 2022 10:01:12 +0000 (12:01 +0200)
- renamed 'main' to 'daemon' for invocation of "php index.php app=hub"

application/hub/class_ApplicationHelper.php
application/hub/classes/commands/console/class_HubConsoleDaemonCommand.php [new file with mode: 0644]
application/hub/classes/commands/console/class_HubConsoleMainCommand.php [deleted file]
application/hub/classes/commands/html/class_HubHtmlIndexCommand.php
application/hub/config.php

index 2202b4c47d268547636f29fb83909638227eca03..8680157e41e60c7a647146995a847d6048545cc7 100644 (file)
@@ -206,6 +206,6 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
         * @return      $masterTemplateName             Name of the master template
         */
        public function buildMasterTemplateName () {
-               return 'node_main';
+               return 'node_daemon';
        }
 }
diff --git a/application/hub/classes/commands/console/class_HubConsoleDaemonCommand.php b/application/hub/classes/commands/console/class_HubConsoleDaemonCommand.php
new file mode 100644 (file)
index 0000000..4826c63
--- /dev/null
@@ -0,0 +1,158 @@
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Command;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Command\BaseCommand;
+use Org\Mxchange\CoreFramework\Command\Commandable;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Controller\Controller;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
+use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+
+/**
+ * A command for the 'daemon' routine
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class HubConsoleDaemonCommand extends BaseCommand implements Commandable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       private function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $resolverInstance       An instance of a command resolver class
+        * @return      $commandInstance        An instance a prepared command class
+        */
+       public static final function createHubConsoleDaemonCommand (CommandResolver $resolverInstance) {
+               // Get new instance
+               $commandInstance = new HubConsoleDaemonCommand();
+
+               // Set the application instance
+               $commandInstance->setResolverInstance($resolverInstance);
+
+               // Return the prepared instance
+               return $commandInstance;
+       }
+
+       /**
+        * Executes the given command with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        Try to create a HubActivationTask or so
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get a registry and the application instance from it
+               $applicationInstance = ApplicationHelper::getSelfInstance();
+
+               /*
+                * ----------------------- Bootstrapping phase ------------------------
+                * Try to bootstrap the node and pass the request instance to it for
+                * extra arguments which mostly override config entries or enable special
+                * features within the hub (none is ready at this development stage)
+                */
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...');
+               $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance);
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Bootstrap finished.');
+
+               // Get node instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN-COMMAND: Creating node instance ...');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // Add some node-specific filters, e.g. announcement
+               $nodeInstance->addExtraNodeFilters();
+
+               /*
+                * -------------------------- Hub activation --------------------------
+                * Activates the node by doing some final preparation steps and setting
+                * the attribute $hubIsActive to TRUE.
+                */
+               $nodeInstance->activateNode($requestInstance, $responseInstance);
+
+               // Get task handler instance
+               $handlerInstance = GenericRegistry::getRegistry()->getInstance('task_handler');
+
+               // Debug message
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Entering main loop. ---');
+
+               /*
+                * ----------------------------- Main loop ----------------------------
+                * This is the main loop. Queried calls should come back here very fast
+                * so the whole application runs on nice speed. This while-loop goes
+                * until the hub is no longer active or all tasks are killed.
+                */
+               while (($nodeInstance->isNodeActive()) && ($handlerInstance->hasTasksLeft())) {
+                       // Handle all tasks here
+                       $handlerInstance->handleTasks();
+               }
+
+               // Debug message
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---');
+       }
+
+       /**
+        * Adds extra filters to the given controller instance
+        *
+        * @param       $controllerInstance             A controller instance
+        * @param       $requestInstance                An instance of a class with an Requestable interface
+        * @return      void
+        * @todo        Should we add some more filters?
+        */
+       public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+               // Add pre filters
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_php_requirements_filter_class'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_initializer_filter_class'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_welcome_teaser_filter_class'));
+
+               // Add bootstrap filters
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_nodeid_filter_class'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_sessionid_filter_class'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_private_key_filter_class'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_extra_bootstrapping_filter_class'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_listener_pool_filter_class'));
+
+               // Add node activation filters
+               $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('node_activation_task_handler_initializer_filter_class'));
+
+               // Add shutdown filters
+               $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_flush_node_list_filter_class'));
+               $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_task_handler_filter_class'));
+
+               // This is the last generic shutdown filter
+               $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_node_filter_class'));
+       }
+
+}
diff --git a/application/hub/classes/commands/console/class_HubConsoleMainCommand.php b/application/hub/classes/commands/console/class_HubConsoleMainCommand.php
deleted file mode 100644 (file)
index 996cd0b..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Command;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Command\BaseCommand;
-use Org\Mxchange\CoreFramework\Command\Commandable;
-use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Controller\Controller;
-use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-
-/**
- * A command for the 'main' routine
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class HubConsoleMainCommand extends BaseCommand implements Commandable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       private function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @param       $resolverInstance       An instance of a command resolver class
-        * @return      $commandInstance        An instance a prepared command class
-        */
-       public static final function createHubConsoleMainCommand (CommandResolver $resolverInstance) {
-               // Get new instance
-               $commandInstance = new HubConsoleMainCommand();
-
-               // Set the application instance
-               $commandInstance->setResolverInstance($resolverInstance);
-
-               // Return the prepared instance
-               return $commandInstance;
-       }
-
-       /**
-        * Executes the given command with given request and response objects
-        *
-        * @param       $requestInstance        An instance of a class with an Requestable interface
-        * @param       $responseInstance       An instance of a class with an Responseable interface
-        * @return      void
-        * @todo        Try to create a HubActivationTask or so
-        */
-       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get a registry and the application instance from it
-               $applicationInstance = ApplicationHelper::getSelfInstance();
-
-               /*
-                * ----------------------- Bootstrapping phase ------------------------
-                * Try to bootstrap the node and pass the request instance to it for
-                * extra arguments which mostly override config entries or enable special
-                * features within the hub (none is ready at this development stage)
-                */
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...');
-               $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance);
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Bootstrap finished.');
-
-               // Get node instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN-COMMAND: Creating node instance ...');
-               $nodeInstance = NodeObjectFactory::createNodeInstance();
-
-               // Add some node-specific filters, e.g. announcement
-               $nodeInstance->addExtraNodeFilters();
-
-               /*
-                * -------------------------- Hub activation --------------------------
-                * Activates the node by doing some final preparation steps and setting
-                * the attribute $hubIsActive to TRUE.
-                */
-               $nodeInstance->activateNode($requestInstance, $responseInstance);
-
-               // Get task handler instance
-               $handlerInstance = GenericRegistry::getRegistry()->getInstance('task_handler');
-
-               // Debug message
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Entering main loop. ---');
-
-               /*
-                * ----------------------------- Main loop ----------------------------
-                * This is the main loop. Queried calls should come back here very fast
-                * so the whole application runs on nice speed. This while-loop goes
-                * until the hub is no longer active or all tasks are killed.
-                */
-               while (($nodeInstance->isNodeActive()) && ($handlerInstance->hasTasksLeft())) {
-                       // Handle all tasks here
-                       $handlerInstance->handleTasks();
-               }
-
-               // Debug message
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---');
-       }
-
-       /**
-        * Adds extra filters to the given controller instance
-        *
-        * @param       $controllerInstance             A controller instance
-        * @param       $requestInstance                An instance of a class with an Requestable interface
-        * @return      void
-        * @todo        Should we add some more filters?
-        */
-       public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
-               // Add pre filters
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_php_requirements_filter_class'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_initializer_filter_class'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_welcome_teaser_filter_class'));
-
-               // Add bootstrap filters
-               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_nodeid_filter_class'));
-               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_sessionid_filter_class'));
-               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_private_key_filter_class'));
-               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_extra_bootstrapping_filter_class'));
-               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_listener_pool_filter_class'));
-
-               // Add node activation filters
-               $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('node_activation_task_handler_initializer_filter_class'));
-
-               // Add shutdown filters
-               $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_flush_node_list_filter_class'));
-               $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_task_handler_filter_class'));
-
-               // This is the last generic shutdown filter
-               $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_node_filter_class'));
-       }
-
-}
index 418e4beeef00ac47eb170df0e2cdc2791414e334..3066057abf176b398a9f514fc5c7d346bcc030dd 100644 (file)
@@ -12,7 +12,7 @@ use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
 use Org\Mxchange\CoreFramework\Response\Responseable;
 
 /**
- * A command for the 'main' routine
+ * A command for the index routine
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
index 920c57c5728095511ec8532c55dd50dc62d1e957..b5fb14205c309919c8a986d83a7f70842b50ffb6 100644 (file)
@@ -157,10 +157,10 @@ $cfg->setConfigEntry('dht_bootstrap_helper_class', 'Org\Shipsimu\Hub\Helper\Dht\
 $cfg->setConfigEntry('dht_publish_entry_helper_class', 'Org\Shipsimu\Hub\Helper\Dht\Publish\DhtPublishEntryHelper');
 
 // CFG: DEFAULT-CONSOLE-COMMAND
-$cfg->setConfigEntry('default_console_command', 'main');
+$cfg->setConfigEntry('default_console_command', 'daemon');
 
 // CFG: DEFAULT-HUB-CONSOLE-COMMAND
-$cfg->setConfigEntry('default_hub_console_command', 'main');
+$cfg->setConfigEntry('default_hub_console_command', 'daemon');
 
 // CFG: HUB-CONSOLE-CONTROLLER_RESOLVER-CLASS
 $cfg->setConfigEntry('hub_console_controller_resolver_class', 'Org\Shipsimu\Hub\Resolver\Controller\HubConsoleControllerResolver');
@@ -168,8 +168,8 @@ $cfg->setConfigEntry('hub_console_controller_resolver_class', 'Org\Shipsimu\Hub\
 // CFG: HUB-HTML-CONTROLLER_RESOLVER-CLASS
 $cfg->setConfigEntry('hub_html_controller_resolver_class', 'Org\Shipsimu\Hub\Resolver\Controller\HubHtmlControllerResolver');
 
-// CFG: HUB-CONSOLE-CMD-MAIN-RESOLVER-CLASS
-$cfg->setConfigEntry('hub_console_cmd_main_resolver_class', 'Org\Shipsimu\Hub\Resolver\Command\HubConsoleCommandResolver');
+// CFG: HUB-CONSOLE-CMD-DAEMON-RESOLVER-CLASS
+$cfg->setConfigEntry('hub_console_cmd_daemon_resolver_class', 'Org\Shipsimu\Hub\Resolver\Command\HubConsoleCommandResolver');
 
 // CFG: NEWS-DOWNLOAD-FILTER-CLASS
 $cfg->setConfigEntry('news_download_filter_class', 'Org\Mxchange\CoreFramework\Filter\News\NewsDownloadFilter');
@@ -273,8 +273,8 @@ $cfg->setConfigEntry('node_answer_message_dht_bootstrap_helper_class', 'Org\Ship
 // CFG: NODE-NEXT-ANNOUNCEMENT-ANSWER-OKAY-HELPER-CLASS
 $cfg->setConfigEntry('node_next_announcement_answer_okay_helper_class', 'Org\Shipsimu\Hub\Node\Helper\Request\NodeList\NodeRequestNodeListHelper');
 
-// CFG: NEWS-READER-MAIN-CLASS
-$cfg->setConfigEntry('news_reader_main_class', 'Org\Mxchange\CoreFramework\Reader\News\Console\ConsoleNewsReader');
+// CFG: NEWS-READER-DAEMON-CLASS
+$cfg->setConfigEntry('news_reader_daemon_class', 'Org\Mxchange\CoreFramework\Reader\News\Console\ConsoleNewsReader');
 
 // CFG: NODE-ANNOUNCEMENT-TEMPLATE-CLASS
 $cfg->setConfigEntry('node_announcement_template_class', 'Org\Shipsimu\Hub\Template\Engine\Xml\Announcement\XmlAnnouncementTemplateEngine');
@@ -507,8 +507,8 @@ $cfg->setConfigEntry('stacker_message_new_max_size', 10);
 // CFG: STACKER-MESSAGE-PROCESSED-MAX_SIZE
 $cfg->setConfigEntry('stacker_message_processed_max_size', 10);
 
-// CFG: NEWS-MAIN-LIMIT
-$cfg->setConfigEntry('news_main_limit', 5);
+// CFG: NEWS-DAEMON-LIMIT
+$cfg->setConfigEntry('news_daemon_limit', 5);
 
 // CFG: TASK-PACKAGE-TAGS-INIT-STARTUP-DELAY
 $cfg->setConfigEntry('task_package_tags_init_startup_delay', 50);
@@ -861,7 +861,7 @@ $cfg->setConfigEntry('max_dht_recipients', 10);
 $cfg->setConfigEntry('connection_info_class', 'Org\Shipsimu\Hub\Information\Connection\ConnectionInfo');
 
 // CFG: DEFAULT-HUB-CONSOLE-CONTROLLER
-$cfg->setConfigEntry('default_hub_console_controller', 'main');
+$cfg->setConfigEntry('default_hub_console_controller', 'daemon');
 
 ///////////////////////////////////////////////////////////////////////////////
 //                              Node states