* @return $masterTemplateName Name of the master template
*/
public function buildMasterTemplateName () {
- return 'node_main';
+ return 'node_daemon';
}
}
--- /dev/null
+<?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'));
+ }
+
+}
+++ /dev/null
-<?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'));
- }
-
-}
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
$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');
// 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');
// 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');
// 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);
$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