From e6a7143107896cd55cbe777da471bd3b976d9d4f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 17 Sep 2022 06:00:52 +0200 Subject: [PATCH] Continued: - further porting from hub import to LFDB2 --- application/lfdb2/class_ApplicationHelper.php | 13 ++--- .../class_Lfdb2ConsoleServerCommand.php | 6 +- ...lass_Lfdb2ConsoleDefaultNewsController.php | 4 +- .../class_ServerShutdownServerFilter.php | 4 +- application/lfdb2/config.php | 2 +- application/lfdb2/data.php | 43 +------------- application/lfdb2/exceptions.php | 9 +-- application/lfdb2/init.php | 38 +------------ application/lfdb2/loader.php | 28 +-------- application/lfdb2/starter.php | 57 +------------------ 10 files changed, 21 insertions(+), 183 deletions(-) diff --git a/application/lfdb2/class_ApplicationHelper.php b/application/lfdb2/class_ApplicationHelper.php index 8680157..f95d8fd 100644 --- a/application/lfdb2/class_ApplicationHelper.php +++ b/application/lfdb2/class_ApplicationHelper.php @@ -3,7 +3,7 @@ namespace Org\Mxchange\CoreFramework\Helper\Application; // Import application-specific sutff -use Org\Shipsimu\Hub\Tools\HubTools; +//use Org\Shipsimu\Hub\Tools\HubTools; // Import framework stuff use Org\Mxchange\CoreFramework\Application\BaseApplication; @@ -37,7 +37,7 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate; * * @author Roland Haeder * @version 0.0 - * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2022 Hub Developer Team + * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2022 LFDB2 Developer Team * @license GNU GPL 3.0 or any newer version * * This program is free software: you can redistribute it and/or modify @@ -86,9 +86,9 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication */ public function setupApplicationData () { // Set all application data - $this->setAppName('Generic Object Sharing Hub'); + $this->setAppName('Local File Database 2'); $this->setAppVersion('0.0.0'); - $this->setAppShortName('hub'); + $this->setAppShortName('lfdb2'); } /** @@ -110,7 +110,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication FrameworkBootstrap::initDatabaseInstance(); // Get own internal address and set it in config - $cfg->setConfigEntry('internal_address', HubTools::determineOwnInternalAddress()); + $cfg->setConfigEntry('internal_address', lfdb2Tools::determineOwnInternalAddress()); } /** @@ -168,8 +168,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication // Only for console requests as this is the actual daemon if ($requestType == 'console') { // -------------------------- Shutdown phase -------------------------- - // Shutting down the hub by saying "good bye" to all connected peers - // and other hubs, flushing all queues and caches. + // Shutting down database system self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown in progress, main loop exited.'); $this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance); self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)'); diff --git a/application/lfdb2/classes/command/console/class_Lfdb2ConsoleServerCommand.php b/application/lfdb2/classes/command/console/class_Lfdb2ConsoleServerCommand.php index 235685e..017c8d8 100644 --- a/application/lfdb2/classes/command/console/class_Lfdb2ConsoleServerCommand.php +++ b/application/lfdb2/classes/command/console/class_Lfdb2ConsoleServerCommand.php @@ -65,7 +65,7 @@ class Lfdb2ConsoleServerCommand extends BaseCommand implements Commandable { * ----------------------- Bootstrapping phase ------------------------ * Try to bootstrap the server 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) + * features within LFDB2 (none is ready at this development stage) */ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); @@ -80,7 +80,7 @@ class Lfdb2ConsoleServerCommand extends BaseCommand implements Commandable { /* * -------------------------- Server activation -------------------------- * Activates the server by doing some final preparation steps and setting - * the attribute $hubIsActive to TRUE. + * the attribute $isActive to TRUE. */ $serverInstance->activateServer($requestInstance, $responseInstance); @@ -94,7 +94,7 @@ class Lfdb2ConsoleServerCommand extends BaseCommand implements Commandable { * ----------------------------- Main loop ---------------------------- * This is the main server 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. + * until LFDB2 is no longer active or all tasks are killed. */ while (($serverInstance->isServerActive()) && ($handlerInstance->hasTasksLeft())) { // Handle all tasks here diff --git a/application/lfdb2/classes/controller/console/class_Lfdb2ConsoleDefaultNewsController.php b/application/lfdb2/classes/controller/console/class_Lfdb2ConsoleDefaultNewsController.php index df36a3a..5ec1b9d 100644 --- a/application/lfdb2/classes/controller/console/class_Lfdb2ConsoleDefaultNewsController.php +++ b/application/lfdb2/classes/controller/console/class_Lfdb2ConsoleDefaultNewsController.php @@ -110,7 +110,7 @@ class Lfdb2ConsoleDefaultNewsController extends BaseController implements Contro } /** - * Add a hub activation filter + * Add a LFDB2 activation filter * * @param $filterInstance A Filterable class * @return void @@ -120,7 +120,7 @@ class Lfdb2ConsoleDefaultNewsController extends BaseController implements Contro } /** - * Executes all hub activation filters + * Executes all LFDB2 activation filters * * @param $requestInstance A Requestable class * @param $responseInstance A Responseable class diff --git a/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdownServerFilter.php b/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdownServerFilter.php index ddcb2a5..56b9a18 100644 --- a/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdownServerFilter.php +++ b/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdownServerFilter.php @@ -1,8 +1,8 @@ * @version 0.0.0 diff --git a/application/lfdb2/config.php b/application/lfdb2/config.php index fca0ae1..4cefa0a 100644 --- a/application/lfdb2/config.php +++ b/application/lfdb2/config.php @@ -21,7 +21,7 @@ * along with this program. If not, see . */ -// Some hub-specific configuration like port hostname where we will listen, etc. +// Some LFDB2-specific configuration like port hostname where we will listen, etc. $cfg = FrameworkConfiguration::getSelfInstance(); // CFG: INTERNAL-ADDRESS diff --git a/application/lfdb2/data.php b/application/lfdb2/data.php index 243ae89..7d6dcee 100644 --- a/application/lfdb2/data.php +++ b/application/lfdb2/data.php @@ -1,43 +1,2 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 . - */ - -// Get config instance -$cfg = FrameworkConfiguration::getSelfInstance(); - -// Get an instance of the helper -$app = call_user_func_array( - array($cfg->getConfigEntry('app_helper_class'), 'getSelfInstance'), - array() -); - -// Set application name and version -$app->setAppName('Local File Database NG'); -$app->setAppVersion('0.0.0'); -$app->setAppShortName('lfdb2'); - -// [EOF] -?> +// @DEPRECATED diff --git a/application/lfdb2/exceptions.php b/application/lfdb2/exceptions.php index 8e18482..24975ff 100644 --- a/application/lfdb2/exceptions.php +++ b/application/lfdb2/exceptions.php @@ -1,6 +1,6 @@ * @version 0.0 @@ -22,7 +22,7 @@ */ // The node's own exception handler -function hub_exception_handler ($exceptionInstance) { +function lfdb2_exception_handler ($exceptionInstance) { // Is it an object and a valid instance? if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof FrameworkException)) { // Init variable @@ -127,7 +127,7 @@ function __assertHandler ($file, $line, $code) { //set_error_handler('__errorHandler'); // Set the new handler -set_exception_handler('hub_exception_handler'); +set_exception_handler('lfdb2_exception_handler'); // Init assert handling assert_options(ASSERT_ACTIVE , TRUE); @@ -135,6 +135,3 @@ assert_options(ASSERT_WARNING , FALSE); assert_options(ASSERT_BAIL , TRUE); assert_options(ASSERT_QUIET_EVAL, FALSE); assert_options(ASSERT_CALLBACK , '__assertHandler'); - -// [EOF] -?> diff --git a/application/lfdb2/init.php b/application/lfdb2/init.php index 41f74e4..7d6dcee 100644 --- a/application/lfdb2/init.php +++ b/application/lfdb2/init.php @@ -1,38 +1,2 @@ - * @version 0.0 - * @copyright Copyright (c) 2013 LFDB2 Developer Team - * @license GNU GPL 3.0 or any newer version - * - * 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 . - */ - -// Get config instance -$cfg = FrameworkConfiguration::getSelfInstance(); - -// Initialize output system -ApplicationHelper::createDebugInstance('ApplicationHelper'); - -// This application needs a database connection then we have to simply include -// the inc/database.php script -require($cfg->getConfigEntry('base_path') . 'inc/database.php'); - -// [EOF] -?> +// @DEPRECATED diff --git a/application/lfdb2/loader.php b/application/lfdb2/loader.php index 09d285a..7d6dcee 100644 --- a/application/lfdb2/loader.php +++ b/application/lfdb2/loader.php @@ -1,28 +1,2 @@ - * @version 0.0 - * @copyright Copyright (c) 2013 LFDB2 Developer Team - * @license GNU GPL 3.0 or any newer version - * - * 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 . - */ - -// Scan for application's classes, exceptions and interfaces -ClassLoader::scanApplicationClasses(); - -// [EOF] -?> +// @DEPRECATED diff --git a/application/lfdb2/starter.php b/application/lfdb2/starter.php index 136a8a8..7d6dcee 100644 --- a/application/lfdb2/starter.php +++ b/application/lfdb2/starter.php @@ -1,57 +1,2 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 . - */ - -// Is there an application helper instance? We need the method main() for -// maining the application -$app = call_user_func_array( - array( - FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class'), 'getSelfInstance' - ), array() -); - -// Some sanity checks -if ((empty($app)) || (is_null($app))) { - // Something went wrong! - ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because the helper class %s is not loaded.", - $application, - FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class') - )); -} elseif (!is_object($app)) { - // No object! - ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because 'app' is not an object.", - $application - )); -} elseif (!method_exists($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method'))) { - // Method not found! - ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because the method %s is missing.", - $application, - FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method') - )); -} - -// Call user function -call_user_func_array(array($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method')), array()); - -// [EOF] -?> +// @DEPRECATED -- 2.39.5