]> git.mxchange.org Git - hub.git/commitdiff
Task handler added, a lot rewrites
authorRoland Häder <roland@mxchange.org>
Tue, 11 Aug 2009 21:48:33 +0000 (21:48 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 11 Aug 2009 21:48:33 +0000 (21:48 +0000)
- Task handler added
- New Interface HandleableTask added (for task handlers)
- A lot interfaces/classes/exceptions extended (sorry for lame description)
- State resolver added (shouldn't we move this to core?)

56 files changed:
.gitattributes
application/hub/config.php
application/hub/debug.php
application/hub/exceptions/lists/class_InvalidListHashException.php
application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php
application/hub/exceptions/lists/class_NoListGroupException.php
application/hub/interfaces/handler/class_Handleable.php
application/hub/interfaces/handler/network/class_Networkable.php
application/hub/interfaces/handler/task/.htaccess [new file with mode: 0644]
application/hub/interfaces/handler/task/class_HandleableTask.php [new file with mode: 0644]
application/hub/interfaces/pool/class_PoolableClient.php [deleted file]
application/hub/interfaces/pool/class_PoolableListener.php [deleted file]
application/hub/interfaces/visitor/class_Visitable.php
application/hub/interfaces/visitor/class_Visitor.php
application/hub/interfaces/visitor/pool/class_PoolVisitor.php
application/hub/interfaces/visitor/pool/listener/class_ListenerPoolVisitor.php
application/hub/main/commands/console/class_HubConsoleMainCommand.php
application/hub/main/connectors/query/local/class_LocalQueryConnector.php
application/hub/main/controller/console/class_HubConsoleDefaultNewsController.php
application/hub/main/filter/activation/class_HubActivation
application/hub/main/filter/bootstrap/class_HubBootstrap
application/hub/main/filter/bootstrap/class_HubBootstrapExtraBootstrappingFilter.php
application/hub/main/filter/bootstrap/class_HubBootstrapGenerateHubIdFilter.php
application/hub/main/filter/bootstrap/class_HubBootstrapGenerateSessionIdFilter.php
application/hub/main/filter/bootstrap/class_HubBootstrapInitQueuesFilter.php
application/hub/main/filter/bootstrap/class_HubBootstrapListenerPoolFilter.php
application/hub/main/filter/bootstrap/class_HubBootstrapRestoreNodeListFilter.php
application/hub/main/filter/class_
application/hub/main/filter/console/class_Console
application/hub/main/filter/console/class_ConsoleWelcomeTeaserFilter.php
application/hub/main/filter/node/class_Node
application/hub/main/filter/node/class_NodeInitializationFilter.php
application/hub/main/filter/shutdown/class_HubShutdown
application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php
application/hub/main/filter/shutdown/class_HubShutdownFlushNodeListFilter.php
application/hub/main/filter/shutdown/class_HubShutdownListenerPoolFilter.php
application/hub/main/filter/shutdown/class_HubShutdownNodeFilter.php
application/hub/main/filter/task/.htaccess [new file with mode: 0644]
application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php [new file with mode: 0644]
application/hub/main/handler/network/class_
application/hub/main/handler/network/class_BaseNetworkPackageHandler.php
application/hub/main/handler/network/tcp/class_ [new file with mode: 0644]
application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php
application/hub/main/handler/network/udp/class_UdpNetworkPackageHandler.php
application/hub/main/handler/tasks/.htaccess [new file with mode: 0644]
application/hub/main/handler/tasks/class_TaskHandler.php [new file with mode: 0644]
application/hub/main/listener/tcp/class_TcpListener.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/resolver/command/console/class_HubConsoleCommandResolver.php
application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php
application/hub/main/resolver/state/.htaccess [new file with mode: 0644]
application/hub/main/resolver/state/class_BaseStateResolver.php [new file with mode: 0644]
application/hub/main/resolver/state/network/.htaccess [new file with mode: 0644]
application/hub/main/resolver/state/network/class_NetworkStateResolver.php [new file with mode: 0644]
application/hub/main/states/generic/.htaccess [new file with mode: 0644]
index.php

index a0c821e2cceb380b943259f1ad12c612ef6e9693..83bf2e2b3b7fa0f9e8bc546957129b0b19fafb56 100644 (file)
@@ -20,6 +20,8 @@ application/hub/interfaces/handler/.htaccess -text
 application/hub/interfaces/handler/class_Handleable.php -text
 application/hub/interfaces/handler/network/.htaccess -text
 application/hub/interfaces/handler/network/class_Networkable.php -text
+application/hub/interfaces/handler/task/.htaccess -text
+application/hub/interfaces/handler/task/class_HandleableTask.php -text
 application/hub/interfaces/listener/.htaccess -text
 application/hub/interfaces/listener/class_Listenable.php -text
 application/hub/interfaces/lists/.htaccess -text
@@ -28,8 +30,6 @@ application/hub/interfaces/nodes/.htaccess -text
 application/hub/interfaces/nodes/class_NodeHelper.php -text
 application/hub/interfaces/pool/.htaccess -text
 application/hub/interfaces/pool/class_Poolable.php -text
-application/hub/interfaces/pool/class_PoolableClient.php -text
-application/hub/interfaces/pool/class_PoolableListener.php -text
 application/hub/interfaces/pool/client/.htaccess -text
 application/hub/interfaces/pool/client/class_PoolableClient.php -text
 application/hub/interfaces/pool/listener/.htaccess -text
@@ -105,6 +105,8 @@ application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php -te
 application/hub/main/filter/shutdown/class_HubShutdownFlushNodeListFilter.php -text
 application/hub/main/filter/shutdown/class_HubShutdownListenerPoolFilter.php -text
 application/hub/main/filter/shutdown/class_HubShutdownNodeFilter.php -text
+application/hub/main/filter/task/.htaccess -text
+application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php -text
 application/hub/main/handler/.htaccess -text
 application/hub/main/handler/class_ -text
 application/hub/main/handler/class_BaseHandler.php -text
@@ -112,9 +114,12 @@ application/hub/main/handler/network/.htaccess -text
 application/hub/main/handler/network/class_ -text
 application/hub/main/handler/network/class_BaseNetworkPackageHandler.php -text
 application/hub/main/handler/network/tcp/.htaccess -text
+application/hub/main/handler/network/tcp/class_ -text
 application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php -text
 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/iterator/.htaccess -text
 application/hub/main/iterator/class_ -text
 application/hub/main/iterator/class_BaseIterator.php -text
@@ -182,11 +187,16 @@ application/hub/main/resolver/command/console/class_HubConsoleCommandResolver.ph
 application/hub/main/resolver/controller/.htaccess -text
 application/hub/main/resolver/controller/console/.htaccess -text
 application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php -text
+application/hub/main/resolver/state/.htaccess -text
+application/hub/main/resolver/state/class_BaseStateResolver.php -text
+application/hub/main/resolver/state/network/.htaccess -text
+application/hub/main/resolver/state/network/class_NetworkStateResolver.php -text
 application/hub/main/states/.htaccess -text
 application/hub/main/states/class_ -text
 application/hub/main/states/class_BaseState.php -text
 application/hub/main/states/client/.htaccess -text
 application/hub/main/states/client/class_BaseClientState.php -text
+application/hub/main/states/generic/.htaccess -text
 application/hub/main/states/hub/.htaccess -text
 application/hub/main/states/hub/class_BaseHubState.php -text
 application/hub/main/visitor/.htaccess -text
index ddf8b6fd43b66d2142a3b0affd1b70ac7a60494f..380a74b26f653698498e3ab6dab83da8f2fd16e9 100644 (file)
@@ -117,15 +117,21 @@ $cfg->setConfigEntry('default_hubconsole_command', 'main');
 // CFG: HUBCONSOLE-CMD-RESOLVER-CLASS
 $cfg->setConfigEntry('hubconsole_cmd_resolver_class', 'HubConsoleCommandResolver');
 
+// CFG: NETWORK-STATE-RESOLVER-CLASS
+$cfg->setConfigEntry('network_state_resolver_class', 'NetworkStateResolver');
+
 // CFG: NEWS-DOWNLOAD-FILTER
 $cfg->setConfigEntry('news_download_filter', 'NewsDownloadFilter');
 
 // CFG: NEWS-PROCESS-FILTER
 $cfg->setConfigEntry('news_process_filter', 'NewsProcessFilter');
 
-// CFG: NODE-INITIALIZATION-FILTER
+// CFG: NODE-INITIALIZER-FILTER
 $cfg->setConfigEntry('node_initializer_filter', 'NodeInitializationFilter');
 
+// CFG: HUB-ACTIVATION-TASK-HANDLER-INITIALIZER-FILTER
+$cfg->setConfigEntry('hub_activation_task_handler_initializer_filter', 'TaskHandlerInitializerFilter');
+
 // CFG: CONSOLE-WELCOME-TEASER-FILTER
 $cfg->setConfigEntry('console_welcome_teaser_filter', 'ConsoleWelcomeTeaserFilter');
 
@@ -165,5 +171,20 @@ $cfg->setConfigEntry('news_reader_class', 'ConsoleNewsReader');
 // CFG: NEWS-MAIN-LIMIT
 $cfg->setConfigEntry('news_main_limit', 5);
 
+// CFG: TASK-HANDLER-CLASS
+$cfg->setConfigEntry('task_handler_class', 'TaskHandler');
+
+// CFG: TASK-NETWORK-PACKAGE-READER-STARTUP-DELAY
+$cfg->setConfigEntry('task_network_package_reader_startup_delay', 5000);
+
+// CFG: TASK-NETWORK-PACKAGE-READER-INTERVAL-DELAY
+$cfg->setConfigEntry('task_network_package_reader_interval_delay', 10);
+
+// CFG: TASK-QUERY-HANDLER-STARTUP-DELAY
+$cfg->setConfigEntry('task_query_handler_startup_delay', 3000);
+
+// CFG: TASK-QUERY-HANDLER-INTERVAL-DELAY
+$cfg->setConfigEntry('task_query_handler_interval_delay', 10);
+
 // [EOF]
 ?>
index 3103b74bf83586d0371a09e977ba3cba080b7106..5f222924a04d1fc7906d74133e6ec6ecf18c3221 100644 (file)
@@ -21,8 +21,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-// Hub main loop debugging
-define('HUB_DEBUG_MAIN', true);
+// Set error reporting
+error_reporting(E_ALL | E_STRICT);
 
 // [EOF]
 ?>
index faf6bb01fea187454c83940f975986f38fe2dd43..19f1b60f0b8fd33893b243a80576bd856bede9f9 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
index d401037dca27cd4fb442279cd8807070dfad1693..fc7098ed7f8c8bdefb805d2eb8e179676517defa 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
index ee8e28284de6bae794ce519c2d237ba671b932fd..6348edf2b61d716f72922bc3e197347db5717737 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
index a143bced37eb17dc7dbfe2112ddaff2b1b8ed66b..e7775272ae1e83b02a80b9d0b7c751d4d4135ade 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
index bb4ce5028218489dd395b949a32fc5dc38f7e4e8..fb4302141e00ff77f263d1234c0190fe01f6262a 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface Networkable extends Handleable {
+       /**
+        * Processes a package from given resource. This is mostly useful for TCP
+        * package handling and is implemented in the TcpListener class
+        *
+        * @param       $resource       A valid resource identifier
+        * @return      void
+        * @throws      InvalidResourceException        If the given resource is invalid
+        */
+       function processResourcePackage ($resource);
 }
 
 //
diff --git a/application/hub/interfaces/handler/task/.htaccess b/application/hub/interfaces/handler/task/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/handler/task/class_HandleableTask.php b/application/hub/interfaces/handler/task/class_HandleableTask.php
new file mode 100644 (file)
index 0000000..7bcb9df
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+/**
+ * A HandleableTask interface
+ *
+ * @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/>.
+ */
+interface HandleableTask extends Handleable {
+       /**
+        * Registers a task with a task handler. This method throws a
+        * TaskAlreadyRegisteredException if the task has already been registered
+        *
+        * @param       $taskName       A task name to register the task on
+        * @param       $taskInstance   The instance we should register as a task
+        * @return      void
+        */
+       function registerTask ($taskName, Visitable $taskInstance);
+}
+
+//
+?>
diff --git a/application/hub/interfaces/pool/class_PoolableClient.php b/application/hub/interfaces/pool/class_PoolableClient.php
deleted file mode 100755 (executable)
index c74c72f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * A default client pool class
- *
- * @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/>.
- */
-interface PoolableClient extends Poolable {
-       /**
-        * Adds a socket resource to the client pool
-        *
-        * @param       $socketResource         A valid (must be!) socket resource
-        * @return      void
-        * @todo        0% done
-        */
-       function addClient ($socketResource);
-}
-
-//
-?>
diff --git a/application/hub/interfaces/pool/class_PoolableListener.php b/application/hub/interfaces/pool/class_PoolableListener.php
deleted file mode 100755 (executable)
index 162d8a6..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * An interface for pools
- *
- * @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/>.
- */
-interface PoolableListener extends Poolable {
-       /**
-        * Adds a listener instance to this pool
-        *
-        * @param       $listenerInstance       An instance of a Listenable class
-        * @return      void
-        */
-       function addListener (Listenable $listenerInstance);
-}
-
-//
-?>
index 8319c3163bd34394cf7852f17b1de865864070e8..6211f0548d8afb63283a92b398d5bd529befc875 100644 (file)
@@ -31,5 +31,5 @@ interface Visitable extends FrameworkInterface {
        function accept (Visitor $visitorInstance);
 }
 
-//
+// [EOF]
 ?>
index e2bce79239ce4895343e8805561e7afa56b364f9..b098a70e6259864148186a8b5028892493afd1f9 100644 (file)
@@ -24,5 +24,5 @@
 interface Visitor extends FrameworkInterface {
 }
 
-//
+// [EOF]
 ?>
index f7df6893e2fb434e49dc8d311f6cbe3e5a7c3362..6a9b6c8e0f9116af2a52277ddd70a51404b71de8 100644 (file)
@@ -31,5 +31,5 @@ interface PoolVisitor extends Visitor {
        function visitPool (Poolable $poolInstance);
 }
 
-//
+// [EOF]
 ?>
index e99be2dc034fff3577828c1e3da998d3e1326c87..109b75d3ab8b2f06c2d92b4daaf70e0c10713dfb 100644 (file)
@@ -39,5 +39,5 @@ interface ListenerPoolVisitor extends PoolVisitor {
        function visitDecorator (Listenable $listenerInstance);
 }
 
-//
+// [EOF]
 ?>
index c9e4a44b0a5f277e7040fd6c2394724868b7037e..4be290c5269ec99e0526d384cb2d5e427c091667 100644 (file)
@@ -1,10 +1,10 @@
 <?php
 /**
- * A command for 'main'
+ * A command for the 'main' routine
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -55,23 +55,11 @@ 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
-        * @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
@@ -83,17 +71,14 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable {
                // Get node instance
                $nodeInstance = Registry::getRegistry()->getInstance('node');
 
-               // Sanity-check on it
-               if (is_null($nodeInstance)) {
-                       // Throws a NullPointerException here
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } // END - if
-
                // -------------------------- Hub activation --------------------------
                // Activates the hub by doing some final preparation steps and setting
                // the attribute $hubIsActive to true
                $nodeInstance->activateHub($requestInstance, $responseInstance);
 
+               // Get task handler instance
+               $handlerInstance = Registry::getRegistry()->getInstance('task');
+
                // Debug message
                $this->debugOutput('MAIN: --- Entering main loop. ---');
 
@@ -101,7 +86,7 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable {
                // This is the main loop. Queried calls should come back here very fast
                // so the whole application runs on nice speed. This while-loop goes
                // until the hub is no longer active.
-               while ($nodeInstance->isHubActive()) {
+               while (($nodeInstance->isHubActive()) && ($handlerInstance->hasTasksLeft())) {
                        // Handle the listeners
                        // @TODO We may have to catch some exceptions here
                        $nodeInstance->getListenerPoolInstance()->handleListenerPool();
@@ -136,6 +121,7 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable {
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('hub_bootstrap_listener_pool_filter'));
 
                // Add hub activation filters
+               $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('hub_activation_task_handler_initializer_filter'));
 
                // Add shutdown filters
                $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('hub_shutdown_flush_node_list_filter'));
index 8dbdc5becabc3534fc019dd45bade9f24e23bed7..c410ca156cb3adfeab84ff22911b2ce0e59bb4d3 100644 (file)
@@ -21,7 +21,7 @@
  * 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 LocalQueryConnector extends BaseQueryConnector implements Connectable, Queryable {
+class LocalQueryConnector extends BaseQueryConnector implements Connectable, Queryable, Visitable {
        /**
         * Protected constructor
         *
@@ -48,6 +48,16 @@ class LocalQueryConnector extends BaseQueryConnector implements Connectable, Que
                // Finally return it
                return $connectorInstance;
        }
+
+       /**
+        * Accepts the visitor to rpocess the visit "request"
+        *
+        * @param       $visitorInstance        An instance of a Visitor class
+        * @return      void
+        */
+       public function accept (Visitor $visitorInstance) {
+               $this->partialStub('visitor='.$visitorInstance->__toString());
+       }
 }
 
 // [EOF]
index 9c2068eb62b82291a8db729528ce26888a82a877..842bd2606d1c20756144b994e7e968cb30933d09 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -115,7 +115,7 @@ class HubConsoleDefaultNewsController extends BaseController implements Controll
         * @param       $filterInstance         A Filterable class
         * @return      void
         */
-       public function addHubActivationFilter (Filterable $filterInstance) {
+       public function addActivationFilter (Filterable $filterInstance) {
                $this->addFilter('activation', $filterInstance);
        }
 
@@ -126,7 +126,7 @@ class HubConsoleDefaultNewsController extends BaseController implements Controll
         * @param       $responseInstance       A Responseable class
         * @return      void
         */
-       public function executeHubActivationFilters (Requestable $requestInstance, Responseable $responseInstance) {
+       public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) {
                $this->executeFilters('activation', $requestInstance, $responseInstance);
        }
 
index 5c3d3dd44e4e6339d23140399939636ffaf9bda3..babe0647026d0323e9af67a8fbbdbf0f9c88b7f7 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -57,12 +57,6 @@ class HubActivation???Filter extends BaseFilter implements Filterable {
                // 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.');
        }
index 25b2ee3392b72fc283e8513642c945c39cf6c056..37520419c403af5bfacf9b082fdb9d84b0e2b805 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -57,12 +57,6 @@ class HubBootstrap???Filter extends BaseFilter implements Filterable {
                // 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.');
        }
index ed47a082f67a1a109e923689bc9b9b518a68296a..cb7474687925fc46efa4955ccd12dce367da54f8 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -57,12 +57,6 @@ class HubBootstrapExtraBootstrappingFilter extends BaseFilter implements Filtera
                // 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
-
                // Do some extra bootstrapping steps
                $nodeInstance->doBootstrapping();
        }
index e00ca12c3dfd4c42960a4173c687f3fa04fe1333..e922b5798b3fdf78e5fa6b2e1bf8c7dc80d7a2d2 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -57,12 +57,6 @@ class HubBootstrapGenerateHubIdFilter extends BaseFilter implements Filterable {
                // 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
-
                // --------------------- Hub-id acquirement phase ---------------------
                // Acquire a hub-id. This step generates on first launch a new one and
                // on any later launches it will restore the hub-id from the database.
index 1dcaf870bfcbc937112d750d4c73dc4bd823b2b2..e8ae454ae02d1774bb3ff5349c9e4d09b9d423a5 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -57,12 +57,6 @@ class HubBootstrapGenerateSessionIdFilter extends BaseFilter implements Filterab
                // 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
-
                // ------------------- More generic bootstrap steps -------------------
                // Generate the session id which will only be stored in RAM and kept for
                // the whole "session".
index 27882b4c2e7365193dbaa87a92f2975faf5a309c..5bb4f15729290d18b264d1dabdf3eded450494fa 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -57,12 +57,6 @@ class HubBootstrapInitQueuesFilter extends BaseFilter implements Filterable {
                // 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();
        }
index b083bcb40fc60dc761e52d4ad4e2bb105bffed89..7fdcd3adafb81c17222a62b80010c87427051eaa 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -57,12 +57,6 @@ class HubBootstrapListenerPoolFilter extends BaseFilter implements Filterable {
                // 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();
        }
index b889d2b373259439982988c9677ef829be48c0cb..6def96e30b361bce7e39664fb50189cc6c70b7e4 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -57,12 +57,6 @@ class HubBootstrapRestoreNodeListFilter extends BaseFilter implements Filterable
                // 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
-
                // Restore a previously downloaded bootstrap-node list.
                $nodeInstance->bootstrapRestoreNodeList();
        }
index 382b6859d75ad5d628d89c17d30980bfc4da8446..f432f10795e97c99d29a1c1c9e8ba52415123218 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -58,12 +58,6 @@ class Hub!!!???Filter extends BaseFilter implements Filterable {
                // 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.');
        }
index 6d5c26efe27bc68f8da95f5001eb43647d096302..52f584f362e59ad65b3a38753b044abbf2a0061c 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -58,12 +58,6 @@ class Console???Filter extends BaseFilter implements Filterable {
                // 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
-
                // Implement this!
                $this->partialStub('Please implement this method.');
        }
index 065be4bf24bf06c3b54212a3ab0fd4c3223ae97c..29e7282c47b548763a9b18ba0d904fb47f1e93a7 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -57,12 +57,6 @@ class ConsoleWelcomeTeaserFilter extends BaseFilter implements Filterable {
                // 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 output the teaser
                $nodeInstance->outputConsoleTeaser();
        }
index 355b084a53bc8888f0592e1e10486724d6e0c811..9495b56af0716625c900a76ede3ba3b9d513c6b4 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
index 5dd157e7cc3e50382882470b9c8ce5e57335d71d..55471b16125c228d02b41addddef447d6c1b0f4d 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
index e5bf7332111cd2f5d786132291ae78f79127a72c..aeefaf44f9096b138f90e5118f9122dc91f39ea6 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -58,12 +58,6 @@ class HubShutdown???Filter extends BaseFilter implements Filterable {
                // 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.');
        }
index 299cc7c838a0d8a7a31a901bfd30bc3e4ab5ebce..aba685df3ad48393616540938ef6d4c8423ff9fa 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -58,12 +58,6 @@ class HubShutdownDeinitQueuesFilter extends BaseFilter implements Filterable {
                // 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
-
                // Get query instance
                $queryInstance = $nodeInstance->getQueryInstance();
 
index f55f3f0349528b9ddd80aba9ac2f459df079b1a7..28c169e771ae58c4f59b676ac096d36a5553f51b 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -58,12 +58,6 @@ class HubShutdownFlushNodeListFilter extends BaseFilter implements Filterable {
                // 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.');
        }
index 5a1e79d5a48834785720aad4d6a41ce0f7226d9f..f9e725df560fcfb7741a7b6a562e04fbc52daa8f 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -58,12 +58,6 @@ class HubShutdownListenerPoolFilter extends BaseFilter implements Filterable {
                // 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
-
                // Get listener pool instance
                $listenerPoolInstance = $nodeInstance->getListenerPoolInstance();
 
index 826acd48a702a36836d09491591c96163c5cfadc..56919564ef8554e7fc1dbaa230f48ee18feab801 100644 (file)
@@ -6,7 +6,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
@@ -59,12 +59,6 @@ class HubShutdownNodeFilter extends BaseFilter implements Filterable {
                // 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
-
                // Shutdown the node. This should be the last line
                $nodeInstance->doShutdown();
        }
diff --git a/application/hub/main/filter/task/.htaccess b/application/hub/main/filter/task/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php b/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php
new file mode 100644 (file)
index 0000000..1da56ef
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+/**
+ * A ??? filter for !!!
+ *
+ * @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 TaskHandlerInitializerFilter 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 createTaskHandlerInitializerFilter () {
+               // Get a new instance
+               $filterInstance = new TaskHandlerInitializerFilter();
+
+               // 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 we need to interrupt the filter chain
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               // Get a new task handler instance
+               $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class');
+
+               // Register some tasks and provide both instances for this:
+               // 1.) Network package reader, needs to be delayed a little
+               $handlerInstance->registerTask('network_package_reader', $nodeInstance->getListenerPoolInstance());
+               // 2.) Query instance
+               $handlerInstance->registerTask('query_handler', $nodeInstance->getQueryInstance());
+
+               // Put the task handler in registry
+               Registry::getRegistry()->addInstance('task', $handlerInstance);
+       }
+}
+
+// [EOF]
+?>
index 57d7a75a080f233df0ab2b1dbe9723e2df41e930..b130b4662905ea54df957a7298ff2006f4f20f20 100644 (file)
@@ -21,7 +21,7 @@
  * 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 ???NetworkPackageHandler extends BaseNetworkPackageHandler implements !!! {
+class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements Networkable {
        /**
         * Protected constructor
         *
@@ -35,7 +35,7 @@ class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements !!!
        /**
         * Creates an instance of this class
         *
-        * @return      $handlerInstance                An instance of a !!! class
+        * @return      $handlerInstance                An instance of a Networkable class
         */
        public final static function create???NetworkPackageHandler () {
                // Get new instance
@@ -44,6 +44,26 @@ class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements !!!
                // Return the prepared instance
                return $handlerInstance;
        }
+
+       /**
+        * Processes a package from given resource. This is mostly useful for TCP
+        * package handling and is implemented in the TcpListener class
+        *
+        * @param       $resource       A valid resource identifier
+        * @return      void
+        * @throws      InvalidResourceException        If the given resource is invalid
+        * @todo        0%
+        */
+       public function processResourcePackage ($resource) {
+               // Check the resource
+               if (!is_resource($resource)) {
+                       // Throw an exception
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
+               } // END - if
+
+               // Implement processing here
+               $this->partialStub('Please implement this method.');
+       }
 }
 
 // [EOF]
index b9762e384666bd79493661f77a2b6f6088c8235a..8d13405f66d463c49b05d73a8259fb40cc69dc31 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseNetworkPackageHandler extends BaseHandler {
+       // Error codes
+       const SOCKET_ERROR_GENERAL            = 'general_error';
+       const SOCKET_ERROR_TRANSPORT_ENDPOINT = 'transport_endpoint';
+       const SOCKET_ERROR_UNHANDLED          = 'unhandled_package';
+       const SOCKET_ERROR_EMPTY_DATA         = 'empty_data';
+       const PACKAGE_ERROR_INVALID_DATA      = 'invalid_data';
+       const PACKAGE_LEVEL_CHECK_OKAY        = 'checked_package';
+
+       /**
+        * Error code from socket
+        */
+       private $errorCode = -1;
+
        /**
         * Protected constructor
         *
@@ -32,6 +45,25 @@ class BaseNetworkPackageHandler extends BaseHandler {
                // Call parent constructor
                parent::__construct($className);
        }
+
+       /**
+        * Setter for error code
+        *
+        * @param       $errorCode      The error code we shall set
+        * @return      void
+        */
+       protected final function setErrorCode ($errorCode) {
+               $this->errorCode = $errorCode;
+       }
+
+       /**
+        * Getter for error code
+        *
+        * @return      $errorCode      The error code
+        */
+       public final function getErrorCode () {
+               return $this->errorCode;
+       }
 }
 
 // [EOF]
diff --git a/application/hub/main/handler/network/tcp/class_ b/application/hub/main/handler/network/tcp/class_
new file mode 100644 (file)
index 0000000..9681823
--- /dev/null
@@ -0,0 +1,208 @@
+while (count($clients) > 0) {
+       // create a copy, so $clients doesn't get modified by socket_select()
+       $read = $clients;
+
+       // get a list of all the clients that have data to be read from
+       // if there are no clients with data, go to next iteration
+       $left = @socket_select($read, $write = null, $except = null, 0, 150);
+       if ($left < 1) {
+               continue;
+       }
+
+       // check if there is a client trying to connect
+       if (in_array($mainSocket, $read)) {
+               // accept the client, and add him to the $clients array
+               $new_sock = socket_accept($mainSocket);
+               $clients[] = $new_sock;
+
+               // send the client a welcome message
+               socket_write($new_sock, "No noobs, but I'll make an exception. :)\n".
+               "There are ".(count($clients) - 1)." client(s) connected to the server.\n");
+
+               socket_getpeername($new_sock, $ip);
+               out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:New client connected: {$ip}");
+
+               // Notify all chatter
+               if (count($clients) > 2) {
+                       foreach ($clients as $send_sock) {
+                               if ($send_sock != $mainSocket && $send_sock != $new_sock) {
+                                       socket_write($send_sock, "Server: Chatter has joined from {$ip}. There are now ".(count($clients) - 1)." clients.\n");
+                               }
+                       }
+               }
+
+               // remove the listening socket from the clients-with-data array
+               $key = array_search($mainSocket, $read);
+               unset($read[$key]);
+       }
+
+       // loop through all the clients that have data to read from
+       foreach ($read as $read_sock) {
+               // Get client data
+               socket_getpeername($read_sock, $ip);
+
+               // read until newline or 1024 bytes
+               // socket_read while show errors when the client is disconnected, so silence the error messages
+               $data = @socket_read($read_sock, 1024, PHP_NORMAL_READ);
+
+               // check if the client is disconnected
+               if (($data === false) || (in_array(strtolower(trim($data)), $leaving))) {
+
+                       // remove client for $clients array
+                       $key = array_search($read_sock, $clients);
+                       unset($clients[$key]);
+                       out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client from {$ip} disconnected. Left: ".(count($clients) - 1)."");
+
+                       // Notify all chatter
+                       if (count($clients) > 1) {
+                               foreach ($clients as $send_sock) {
+                                       if ($send_sock != $mainSocket) {
+                                               socket_write($send_sock, "Server: Chatter from {$ip} has logged out. ".(count($clients) - 1)." client(s) left.\n");
+                                       }
+                               }
+                       }
+
+                       // continue to the next client to read from, if any
+                       socket_write($read_sock, "Server: Good bye.\n");
+                       socket_shutdown($read_sock, 2);
+                       socket_close($read_sock);
+                       continue;
+               } elseif (in_array(trim($data), $shutdown)) {
+                       // Is he allowed to shutdown?
+                       if (!in_array($ip, $masters)) {
+                               out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has tried to shutdown the server!");
+                               socket_write($read_sock, "Server: You are not allowed to shutdown the server!\n");
+                               $data = "";
+                               continue;
+                       }
+
+                       // Close all connections a leave here
+                       foreach ($clients as $client) {
+                               // Send message to client
+                               if ($client !== $mainSocket && $client != $read_sock) {
+                                       socket_write($client, "Server: Shutting down! Thank you for joining us.\n");
+                               }
+
+                               // Quit him
+                               socket_shutdown($client, 2);
+                               socket_close($client);
+                       } // end foreach
+
+                       // Leave the loop
+                       $data = "";
+                       $clients = array();
+                       continue;
+               }
+
+               // trim off the trailing/beginning white spaces
+               $data = trim($data);
+
+               // Test for HTML codes
+               $tags = strip_tags($data);
+
+               // check if there is any data after trimming off the spaces
+               if (!empty($data) && $tags == $data && count($clients) > 2) {
+                       // Send confirmation to "chatter"
+                       socket_write($read_sock, "\nServer: Message accepted.\n");
+
+                       // send this to all the clients in the $clients array (except the first one, which is a listening socket)
+                       foreach ($clients as $send_sock) {
+
+                               // if its the listening sock or the client that we got the message from, go to the next one in the list
+                               if ($send_sock == $mainSocket || $send_sock == $read_sock)
+                                       continue;
+
+                               // write the message to the client -- add a newline character to the end of the message
+                               socket_write($send_sock, "{$ip}:{$data}\n");
+
+                       } // end of broadcast foreach
+               } elseif ($tags != $data) {
+                       // HTML codes are not allowed
+                       out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has entered HTML code!");
+                       socket_write($read_sock, "Server: HTML is forbidden!\n");
+               } elseif ((count($clients) == 2) && ($read_sock != $mainSocket)) {
+                       // No one else will hear the "chatter"
+                       out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} speaks with himself.");
+                       socket_write($read_sock, "Server: No one will hear you!\n");
+               }
+       } // end of reading foreach
+}
+
+// close the listening socket
+socket_close($mainSocket);
+
+?>
+<?php
+/**
+ * A TCP ??? listener
+ *
+ * @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 ???Listener extends BaseListener implements Listenable, Visitable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $nodeInstance           A NodeHelper instance
+        * @return      $listenerInstance       An instance a prepared listener class
+        */
+       public final static function create???Listener (NodeHelper $nodeInstance) {
+               // Get new instance
+               $listenerInstance = new ???Listener();
+
+               // Set the application instance
+               $listenerInstance->setNodeInstance($nodeInstance);
+
+               // Return the prepared instance
+               return $listenerInstance;
+       }
+
+       /**
+        * Initializes the listener by setting up the required socket server
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function initListener() {
+               $this->partialStub('Need to implement this method.');
+       }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function doListen() {
+               $this->partialStub('Need to implement this method.');
+       }
+}
+
+// [EOF]
+?>
index 805c7627b958482f8398756f6712acc124df90e0..f2544adcd476ad551a09fede67013fce13f0f4ea 100644 (file)
@@ -35,15 +35,62 @@ class TcpNetworkPackageHandler extends BaseNetworkPackageHandler implements Netw
        /**
         * Creates an instance of this class
         *
-        * @return      $handlerInstance                An instance of a !!! class
+        * @return      $handlerInstance                An instance of a Networkable class
         */
        public final static function createTcpNetworkPackageHandler () {
                // Get new instance
                $handlerInstance = new TcpNetworkPackageHandler();
 
+               // Initialize new resolver instance
+               $resolverInstance = ObjectFactory::createObjectByConfiguredName('network_state_resolver_class');
+
+               // Set it in this class
+               $handlerInstance->setResolverInstance($resolverInstance);
+
                // Return the prepared instance
                return $handlerInstance;
        }
+
+       /**
+        * Processes a package from given resource. This is mostly useful for TCP
+        * package handling and is implemented in the TcpListener class
+        *
+        * @param       $resource       A valid resource identifier
+        * @return      void
+        * @throws      InvalidResourceException        If the given resource is invalid
+        * @todo        0%
+        */
+       public function processResourcePackage ($resource) {
+               // Check the resource
+               if (!is_resource($resource)) {
+                       // Throw an exception
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
+               } // END - if
+
+               // Reset error code to unhandled
+               $this->setErrorCode(self::SOCKET_ERROR_UNHANDLED);
+
+               // Read the raw data from socket
+               $rawData = socket_read($resource, 1500, PHP_BINARY_READ);
+
+               // Is it valid?
+               if (($rawData === false) || (socket_last_error($resource) > 0)) {
+                       // Network error or connection lost
+                       $this->setErrorCode(socket_last_error($resource));
+               } elseif (empty($rawData)) {
+                       // The peer did send nothing to us
+                       $this->setErrorCode(self::SOCKET_ERROR_EMPTY_DATA);
+               } elseif (!$this->isPackageDataValid($rawData)) {
+                       // Invalid package data
+                       $this->setErrorCode(self::PACKAGE_ERROR_INVALID_DATA);
+               } else {
+                       // Low-level checks are all green
+                       $this->setErrorCode(self::PACKAGE_LEVEL_CHECK_OKAY);
+               }
+
+               // Get a state from the resolver for this package
+               $stateInstance = $this->getResolverInstance()->resolveStateByPackage($this, $rawData);
+       }
 }
 
 // [EOF]
