]> git.mxchange.org Git - hub.git/commitdiff
Wrapper added for node list
authorRoland Häder <roland@mxchange.org>
Sun, 2 Aug 2009 18:17:15 +0000 (18:17 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 2 Aug 2009 18:17:15 +0000 (18:17 +0000)
.gitattributes
application/hub/config.php
application/hub/interfaces/nodes/class_NodeHelper.php
application/hub/main/database/wrapper/class_NodeListDatabaseWrapper.php [new file with mode: 0644]
application/hub/main/nodes/class_BaseHubNode.php

index 88950cd2b7ccb43c482a634d47f258278733993f..2888cdc48418ba5635c10a6d9097bd518d808ca5 100644 (file)
@@ -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
index d6e4eeb6cb1349ffcf04fcd27fd9ac93e02f683b..075390038e073fb81fb69305df02c51c138914f6 100644 (file)
@@ -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', '');
 
index 36b221729ca4c39a7119d5b141b54727e090a01d..1822552eedbb8a93b808176522ea80d6a16f7465 100644 (file)
@@ -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 (file)
index 0000000..7d4acea
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+/**
+ * A database wrapper for node list
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index 7e5b121e5d643aded57b8c68c0aabfea316b98e0..13bdbf75b22fd7a382f72679c84f9d7b00d660c2 100644 (file)
@@ -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.');
        }
 }