From 0954352df67a1f112c736e08dd31a13ff9dda03d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 24 Mar 2009 07:32:57 +0000 Subject: [PATCH] Initial coding of hub node-mode. - Directories created which should hold the classes for our different node types (aka. node-mode) - README extended how to launch the hub... - Exception handler does now output a warning message if you did not throw an exception which inherits our FrameworkException exception class --- .gitattributes | 5 +++++ application/hub/class_ApplicationHelper.php | 20 ++++++++++++++++++-- application/hub/config.php | 19 +++++++++++-------- application/hub/exceptions.php | 19 ++++++++++++------- application/hub/main/nodes/.htaccess | 1 + application/hub/main/nodes/boot/.htaccess | 1 + application/hub/main/nodes/list/.htaccess | 1 + application/hub/main/nodes/master/.htaccess | 1 + application/hub/main/nodes/regular/.htaccess | 1 + docs/README | 13 ++++++++++++- 10 files changed, 63 insertions(+), 18 deletions(-) create mode 100644 application/hub/main/nodes/.htaccess create mode 100644 application/hub/main/nodes/boot/.htaccess create mode 100644 application/hub/main/nodes/list/.htaccess create mode 100644 application/hub/main/nodes/master/.htaccess create mode 100644 application/hub/main/nodes/regular/.htaccess diff --git a/.gitattributes b/.gitattributes index 765e04793..b2d835ffa 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12,6 +12,11 @@ application/hub/init.php -text application/hub/interfaces/.htaccess -text application/hub/loader.php -text application/hub/main/.htaccess -text +application/hub/main/nodes/.htaccess -text +application/hub/main/nodes/boot/.htaccess -text +application/hub/main/nodes/list/.htaccess -text +application/hub/main/nodes/master/.htaccess -text +application/hub/main/nodes/regular/.htaccess -text application/hub/starter.php -text /clear-cache.sh -text db/.htaccess -text diff --git a/application/hub/class_ApplicationHelper.php b/application/hub/class_ApplicationHelper.php index 85c51d124..eb29ff7b1 100644 --- a/application/hub/class_ApplicationHelper.php +++ b/application/hub/class_ApplicationHelper.php @@ -153,7 +153,23 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica * @return void */ public final function entryPoint () { - trigger_error(__METHOD__.": Cleared!"); + // The default node mode is from config. This mode is being "transfered" into a class name + $nodeMode = $this->getConfigInstance()->readConfig('node_mode'); + + // Prepare a ConsoleRequest class to catch all parameters + $requestInstance = ObjectFactory::createObjectByName('ConsoleRequest'); + + // Is the node 'mode' parameter set? + if ($requestInstance->isRequestElementSet('mode')) { + // Then use this which overrides the config entry temporarily + $nodeMode = $requestInstance->getRequestElement('mode'); + } // END - if + + // Now convert the node-mode in a class name + $className = 'Hub' . $this->convertToClassName($nodeMode) . 'Node'; + + // And try to instance it + $nodeInstance = ObjectFactory::createObjectByName($className); } /** @@ -176,7 +192,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica * @return $masterTemplateName Name of the master template */ public function buildMasterTemplateName () { - return "hub_main"; + return "node_main"; } } diff --git a/application/hub/config.php b/application/hub/config.php index 6db0076fe..dfa719473 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -24,23 +24,26 @@ // Some hub-specific configuration like port hostname where we will listen, etc. $cfg = FrameworkConfiguration::getInstance(); -// CFG: HUB-LISTEN-ADDR -$cfg->setConfigEntry("hub_listen_addr", "0.0.0.0"); +// CFG: NODE-LISTEN-ADDR +$cfg->setConfigEntry('node_listen_addr', "0.0.0.0"); -// CFG: HUB-LISTEN-PORT (zero = auto-choose) -$cfg->setConfigEntry("hub_listen_port", 9060); +// CFG: NODE-LISTEN-PORT +$cfg->setConfigEntry('node_listen_port', 9060); + +// CFG: NODE-MODE (can be 'regular', 'list', 'master' or 'boot', default is 'regular') +$cfg->setConfigEntry('node_mode', "regular"); // CFG: TEMPLATE-ENGINE -$cfg->setConfigEntry("tpl_engine", "ConsoleOutput"); +$cfg->setConfigEntry('tpl_engine', "ConsoleOutput"); // CFG: WEB-ENGINE -$cfg->setConfigEntry("web_engine", "DebugConsoleOutput"); +$cfg->setConfigEntry('web_engine', "DebugConsoleOutput"); // CFG: DEBUG-ENGINE -$cfg->setConfigEntry("debug_engine", "DebugErrorLogOutput"); +$cfg->setConfigEntry('debug_engine', "DebugErrorLogOutput"); // CFG: WEB-CONTENT-TYPE -$cfg->setConfigEntry("web_content_type", ""); +$cfg->setConfigEntry('web_content_type', ""); // [EOF] ?> diff --git a/application/hub/exceptions.php b/application/hub/exceptions.php index 69284bdcc..c8fcdcb27 100644 --- a/application/hub/exceptions.php +++ b/application/hub/exceptions.php @@ -32,14 +32,14 @@ function hub_exception_handler ($exceptionInstance) { // Get 3 call levels $backTrace = ""; for ($idx = 0; $idx < 3; $idx++) { + // Copy array for argument analysis and init variable $traceArray = $trace[$idx]; + $argsString = ""; // Convert arguments type into human-readable - $args = $traceArray['args']; - $argsString = ""; - foreach ($args as $arg) { - $argsString .= ", ".gettype($arg); - } + foreach ($traceArray['args'] as $arg) { + $argsString .= ", " . gettype($arg); + } // END - foreach $argsString = substr($argsString, 2); $backTrace .= sprintf("---------- Pos %d: ---------- @@ -55,7 +55,7 @@ Line : %d\n", basename($traceArray['file']), $traceArray['line'] ); - } + } // END - for // Construct the message $message = sprintf("-------------------------------------------------------------------------------- @@ -79,7 +79,12 @@ Backtrace: ); // Output the message - print $message; + print($message); + } else { + // Invalid exception instance detected! Do *only* throw exceptions that + // extends our own exception 'FrameworkException' to get such nice + // outputs like above. + print("exceptionInstance is invalid! Please inform the core developer team.\n"); } } diff --git a/application/hub/main/nodes/.htaccess b/application/hub/main/nodes/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/nodes/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/nodes/boot/.htaccess b/application/hub/main/nodes/boot/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/nodes/boot/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/nodes/list/.htaccess b/application/hub/main/nodes/list/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/nodes/list/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/nodes/master/.htaccess b/application/hub/main/nodes/master/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/nodes/master/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/nodes/regular/.htaccess b/application/hub/main/nodes/regular/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/nodes/regular/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/docs/README b/docs/README index f196a1dac..2f4c925e2 100644 --- a/docs/README +++ b/docs/README @@ -1,4 +1,15 @@ README ------ -This file needs some extending... ;) +1.) How to launch the hub: +-------------------------- + +At the current stage of code base you need to launch the hub by entering the +following command at at command prompt (Win32) or console (Linux etc.) in the +root directory of this script: + +php index.php app=hub + +Another other (later added) parameters should be added after app=hub in the same +way due to the "design" of the inc/includes.php script. We need to change that +anyway. -- 2.39.2