From 3d2b905ec24eab672dab8eae54f68774231b3834 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 6 Jul 2009 18:43:29 +0000 Subject: [PATCH] More connector classes added --- .gitattributes | 7 +++ application/hub/config.php | 5 +- application/hub/interfaces/query/.htaccess | 1 + .../hub/interfaces/query/class_Queryable.php | 28 ++++++++++ .../main/connectors/class_BaseConnector.php | 24 +++++++++ .../hub/main/connectors/query/.htaccess | 1 + application/hub/main/connectors/query/class_ | 50 +++++++++++++++++ .../query/class_BaseQueryConnector.php | 38 +++++++++++++ .../hub/main/connectors/query/local/.htaccess | 1 + .../query/local/class_LocalQueryConnector.php | 54 +++++++++++++++++++ application/hub/main/connectors/queues/class_ | 5 +- .../local/class_LocalQueueConnector.php | 10 ++-- .../hub/main/nodes/boot/class_HubBootNode.php | 3 -- .../hub/main/nodes/class_BaseHubNode.php | 15 ++++-- .../hub/main/nodes/list/class_HubListNode.php | 3 -- .../main/nodes/master/class_HubMasterNode.php | 3 -- .../nodes/regular/class_HubRegularNode.php | 3 -- 17 files changed, 229 insertions(+), 22 deletions(-) create mode 100644 application/hub/interfaces/query/.htaccess create mode 100644 application/hub/interfaces/query/class_Queryable.php create mode 100644 application/hub/main/connectors/query/.htaccess create mode 100644 application/hub/main/connectors/query/class_ create mode 100644 application/hub/main/connectors/query/class_BaseQueryConnector.php create mode 100644 application/hub/main/connectors/query/local/.htaccess create mode 100644 application/hub/main/connectors/query/local/class_LocalQueryConnector.php diff --git a/.gitattributes b/.gitattributes index aa7e5161f..86daee16c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14,12 +14,19 @@ 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/query/.htaccess -text +application/hub/interfaces/query/class_Queryable.php -text 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/connectors/.htaccess -text application/hub/main/connectors/class_BaseConnector.php -text +application/hub/main/connectors/query/.htaccess -text +application/hub/main/connectors/query/class_ -text +application/hub/main/connectors/query/class_BaseQueryConnector.php -text +application/hub/main/connectors/query/local/.htaccess -text +application/hub/main/connectors/query/local/class_LocalQueryConnector.php -text application/hub/main/connectors/queues/.htaccess -text application/hub/main/connectors/queues/class_ -text application/hub/main/connectors/queues/class_BaseQueueConnector.php -text diff --git a/application/hub/config.php b/application/hub/config.php index c52c6dbe7..6c7bc5c99 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -48,8 +48,11 @@ $cfg->setConfigEntry('node_info_db_wrapper_class', "NodeInformationDatabaseWrapp // CFG: WEB-CONTENT-TYPE $cfg->setConfigEntry('web_content_type', ""); +// CFG: QUERY-CONNECTOR +$cfg->setConfigEntry('query_connector_class', "LocalQueryConnector"); + // CFG: QUEUE-CONNECTOR -$cfg->setConfigEntry('queue_connector', "LocalQueueConnector"); +$cfg->setConfigEntry('queue_connector_class', "LocalQueueConnector"); // [EOF] ?> diff --git a/application/hub/interfaces/query/.htaccess b/application/hub/interfaces/query/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/query/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/query/class_Queryable.php b/application/hub/interfaces/query/class_Queryable.php new file mode 100644 index 000000000..29ecd46b8 --- /dev/null +++ b/application/hub/interfaces/query/class_Queryable.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 Queryable extends FrameworkInterface { +} + +// +?> diff --git a/application/hub/main/connectors/class_BaseConnector.php b/application/hub/main/connectors/class_BaseConnector.php index 592a6ba7e..1945a6529 100644 --- a/application/hub/main/connectors/class_BaseConnector.php +++ b/application/hub/main/connectors/class_BaseConnector.php @@ -22,6 +22,11 @@ * along with this program. If not, see . */ class BaseConnector extends BaseFrameworkSystem { + /** + * An instance of a node + */ + private $nodeInstance = null; + /** * Protected constructor * @@ -36,6 +41,25 @@ class BaseConnector extends BaseFrameworkSystem { $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/query/.htaccess b/application/hub/main/connectors/query/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/connectors/query/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/connectors/query/class_ b/application/hub/main/connectors/query/class_ new file mode 100644 index 000000000..dc72d3a09 --- /dev/null +++ b/application/hub/main/connectors/query/class_ @@ -0,0 +1,50 @@ + + * @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 ???QueueConnector extends BaseQueueConnector implements Connectable, Queueable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this queue connector class + * + * @return $connectorInstance An instance of this queue connector class + */ + public final static function create???QueueConnector () { + // Create the instance + $connectorInstance = new ???QueueConnector(); + + // Finally return it + return $connectorInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/connectors/query/class_BaseQueryConnector.php b/application/hub/main/connectors/query/class_BaseQueryConnector.php new file mode 100644 index 000000000..df6df0a0b --- /dev/null +++ b/application/hub/main/connectors/query/class_BaseQueryConnector.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 BaseQueryConnector extends BaseConnector { + /** + * 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/connectors/query/local/.htaccess b/application/hub/main/connectors/query/local/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/connectors/query/local/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php new file mode 100644 index 000000000..69a6efb54 --- /dev/null +++ b/application/hub/main/connectors/query/local/class_LocalQueryConnector.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 LocalQueryConnector extends BaseQueryConnector implements Connectable, Queryable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this query connector class + * + * @param $nodeInstance An instance of a node + * @return $connectorInstance An instance of this query connector class + */ + public final static function createLocalQueryConnector (NodeHelper $nodeInstance) { + // Create the instance + $connectorInstance = new LocalQueryConnector(); + + // Set the node instance + $connectorInstance->setNodeInstance($nodeInstance); + + // Finally return it + return $connectorInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/connectors/queues/class_ b/application/hub/main/connectors/queues/class_ index c9d1d522f..dc72d3a09 100644 --- a/application/hub/main/connectors/queues/class_ +++ b/application/hub/main/connectors/queues/class_ @@ -25,12 +25,11 @@ class ???QueueConnector extends BaseQueueConnector implements Connectable, Queue /** * Protected constructor * - * @param $className Name of the class * @return void */ - protected function __construct ($className) { + protected function __construct () { // Call parent constructor - parent::__construct($className); + parent::__construct(__CLASS__); } /** diff --git a/application/hub/main/connectors/queues/local/class_LocalQueueConnector.php b/application/hub/main/connectors/queues/local/class_LocalQueueConnector.php index 29f30077d..4c03caf2a 100644 --- a/application/hub/main/connectors/queues/local/class_LocalQueueConnector.php +++ b/application/hub/main/connectors/queues/local/class_LocalQueueConnector.php @@ -28,20 +28,24 @@ class LocalQueueConnector extends BaseQueueConnector implements Connectable, Que * @param $className Name of the class * @return void */ - protected function __construct ($className) { + protected function __construct () { // Call parent constructor - parent::__construct($className); + parent::__construct(__CLASS__); } /** * Creates an instance of this queue connector class * + * @param $nodeInstance An instance of a hub node * @return $connectorInstance An instance of this queue connector class */ - public final static function createLocalQueueConnector () { + public final static function createLocalQueueConnector (NodeHelper $nodeInstance) { // Create the instance $connectorInstance = new LocalQueueConnector(); + // Set the node instance + $connectorInstance->setNodeInstance($nodeInstance); + // Finally return it return $connectorInstance; } diff --git a/application/hub/main/nodes/boot/class_HubBootNode.php b/application/hub/main/nodes/boot/class_HubBootNode.php index 93befa342..e3d294aaa 100644 --- a/application/hub/main/nodes/boot/class_HubBootNode.php +++ b/application/hub/main/nodes/boot/class_HubBootNode.php @@ -91,9 +91,6 @@ class HubBootNode extends BaseHubNode implements NodeHelper { // This might not be all... $this->partialStub('Please implement more bootsrapping steps.'); - - // This should be the last thing to do: output teaser lines - $this->outputConsoleTeaser(); } /** diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index b6ff400aa..a47136f62 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -32,6 +32,11 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { */ private $bootIpPort = ''; + /** + * Query connector instance + */ + private $queryInstance = null; + /** * Protected constructor * @@ -143,7 +148,10 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { * @todo This method is maybe not yet finished. */ protected function doGenericBootstrapping () { - // @TODO Empty method + // This should be the last line: output teaser + $this->outputConsoleTeaser(); + + // @TODO Add some generic bootstrap steps $this->partialStub('Add some generic bootstrap steps here.'); } @@ -206,7 +214,8 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { * @return void */ protected function initGenericQueues () { - $this->partialStub('Init query queue here.'); + // Set it + $this->queryInstance = ObjectFactory::createObjectByConfiguredName('query_connector_class', array($this)); } /** @@ -236,7 +245,7 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { */ public function updateDatabaseField ($fieldName, $fieldValue) { // Unfinished - $this->partialStub("Unfinished!"); + $this->partialStub('Unfinished!'); return; // Get a critieria instance diff --git a/application/hub/main/nodes/list/class_HubListNode.php b/application/hub/main/nodes/list/class_HubListNode.php index c490782db..e1375702b 100644 --- a/application/hub/main/nodes/list/class_HubListNode.php +++ b/application/hub/main/nodes/list/class_HubListNode.php @@ -68,9 +68,6 @@ class HubListNode extends BaseHubNode implements NodeHelper { // Call generic (parent) bootstrapping method first parent::doGenericBootstrapping(); $this->partialStub('Please implement this method.'); - - // This should be the last line: output teaser - $this->outputConsoleTeaser(); } /** diff --git a/application/hub/main/nodes/master/class_HubMasterNode.php b/application/hub/main/nodes/master/class_HubMasterNode.php index 983281756..803bc8926 100644 --- a/application/hub/main/nodes/master/class_HubMasterNode.php +++ b/application/hub/main/nodes/master/class_HubMasterNode.php @@ -68,9 +68,6 @@ class HubMasterNode extends BaseHubNode implements NodeHelper { // Call generic (parent) bootstrapping method first parent::doGenericBootstrapping(); $this->partialStub('Please implement this method.'); - - // This should be the last line: output teaser - $this->outputConsoleTeaser(); } /** diff --git a/application/hub/main/nodes/regular/class_HubRegularNode.php b/application/hub/main/nodes/regular/class_HubRegularNode.php index 20ae415d4..b6cb2d36a 100644 --- a/application/hub/main/nodes/regular/class_HubRegularNode.php +++ b/application/hub/main/nodes/regular/class_HubRegularNode.php @@ -69,9 +69,6 @@ class HubRegularNode extends BaseHubNode implements NodeHelper { // Call generic (parent) bootstrapping method first parent::doGenericBootstrapping(); $this->partialStub('Please implement this method.'); - - // This is the last line: output teaser - $this->outputConsoleTeaser(); } /** -- 2.39.5