]> git.mxchange.org Git - hub.git/commitdiff
Bootstrap filter for initialization of queues added, bootstrap filters should work now
authorRoland Häder <roland@mxchange.org>
Thu, 23 Jul 2009 22:50:42 +0000 (22:50 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 23 Jul 2009 22:50:42 +0000 (22:50 +0000)
.gitattributes
application/hub/class_ApplicationHelper.php
application/hub/config.php
application/hub/main/commands/console/class_HubConsoleMainCommand.php
application/hub/main/filter/bootstrap/class_
application/hub/main/filter/bootstrap/class_HubBootstrapInitQueuesFilter.php [new file with mode: 0644]

index 229668f8ef454fe3b401a20834a520324f896228..358421f21242e26ca36b7256fb300aba7b8fb0b2 100644 (file)
@@ -62,6 +62,7 @@ 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_HubBootstrapGenSessionIdFilter.php -text
+application/hub/main/filter/bootstrap/class_HubBootstrapInitQueuesFilter.php -text
 application/hub/main/filter/bootstrap/class_HubBootstrapRestoreNodeListFilter.php -text
 application/hub/main/filter/console/.htaccess -text
 application/hub/main/filter/console/class_Console -text
index 7a78ebb171f6fbfacac525ec72a36152f79af8d8..c3c3efd4c06d1cf1a856200901e1777e82b27c38 100644 (file)
@@ -194,7 +194,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                $resolverInstance = ObjectFactory::createObjectByName($resolverClass, array($commandName, $this));
 
                // Get a controller instance as well
-               $this->controllerInstance = $resolverInstance->resolveController();
+               $this->setControllerInstance($resolverInstance->resolveController());
 
                // Get the registry
                $registryInstance = Registry::getRegistry();
@@ -202,23 +202,10 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                // Set this application
                $registryInstance->addInstance('app', $this);
 
-               // Handle the request
-               $this->controllerInstance->handleRequest($requestInstance, $responseInstance);
+               // Launch the hub main routine here
+               $this->getControllerInstance()->handleRequest($requestInstance, $responseInstance);
                die("STOP\n");
 
-               // ----------------------- Bootstrapping phase ------------------------
-               // Try to bootstrap the node and pass the request instance to it for
-               // extra arguments which mostly override config entries or enable special
-               // features within the hub (none is ready at this development stage)
-               $this->debugOutput('BOOTSTRAP: Beginning with bootstrap...');
-               $nodeInstance->doBootstrapping();
-               $this->debugOutput('BOOTSTRAP: Bootstrap finished.');
-
-               // ----------------------- Init all query queues ----------------------
-               // After the bootstrap is done we need to initialize the queues which
-               // will help us to communicate between the "tasks" a hub needs to do.
-               $nodeInstance->initQueues();
-
                // -------------------------- Hub activation --------------------------
                // Activates the hub by doing some final preparation steps and setting
                // the attribute $hubIsActive to true
@@ -234,7 +221,8 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                // -------------------------- Shutdown phase --------------------------
                // Shutting down the hub by saying "good bye" to all connected clients
                // and other hubs, flushing all queues and caches.
-               $nodeInstance->doShutdown();
+               $this->controllerInstance->executeShutdownFilters($requestInstance, $responseInstance);
+               //$nodeInstance->doShutdown();
        }
 
        /**
index 09eaab9473f10d93c92e0340d44bc5582816816b..46f2acf83fe13972bbbaac04692183785baeb052 100644 (file)
@@ -111,6 +111,9 @@ $cfg->setConfigEntry('hub_bootstrap_gen_sessionid_filter', 'HubBootstrapGenSessi
 // CFG: HUB-BOOTSTRAP-RESTORE-NODELIST-FILTER
 $cfg->setConfigEntry('hub_bootstrap_restore_nodelist_filter', 'HubBootstrapRestoreNodeListFilter');
 
+// CFG: HUB-BOOTSTRAP-INIT-QUEUES-FILTER
+$cfg->setConfigEntry('hub_bootstrap_init_queues_filter', 'HubBootstrapInitQueuesFilter');
+
 // CFG: NEWS-READER-CLASS
 $cfg->setConfigEntry('news_reader_class', 'ConsoleNewsReader');
 
index d89548d8ed2485f997b3bc034963fed211408af8..052d7ef556b7b958cabdc2ac77b18d44239440c8 100644 (file)
@@ -55,9 +55,32 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable {
         * @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
+        * @throws      NullPointerException    When $applicationInstance is null
+        * @throws      InvalidInterfaceException       When $applicationInstance does not implement ManageableApplication
+        * @todo        ~10% done
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get a registry and the application instance from it
+               $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+               // Is this a ManageableApplication instance?
+               if (is_null($applicationInstance)) {
+                       // Something really bad went wrong
+                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+               } elseif (!$applicationInstance instanceof ManageableApplication) {
+                       // Something went badly wrong
+                       throw new InvalidInterfaceException(array($this, 'ManageableApplication'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
+               } // END - if
+
+               // ----------------------- Bootstrapping phase ------------------------
+               // Try to bootstrap the node and pass the request instance to it for
+               // extra arguments which mostly override config entries or enable special
+               // features within the hub (none is ready at this development stage)
+               $this->debugOutput('BOOTSTRAP: Beginning with bootstrap...');
+               $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance);
+               $this->debugOutput('BOOTSTRAP: Bootstrap finished.');
+
+               // Still unfinished:
                $this->partialStub('Unfinished method.');
        }
 
@@ -77,6 +100,7 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable {
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_aquire_hubid_filter'));
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_gen_sessionid_filter'));
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_restore_nodelist_filter'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_init_queues_filter'));
        }
 }
 
index 058c86450288cd0a69e2c4e7e07004a51cb5e9df..25b2ee3392b72fc283e8513642c945c39cf6c056 100644 (file)
@@ -53,69 +53,6 @@ class HubBootstrap???Filter extends BaseFilter implements Filterable {
         * @return      void
         * @todo        0% done
         */
-       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               // Implement this!
-               $this->partialStub('Please implement this method.');
-       }
-}
-
-// [EOF]
-?>
-<?php
-/**
- * A welcome-teaser filter for the console
- *
- * @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 ConsoleWelcomeTeaserFilter 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 createConsoleWelcomeTeaserFilter () {
-               // Get a new instance
-               $filterInstance = new ConsoleWelcomeTeaserFilter();
-
-               // 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
-        * @throws      FilterChainException    If the nodeInstance was not set
-        */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get node instance
                $nodeInstance = Registry::getRegistry()->getInstance('node');
@@ -126,8 +63,8 @@ class ConsoleWelcomeTeaserFilter extends BaseFilter implements Filterable {
                        throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } // END - if
 
-               // Now output the teaser
-               $nodeInstance->outputConsoleTeaser();
+               // Now do something
+               $this->partialStub('Please implement this step.');
        }
 }
 
diff --git a/application/hub/main/filter/bootstrap/class_HubBootstrapInitQueuesFilter.php b/application/hub/main/filter/bootstrap/class_HubBootstrapInitQueuesFilter.php
new file mode 100644 (file)
index 0000000..dff9651
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A InitQueues 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 HubBootstrapInitQueuesFilter 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 createHubBootstrapInitQueuesFilter () {
+               // Get a new instance
+               $filterInstance = new HubBootstrapInitQueuesFilter();
+
+               // 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 init the queues
+               $nodeInstance->initQueues();
+       }
+}
+
+// [EOF]
+?>