From: Roland Häder Date: Tue, 7 Jul 2009 18:02:19 +0000 (+0000) Subject: Prepared for listener classes (TCP/UDP and listener pool) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c9d2506483b57950d5ff148b112e82a2e5713337;p=hub.git Prepared for listener classes (TCP/UDP and listener pool) --- diff --git a/.gitattributes b/.gitattributes index 86daee16c..ef9042806 100644 --- a/.gitattributes +++ b/.gitattributes @@ -20,6 +20,7 @@ application/hub/interfaces/queues/.htaccess -text application/hub/interfaces/queues/class_Queueable.php -text application/hub/loader.php -text application/hub/main/.htaccess -text +application/hub/main/class_BaseHubSystem.php -text application/hub/main/connectors/.htaccess -text application/hub/main/connectors/class_BaseConnector.php -text application/hub/main/connectors/query/.htaccess -text @@ -35,6 +36,12 @@ application/hub/main/connectors/queues/local/class_LocalQueueConnector.php -text application/hub/main/database/.htaccess -text application/hub/main/database/wrapper/.htaccess -text application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php -text +application/hub/main/listener/.htaccess -text +application/hub/main/listener/class_ -text +application/hub/main/listener/class_BaseListener.php -text +application/hub/main/listener/pool/.htaccess -text +application/hub/main/listener/tcp/.htaccess -text +application/hub/main/listener/udp/.htaccess -text application/hub/main/nodes/.htaccess -text application/hub/main/nodes/boot/.htaccess -text application/hub/main/nodes/boot/class_HubBootNode.php -text diff --git a/application/hub/config.php b/application/hub/config.php index ce9a20001..b1bac59bc 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -57,6 +57,9 @@ $cfg->setConfigEntry('query_connector_class', "LocalQueryConnector"); // CFG: QUEUE-CONNECTOR-CLASS $cfg->setConfigEntry('queue_connector_class', "LocalQueueConnector"); +// CFG: LISTENER-POOL-CLAS +$cfg->setConfigEntry('listener_pool_class', "ListenerPool"); + // CFG: TCP-LISTENER-CLASS $cfg->setConfigEntry('tcp_listener_class', "TcpListener"); diff --git a/application/hub/main/class_BaseHubSystem.php b/application/hub/main/class_BaseHubSystem.php new file mode 100644 index 000000000..53ed8c052 --- /dev/null +++ b/application/hub/main/class_BaseHubSystem.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core 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 BaseHubSystem extends BaseFrameworkSystem { + /** + * An instance of a node + */ + private $nodeInstance = null; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Setter for node instance + * + * @param $nodeInstance An instance of a node node + * @return void + */ + protected final function setNodeInstance (NodeHelper $nodeInstance) { + $this->nodeInstance = $nodeInstance; + } + + /** + * Getter for node instance + * + * @return $nodeInstance An instance of a node node + */ + public final function getNodeInstance () { + return $this->nodeInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/connectors/class_BaseConnector.php b/application/hub/main/connectors/class_BaseConnector.php index 1945a6529..70356f57b 100644 --- a/application/hub/main/connectors/class_BaseConnector.php +++ b/application/hub/main/connectors/class_BaseConnector.php @@ -21,12 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseConnector extends BaseFrameworkSystem { - /** - * An instance of a node - */ - private $nodeInstance = null; - +class BaseConnector extends BaseHubSystem { /** * Protected constructor * @@ -36,29 +31,6 @@ class BaseConnector extends BaseFrameworkSystem { protected function __construct ($className) { // Call parent constructor parent::__construct($className); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); - } - - /** - * Setter for node instance - * - * @param $nodeInstance An instance of a node node - * @return void - */ - protected final function setNodeInstance (NodeHelper $nodeInstance) { - $this->nodeInstance = $nodeInstance; - } - - /** - * Getter for node instance - * - * @return $nodeInstance An instance of a node node - */ - public final function getNodeInstance () { - return $this->nodeInstance; } } diff --git a/application/hub/main/listener/.htaccess b/application/hub/main/listener/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/listener/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/listener/class_ b/application/hub/main/listener/class_ new file mode 100644 index 000000000..6eb013c3c --- /dev/null +++ b/application/hub/main/listener/class_ @@ -0,0 +1,54 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core 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 ???Listener extends BaseListener implements Listenerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $nodeInstance A NodeHelper instance + * @return $listenerInstance An instance a prepared listener class + */ + public final static function create???Listener (NodeHelper $nodeInstance) { + // Get new instance + $listenerInstance = new ???Listener(); + + // Set the application instance + $listenerInstance->setNodeInstance($nodeInstance); + + // Return the prepared instance + return $listenerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/listener/class_BaseListener.php b/application/hub/main/listener/class_BaseListener.php new file mode 100644 index 000000000..ababd57ed --- /dev/null +++ b/application/hub/main/listener/class_BaseListener.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core 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 BaseListener extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/main/listener/pool/.htaccess b/application/hub/main/listener/pool/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/listener/pool/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/listener/tcp/.htaccess b/application/hub/main/listener/tcp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/listener/tcp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/listener/udp/.htaccess b/application/hub/main/listener/udp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/listener/udp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index 590aaa8fe..a52541a2e 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseHubNode extends BaseFrameworkSystem implements Updateable { +class BaseHubNode extends BaseHubSystem implements Updateable { /** * Node id */ @@ -56,10 +56,6 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { protected function __construct ($className) { // Call parent constructor parent::__construct($className); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); } /** @@ -305,6 +301,8 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { /** * Activates the hub by doing some final preparation and setting * $hubIsActive to true + * + * @return void */ public function activateHub () { // Checks wether a listener is still active and shuts it down if one @@ -325,6 +323,22 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { $this->hubIsActive = true; // ---------------------- Last step until here ------------------------ } + + /** + * Initializes the listener pool (class) + * + * @return void + */ + private function initializeListenerPool () { + // Get a new pool instance + $this->listenerPoolInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this)); + + // Initialize the TCP listener + $tcpListenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this)); + + // Initialize the UDP listener + $udpListenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this)); + } } // [EOF]