From: Roland Haeder Date: Tue, 25 Aug 2015 16:49:15 +0000 (+0200) Subject: Updated 'core' + renamed 'main' -> 'classes'. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8abf3719ddd98cf8681ad502646318ce8532a8af;p=lfdb2.git Updated 'core' + renamed 'main' -> 'classes'. Signed-off-by: Roland Haeder --- diff --git a/application/lfdb2/classes/.htaccess b/application/lfdb2/classes/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/command/.htaccess b/application/lfdb2/classes/command/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/command/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/command/console/.htaccess b/application/lfdb2/classes/command/console/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/command/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/command/console/class_Lfdb2ConsoleServerCommand.php b/application/lfdb2/classes/command/console/class_Lfdb2ConsoleServerCommand.php new file mode 100644 index 0000000..235685e --- /dev/null +++ b/application/lfdb2/classes/command/console/class_Lfdb2ConsoleServerCommand.php @@ -0,0 +1,138 @@ + + * @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 . + */ +class Lfdb2ConsoleServerCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected 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 createLfdb2ConsoleServerCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new Lfdb2ConsoleServerCommand(); + + // 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 Lfdb2ActivationTask or so + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a registry and the application instance from it + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + /* + * ----------------------- 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) + */ + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); + $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); + + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Add some server-specific filters, e.g. announcement + $serverInstance->addExtraServerFilters(); + + /* + * -------------------------- Server activation -------------------------- + * Activates the server by doing some final preparation steps and setting + * the attribute $hubIsActive to TRUE. + */ + $serverInstance->activateServer($requestInstance, $responseInstance); + + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); + + /* + * ----------------------------- 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. + */ + while (($serverInstance->isServerActive()) && ($handlerInstance->hasTasksLeft())) { + // Handle all tasks here + $handlerInstance->handleTasks(); + } // END - while + + // Debug message + self::createDebugInstance(__CLASS__)->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('server_php_requirements_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('server_initializer_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('server_welcome_teaser_filter')); + + // Add bootstrap filters + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('server_bootstrap_extra_bootstrapping_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('server_bootstrap_listener_pool_filter')); + + // Add server activation filters + $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('server_activation_task_handler_initializer_filter')); + + // Add shutdown filters + $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('server_shutdown_task_handler_filter')); + + // This is the last generic shutdown filter + $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('server_shutdown_server_filter')); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/controller/.htaccess b/application/lfdb2/classes/controller/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/controller/console/.htaccess b/application/lfdb2/classes/controller/console/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/controller/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/controller/console/class_Lfdb2ConsoleDefaultNewsController.php b/application/lfdb2/classes/controller/console/class_Lfdb2ConsoleDefaultNewsController.php new file mode 100644 index 0000000..df36a3a --- /dev/null +++ b/application/lfdb2/classes/controller/console/class_Lfdb2ConsoleDefaultNewsController.php @@ -0,0 +1,156 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 . + */ +class Lfdb2ConsoleDefaultNewsController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init additional filter chains + foreach (array('bootstrap', 'activation','shutdown') as $filterChain) { + $this->initFilterChain($filterChain); + } // END - foreach + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createLfdb2ConsoleDefaultNewsController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new Lfdb2ConsoleDefaultNewsController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add news filters to this controller + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } + + /** + * Add a bootstrap filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addBootstrapFilter (Filterable $filterInstance) { + $this->addFilter('bootstrap', $filterInstance); + } + + /** + * Executes all bootstrap filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('bootstrap', $requestInstance, $responseInstance); + } + + /** + * Add a hub activation filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addActivationFilter (Filterable $filterInstance) { + $this->addFilter('activation', $filterInstance); + } + + /** + * Executes all hub activation filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('activation', $requestInstance, $responseInstance); + } + + /** + * Add a shutdown filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addShutdownFilter (Filterable $filterInstance) { + $this->addFilter('shutdown', $filterInstance); + } + + /** + * Executes all shutdown filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeShutdownFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('shutdown', $requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/.htaccess b/application/lfdb2/classes/filter/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/filter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/filter/bootstrap/.htaccess b/application/lfdb2/classes/filter/bootstrap/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/filter/bootstrap/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/filter/bootstrap/server/.htaccess b/application/lfdb2/classes/filter/bootstrap/server/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/filter/bootstrap/server/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/filter/bootstrap/server/class_ServerBootstrap b/application/lfdb2/classes/filter/bootstrap/server/class_ServerBootstrap new file mode 100644 index 0000000..114e922 --- /dev/null +++ b/application/lfdb2/classes/filter/bootstrap/server/class_ServerBootstrap @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Server 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 ServerBootstrap???Filter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createServerBootstrap???Filter () { + // Get a new instance + $filterInstance = new ServerBootstrap???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/bootstrap/server/class_ServerBootstrapExtraBootstrappingFilter.php b/application/lfdb2/classes/filter/bootstrap/server/class_ServerBootstrapExtraBootstrappingFilter.php new file mode 100644 index 0000000..6dd5059 --- /dev/null +++ b/application/lfdb2/classes/filter/bootstrap/server/class_ServerBootstrapExtraBootstrappingFilter.php @@ -0,0 +1,66 @@ + + * @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 . + */ +class ServerBootstrapExtraBootstrappingFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerBootstrapExtraBootstrappingFilter () { + // Get a new instance + $filterInstance = new ServerBootstrapExtraBootstrappingFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 + * @throws FilterChainException If $serverInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Do some extra bootstrapping steps + $serverInstance->doBootstrapping(); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/bootstrap/server/class_ServerBootstrapListenerPoolFilter.php b/application/lfdb2/classes/filter/bootstrap/server/class_ServerBootstrapListenerPoolFilter.php new file mode 100644 index 0000000..65d496a --- /dev/null +++ b/application/lfdb2/classes/filter/bootstrap/server/class_ServerBootstrapListenerPoolFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 . + */ +class ServerBootstrapListenerPoolFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerBootstrapListenerPoolFilter () { + // Get a new instance + $filterInstance = new ServerBootstrapListenerPoolFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 + * @throws FilterChainException If $serverInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Now do something + $serverInstance->initializeListenerPool(); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/class_BaseLfdb2Filter.php b/application/lfdb2/classes/filter/class_BaseLfdb2Filter.php new file mode 100644 index 0000000..57fc2cc --- /dev/null +++ b/application/lfdb2/classes/filter/class_BaseLfdb2Filter.php @@ -0,0 +1,114 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 . + */ +class BaseLfdb2Filter extends BaseFilter { + /** + * Array with all data XML nodes (which hold the actual data) and their values + */ + protected $dataXmlNodes = array(); + + /** + * Protected constructor + * + * @param $className Real name of class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Processes the given raw message content. The method renderXmlContent + * may throw (not the method itself) several exceptions: + * + * InvalidXmlNodeException - If an invalid XML node has been found (e.g. + * wrong/out-dated template used) + * XmlNodeMismatchException - Again might be caused by invalid XML node + * usage + * XmlParserException - If the XML message is damaged or not + * well-formed + * + * @param $messageType Type of message + * @param $messageContent Raw message content + * @param $packageInstance An instance of a Receivable class + * @return void + * @todo Exceptions from renderXmlContent() are currently unhandled + */ + protected function genericProcessMessage ($messageType, $messageContent, Receivable $packageInstance) { + $this->partialStub('Please fix this imported code.'); + die(); + + // Get a template instance from the factory + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_' . $messageType . '_template_class'); + + // And render the XML content (aka message) + $templateInstance->renderXmlContent($messageContent); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Handling ' . strlen($messageContent) . ' bytes: ' . $messageContent); + + /* + * The template system now stores all required data as 'general' + * variables, so simply get them. If there is an invalid XML node + * inside the message, the above method call will cause exceptions. + */ + foreach ($this->dataXmlNodes as $key => $dummy) { + // Call it + $value = $templateInstance->readXmlData($key); + + /* + * If value is NULL, a variable hasn't been found. This could mean + * that *this* node is running an out-dated software or the other + * peer is using an out-dated $messageType.xml template. + */ + if (is_null($value)) { + // Output a warning + self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Found not fully supported variable ' . $key . ' - skipping.'); + + // Skip this part, don't write NULLs to the array + continue; + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value); + + // Set it now + $this->dataXmlNodes[$key] = $value; + } // END - foreach + + // Construct an array for pushing it on next stack + $messageArray = array( + // Message data itself + NetworkPackage::MESSAGE_ARRAY_DATA => $this->dataXmlNodes, + // Message type (which is $messageType) + NetworkPackage::MESSAGE_ARRAY_TYPE => $messageType + ); + + // Push the processed message back on stack + $packageInstance->getStackerInstance()->pushNamed(NetworkPackage::STACKER_NAME_PROCESSED_MESSAGE, $messageArray); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/class_BaseServerFilter.php b/application/lfdb2/classes/filter/class_BaseServerFilter.php new file mode 100644 index 0000000..2a09e5e --- /dev/null +++ b/application/lfdb2/classes/filter/class_BaseServerFilter.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 . + */ +class BaseServerFilter extends BaseLfdb2Filter { + /** + * Protected constructor + * + * @param $className Real name of class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/server/.htaccess b/application/lfdb2/classes/filter/server/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/filter/server/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/filter/server/class_Server b/application/lfdb2/classes/filter/server/class_Server new file mode 100644 index 0000000..33cc50a --- /dev/null +++ b/application/lfdb2/classes/filter/server/class_Server @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 Server???Filter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createServer???Filter () { + // Get a new instance + $filterInstance = new Server???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Implement this! + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/server/class_ServerInitializationFilter.php b/application/lfdb2/classes/filter/server/class_ServerInitializationFilter.php new file mode 100644 index 0000000..0e95f96 --- /dev/null +++ b/application/lfdb2/classes/filter/server/class_ServerInitializationFilter.php @@ -0,0 +1,101 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 . + */ +class ServerInitializationFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerInitializationFilter () { + // Get a new instance + $filterInstance = new ServerInitializationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->partialStub('Unported.'); + die(); + + // The default node-mode is from our configuration + $nodeMode = $this->getConfigInstance()->getConfigEntry('node_default_mode'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[INIT:] Got default node mode ' . $nodeMode . ' from configuration.'); + + // Is the node 'mode' parameter set? + if ($requestInstance->isRequestElementSet('mode')) { + // Then use this which overrides the config entry temporarily + $nodeMode = $requestInstance->getRequestElement('mode'); + } else { + // Set it for easier re-usage + $requestInstance->setRequestElement('mode', $nodeMode); + } + + // Now convert the node-mode in a class name + $className = 'Lfdb2' . self::convertToClassName($nodeMode) . 'Server'; + + // And try to instance it + try { + // Get an instance + $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); + + // Get a registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Set the app instance + $nodeInstance->setApplicationInstance($applicationInstance); + + // Add node-specific filters + $nodeInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); + } catch (ClassNotFoundException $e) { + // This exception means, the node mode is invalid. + // @TODO Can we rewrite this to app_exit() ? + $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: node mode ' . $nodeMode . ' is invalid.'); + } + + // Set the node instance in registry + Registry::getRegistry()->addInstance('node', $nodeInstance); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[INIT:] Server ' . $nodeMode . ' has been added to registry.'); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/server/class_ServerPhpRequirementsFilter.php b/application/lfdb2/classes/filter/server/class_ServerPhpRequirementsFilter.php new file mode 100644 index 0000000..9c7c0be --- /dev/null +++ b/application/lfdb2/classes/filter/server/class_ServerPhpRequirementsFilter.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 . + */ +class ServerPhpRequirementsFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerPhpRequirementsFilter () { + // Get a new instance + $filterInstance = new ServerPhpRequirementsFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 + * @throws FilterChainException If a required PHP function is not available + * @todo Add more test and try to add an extra message to the thrown exception + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // By default, the requirement check is passed and zero checks are failed + $checkPassed = TRUE; + $checksFailed = 0; + + // Socket support is essential... + if (!function_exists('socket_create')) { + // Test failed + $checkPassed = FALSE; + $checksFailed++; + } // END -if + + // Are all tests passed? + if ($checkPassed === FALSE) { + // Throw an exception + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/server/class_ServerWelcomeTeaserFilter.php b/application/lfdb2/classes/filter/server/class_ServerWelcomeTeaserFilter.php new file mode 100644 index 0000000..bed3a44 --- /dev/null +++ b/application/lfdb2/classes/filter/server/class_ServerWelcomeTeaserFilter.php @@ -0,0 +1,67 @@ + + * @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 . + */ +class ServerWelcomeTeaserFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerWelcomeTeaserFilter () { + // Get a new instance + $filterInstance = new ServerWelcomeTeaserFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo Handle over the $responseInstance to outputConsoleTeaser() + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Now output the teaser + $serverInstance->outputConsoleTeaser(); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/shutdown/.htaccess b/application/lfdb2/classes/filter/shutdown/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/filter/shutdown/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/filter/shutdown/server/.htaccess b/application/lfdb2/classes/filter/shutdown/server/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/filter/shutdown/server/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdown b/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdown new file mode 100644 index 0000000..4822e38 --- /dev/null +++ b/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdown @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 ServerShutdown???Filter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createServerShutdown???Filter () { + // Get a new instance + $filterInstance = new ServerShutdown???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 + * @throws FilterChainException If $serverInstance is null (no NullPointerException here) + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdownServerFilter.php b/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdownServerFilter.php new file mode 100644 index 0000000..ddcb2a5 --- /dev/null +++ b/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdownServerFilter.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 . + */ +class ServerShutdownServerFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerShutdownServerFilter () { + // Get a new instance + $filterInstance = new ServerShutdownServerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 + * @throws FilterChainException If $serverInstance is null (no NullPointerException please) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Shutdown the server. This should be the last line + $serverInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdownTaskHandlerFilter.php b/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdownTaskHandlerFilter.php new file mode 100644 index 0000000..20cb1f0 --- /dev/null +++ b/application/lfdb2/classes/filter/shutdown/server/class_ServerShutdownTaskHandlerFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 . + */ +class ServerShutdownTaskHandlerFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerShutdownTaskHandlerFilter () { + // Get a new instance + $filterInstance = new ServerShutdownTaskHandlerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Shutdown the task manager and all its registered tasks + $handlerInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/filter/task/.htaccess b/application/lfdb2/classes/filter/task/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/filter/task/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/filter/task/server/.htaccess b/application/lfdb2/classes/filter/task/server/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/filter/task/server/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/filter/task/server/class_ServerTaskHandlerInitializerFilter.php b/application/lfdb2/classes/filter/task/server/class_ServerTaskHandlerInitializerFilter.php new file mode 100644 index 0000000..cf3f171 --- /dev/null +++ b/application/lfdb2/classes/filter/task/server/class_ServerTaskHandlerInitializerFilter.php @@ -0,0 +1,142 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 . + */ +class ServerTaskHandlerInitializerFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerTaskHandlerInitializerFilter () { + // Get a new instance + $filterInstance = new ServerTaskHandlerInitializerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter 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 + * @throws FilterChainException If we need to interrupt the filter chain + * @todo Maybe some more tasks needs to be added? + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->partialStub('Unported.'); + die(); + + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Get a new task handler instance + $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); + + // Generate socket listener task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_socket_listener_task_class'); + + // Network package reader, needs to be delayed a little + $handlerInstance->registerTask('socket_listener', $taskInstance); + + // Generate package reader task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_reader_task_class', array($nodeInstance->getListenerPoolInstance())); + + // Network package reader, needs to be delayed a little + $handlerInstance->registerTask('network_package_reader', $taskInstance); + + // Generate package writer task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_writer_task_class'); + + // Register it as well + $handlerInstance->registerTask('network_package_writer', $taskInstance); + + // Generate chunk assembler task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_chunk_assembler_task_class'); + + // Register it as well + $handlerInstance->registerTask('chunk_assembler', $taskInstance); + + // Generate package decoder task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_decoder_task_class'); + + // Register it as well + $handlerInstance->registerTask('package_decoder', $taskInstance); + + // Generate DHT initialization task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_init_task_class'); + + // Register it as well + $handlerInstance->registerTask('dht_init', $taskInstance); + + // Generate DHT query task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_query_task_class'); + + // Register it as well + $handlerInstance->registerTask('dht_query', $taskInstance); + + // Prepare a package-tags initialization task for the listeners + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_tags_init_task_class'); + + // Register it + $handlerInstance->registerTask('package_tags_init', $taskInstance); + + // Prepare a self-test task for the listeners + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_selfconnect_task_class'); + + // Register it + $handlerInstance->registerTask('self_connect', $taskInstance); + + // Prepare a update-check task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_update_check_task_class'); + + // Register it + $handlerInstance->registerTask('update_check', $taskInstance); + + // Get the list instance here + $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); + + // Prepare a ping task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_ping_task_class', array($listInstance)); + + // Register it + $handlerInstance->registerTask('ping', $taskInstance); + + // Put the task handler in registry + Registry::getRegistry()->addInstance('task_handler', $handlerInstance); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/resolver/.htaccess b/application/lfdb2/classes/resolver/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/resolver/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/resolver/command/.htaccess b/application/lfdb2/classes/resolver/command/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/resolver/command/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/resolver/command/console/.htaccess b/application/lfdb2/classes/resolver/command/console/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/resolver/command/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/resolver/command/console/class_Lfdb2ConsoleCommandResolver.php b/application/lfdb2/classes/resolver/command/console/class_Lfdb2ConsoleCommandResolver.php new file mode 100644 index 0000000..decf986 --- /dev/null +++ b/application/lfdb2/classes/resolver/command/console/class_Lfdb2ConsoleCommandResolver.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 . + */ +class Lfdb2ConsoleCommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Lfdb2Console" + $this->setClassPrefix('lfdb2_console'); + } + + /** + * Creates an instance of a Lfdb2Console command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidCommandException Thrown if default command is invalid + */ + public static final function createLfdb2ConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new Lfdb2ConsoleCommandResolver(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/application/lfdb2/classes/resolver/controller/.htaccess b/application/lfdb2/classes/resolver/controller/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/resolver/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/resolver/controller/console/.htaccess b/application/lfdb2/classes/resolver/controller/console/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/classes/resolver/controller/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/classes/resolver/controller/console/class_Lfdb2ConsoleControllerResolver.php b/application/lfdb2/classes/resolver/controller/console/class_Lfdb2ConsoleControllerResolver.php new file mode 100644 index 0000000..c925880 --- /dev/null +++ b/application/lfdb2/classes/resolver/controller/console/class_Lfdb2ConsoleControllerResolver.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 . + */ +class Lfdb2ConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "lfdb2_console" + $this->setClassPrefix('lfdb2_console'); + } + + /** + * Creates an instance of a resolver class with a given command + * + * @param $controllerName The controller we shall resolve + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared controller resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidControllerException Thrown if default controller is invalid + */ + public static final function createLfdb2ConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new Lfdb2ConsoleControllerResolver(); + + // Is the variable $controllerName set and the command is valid? + if (empty($controllerName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { + // Invalid command found + throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Set command name + $resolverInstance->setControllerName($controllerName); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Resolves the default controller of the given command + * + * @return $controllerInstance A controller instance for the default + * command + * @throws InvalidControllerInstanceException Thrown if $controllerInstance + * is invalid + */ + public function resolveController () { + // Init variables + $controllerName = ''; + $controllerInstance = NULL; + + // Get the command name + $controllerName = $this->getControllerName(); + + // Get the command + $controllerInstance = $this->loadController($controllerName); + + // And validate it + if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { + // This command has an invalid instance! + throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } // END - if + + // Set last controller + $this->setResolvedInstance($controllerInstance); + + // Return the maybe resolved instance + return $controllerInstance; + } +} + +// [EOF] +?> diff --git a/application/lfdb2/main/.htaccess b/application/lfdb2/main/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/command/.htaccess b/application/lfdb2/main/command/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/command/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/command/console/.htaccess b/application/lfdb2/main/command/console/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/command/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/command/console/class_Lfdb2ConsoleServerCommand.php b/application/lfdb2/main/command/console/class_Lfdb2ConsoleServerCommand.php deleted file mode 100644 index 235685e..0000000 --- a/application/lfdb2/main/command/console/class_Lfdb2ConsoleServerCommand.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @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 . - */ -class Lfdb2ConsoleServerCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected 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 createLfdb2ConsoleServerCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new Lfdb2ConsoleServerCommand(); - - // 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 Lfdb2ActivationTask or so - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a registry and the application instance from it - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - /* - * ----------------------- 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) - */ - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); - $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); - - // Get server instance - $serverInstance = Registry::getRegistry()->getInstance('server'); - - // Add some server-specific filters, e.g. announcement - $serverInstance->addExtraServerFilters(); - - /* - * -------------------------- Server activation -------------------------- - * Activates the server by doing some final preparation steps and setting - * the attribute $hubIsActive to TRUE. - */ - $serverInstance->activateServer($requestInstance, $responseInstance); - - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); - - /* - * ----------------------------- 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. - */ - while (($serverInstance->isServerActive()) && ($handlerInstance->hasTasksLeft())) { - // Handle all tasks here - $handlerInstance->handleTasks(); - } // END - while - - // Debug message - self::createDebugInstance(__CLASS__)->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('server_php_requirements_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('server_initializer_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('server_welcome_teaser_filter')); - - // Add bootstrap filters - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('server_bootstrap_extra_bootstrapping_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('server_bootstrap_listener_pool_filter')); - - // Add server activation filters - $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('server_activation_task_handler_initializer_filter')); - - // Add shutdown filters - $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('server_shutdown_task_handler_filter')); - - // This is the last generic shutdown filter - $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('server_shutdown_server_filter')); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/controller/.htaccess b/application/lfdb2/main/controller/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/controller/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/controller/console/.htaccess b/application/lfdb2/main/controller/console/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/controller/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/controller/console/class_Lfdb2ConsoleDefaultNewsController.php b/application/lfdb2/main/controller/console/class_Lfdb2ConsoleDefaultNewsController.php deleted file mode 100644 index df36a3a..0000000 --- a/application/lfdb2/main/controller/console/class_Lfdb2ConsoleDefaultNewsController.php +++ /dev/null @@ -1,156 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 . - */ -class Lfdb2ConsoleDefaultNewsController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init additional filter chains - foreach (array('bootstrap', 'activation','shutdown') as $filterChain) { - $this->initFilterChain($filterChain); - } // END - foreach - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createLfdb2ConsoleDefaultNewsController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new Lfdb2ConsoleDefaultNewsController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Add news filters to this controller - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance from the resolver by sending a request instance to the resolver - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Run the pre filters - $this->executePostFilters($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } - - /** - * Add a bootstrap filter - * - * @param $filterInstance A Filterable class - * @return void - */ - public function addBootstrapFilter (Filterable $filterInstance) { - $this->addFilter('bootstrap', $filterInstance); - } - - /** - * Executes all bootstrap filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->executeFilters('bootstrap', $requestInstance, $responseInstance); - } - - /** - * Add a hub activation filter - * - * @param $filterInstance A Filterable class - * @return void - */ - public function addActivationFilter (Filterable $filterInstance) { - $this->addFilter('activation', $filterInstance); - } - - /** - * Executes all hub activation filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->executeFilters('activation', $requestInstance, $responseInstance); - } - - /** - * Add a shutdown filter - * - * @param $filterInstance A Filterable class - * @return void - */ - public function addShutdownFilter (Filterable $filterInstance) { - $this->addFilter('shutdown', $filterInstance); - } - - /** - * Executes all shutdown filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeShutdownFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->executeFilters('shutdown', $requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/.htaccess b/application/lfdb2/main/filter/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/filter/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/filter/bootstrap/.htaccess b/application/lfdb2/main/filter/bootstrap/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/filter/bootstrap/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/filter/bootstrap/server/.htaccess b/application/lfdb2/main/filter/bootstrap/server/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/filter/bootstrap/server/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrap b/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrap deleted file mode 100644 index 114e922..0000000 --- a/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrap +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Server 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 ServerBootstrap???Filter extends BaseServerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createServerBootstrap???Filter () { - // Get a new instance - $filterInstance = new ServerBootstrap???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter 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 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get server instance - $serverInstance = Registry::getRegistry()->getInstance('server'); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapExtraBootstrappingFilter.php b/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapExtraBootstrappingFilter.php deleted file mode 100644 index 6dd5059..0000000 --- a/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapExtraBootstrappingFilter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @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 . - */ -class ServerBootstrapExtraBootstrappingFilter extends BaseServerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createServerBootstrapExtraBootstrappingFilter () { - // Get a new instance - $filterInstance = new ServerBootstrapExtraBootstrappingFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter 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 - * @throws FilterChainException If $serverInstance is null (no NullPointerException here) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get server instance - $serverInstance = Registry::getRegistry()->getInstance('server'); - - // Do some extra bootstrapping steps - $serverInstance->doBootstrapping(); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapListenerPoolFilter.php b/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapListenerPoolFilter.php deleted file mode 100644 index 65d496a..0000000 --- a/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapListenerPoolFilter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 . - */ -class ServerBootstrapListenerPoolFilter extends BaseServerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createServerBootstrapListenerPoolFilter () { - // Get a new instance - $filterInstance = new ServerBootstrapListenerPoolFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter 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 - * @throws FilterChainException If $serverInstance is null (no NullPointerException here) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get server instance - $serverInstance = Registry::getRegistry()->getInstance('server'); - - // Now do something - $serverInstance->initializeListenerPool(); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/class_BaseLfdb2Filter.php b/application/lfdb2/main/filter/class_BaseLfdb2Filter.php deleted file mode 100644 index 57fc2cc..0000000 --- a/application/lfdb2/main/filter/class_BaseLfdb2Filter.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 . - */ -class BaseLfdb2Filter extends BaseFilter { - /** - * Array with all data XML nodes (which hold the actual data) and their values - */ - protected $dataXmlNodes = array(); - - /** - * Protected constructor - * - * @param $className Real name of class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Processes the given raw message content. The method renderXmlContent - * may throw (not the method itself) several exceptions: - * - * InvalidXmlNodeException - If an invalid XML node has been found (e.g. - * wrong/out-dated template used) - * XmlNodeMismatchException - Again might be caused by invalid XML node - * usage - * XmlParserException - If the XML message is damaged or not - * well-formed - * - * @param $messageType Type of message - * @param $messageContent Raw message content - * @param $packageInstance An instance of a Receivable class - * @return void - * @todo Exceptions from renderXmlContent() are currently unhandled - */ - protected function genericProcessMessage ($messageType, $messageContent, Receivable $packageInstance) { - $this->partialStub('Please fix this imported code.'); - die(); - - // Get a template instance from the factory - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_' . $messageType . '_template_class'); - - // And render the XML content (aka message) - $templateInstance->renderXmlContent($messageContent); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Handling ' . strlen($messageContent) . ' bytes: ' . $messageContent); - - /* - * The template system now stores all required data as 'general' - * variables, so simply get them. If there is an invalid XML node - * inside the message, the above method call will cause exceptions. - */ - foreach ($this->dataXmlNodes as $key => $dummy) { - // Call it - $value = $templateInstance->readXmlData($key); - - /* - * If value is NULL, a variable hasn't been found. This could mean - * that *this* node is running an out-dated software or the other - * peer is using an out-dated $messageType.xml template. - */ - if (is_null($value)) { - // Output a warning - self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Found not fully supported variable ' . $key . ' - skipping.'); - - // Skip this part, don't write NULLs to the array - continue; - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value); - - // Set it now - $this->dataXmlNodes[$key] = $value; - } // END - foreach - - // Construct an array for pushing it on next stack - $messageArray = array( - // Message data itself - NetworkPackage::MESSAGE_ARRAY_DATA => $this->dataXmlNodes, - // Message type (which is $messageType) - NetworkPackage::MESSAGE_ARRAY_TYPE => $messageType - ); - - // Push the processed message back on stack - $packageInstance->getStackerInstance()->pushNamed(NetworkPackage::STACKER_NAME_PROCESSED_MESSAGE, $messageArray); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/class_BaseServerFilter.php b/application/lfdb2/main/filter/class_BaseServerFilter.php deleted file mode 100644 index 2a09e5e..0000000 --- a/application/lfdb2/main/filter/class_BaseServerFilter.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 . - */ -class BaseServerFilter extends BaseLfdb2Filter { - /** - * Protected constructor - * - * @param $className Real name of class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/server/.htaccess b/application/lfdb2/main/filter/server/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/filter/server/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/filter/server/class_Server b/application/lfdb2/main/filter/server/class_Server deleted file mode 100644 index 33cc50a..0000000 --- a/application/lfdb2/main/filter/server/class_Server +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 Server???Filter extends BaseServerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createServer???Filter () { - // Get a new instance - $filterInstance = new Server???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter 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 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Implement this! - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/server/class_ServerInitializationFilter.php b/application/lfdb2/main/filter/server/class_ServerInitializationFilter.php deleted file mode 100644 index 0e95f96..0000000 --- a/application/lfdb2/main/filter/server/class_ServerInitializationFilter.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 . - */ -class ServerInitializationFilter extends BaseServerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createServerInitializationFilter () { - // Get a new instance - $filterInstance = new ServerInitializationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter 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 - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub('Unported.'); - die(); - - // The default node-mode is from our configuration - $nodeMode = $this->getConfigInstance()->getConfigEntry('node_default_mode'); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[INIT:] Got default node mode ' . $nodeMode . ' from configuration.'); - - // Is the node 'mode' parameter set? - if ($requestInstance->isRequestElementSet('mode')) { - // Then use this which overrides the config entry temporarily - $nodeMode = $requestInstance->getRequestElement('mode'); - } else { - // Set it for easier re-usage - $requestInstance->setRequestElement('mode', $nodeMode); - } - - // Now convert the node-mode in a class name - $className = 'Lfdb2' . self::convertToClassName($nodeMode) . 'Server'; - - // And try to instance it - try { - // Get an instance - $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); - - // Get a registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Set the app instance - $nodeInstance->setApplicationInstance($applicationInstance); - - // Add node-specific filters - $nodeInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); - } catch (ClassNotFoundException $e) { - // This exception means, the node mode is invalid. - // @TODO Can we rewrite this to app_exit() ? - $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: node mode ' . $nodeMode . ' is invalid.'); - } - - // Set the node instance in registry - Registry::getRegistry()->addInstance('node', $nodeInstance); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[INIT:] Server ' . $nodeMode . ' has been added to registry.'); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/server/class_ServerPhpRequirementsFilter.php b/application/lfdb2/main/filter/server/class_ServerPhpRequirementsFilter.php deleted file mode 100644 index 9c7c0be..0000000 --- a/application/lfdb2/main/filter/server/class_ServerPhpRequirementsFilter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 . - */ -class ServerPhpRequirementsFilter extends BaseServerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createServerPhpRequirementsFilter () { - // Get a new instance - $filterInstance = new ServerPhpRequirementsFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter 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 - * @throws FilterChainException If a required PHP function is not available - * @todo Add more test and try to add an extra message to the thrown exception - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // By default, the requirement check is passed and zero checks are failed - $checkPassed = TRUE; - $checksFailed = 0; - - // Socket support is essential... - if (!function_exists('socket_create')) { - // Test failed - $checkPassed = FALSE; - $checksFailed++; - } // END -if - - // Are all tests passed? - if ($checkPassed === FALSE) { - // Throw an exception - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/server/class_ServerWelcomeTeaserFilter.php b/application/lfdb2/main/filter/server/class_ServerWelcomeTeaserFilter.php deleted file mode 100644 index bed3a44..0000000 --- a/application/lfdb2/main/filter/server/class_ServerWelcomeTeaserFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @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 . - */ -class ServerWelcomeTeaserFilter extends BaseServerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createServerWelcomeTeaserFilter () { - // Get a new instance - $filterInstance = new ServerWelcomeTeaserFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter 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 - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - * @todo Handle over the $responseInstance to outputConsoleTeaser() - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get server instance - $serverInstance = Registry::getRegistry()->getInstance('server'); - - // Now output the teaser - $serverInstance->outputConsoleTeaser(); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/shutdown/.htaccess b/application/lfdb2/main/filter/shutdown/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/filter/shutdown/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/filter/shutdown/server/.htaccess b/application/lfdb2/main/filter/shutdown/server/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/filter/shutdown/server/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/filter/shutdown/server/class_ServerShutdown b/application/lfdb2/main/filter/shutdown/server/class_ServerShutdown deleted file mode 100644 index 4822e38..0000000 --- a/application/lfdb2/main/filter/shutdown/server/class_ServerShutdown +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 ServerShutdown???Filter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createServerShutdown???Filter () { - // Get a new instance - $filterInstance = new ServerShutdown???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter 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 - * @throws FilterChainException If $serverInstance is null (no NullPointerException here) - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get server instance - $serverInstance = Registry::getRegistry()->getInstance('server'); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownServerFilter.php b/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownServerFilter.php deleted file mode 100644 index ddcb2a5..0000000 --- a/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownServerFilter.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 . - */ -class ServerShutdownServerFilter extends BaseServerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createServerShutdownServerFilter () { - // Get a new instance - $filterInstance = new ServerShutdownServerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter 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 - * @throws FilterChainException If $serverInstance is null (no NullPointerException please) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get server instance - $serverInstance = Registry::getRegistry()->getInstance('server'); - - // Shutdown the server. This should be the last line - $serverInstance->doShutdown(); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownTaskHandlerFilter.php b/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownTaskHandlerFilter.php deleted file mode 100644 index 20cb1f0..0000000 --- a/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownTaskHandlerFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 . - */ -class ServerShutdownTaskHandlerFilter extends BaseServerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createServerShutdownTaskHandlerFilter () { - // Get a new instance - $filterInstance = new ServerShutdownTaskHandlerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter 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 - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Shutdown the task manager and all its registered tasks - $handlerInstance->doShutdown(); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/filter/task/.htaccess b/application/lfdb2/main/filter/task/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/filter/task/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/filter/task/server/.htaccess b/application/lfdb2/main/filter/task/server/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/filter/task/server/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/filter/task/server/class_ServerTaskHandlerInitializerFilter.php b/application/lfdb2/main/filter/task/server/class_ServerTaskHandlerInitializerFilter.php deleted file mode 100644 index cf3f171..0000000 --- a/application/lfdb2/main/filter/task/server/class_ServerTaskHandlerInitializerFilter.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 . - */ -class ServerTaskHandlerInitializerFilter extends BaseServerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createServerTaskHandlerInitializerFilter () { - // Get a new instance - $filterInstance = new ServerTaskHandlerInitializerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter 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 - * @throws FilterChainException If we need to interrupt the filter chain - * @todo Maybe some more tasks needs to be added? - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub('Unported.'); - die(); - - // Get server instance - $serverInstance = Registry::getRegistry()->getInstance('server'); - - // Get a new task handler instance - $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); - - // Generate socket listener task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_socket_listener_task_class'); - - // Network package reader, needs to be delayed a little - $handlerInstance->registerTask('socket_listener', $taskInstance); - - // Generate package reader task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_reader_task_class', array($nodeInstance->getListenerPoolInstance())); - - // Network package reader, needs to be delayed a little - $handlerInstance->registerTask('network_package_reader', $taskInstance); - - // Generate package writer task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_writer_task_class'); - - // Register it as well - $handlerInstance->registerTask('network_package_writer', $taskInstance); - - // Generate chunk assembler task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_chunk_assembler_task_class'); - - // Register it as well - $handlerInstance->registerTask('chunk_assembler', $taskInstance); - - // Generate package decoder task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_decoder_task_class'); - - // Register it as well - $handlerInstance->registerTask('package_decoder', $taskInstance); - - // Generate DHT initialization task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_init_task_class'); - - // Register it as well - $handlerInstance->registerTask('dht_init', $taskInstance); - - // Generate DHT query task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_query_task_class'); - - // Register it as well - $handlerInstance->registerTask('dht_query', $taskInstance); - - // Prepare a package-tags initialization task for the listeners - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_tags_init_task_class'); - - // Register it - $handlerInstance->registerTask('package_tags_init', $taskInstance); - - // Prepare a self-test task for the listeners - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_selfconnect_task_class'); - - // Register it - $handlerInstance->registerTask('self_connect', $taskInstance); - - // Prepare a update-check task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_update_check_task_class'); - - // Register it - $handlerInstance->registerTask('update_check', $taskInstance); - - // Get the list instance here - $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); - - // Prepare a ping task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_ping_task_class', array($listInstance)); - - // Register it - $handlerInstance->registerTask('ping', $taskInstance); - - // Put the task handler in registry - Registry::getRegistry()->addInstance('task_handler', $handlerInstance); - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/resolver/.htaccess b/application/lfdb2/main/resolver/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/resolver/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/resolver/command/.htaccess b/application/lfdb2/main/resolver/command/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/resolver/command/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/resolver/command/console/.htaccess b/application/lfdb2/main/resolver/command/console/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/resolver/command/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/resolver/command/console/class_Lfdb2ConsoleCommandResolver.php b/application/lfdb2/main/resolver/command/console/class_Lfdb2ConsoleCommandResolver.php deleted file mode 100644 index decf986..0000000 --- a/application/lfdb2/main/resolver/command/console/class_Lfdb2ConsoleCommandResolver.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 . - */ -class Lfdb2ConsoleCommandResolver extends BaseCommandResolver implements CommandResolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to "Lfdb2Console" - $this->setClassPrefix('lfdb2_console'); - } - - /** - * Creates an instance of a Lfdb2Console command resolver with a given default command - * - * @param $commandName The default command we shall execute - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared command resolver instance - * @throws EmptyVariableException Thrown if default command is not set - * @throws InvalidCommandException Thrown if default command is invalid - */ - public static final function createLfdb2ConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new Lfdb2ConsoleCommandResolver(); - - // Is the variable $commandName set and the command is valid? - if (empty($commandName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { - // Invalid command found - throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Return the prepared instance - return $resolverInstance; - } -} - -// [EOF] -?> diff --git a/application/lfdb2/main/resolver/controller/.htaccess b/application/lfdb2/main/resolver/controller/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/resolver/controller/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/resolver/controller/console/.htaccess b/application/lfdb2/main/resolver/controller/console/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/lfdb2/main/resolver/controller/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/lfdb2/main/resolver/controller/console/class_Lfdb2ConsoleControllerResolver.php b/application/lfdb2/main/resolver/controller/console/class_Lfdb2ConsoleControllerResolver.php deleted file mode 100644 index c925880..0000000 --- a/application/lfdb2/main/resolver/controller/console/class_Lfdb2ConsoleControllerResolver.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2013 LFDB2 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 . - */ -class Lfdb2ConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to "lfdb2_console" - $this->setClassPrefix('lfdb2_console'); - } - - /** - * Creates an instance of a resolver class with a given command - * - * @param $controllerName The controller we shall resolve - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if default command is not set - * @throws InvalidControllerException Thrown if default controller is invalid - */ - public static final function createLfdb2ConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new Lfdb2ConsoleControllerResolver(); - - // Is the variable $controllerName set and the command is valid? - if (empty($controllerName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { - // Invalid command found - throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Set command name - $resolverInstance->setControllerName($controllerName); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Resolves the default controller of the given command - * - * @return $controllerInstance A controller instance for the default - * command - * @throws InvalidControllerInstanceException Thrown if $controllerInstance - * is invalid - */ - public function resolveController () { - // Init variables - $controllerName = ''; - $controllerInstance = NULL; - - // Get the command name - $controllerName = $this->getControllerName(); - - // Get the command - $controllerInstance = $this->loadController($controllerName); - - // And validate it - if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { - // This command has an invalid instance! - throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if - - // Set last controller - $this->setResolvedInstance($controllerInstance); - - // Return the maybe resolved instance - return $controllerInstance; - } -} - -// [EOF] -?> diff --git a/core b/core index 23aa45d..7bc4014 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 23aa45d4a6205e26184190ca446316d06a9b4648 +Subproject commit 7bc4014657a70dedfc38b9b28d134aa7c3a6158c