]> git.mxchange.org Git - hub.git/commitdiff
Filters and chains added:
authorRoland Häder <roland@mxchange.org>
Sun, 2 Aug 2009 10:44:19 +0000 (10:44 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 2 Aug 2009 10:44:19 +0000 (10:44 +0000)
- Filter chain 'hub_activation' added
- Initializing of listeners is now done by a bootstrap filter

.gitattributes
application/hub/config.php
application/hub/interfaces/nodes/class_NodeHelper.php
application/hub/main/commands/console/class_HubConsoleMainCommand.php
application/hub/main/controller/console/class_HubConsoleDefaultNewsController.php
application/hub/main/filter/activation/.htaccess [new file with mode: 0644]
application/hub/main/filter/activation/class_ [new file with mode: 0644]
application/hub/main/filter/bootstrap/class_HubBootstrapListenerPoolFilter.php [new file with mode: 0644]
application/hub/main/filter/class_ [new file with mode: 0644]
application/hub/main/nodes/class_BaseHubNode.php

index 5c741ad66fdd6348aca6bc6bc74762afc590c235..88950cd2b7ccb43c482a634d47f258278733993f 100644 (file)
@@ -58,13 +58,17 @@ 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/filter/.htaccess -text
+application/hub/main/filter/activation/.htaccess -text
+application/hub/main/filter/activation/class_ -text
 application/hub/main/filter/bootstrap/.htaccess -text
 application/hub/main/filter/bootstrap/class_ -text
 application/hub/main/filter/bootstrap/class_HubBootstrapAquireHubIdFilter.php -text
 application/hub/main/filter/bootstrap/class_HubBootstrapExtraBootstrappingFilter.php -text
 application/hub/main/filter/bootstrap/class_HubBootstrapGenSessionIdFilter.php -text
 application/hub/main/filter/bootstrap/class_HubBootstrapInitQueuesFilter.php -text
+application/hub/main/filter/bootstrap/class_HubBootstrapListenerPoolFilter.php -text
 application/hub/main/filter/bootstrap/class_HubBootstrapRestoreNodeListFilter.php -text
+application/hub/main/filter/class_ -text
 application/hub/main/filter/console/.htaccess -text
 application/hub/main/filter/console/class_Console -text
 application/hub/main/filter/console/class_ConsoleWelcomeTeaserFilter.php -text
index db9722b8343e610de2121c6888e9ff3a6c57d524..d6e4eeb6cb1349ffcf04fcd27fd9ac93e02f683b 100644 (file)
@@ -117,6 +117,9 @@ $cfg->setConfigEntry('hub_bootstrap_init_queues_filter', 'HubBootstrapInitQueues
 // CFG: HUB-BOOTSTRAP-EXTRA-BOOTSTRAP-FILTER
 $cfg->setConfigEntry('hub_bootstrap_extra_bootstrap_filter', 'HubBootstrapExtraBootstrappingFilter');
 
+// CFG: HUB-BOOTSTRAP-LISTENER-POOL-FILTER
+$cfg->setConfigEntry('hub_bootstrap_listener_pool_filter', 'HubBootstrapListenerPoolFilter');
+
 // CFG: NEWS-READER-CLASS
 $cfg->setConfigEntry('news_reader_class', 'ConsoleNewsReader');
 
index 00d8c3c701602b29c8f0297ede652a88e7c27edf..36b221729ca4c39a7119d5b141b54727e090a01d 100644 (file)
@@ -60,9 +60,11 @@ interface NodeHelper extends FrameworkInterface {
         * Activates the hub by doing some final preparation and setting
         * $hubIsActive to true
         *
+        * @param       $requestInstance        A Requestable class
+        * @param       $responseInstance       A Responseable class
         * @return      void
         */
-       function activateHub ();
+       function activateHub (Requestable $requestInstance, Responseable $responseInstance);
 }
 
 //
index 20b23e4c8185584d827d32764bdb235e97ce98e6..996298827186cb56fb61a084001de5554ef0c590 100644 (file)
@@ -92,7 +92,7 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable {
                // -------------------------- Hub activation --------------------------
                // Activates the hub by doing some final preparation steps and setting
                // the attribute $hubIsActive to true
-               $nodeInstance->activateHub();
+               $nodeInstance->activateHub($requestInstance, $responseInstance);
 
                // ----------------------------- Main loop ----------------------------
                // This is the main loop. Queried calls should come back here very fast
@@ -108,6 +108,7 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable {
         * @param       $controllerInstance             A controller instance
         * @param       $requestInstance                An instance of a class with an Requestable interface
         * @return      void
+        * @todo        Should we add some more filters?
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
                // Add pre filters
@@ -120,6 +121,9 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable {
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_restore_nodelist_filter'));
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_init_queues_filter'));
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_extra_bootstrap_filter'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_listener_pool_filter'));
+
+               // Add hub activation filters
        }
 }
 
index 1226e59a035713f2504f79fabc9a53b8464e5855..ed9fbe8bed835f1403b9f4635ddf562605b4a920 100644 (file)
@@ -33,6 +33,7 @@ class HubConsoleDefaultNewsController extends BaseController implements Controll
 
                // Init additional filter groups
                $this->initFilterChain('bootstrap');
+               $this->initFilterChain('hub_activation');
        }
 
        /**
@@ -106,6 +107,27 @@ class HubConsoleDefaultNewsController extends BaseController implements Controll
        public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) {
                $this->executeFilters('bootstrap', $requestInstance, $responseInstance);
        }
+
+       /**
+        * Add a hub activation filter
+        *
+        * @param       $filterInstance         A Filterable class
+        * @return      void
+        */
+       public function addHubActivationFilter (Filterable $filterInstance) {
+               $this->addFilter('hub_activation', $filterInstance);
+       }
+
+       /**
+        * Executes all hub activation filters
+        *
+        * @param       $requestInstance        A Requestable class
+        * @param       $responseInstance       A Responseable class
+        * @return      void
+        */
+       public function executeHubActivationFilters (Requestable $requestInstance, Responseable $responseInstance) {
+               $this->executeFilters('hub_activation', $requestInstance, $responseInstance);
+       }
 }
 
 // [EOF]
