From: Roland Häder Date: Sun, 2 Aug 2009 18:17:15 +0000 (+0000) Subject: Wrapper added for node list X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b4d2a4339347d54a4a6f1969b49f9967d3034449;p=hub.git Wrapper added for node list --- diff --git a/.gitattributes b/.gitattributes index 88950cd2b..2888cdc48 100644 --- a/.gitattributes +++ b/.gitattributes @@ -57,6 +57,7 @@ application/hub/main/controller/console/class_HubConsoleDefaultNewsController.ph 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/database/wrapper/class_NodeListDatabaseWrapper.php -text application/hub/main/filter/.htaccess -text application/hub/main/filter/activation/.htaccess -text application/hub/main/filter/activation/class_ -text diff --git a/application/hub/config.php b/application/hub/config.php index d6e4eeb6c..075390038 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -48,6 +48,9 @@ $cfg->setConfigEntry('debug_class', 'DebugConsoleOutput'); // CFG: NODE-INFO-DB-WRAPPER-CLASS $cfg->setConfigEntry('node_info_db_wrapper_class', 'NodeInformationDatabaseWrapper'); +// CFG: NODE-LIST-DB-WRAPPER-CLASS +$cfg->setConfigEntry('node_list_db_wrapper_class', 'NodeListDatabaseWrapper'); + // CFG: WEB-CONTENT-TYPE $cfg->setConfigEntry('web_content_type', ''); diff --git a/application/hub/interfaces/nodes/class_NodeHelper.php b/application/hub/interfaces/nodes/class_NodeHelper.php index 36b221729..1822552ee 100644 --- a/application/hub/interfaces/nodes/class_NodeHelper.php +++ b/application/hub/interfaces/nodes/class_NodeHelper.php @@ -65,6 +65,27 @@ interface NodeHelper extends FrameworkInterface { * @return void */ function activateHub (Requestable $requestInstance, Responseable $responseInstance); + + /** + * Generates a session id which will be sent to the other hubs and clients + * + * @return void + */ + function bootstrapGenerateSessionId (); + + /** + * Initializes the listener pool (class) + * + * @return void + */ + function initializeListenerPool (); + + /** + * Restores a previously stored node list from database + * + * @return void + */ + function bootstrapRestoreNodeList (); } // diff --git a/application/hub/main/database/wrapper/class_NodeListDatabaseWrapper.php b/application/hub/main/database/wrapper/class_NodeListDatabaseWrapper.php new file mode 100644 index 000000000..7d4acea49 --- /dev/null +++ b/application/hub/main/database/wrapper/class_NodeListDatabaseWrapper.php @@ -0,0 +1,65 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 NodeListDatabaseWrapper extends BaseDatabaseWrapper { + // Table names + const DB_TABLE_NODE_LIST = 'node_list'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct() { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public final static function createNodeListDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new NodeListDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_NODE_LIST); + + // Return the instance + return $wrapperInstance; + } + + /** + * Getter for index key + * + * @return $indexKey Index key + */ + public final function getIndexKey () { + return $this->getDatabaseInstance()->getIndexKey(); + } +} + +// [EOF] +?> diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index 7e5b121e5..13bdbf75b 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -285,14 +285,17 @@ class BaseHubNode extends BaseHubSystem implements Updateable { * @return void */ protected function initGenericQueues () { + // Debug message + $this->debugOutput('BOOTSTRAP: Initialize queues: START'); + // Set the query connector instance $this->setQueryInstance(ObjectFactory::createObjectByConfiguredName('query_connector_class', array($this))); // Run a test query $this->getQueryInstance()->doTestQuery(); - // Query queue initialized - $this->debugOutput('BOOTSTRAP: Query queue initialized.'); + // Debug message + $this->debugOutput('BOOTSTRAP: Initialize queues: FINISHED'); } /** @@ -401,7 +404,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable { */ public function initializeListenerPool () { // Debug output - $this->debugOutput('HUB: Initializing listeners...'); + $this->debugOutput('HUB: Initialize listener: START'); // Get a new pool instance $this->listenerPoolInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this)); @@ -451,7 +454,42 @@ class BaseHubNode extends BaseHubSystem implements Updateable { $this->listenerPoolInstance->addListener($decoratorInstance); // Debug output - $this->debugOutput('HUB: All listeners are initialized.'); + $this->debugOutput('HUB: Initialize listener: FINISHED.'); + } + + /** + * Restores a previously stored node list from database + * + * @return void + */ + public function bootstrapRestoreNodeList () { + // Debug output + $this->debugOutput('HUB: Restore node list: START'); + + // Get a wrapper instance + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_list_db_wrapper_class'); + + // Now get a search criteria instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Search for the node number zero which is hard-coded the default + // @TODO Add some criteria, e.g. if the node is active or so + //$searchInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_NODE_NR, 1); + //$searchInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->getRequestInstance()->getRequestElement('mode')); + //$searchInstance->setLimit(1); + + // Get a result back + $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance); + + // Is it valid? + if ($resultInstance->next()) { + $this->partialStub('Do something for restoring the list.'); + // Output message + //$this->debugOutput('BOOTSTRAP: '); + } // END - if + + // Debug output + $this->debugOutput('HUB: Restore node list: FINISHED.'); } }