From: Roland Häder Date: Sat, 26 Sep 2009 18:56:11 +0000 (+0000) Subject: Self-announcement rewritten to a task X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f8058aae045a8de12d89bead533232c8dc071df2;p=hub.git Self-announcement rewritten to a task --- diff --git a/.gitattributes b/.gitattributes index e5858576e..d40c75773 100644 --- a/.gitattributes +++ b/.gitattributes @@ -98,6 +98,7 @@ application/hub/main/decorators/class_BaseDecorator.php -text application/hub/main/filter/.htaccess -text application/hub/main/filter/activation/.htaccess -text application/hub/main/filter/activation/class_HubActivation -text +application/hub/main/filter/activation/class_HubActivationSelfAnnouncementFilter.php -text application/hub/main/filter/bootstrap/.htaccess -text application/hub/main/filter/bootstrap/class_HubBootstrap -text application/hub/main/filter/bootstrap/class_HubBootstrapAquireHubIdFilter.php -text @@ -136,6 +137,12 @@ application/hub/main/handler/network/udp/.htaccess -text application/hub/main/handler/network/udp/class_UdpNetworkPackageHandler.php -text application/hub/main/handler/tasks/.htaccess -text application/hub/main/handler/tasks/class_TaskHandler.php -text +application/hub/main/helper/.htaccess -text +application/hub/main/helper/hub/.htaccess -text +application/hub/main/helper/hub/announcement/.htaccess -text +application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php -text +application/hub/main/helper/hub/class_ -text +application/hub/main/helper/hub/class_BaseHubHelper.php -text application/hub/main/iterator/.htaccess -text application/hub/main/iterator/class_ -text application/hub/main/iterator/class_BaseIterator.php -text @@ -233,6 +240,8 @@ application/hub/main/tasks/.htaccess -text application/hub/main/tasks/class_ -text application/hub/main/tasks/class_BaseTask.php -text application/hub/main/tasks/hub/.htaccess -text +application/hub/main/tasks/hub/announcement/.htaccess -text +application/hub/main/tasks/hub/announcement/class_HubSelfAnnouncementTask.php -text application/hub/main/tasks/hub/class_HubSelfConnectTask.php -text application/hub/main/tasks/hub/ping/.htaccess -text application/hub/main/tasks/hub/ping/class_HubPingTask.php -text @@ -253,6 +262,11 @@ application/hub/main/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php application/hub/main/visitor/tasks/.htaccess -text application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php -text application/hub/starter.php -text +application/hub/templates/.htaccess -text +application/hub/templates/xml/.htaccess -text +application/hub/templates/xml/.xml -text +application/hub/templates/xml/announcement/.htaccess -text +application/hub/templates/xml/announcement/self_announcement.xml -text /clear-cache.sh -text db/.htaccess -text db/news/.htaccess -text diff --git a/application/hub/config.php b/application/hub/config.php index 1956c8dc0..95eceb9cf 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -108,6 +108,9 @@ $cfg->setConfigEntry('active_task_visitor_class', 'ActiveTaskVisitor'); // CFG: LIST-GROUP-CLASS $cfg->setConfigEntry('list_group_class', 'ListGroupList'); +// CFG: HUB-DESCRIPTOR-CLASS +$cfg->setConfigEntry('hub_descriptor_class', 'HubDescriptorHelper'); + // CFG: DEFAULT-CONSOLE-COMMAND $cfg->setConfigEntry('default_console_command', 'main'); @@ -132,6 +135,9 @@ $cfg->setConfigEntry('node_initializer_filter', 'NodeInitializationFilter'); // CFG: HUB-ACTIVATION-TASK-HANDLER-INITIALIZER-FILTER $cfg->setConfigEntry('hub_activation_task_handler_initializer_filter', 'TaskHandlerInitializerFilter'); +// CFG: HUB-ACTIVATION-SELF-ANNOUNCEMENT-TASK-FILTER +$cfg->setConfigEntry('hub_activation_self_announcement_task_filter', 'HubActivationSelfAnnouncementFilter'); + // CFG: CONSOLE-WELCOME-TEASER-FILTER $cfg->setConfigEntry('console_welcome_teaser_filter', 'ConsoleWelcomeTeaserFilter'); @@ -180,36 +186,63 @@ $cfg->setConfigEntry('task_network_package_reader_startup_delay', 2000); // CFG: TASK-NETWORK-PACKAGE-READER-INTERVAL-DELAY $cfg->setConfigEntry('task_network_package_reader_interval_delay', 10); +// CFG: TASK-NETWORK-PACKAGE-READER-MAX-RUNS +$cfg->setConfigEntry('task_network_package_reader_max_runs', 0); + // CFG: TASK-QUERY-HANDLER-STARTUP-DELAY $cfg->setConfigEntry('task_query_handler_startup_delay', 1000); // CFG: TASK-QUERY-HANDLER-INTERVAL-DELAY $cfg->setConfigEntry('task_query_handler_interval_delay', 10); +// CFG: TASK-QUERY-HANDLER-MAX-RUNS +$cfg->setConfigEntry('task_query_handler_max_runs', 0); + // CFG: TASK-IDLE-LOOP-STARTUP-DELAY $cfg->setConfigEntry('task_idle_loop_startup_delay', 0); // CFG: TASK-IDLE-LOOP-INTERVAL-DELAY $cfg->setConfigEntry('task_idle_loop_interval_delay', 0); +// CFG: TASK-IDLE-LOOP-MAX-RUNS +$cfg->setConfigEntry('task_idle_loop_max_runs', 0); + // CFG: TASK-SELF-CONNECT-STARTUP-DELAY $cfg->setConfigEntry('task_self_connect_startup_delay', 4000); // CFG: TASK-SELF-CONNECT-INTERVAL-DELAY $cfg->setConfigEntry('task_self_connect_interval_delay', 1000*60*30); +// CFG: TASK-SELF-CONNECT-MAX-RUNS +$cfg->setConfigEntry('task_self_connect_max_runs', 0); + +// CFG: TASK-SELF-ANNOUNCEMENT-STARTUP-DELAY +$cfg->setConfigEntry('task_self_announcement_startup_delay', 10000); + +// CFG: TASK-SELF-ANNOUNCEMENT-INTERVAL-DELAY +$cfg->setConfigEntry('task_self_announcement_interval_delay', 1000); + +// CFG: TASK-SELF-ANNOUNCEMENT-MAX-RUNS +$cfg->setConfigEntry('task_self_announcement_max_runs', 1); + // CFG: TASK-UPDATE-CHECK-STARTUP-DELAY $cfg->setConfigEntry('task_update_check_startup_delay', 1000*60*60*6); // CFG: TASK-UPDATE-CHECK-INTERVAL-DELAY $cfg->setConfigEntry('task_update_check_interval_delay', 1000*60*60*24); +// CFG: TASK-UPDATE-CHECK-MAX-RUNS +$cfg->setConfigEntry('task_update_check_max_runs', 0); + // CFG: TASK-PING-STARTUP-DELAY $cfg->setConfigEntry('task_ping_startup_delay', 1000*60); // CFG: TASK-PING-INTERVAL-DELAY $cfg->setConfigEntry('task_ping_interval_delay', 1000*60*60); +// CFG: TASK-PING-MAX-RUNS +$cfg->setConfigEntry('task_ping_max_runs', 0); + // CFG: IDLE-TASK-CLASS $cfg->setConfigEntry('idle_task_class', 'IdleLoopTask'); @@ -222,6 +255,9 @@ $cfg->setConfigEntry('hub_update_check_task_class', 'HubUpdateCheckTask'); // CFG: HUB-PING-TASK-CLASS $cfg->setConfigEntry('hub_ping_task_class', 'HubPingTask'); +// CFG: HUB-SELF-ANNOUNCEMENT-TASK-CLASS +$cfg->setConfigEntry('hub_self_announcement_task_class', 'HubSelfAnnouncementTask'); + // CFG: TASK-LIST-CLASS $cfg->setConfigEntry('task_list_class', 'TaskList'); diff --git a/application/hub/interfaces/nodes/class_NodeHelper.php b/application/hub/interfaces/nodes/class_NodeHelper.php index 196d1ecac..71c0b08f6 100644 --- a/application/hub/interfaces/nodes/class_NodeHelper.php +++ b/application/hub/interfaces/nodes/class_NodeHelper.php @@ -66,15 +66,6 @@ interface NodeHelper extends FrameworkInterface { */ function activateHub (Requestable $requestInstance, Responseable $responseInstance); - /** - * Adds some node-specific filters to the filter chains - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - function addExtraFilters (Requestable $requestInstance, Responseable $responseInstance); - /** * Generates a session id which will be sent to the other hubs and clients * @@ -95,6 +86,13 @@ interface NodeHelper extends FrameworkInterface { * @return void */ function bootstrapRestoreNodeList (); + + /** + * Add some node-specific filters + * + * @return void + */ + function addExtraHubFilters (); } // diff --git a/application/hub/main/commands/console/class_HubConsoleMainCommand.php b/application/hub/main/commands/console/class_HubConsoleMainCommand.php index 2463c9a58..4f087269f 100644 --- a/application/hub/main/commands/console/class_HubConsoleMainCommand.php +++ b/application/hub/main/commands/console/class_HubConsoleMainCommand.php @@ -71,6 +71,9 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable { // Get node instance $nodeInstance = Registry::getRegistry()->getInstance('node'); + // Add some node-specific filters, e.g. self-announcement + $nodeInstance->addExtraHubFilters(); + // -------------------------- Hub activation -------------------------- // Activates the hub by doing some final preparation steps and setting // the attribute $hubIsActive to true diff --git a/application/hub/main/filter/activation/class_HubActivationSelfAnnouncementFilter.php b/application/hub/main/filter/activation/class_HubActivationSelfAnnouncementFilter.php new file mode 100644 index 000000000..8fbcced23 --- /dev/null +++ b/application/hub/main/filter/activation/class_HubActivationSelfAnnouncementFilter.php @@ -0,0 +1,69 @@ + + * @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 HubActivationSelfAnnouncementFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createHubActivationSelfAnnouncementFilter () { + // Get a new instance + $filterInstance = new HubActivationSelfAnnouncementFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task'); + + // Prepare a self-test task for the listeners + $taskInstance = ObjectFactory::createObjectByConfiguredName('hub_self_announcement_task_class'); + + // Register it + $handlerInstance->registerTask('self_announcement', $taskInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/main/handler/tasks/class_TaskHandler.php b/application/hub/main/handler/tasks/class_TaskHandler.php index ee751541a..a53edd931 100644 --- a/application/hub/main/handler/tasks/class_TaskHandler.php +++ b/application/hub/main/handler/tasks/class_TaskHandler.php @@ -119,7 +119,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { $diff = ($this->getMilliTime() - $currentTask['task_last_activity']) * 1000; // Is the interval delay reached? - if ($diff < $currentTask['task_interval_delay']) { + if ((($diff < $currentTask['task_interval_delay']) && ($currentTask['task_max_runs'] == 0)) || (($currentTask['task_total_runs'] == $currentTask['task_max_runs']) && ($currentTask['task_max_runs'] > 0))) { // Should we update the task from startup? if ($updateTask === true) { // Update the task before leaving @@ -133,6 +133,9 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { // Set last activity $currentTask['task_last_activity'] = $this->getMilliTime(); + // Count this run + $currentTask['task_total_runs']++; + // Update the task $this->updateTask($currentTask); @@ -180,12 +183,16 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { 'task_registered' => $this->getMilliTime(), // Last activity timestamp 'task_last_activity' => 0, + // Total runs of this task + 'task_total_runs' => 0, // Task instance itself 'task_instance' => $taskInstance, // Startup delay in milliseconds 'task_startup_delay' => $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_startup_delay'), // Interval time (delay) in milliseconds before this task is executed again 'task_interval_delay' => $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_interval_delay'), + // How often should this task run? + 'task_max_runs' => $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_max_runs'), ); // Add the entry @@ -195,7 +202,8 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { $this->debugOutput('TASK-HANDLER: Task ' . $taskName . ' (taskInstance=' . $taskInstance->__toString() . ')' . ', startupDelay=' . $taskEntry['task_startup_delay'] . 'ms' . - ', intervalDelay=' . $taskEntry['task_interval_delay'] . 'ms registered.' + ', intervalDelay=' . $taskEntry['task_interval_delay'] . 'ms' . + ', maxRuns=' . $taskEntry['task_max_runs'] . ' times registered.' ); } diff --git a/application/hub/main/helper/.htaccess b/application/hub/main/helper/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/hub/.htaccess b/application/hub/main/helper/hub/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/hub/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/hub/announcement/.htaccess b/application/hub/main/helper/hub/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/hub/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php b/application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php new file mode 100644 index 000000000..3f3833a35 --- /dev/null +++ b/application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.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 HubDescriptorHelper extends BaseHubHelper { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class + * + * @param $nodeInstance An instance of a NodeHelper class + * @return $helperInstance A prepared instance of this helper + */ + public final static function createHubDescriptorHelper (NodeHelper $nodeInstance) { + // Get new instance + $helperInstance = new HubDescriptorHelper(); + + // Set the node instance + $helperInstance->setNodeInstance($nodeInstance); + + // Return the prepared instance + return $helperInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/hub/class_ b/application/hub/main/helper/hub/class_ new file mode 100644 index 000000000..46a974e53 --- /dev/null +++ b/application/hub/main/helper/hub/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 Hub???Helper extends BaseHubHelper { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function createHub???Helper () { + // Get new instance + $helperInstance = new Hub???Helper(); + + // Return the prepared instance + return $helperInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/hub/class_BaseHubHelper.php b/application/hub/main/helper/hub/class_BaseHubHelper.php new file mode 100644 index 000000000..d3ae9e71f --- /dev/null +++ b/application/hub/main/helper/hub/class_BaseHubHelper.php @@ -0,0 +1,62 @@ + + * @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 BaseHubHelper extends BaseHelper { + /** + * An instance of a node + */ + private $nodeInstance = null; + + /** + * Protected constructor + * + * @param $className Name of the concrete class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * 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/nodes/boot/class_HubBootNode.php b/application/hub/main/nodes/boot/class_HubBootNode.php index ce7841e4a..7ba796889 100644 --- a/application/hub/main/nodes/boot/class_HubBootNode.php +++ b/application/hub/main/nodes/boot/class_HubBootNode.php @@ -105,15 +105,19 @@ class HubBootNode extends BaseHubNode implements NodeHelper, Registerable { } /** - * Adds some node-specific filters to the filter chains + * Add some node-specific filters * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class * @return void - * @todo 0% */ - public function addExtraFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub('Please implement this method.'); + public function addExtraHubFilters () { + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Get the controller from the application + $controllerInstance = $applicationInstance->getControllerInstance(); + + // @TODO Add some filters here + $this->partialStub('Add some filters here.'); } } diff --git a/application/hub/main/nodes/class_ b/application/hub/main/nodes/class_ index e82e94c7a..b7a73281c 100644 --- a/application/hub/main/nodes/class_ +++ b/application/hub/main/nodes/class_ @@ -74,15 +74,12 @@ class Hub???Node extends BaseHubNode implements NodeHelper, Registerable { } /** - * Adds some node-specific filters to the filter chains + * Add some node-specific filters * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class * @return void - * @todo 0% */ - public function addExtraFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub('Please implement this method.'); + public function addExtraHubFilters () { + // Add some filters here } } diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index cebc45bde..c2193853e 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -317,16 +317,6 @@ class BaseHubNode extends BaseHubSystem implements Updateable { $this->debugOutput('BOOTSTRAP: Initialize queues: FINISHED'); } - /** - * Publish our hub descriptor to the upper hub(s) - * - * @return void - * @todo This should be implemented in a generic way to keep things easy. - */ - protected function publishHubDescriptor () { - $this->partialStub('Unfinished method.'); - } - /** * Adds hub data elements to a given dataset instance * diff --git a/application/hub/main/nodes/list/class_HubListNode.php b/application/hub/main/nodes/list/class_HubListNode.php index 37e74a0ad..7b6f59cc8 100644 --- a/application/hub/main/nodes/list/class_HubListNode.php +++ b/application/hub/main/nodes/list/class_HubListNode.php @@ -58,14 +58,7 @@ class HubListNode extends BaseHubNode implements NodeHelper, Registerable { * @todo Implement more bootstrap steps */ public function doBootstrapping () { - // Do more here - $this->partialStub('Do something before hub descriptor is published.'); - - // Publish the descriptor of this hub, this will "announce" us to upper hubs - $this->publishHubDescriptor(); - - // Do more here - $this->partialStub('Do something after hub descriptor is published.'); + $this->partialStub(); } /** @@ -81,15 +74,22 @@ class HubListNode extends BaseHubNode implements NodeHelper, Registerable { } /** - * Adds some node-specific filters to the filter chains + * Add some node-specific filters * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class * @return void - * @todo 0% */ - public function addExtraFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub('Please implement this method.'); + public function addExtraHubFilters () { + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Get the controller from the application + $controllerInstance = $applicationInstance->getControllerInstance(); + + // Self-announcement task + $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('hub_activation_self_announcement_task_filter')); + + // @TODO Add some filters here + $this->partialStub('Add some filters here.'); } } diff --git a/application/hub/main/nodes/master/class_HubMasterNode.php b/application/hub/main/nodes/master/class_HubMasterNode.php index c68d0a321..e00cab0c3 100644 --- a/application/hub/main/nodes/master/class_HubMasterNode.php +++ b/application/hub/main/nodes/master/class_HubMasterNode.php @@ -58,14 +58,7 @@ class HubMasterNode extends BaseHubNode implements NodeHelper, Registerable { * @todo Implement this method */ public function doBootstrapping () { - // Do more here - $this->partialStub('Do something before hub descriptor is published.'); - - // Publish the descriptor of this hub, this will "announce" us to upper hubs - $this->publishHubDescriptor(); - - // Do more here - $this->partialStub('Do something after hub descriptor is published.'); + $this->partialStub(); } /** @@ -81,15 +74,22 @@ class HubMasterNode extends BaseHubNode implements NodeHelper, Registerable { } /** - * Adds some node-specific filters to the filter chains + * Add some node-specific filters * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class * @return void - * @todo 0% */ - public function addExtraFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub('Please implement this method.'); + public function addExtraHubFilters () { + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Get the controller from the application + $controllerInstance = $applicationInstance->getControllerInstance(); + + // Self-announcement task + $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('hub_activation_self_announcement_task_filter')); + + // @TODO Add some filters here + $this->partialStub('Add some filters here.'); } } diff --git a/application/hub/main/nodes/regular/class_HubRegularNode.php b/application/hub/main/nodes/regular/class_HubRegularNode.php index d73ba618c..23b1be87f 100644 --- a/application/hub/main/nodes/regular/class_HubRegularNode.php +++ b/application/hub/main/nodes/regular/class_HubRegularNode.php @@ -58,14 +58,7 @@ class HubRegularNode extends BaseHubNode implements NodeHelper, Registerable { * @todo Implement this method */ public function doBootstrapping () { - // Do more here - $this->partialStub('Do something before hub descriptor is published.'); - - // Publish the descriptor of this hub, this will "announce" us to upper hubs - $this->publishHubDescriptor(); - - // Do more here - $this->partialStub('Do something after hub descriptor is published.'); + $this->partialStub(); } /** @@ -81,15 +74,22 @@ class HubRegularNode extends BaseHubNode implements NodeHelper, Registerable { } /** - * Adds some node-specific filters to the filter chains + * Add some node-specific filters * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class * @return void - * @todo 0% */ - public function addExtraFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub('Please implement this method.'); + public function addExtraHubFilters () { + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Get the controller from the application + $controllerInstance = $applicationInstance->getControllerInstance(); + + // Self-announcement task + $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('hub_activation_self_announcement_task_filter')); + + // @TODO Add some filters here + $this->partialStub('Add some filters here.'); } } diff --git a/application/hub/main/tasks/hub/announcement/.htaccess b/application/hub/main/tasks/hub/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/tasks/hub/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/tasks/hub/announcement/class_HubSelfAnnouncementTask.php b/application/hub/main/tasks/hub/announcement/class_HubSelfAnnouncementTask.php new file mode 100644 index 000000000..8313c5d48 --- /dev/null +++ b/application/hub/main/tasks/hub/announcement/class_HubSelfAnnouncementTask.php @@ -0,0 +1,71 @@ + + * @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 HubSelfAnnouncementTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createHubSelfAnnouncementTask () { + // Get new instance + $taskInstance = new HubSelfAnnouncementTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to rpocess the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo 0% + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function execute () { + $this->partialStub('Unimplemented task.'); + } +} + +// [EOF] +?> diff --git a/application/hub/templates/.htaccess b/application/hub/templates/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/templates/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/templates/xml/.htaccess b/application/hub/templates/xml/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/templates/xml/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/templates/xml/.xml b/application/hub/templates/xml/.xml new file mode 100644 index 000000000..e253bddb1 --- /dev/null +++ b/application/hub/templates/xml/.xml @@ -0,0 +1,23 @@ + + diff --git a/application/hub/templates/xml/announcement/.htaccess b/application/hub/templates/xml/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/templates/xml/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/templates/xml/announcement/self_announcement.xml b/application/hub/templates/xml/announcement/self_announcement.xml new file mode 100644 index 000000000..ca854f602 --- /dev/null +++ b/application/hub/templates/xml/announcement/self_announcement.xml @@ -0,0 +1,36 @@ + + + + + + + {?node_id?} + + {?session_id?} + + + + + +