]> git.mxchange.org Git - hub.git/commitdiff
Self-announcement rewritten to a task
authorRoland Häder <roland@mxchange.org>
Sat, 26 Sep 2009 18:56:11 +0000 (18:56 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 26 Sep 2009 18:56:11 +0000 (18:56 +0000)
25 files changed:
.gitattributes
application/hub/config.php
application/hub/interfaces/nodes/class_NodeHelper.php
application/hub/main/commands/console/class_HubConsoleMainCommand.php
application/hub/main/filter/activation/class_HubActivationSelfAnnouncementFilter.php [new file with mode: 0644]
application/hub/main/handler/tasks/class_TaskHandler.php
application/hub/main/helper/.htaccess [new file with mode: 0644]
application/hub/main/helper/hub/.htaccess [new file with mode: 0644]
application/hub/main/helper/hub/announcement/.htaccess [new file with mode: 0644]
application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php [new file with mode: 0644]
application/hub/main/helper/hub/class_ [new file with mode: 0644]
application/hub/main/helper/hub/class_BaseHubHelper.php [new file with mode: 0644]
application/hub/main/nodes/boot/class_HubBootNode.php
application/hub/main/nodes/class_
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/nodes/list/class_HubListNode.php
application/hub/main/nodes/master/class_HubMasterNode.php
application/hub/main/nodes/regular/class_HubRegularNode.php
application/hub/main/tasks/hub/announcement/.htaccess [new file with mode: 0644]
application/hub/main/tasks/hub/announcement/class_HubSelfAnnouncementTask.php [new file with mode: 0644]
application/hub/templates/.htaccess [new file with mode: 0644]
application/hub/templates/xml/.htaccess [new file with mode: 0644]
application/hub/templates/xml/.xml [new file with mode: 0644]
application/hub/templates/xml/announcement/.htaccess [new file with mode: 0644]
application/hub/templates/xml/announcement/self_announcement.xml [new file with mode: 0644]

index e5858576e80af80df2e9d3db08d15f44f03228aa..d40c757735ab6a477a36967b0f0366188058661e 100644 (file)
@@ -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
index 1956c8dc09d93777d4ce4df7f57348ae2ba56cfa..95eceb9cfb78705bb238717655e3b67f6bf7fb44 100644 (file)
@@ -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');
 
index 196d1ecaca6b2552079d7f2a5a109665370dcb60..71c0b08f65812c70b1f372c1a19ce4b8c21b0c78 100644 (file)
@@ -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 ();
 }
 
 //
index 2463c9a58a8e16669f88df4ea62f0da70a6d9bc9..4f087269f40b712845683ba9ec5b7b2dc871b2e1 100644 (file)
@@ -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 (file)
index 0000000..8fbcced
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+/**
+ * A SelfAnnouncement filter for hub activation
+ *
+ * @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 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]
+?>
index ee751541aaaa874ba42a33499ebcd37fc13027d5..a53edd931ffb72fdad297b0a2d7751a735c8f6df 100644 (file)
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..3f3833a
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/**
+ * A Descriptor hub helper class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..46a974e
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A ??? hub helper class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..d3ae9e7
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+/**
+ * A general hub helper class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index ce7841e4ae6dbf3b394fd684782490f340040c85..7ba79688958a5093430354fe95cf41fed7db43cf 100644 (file)
@@ -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.');
        }
 }
 
index e82e94c7a84394f0f858716863cd8e9768b78170..b7a73281c970a2ec3c312be162fd691f5a109213 100644 (file)
@@ -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
        }
 }
 
index cebc45bdeb2078bd100a07397de70a9310b1e275..c2193853e448993a65d2460bc3891f4797f9ef8f 100644 (file)
@@ -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
         *
index 37e74a0ad5b038716b015eeb855cc4a6bfa0f0f7..7b6f59cc8f0ae213a9a5e06c2c54df23ed4fd542 100644 (file)
@@ -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.');
        }
 }
 
index c68d0a321612891f96265d80f1ff35409eaa08dc..e00cab0c33f4536ebdf159609a09e9c31c1d07d2 100644 (file)
@@ -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.');
        }
 }
 
index d73ba618c1bb32a7e8817c8b7118e503edd55bfd..23b1be87f8c2db36151c87308edf1758abcbadf3 100644 (file)
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..8313c5d
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+/**
+ * A HubSelfAnnouncement task
+ *
+ * @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 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 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/templates/xml/.htaccess b/application/hub/templates/xml/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/templates/xml/.xml b/application/hub/templates/xml/.xml
new file mode 100644 (file)
index 0000000..e253bdd
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+
+
+@author                Roland Haeder <webmaster@ship-simu.org>
+@version       0.0.0
+@copyright     Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu 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/>
+//-->
diff --git a/application/hub/templates/xml/announcement/.htaccess b/application/hub/templates/xml/announcement/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..ca854f6
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+A template for announcing itself to upper hubs.
+
+@author                Roland Haeder <webmaster@ship-simu.org>
+@version       0.0.0
+@copyright     Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu 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/>
+//-->
+<announcement>
+       <!-- Announcement data like, node id, session id and object types. //-->
+       <annoucement-data>
+               <!-- Our node id. This should be announced only to upper hubs. //-->
+               <node-id>{?node_id?}</node-id>
+               <!-- The session id. This should be announced to all other hubs. //-->
+               <session-id>{?session_id?}</session-id>
+               <!-- A list of shared object types. //-->
+               <object-type-list>
+                       <object-type type="{?object_type?}" />
+               </object-type-list>
+       </annoucement-data>
+</announcement>