index ce6489d7e8962faa911d59f72e15756ba2d65f6f..c62e7fca85099bc54e786f149c3be1509fc27a04 100644 (file)
@@ -35,7 +35,7 @@ class UdpNetworkPackageHandler extends BaseNetworkPackageHandler implements Netw
        /**
         * Creates an instance of this class
         *
-        * @return      $handlerInstance                An instance of a !!! class
+        * @return      $handlerInstance                An instance of a Networkable class
         */
        public final static function createUdpNetworkPackageHandler () {
                // Get new instance
@@ -44,6 +44,26 @@ class UdpNetworkPackageHandler extends BaseNetworkPackageHandler implements Netw
                // Return the prepared instance
                return $handlerInstance;
        }
+
+       /**
+        * Processes a package from given resource. This is mostly useful for TCP
+        * package handling and is implemented in the TcpListener class
+        *
+        * @param       $resource       A valid resource identifier
+        * @return      void
+        * @throws      InvalidResourceException        If the given resource is invalid
+        * @todo        0%
+        */
+       public function processResourcePackage ($resource) {
+               // Check the resource
+               if (!is_resource($resource)) {
+                       // Throw an exception
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
+               } // END - if
+
+               // Implement processing here
+               $this->partialStub('Please implement this method.');
+       }
 }
 
 // [EOF]
