From: Roland Häder Date: Tue, 7 Jul 2009 18:47:12 +0000 (+0000) Subject: ListenerPool added with Poolable interface (should we change the name of the interface?) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bb06bccb4d08f8ff539388d1d141bb767db34cc6;p=hub.git ListenerPool added with Poolable interface (should we change the name of the interface?) --- diff --git a/.gitattributes b/.gitattributes index ef9042806..9f1b7ac6a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14,6 +14,8 @@ application/hub/interfaces/connectors/.htaccess -text application/hub/interfaces/connectors/class_Connectable.php -text application/hub/interfaces/nodes/.htaccess -text application/hub/interfaces/nodes/class_NodeHelper.php -text +application/hub/interfaces/pool/.htaccess -text +application/hub/interfaces/pool/class_Poolable.php -text application/hub/interfaces/query/.htaccess -text application/hub/interfaces/query/class_Queryable.php -text application/hub/interfaces/queues/.htaccess -text @@ -39,7 +41,6 @@ application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php - 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 @@ -53,6 +54,11 @@ application/hub/main/nodes/master/.htaccess -text application/hub/main/nodes/master/class_HubMasterNode.php -text application/hub/main/nodes/regular/.htaccess -text application/hub/main/nodes/regular/class_HubRegularNode.php -text +application/hub/main/pools/.htaccess -text +application/hub/main/pools/class_ -text +application/hub/main/pools/class_BasePool.php -text +application/hub/main/pools/listener/.htaccess -text +application/hub/main/pools/listener/class_DefaultListenerPool.php -text application/hub/starter.php -text /clear-cache.sh -text db/.htaccess -text diff --git a/application/hub/config.php b/application/hub/config.php index b1bac59bc..243bd3ac4 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -58,7 +58,7 @@ $cfg->setConfigEntry('query_connector_class', "LocalQueryConnector"); $cfg->setConfigEntry('queue_connector_class', "LocalQueueConnector"); // CFG: LISTENER-POOL-CLAS -$cfg->setConfigEntry('listener_pool_class', "ListenerPool"); +$cfg->setConfigEntry('listener_pool_class', "DefaultListenerPool"); // CFG: TCP-LISTENER-CLASS $cfg->setConfigEntry('tcp_listener_class', "TcpListener"); diff --git a/application/hub/interfaces/pool/.htaccess b/application/hub/interfaces/pool/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/pool/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/pool/class_Poolable.php b/application/hub/interfaces/pool/class_Poolable.php new file mode 100644 index 000000000..966673b1f --- /dev/null +++ b/application/hub/interfaces/pool/class_Poolable.php @@ -0,0 +1,28 @@ + + * @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 . + */ +interface Poolable extends FrameworkInterface { +} + +// +?> diff --git a/application/hub/main/listener/class_ b/application/hub/main/listener/class_ index 6eb013c3c..996f6750e 100644 --- a/application/hub/main/listener/class_ +++ b/application/hub/main/listener/class_ @@ -21,7 +21,7 @@ * 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 { +class ???Listener extends BaseListener implements Listenable { /** * Protected constructor * diff --git a/application/hub/main/listener/pool/.htaccess b/application/hub/main/listener/pool/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/listener/pool/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index a52541a2e..77c80e084 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -334,10 +334,18 @@ class BaseHubNode extends BaseHubSystem implements Updateable { $this->listenerPoolInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this)); // Initialize the TCP listener - $tcpListenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this)); + $listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this)); + + // Setup address and port + $listenerInstance->setListenAddressByConfiguration('node_listen_addr'); + $listenerInstance->setListenPortByConfiguration('node_tcp_listen_port'); // Initialize the UDP listener - $udpListenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this)); + $listenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this)); + + // Setup address and port + $listenerInstance->setListenAddressByConfiguration('node_listen_addr'); + $listenerInstance->setListenPortByConfiguration('node_udp_listen_port'); } } diff --git a/application/hub/main/pools/.htaccess b/application/hub/main/pools/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/pools/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/pools/class_ b/application/hub/main/pools/class_ new file mode 100644 index 000000000..06299ccc9 --- /dev/null +++ b/application/hub/main/pools/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 ???Pool extends BasePool implements Poolable { + /** + * 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???Pool (NodeHelper $nodeInstance) { + // Get new instance + $listenerInstance = new ???Pool(); + + // Set the application instance + $listenerInstance->setNodeInstance($nodeInstance); + + // Return the prepared instance + return $listenerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/pools/class_BasePool.php b/application/hub/main/pools/class_BasePool.php new file mode 100644 index 000000000..4c0d94908 --- /dev/null +++ b/application/hub/main/pools/class_BasePool.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 BasePool 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/pools/listener/.htaccess b/application/hub/main/pools/listener/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/pools/listener/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/pools/listener/class_DefaultListenerPool.php b/application/hub/main/pools/listener/class_DefaultListenerPool.php new file mode 100644 index 000000000..3448cea2f --- /dev/null +++ b/application/hub/main/pools/listener/class_DefaultListenerPool.php @@ -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 DefaultListenerPool extends BasePool implements Poolable { + /** + * 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 createDefaultListenerPool (NodeHelper $nodeInstance) { + // Get new instance + $listenerInstance = new DefaultListenerPool(); + + // Set the application instance + $listenerInstance->setNodeInstance($nodeInstance); + + // Return the prepared instance + return $listenerInstance; + } +} + +// [EOF] +?>