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
$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();
// 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
// -------------------------- 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();
}
/**
// 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');
* @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.');
}
$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'));
}
}
* @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');
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.');
}
}
--- /dev/null
+<?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]
+?>