diff --git a/application/hub/main/handler/tasks/.htaccess b/application/hub/main/handler/tasks/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/handler/tasks/class_TaskHandler.php b/application/hub/main/handler/tasks/class_TaskHandler.php
new file mode 100644 (file)
index 0000000..c9b6c20
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+/**
+ * A Task handler
+ *
+ * @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 TaskHandler extends BaseHandler implements Registerable, HandleableTask {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableTask class
+        */
+       public final static function createTaskHandler () {
+               // Get new instance
+               $handlerInstance = new TaskHandler();
+
+               // Output debug message
+               $handlerInstance->debugOutput('TASK-HANDLER: Task handler initialized.');
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Registers a task with a task handler. This method throws a
+        * TaskAlreadyRegisteredException if the task has already been registered
+        *
+        * @param       $taskName               A task name to register the task on
+        * @param       $taskInstance   The instance we should register as a task
+        * @return      void
+        */
+       public function registerTask ($taskName, Visitable $taskInstance) {
+               $this->partialStub('taskName=' . $taskName . '/' . $taskInstance->__toString());
+       }
+}
+
+// [EOF]
+?>
index df8b0111d1812133db023bb80043a169baedb4f6..50e6c068554439352e3e6e54f07305f6d23e7618 100644 (file)
@@ -191,7 +191,7 @@ class TcpListener extends BaseListener implements Listenable {
                $current = $this->getIteratorInstance()->current();
 
                // Handle it here
-               $this->getPackageInstance()->processPackage($current);
+               $this->getPackageInstance()->processResourcePackage($current);
 
                // Advance to next entry. This should be the last line
                $this->getIteratorInstance()->next();
index ea65be5b70590a6f3d4268a5b04881a5df39085a..c6aba05b665b3d91819f26623df684bda00e97a5 100644 (file)
@@ -413,7 +413,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $controllerInstance = Registry::getRegistry()->getInstance('controller');
 
                // Run all filters for the hub activation
-               $controllerInstance->executeHubActivationFilters($requestInstance, $responseInstance);
+               $controllerInstance->executeActivationFilters($requestInstance, $responseInstance);
 
                // ----------------------- Last step from here ------------------------
                // Activate the hub. This is ALWAYS the last step in this method
index f5a7fe1bd82b56d9cc3f8aad417439a4992d9251..54d2304f2091828a455f4548fe9cb6a0a1d74a91 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
index 7bb04a909079e6d835d08701a81a85dffd0973d5..c8f291c7a971cbb5a9996c2c954c69bafbef848c 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @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
  *
diff --git a/application/hub/main/resolver/state/.htaccess b/application/hub/main/resolver/state/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/resolver/state/class_BaseStateResolver.php b/application/hub/main/resolver/state/class_BaseStateResolver.php
new file mode 100644 (file)
index 0000000..a7dbc97
--- /dev/null
@@ -0,0 +1,165 @@
+<?php
+/**
+ * A generic state resolver class
+ *
+ * @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 BaseStateResolver extends BaseResolver {
+       /**
+        * Prefix for local, remote or other resolver
+        */
+       private $statePrefix = '';
+
+       /**
+        * Validated state name
+        */
+       private $stateName = '';
+
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the real class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+
+       /**
+        * Setter for state prefix
+        *
+        * @param       $statePrefix    Last validated statePrefix
+        * @return      void
+        */
+       protected final function setStatePrefix ($statePrefix) {
+               $this->statePrefix = $statePrefix;
+       }
+
+       /**
+        * Getter for state prefix
+        *
+        * @param       $statePrefix    Last validated statePrefix
+        * @return      void
+        */
+       protected final function getStatePrefix () {
+               return $this->statePrefix;
+       }
+
+       /**
+        * Setter for state name
+        *
+        * @param       $stateName              Last validated state name
+        * @return      void
+        */
+       protected final function setStateName ($stateName) {
+               $this->stateName = $stateName;
+       }
+
+       /**
+        * Getter for state name
+        *
+        * @return      $stateName      Last validated state name
+        */
+       public final function getStateName () {
+               return $this->stateName;
+       }
+
+       /**
+        * "Loads" a given state and instances it if not yet cached. If the
+        * state was not found an InvalidStateException is thrown
+        *
+        * @param       $stateName                      A state name we shall look for
+        * @return      $stateInstance          A loaded state instance
+        * @throws      InvalidStateException   Thrown if even the requested
+        *                                                                      state class is missing (bad!)
+        */
+       protected function loadState ($stateName) {
+               // Init state instance
+               $stateInstance = null;
+
+               // Create state class name
+               $className = $this->getStatePrefix() . '' . $this->convertToClassName($stateName) . 'State';
+
+               // ... and set it
+               $this->setClassName($className);
+
+               // Is this class loaded?
+               if (!class_exists($this->getClassName())) {
+                       // Throw an exception here
+                       throw new InvalidStateException(array($this, $stateName), self::EXCEPTION_INVALID_STATE);
+               } // END - if
+
+               // Initialize the state
+               $stateInstance = ObjectFactory::createObjectByName(
+                       $this->getClassName(),
+                       array($this)
+               );
+
+               // Return the result
+               return $stateInstance;
+       }
+
+       /**
+        * Checks wether the given state is valid
+        *
+        * @param       $stateName                              The default state we shall execute
+        * @return      $isValid                                Wether the given state is valid
+        * @throws      EmptyVariableException  Thrown if given state is not set
+        * @throws      DefaultStateException   Thrown if default state was not found
+        */
+       public function isStateValid ($stateName) {
+               // By default nothing shall be valid
+               $isValid = false;
+
+               // Is a state set?
+               if (empty($stateName)) {
+                       // Then thrown an exception here
+                       throw new EmptyVariableException(array($this, 'stateName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } // END - if
+
+               // Create class name
+               $className = $this->statePrefix . $this->convertToClassName($stateName) . 'State';
+
+               // Now, let us create the full name of the state class
+               $this->setClassName($className);
+
+               // Try it hard to get an state
+               while ($isValid === false) {
+                       // Is this class already loaded?
+                       if (class_exists($this->getClassName())) {
+                               // This class does exist. :-)
+                               $isValid = true;
+                       } elseif ($this->getClassName() != $this->statePrefix.'DefaultNewsState') {
+                               // Set default state
+                               $this->setClassName($this->statePrefix . 'DefaultNewsState');
+                       } else {
+                               // All is tried, give it up here
+                               throw new DefaultStateException($this, self::EXCEPTION_DEFAULT_STATE_GONE);
+                       }
+               } // END - while
+
+               // Return the result
+               return $isValid;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/resolver/state/network/.htaccess b/application/hub/main/resolver/state/network/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/resolver/state/network/class_NetworkStateResolver.php b/application/hub/main/resolver/state/network/class_NetworkStateResolver.php
new file mode 100644 (file)
index 0000000..11c129e
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+/**
+ * A resolver for resolving states locally
+ *
+ * @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 NetworkStateResolver extends BaseStateResolver implements StateResolver {
+       /**
+        * Last successfull resolved state (name)
+        */
+       private $lastStateName = '';
+
+       /**
+        * Last successfull resolved state (instance)
+        */
+       private $lastStateInstance = null;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set prefix to 'Network'
+               $this->setStatePrefix('Network');
+       }
+
+       /**
+        * Creates an instance of a resolver class with a given state
+        *
+        * @return      $resolverInstance                       The prepared state resolver instance
+        * @throws      EmptyVariableException          Thrown if default state is not set
+        * @throws      InvalidStateException   Thrown if default state is invalid
+        */
+       public final static function createNetworkStateResolver () {
+               // Create the new instance
+               $resolverInstance = new NetworkStateResolver();
+
+               // Return the prepared instance
+               return $resolverInstance;
+       }
+
+       /**
+        * Returns an state instance for a given package class
+        *
+        * @param       $packageInstance        An instance of a package class
+        * @param       $rawData                        The raw data
+        * @return      $stateInstance          An instance of the resolved state
+        * @todo        0%
+        */
+       public function resolveStateByPackage (Networkable $packageInstance, $rawData) {
+               // Get error code
+               $errorCode = $packageInstance->getErrorCode();
+
+               // Is the code a number, then we have to change it
+               if ($errorCode == 134) {
+                       // Transport endpoint not connected, should be handled else!
+                       $errorCode = BaseNetworkPackageHandler::SOCKET_ERROR_TRANSPORT_ENDPOINT;
+               } elseif (is_int($errorCode)) {
+                       // Debug output (because we might want to handle it like the above(s)
+                       $this->debugOutput(__METHOD__ . ': errorCode=' . $errorCode);
+
+                       // Change it only in this class
+                       $errorCode = BaseNetworkPackageHandler::SOCKET_ERROR_GENERAL;
+               } // END - if
+
+               $this->partialStub('errorCode='.$errorCode.',rawData[] = '.gettype($rawData).'('.strlen($rawData).')');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/generic/.htaccess b/application/hub/main/states/generic/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
index cf898bf7dbb77fe8967570faa0a48e168b4c4a5c..f717dd4fabf5277770af16eee9cb5ded8b80ae7e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -12,7 +12,7 @@ define('DEVELOPER', true);
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @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
  *