diff --git a/application/hub/main/filter/activation/.htaccess b/application/hub/main/filter/activation/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/filter/activation/class_ b/application/hub/main/filter/activation/class_
new file mode 100644 (file)
index 0000000..eae234f
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A ??? filter for hub activation
+ *
+ * @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 HubActivation???Filter 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 createHubActivation???Filter () {
+               // Get a new instance
+               $filterInstance = new HubActivation???Filter();
+
+               // 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 node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               // Sanity-check on it
+               if (is_null($nodeInstance)) {
+                       // Throws a FilterChainException to stop further processing
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+               } // END - if
+
+               // Now do something
+               $this->partialStub('Please implement this step.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/bootstrap/class_HubBootstrapListenerPoolFilter.php b/application/hub/main/filter/bootstrap/class_HubBootstrapListenerPoolFilter.php
new file mode 100644 (file)
index 0000000..c35aaef
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A ListenerPool filter for bootstrapping
+ *
+ * @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 HubBootstrapListenerPoolFilter 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 createHubBootstrapListenerPoolFilter () {
+               // Get a new instance
+               $filterInstance = new HubBootstrapListenerPoolFilter();
+
+               // 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 node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               // Sanity-check on it
+               if (is_null($nodeInstance)) {
+                       // Throws a FilterChainException to stop further processing
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+               } // END - if
+
+               // Now do something
+               $nodeInstance->initializeListenerPool();
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/class_ b/application/hub/main/filter/class_
new file mode 100644 (file)
index 0000000..405ba8a
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A ??? filter for !!!
+ *
+ * @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!!!???Filter 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 createHub!!!???Filter () {
+               // Get a new instance
+               $filterInstance = new Hub!!!???Filter();
+
+               // 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 node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               // Sanity-check on it
+               if (is_null($nodeInstance)) {
+                       // Throws a FilterChainException to stop further processing
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+               } // END - if
+
+               // Now do something
+               $this->partialStub('Please implement this step.');
+       }
+}
+
+// [EOF]
+?>
index 6325a94fbb3c6a7298f2064203c03036a285c8f8..7e5b121e5d643aded57b8c68c0aabfea316b98e0 100644 (file)
@@ -357,13 +357,24 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                return $this->hubIsActive;
        }
 
+       /**
+        * Setter for $hubIsActive attribute
+        *
+        * @param       $hubIsActive    Wether the hub is activer
+        */
+       public final function enableHubIsActive ($hubIsActive = true) {
+               $this->hubIsActive = $hubIsActive;
+       }
+
        /**
         * Activates the hub by doing some final preparation and setting
         * $hubIsActive to true
         *
+        * @param       $requestInstance        A Requestable class
+        * @param       $responseInstance       A Responseable class
         * @return      void
         */
-       public function activateHub () {
+       public function activateHub (Requestable $requestInstance, Responseable $responseInstance) {
                // Checks wether a listener is still active and shuts it down if one
                // is still listening
                if (($this->determineIfListenerIsActive()) && ($this->isHubActive())) {
@@ -371,15 +382,15 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                        $this->shutdownListenerPool();
                } // END - if
 
-               // Initialize the TCP/UDP listener pool
-               $this->initializeListenerPool();
+               // Get the controller here
+               $controllerInstance = Registry::getRegistry()->getInstance('controller');
 
-               // @TODO Do some final preparation
-               $this->partialStub('Do some final preparation before the hub gots activated.');
+               // Run all filters for the hub activation
+               $controllerInstance->executeHubActivationFilters($requestInstance, $responseInstance);
 
                // ----------------------- Last step from here ------------------------
                // Activate the hub. This is ALWAYS the last step in this method
-               $this->hubIsActive = true;
+               $this->enableHubIsActive();
                // ---------------------- Last step until here ------------------------
        }
 
@@ -388,7 +399,10 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
         *
         * @return      void
         */
-       private function initializeListenerPool () {
+       public function initializeListenerPool () {
+               // Debug output
+               $this->debugOutput('HUB: Initializing listeners...');
+
                // Get a new pool instance
                $this->listenerPoolInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this));
 
@@ -435,6 +449,9 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
 
                // Add this listener to the pool
                $this->listenerPoolInstance->addListener($decoratorInstance);
+
+               // Debug output
+               $this->debugOutput('HUB: All listeners are initialized.');
        }
 }