]> git.mxchange.org Git - hub.git/commitdiff
Rewrites:
authorRoland Häder <roland@mxchange.org>
Thu, 18 May 2017 21:03:48 +0000 (23:03 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 21 Aug 2020 16:49:56 +0000 (18:49 +0200)
- new way of launching applications (core update)
- first namespaces added + imported BaseHubSystem where needed

Signed-off-by: Roland Häder <roland@mxchange.org>
54 files changed:
application/hub/class_ApplicationHelper.php
application/hub/classes/apt-proxy/class_BaseNodeAptProxy.php
application/hub/classes/blocks/class_BaseBlock.php
application/hub/classes/chat/class_BaseNodeChat.php
application/hub/classes/class_BaseHubSystem.php
application/hub/classes/communicator/class_BaseCommunicator.php
application/hub/classes/compressor/decorator/class_NetworkPackageCompressorDecorator.php
application/hub/classes/crawler/class_BaseNodeCrawler.php
application/hub/classes/cruncher/class_BaseHubCruncher.php
application/hub/classes/decoder/class_BaseDecoder.php
application/hub/classes/dht/class_BaseDht.php
application/hub/classes/dht/node/class_NodeDhtFacade.php
application/hub/classes/discovery/class_BaseNodeDiscovery.php
application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php
application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php
application/hub/classes/handler/message-types/class_BaseMessageHandler.php
application/hub/classes/helper/class_BaseHubSystemHelper.php
application/hub/classes/helper/dht/class_DhtBootstrapHelper.php
application/hub/classes/helper/dht/class_DhtPublishEntryHelper.php
application/hub/classes/helper/node/class_BaseNodeHelper.php
application/hub/classes/info/class_BaseInfo.php
application/hub/classes/menu/class_HubIndexMenu.php
application/hub/classes/miner/class_BaseHubMiner.php
application/hub/classes/nodes/class_BaseHubNode.php
application/hub/classes/package/assembler/class_PackageAssembler.php
application/hub/classes/package/class_NetworkPackage.php
application/hub/classes/package/fragmenter/class_PackageFragmenter.php
application/hub/classes/pools/class_BasePool.php
application/hub/classes/recipient/class_BaseRecipient.php
application/hub/classes/recipient/upper/class_UpperRecipient.php
application/hub/classes/resolver/protocol/class_BaseProtocolResolver.php
application/hub/classes/scanner/class_BaseScanner.php
application/hub/classes/source/class_BaseSource.php
application/hub/classes/statistics/connection/class_ConnectionStatisticsHelper.php
application/hub/classes/streams/raw_data/input/class_RawDataInputStream.php
application/hub/classes/tags/class_BaseTag.php
application/hub/classes/template/class_BaseXmlTemplateEngine.php
application/hub/classes/tools/class_HubTools.php
application/hub/config-local.php-dist
application/hub/config.php
application/hub/data.php
application/hub/debug.php
application/hub/exceptions.php
application/hub/init.php
application/hub/loader.php
application/hub/starter.php
contrib/chat-server.php
contrib/mhash-benchmark.php
contrib/udp-client.php
contrib/udp-inc.php
contrib/udp-server.php
core
inc [deleted symlink]
index.php

index ad4d8626ac19d789728f78132992f6e6ab685ba6..921e80961975587629633356afa86c94e74b480a 100644 (file)
@@ -1,4 +1,18 @@
 <?php
+// Must be this namespace, else the launcher cannot find the class.
+namespace CoreFramework\Helper\Application;
+
+// Import framework stuff
+use CoreFramework\Bootstrap\FrameworkBootstrap;
+use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Loader\ClassLoader;
+use CoreFramework\Manager\ManageableApplication;
+use CoreFramework\Object\BaseFrameworkSystem;
+use CoreFramework\Registry\Registerable;
+use CoreFramework\Registry\Registry;
+use CoreFramework\Template\CompileableTemplate;
+
 /**
  * A class holding general data about the application and some methods for
  * the management including the entry point.
@@ -144,43 +158,48 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
        }
 
        /**
-        * Launches the hub system
+        * 1) Setups application data
         *
         * @return      void
         */
-       public final function entryPoint () {
-               // Set this application in registry
-               Registry::getRegistry()->addInstance('app', $this);
-
-               // Is no external address set?
-               if ($this->getConfigInstance()->getConfigEntry('external_address') == '') {
-                       // Determine external address
-                       $this->getConfigInstance()->setConfigEntry('external_address', HubTools::determineOwnExternalAddress());
-               } // END - if
-
-               // Default response is console
-               $response = self::getResponseTypeFromSystem();
-               $responseType = self::getResponseTypeFromSystem();
+       public function setupApplicationData () {
+               // Set all application data
+               $this->setAppName('Unit tests and more');
+               $this->setAppVersion('0.0.0');
+               $this->setAppShortName('tests');
+       }
 
-               // Create a new request object
-               $requestInstance = ObjectFactory::createObjectByName(self::convertToClassName($response) . 'Request');
+       /**
+        * 2) Does initial stuff before starting the application
+        *
+        * @return      void
+        */
+       public function initApplication () {
+               // Get config instance
+               $cfg = FrameworkConfiguration::getSelfInstance();
 
-               // Remember request instance here
-               $this->setRequestInstance($requestInstance);
+               // Initialize output system
+               ApplicationHelper::createDebugInstance('ApplicationHelper');
 
-               // Do we have another response?
-               if ($requestInstance->isRequestElementSet('request')) {
-                       // Then use it
-                       $response = strtolower($requestInstance->getRequestElement('request'));
-                       $responseType = $response;
-               } // END - if
+               /*
+                * This application needs a database connection then simply call init
+                * method.
+                */
+               FrameworkBootstrap::initDatabaseInstance();
 
-               // ... and a new response object
-               $responseClass = sprintf('%sResponse', self::convertToClassName($response));
-               $responseInstance = ObjectFactory::createObjectByName($responseClass, array($this));
+               // Get own internal address and set it in config
+               $cfg->setConfigEntry('internal_address', HubTools::determineOwnInternalAddress());
+       }
 
-               // Remember response instance here
-               $this->setResponseInstance($responseInstance);
+       /**
+        * 3) Launches the application
+        *
+        * @return      void
+        */
+       public function launchApplication () {
+               // Get request/response instances
+               $requestInstance  = FrameworkBootstrap::getRequestInstance();
+               $responseInstance = FrameworkBootstrap::getResponseInstance();
 
                // Get the parameter from the request
                $commandName = $requestInstance->getRequestElement('command');
@@ -257,6 +276,3 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                return 'node_main';
        }
 }
-
-// [EOF]
-?>
index c372b2e26600ff42262acd65eee2e627ebb86ede..babe4473da662750353498e7cfb57b90f72c1f9e 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\AptProxy;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general NodeAptProxy class
  *
@@ -57,6 +63,3 @@ class BaseNodeAptProxy extends BaseHubSystem {
                return $this->isActive;
        }
 }
-
-// [EOF]
-?>
index 9425bf744bcd00e40741bf29b7490b325fdcc6bd..9eba5a4dd0d64ec5909a561c42b2a9b47a2f878a 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Block;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general Block class
  *
index a7acc995a1dd67fce65990dc6b5ce6eb48e9260f..03d9fb5f8a1dd65ac845529360017d05e952acaf 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Chat;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general NodeChat class
  *
@@ -57,6 +63,3 @@ class BaseNodeChat extends BaseHubSystem {
                return $this->isActive;
        }
 }
-
-// [EOF]
-?>
index da5841a67400680fc7eccf2d4ea95b9f6f27f53e..bc5128542781eb4f09435e586f647240818ec8fe 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+// Own namespace
+namespace Hub\Generic;
+
 /**
  * A general hub system class
  *
@@ -286,6 +289,3 @@ class BaseHubSystem extends BaseFrameworkSystem {
                return $this->getConfigInstance()->getConfigEntry('session_id');
        }
 }
-
-// [EOF]
-?>
index 8be2c2aecaa3de12c3ed33fd263e90baaac0494b..a16daf3df98ee74a54f29f25a26802ff48e06b6c 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Communicator;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general communicator class
  *
index 06957ef6015b756e50883d9e2974dd7d27fbafe8..be047df9017cb5e21b8cf8c3607f0d4097f9a85e 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Network\Package;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A NetworkPackageCompressor decorator class. This decorator can later be
  * easily extended without changing any other code.
index d5ce4a5d8288dee6372f70b4694f93bbd70f3ad2..71be29186a69d6234c63ab5aa4c92271001c6ecb 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Crawler;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general NodeCrawler class
  *
index 76feae5d2beebbe95c50fe5df4b9f13ac68bd018..3e5bee5c8d3bcde29af168c270caf8b13ed5c57b 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Cruncher;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general hub cruncher class
  *
@@ -208,6 +214,3 @@ abstract class BaseHubCruncher extends BaseHubSystem implements Updateable {
                return;
        }
 }
-
-// [EOF]
-?>
index ba2a1e43d865007d6daf6b3dbdff450d5085d86d..2170964c14361cf1808aeb5b169bdac62c31e85c 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Decoder;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general Decoder class
  *
index 5452bc00e0ad529cbdc5de1d378ee96370b81e9a..c30d8daee1af8ae9953677fd282954a3b74a4d87 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Dht;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general DHT class
  *
index 18d9addbd19bc3ff8ffb6923a430cd0fe35f6a6f..0f3eacf15eda2dcb62e73a3be03957c37c7cd4cb 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Node\Dht;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A Node DHT facade class
  *
index 72c2dd8e201b73daae08f96c8381bb1b0649e80b..8da4919404661a1fbd0e37fae27ec205e524927c 100644 (file)
@@ -33,6 +33,3 @@ class BaseNodeDiscovery extends BaseDiscovery implements Discoverable {
                parent::__construct($className);
        }
 }
-
-// [EOF]
-?>
index 698c44cb186f296907f0061fd88d76f2d76d0f54..4bf16c7a4af074972d0bbc3e7fbd64715bce565a 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Network\Discovery\Socket;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A socket discovery class
  *
index 6e4b5030035b99a8fdb15621a66d085f6974e86f..e9ed6af793110c4c0abaa64bc52d66f285a70047 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Handler\Node\Message\Announcement;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A NodeMessageAnnouncement handler
  *
index 936f0178aa631686328f7d9d5e4200ddce61e92c..9ecd0ac0db7393b234743003ce64755131761fe7 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Handler\Message;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general message handler, this class must be abstract to make the template
  * method pattern working.
index 38d6a9c5e5bf0d6b8feac549982745ea578f6ce5..482a99d084f644800a578fb83d17851abf05b93e 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Helper;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general hub helper class. This class does not extend BaseHelper.
  *
@@ -91,6 +97,3 @@ class BaseHubSystemHelper extends BaseHubSystem implements HubHelper {
                // Return it
        }
 }
-
-// [EOF]
-?>
index 1fc25af2178cc2268bf917a1f7b02444c18fe2cc..370afe301749b3b96d9e1f417960fd492614a7c8 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Helper\Dht\Bootstrap;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A Bootstrap Dht helper class
  *
index b4cd7cedf3d2e83a552a98aba5eee780f0dbe4c9..6219ff6cd8768e8511df31c3d2242d97fc8c3ee8 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Helper\Dht\Publish;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A PublishingEntry Dht helper class
  *
index e2a92b051d744838903adf60f866f339b3038719..6882f20e47f8d72596a4a33c7438a091fed6ebd7 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Helper\Node;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general node helper class
  *
index 1a24194e950599681cef85bc55957c4b248426bb..210ef070dc4b9829f5f7267fcf9ba74ef8156bf0 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Information;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general Info class
  *
index 2b004eb1b08bba5c331ad91778b5edb86590bade..d4f8612d85bcadb7716844af0d470924f191b1df 100644 (file)
@@ -45,6 +45,3 @@ class HubIndexMenu extends BaseMenu implements RenderableMenu {
                return $menuInstance;
        }
 }
-
-// [EOF]
-?>
index ecdfaa459c8c636a3f4865d98e4b405dff01e54a..823596aab5371e801d6cbc13378630c12ece83e3 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Miner;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general hub miner class
  *
index c7677c91f3625c364f8e83ef87fce57ae9544cbd..1d349d636491f259718cde9b115c4a2dc4d65318 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Node;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general hub node class
  *
@@ -841,6 +847,3 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                } // END - foreac
        }
 }
-
-// [EOF]
-?>
index 21d7fd11036dc2d8067333676fb7375e3179bc6d..e85d72c2a708343fe79a104b213717191c3e54c0 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Network\Package\Assembler;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A PackageAssembler class to assemble a package content stream fragemented
  * by PackageFragmenter back to a raw package data array.
index c60064e4dc0ca3b1b62b39e581e2daa604097d35..4d753b1119565ceebdba3d124dfff183718737d1 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Network\Package;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A NetworkPackage class. This class implements Deliverable and Receivable
  * because all network packages should be deliverable to other nodes and
index a816686c8cb6521e805d25ab405dbfd2cfaa27f0..c9337d39e4cd98d5cd33818ad011101a171ebff8 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Network\Package\Fragment;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A PackageFragmenter class to fragment package data into smaller chunks for
  * delivery. This class calculates a final hash on the raw input data and
index b03caebb80bd2bf22f0a820d6e58a295cdb0470f..40f26c4a07c8fe8a54da93c985edbc0a72a2470a 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Pool;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general pool class
  *
@@ -185,6 +191,3 @@ class BasePool extends BaseHubSystem implements Visitable {
                return $isValid;
        }
 }
-
-// [EOF]
-?>
index bdcf99319b05cf4d0c2456fbf3da6e71477eaee1..e0d9f87e801527a027b84da583ffd67d654b4f38 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Receipt;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general Recipient class
  *
index 026c6eeaeb46bbf267d4cd918c1999a2160c573c..04daf637c2d614aed17c18336e82aaddffd356e8 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Network\Receipt\Upper;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A Upper recipient
  *
index 966971b083c293921ccf72e1cfb7dbf2511924e4..09cb6bf881ff55c46d7bce36602584c786d53d3c 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Resolver\Protocol;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A generic protocol resolver class
  *
index a890efa8c72fae2ba527c766397f29f394141d19..a2f174cb664dcd9714091199114a7a4fcf874fca 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Scanner;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general Scanner class
  *
index d15fd23693894b67c82e7afa91c45ae5e9830f71..875c8e114e95158aefebcbb3b8f3cc90925b7f22 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Source;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general Source class
  *
index a624e8dd51b7c8a07760a5fed7eb22c2f85bf552..8299f0f5dfaac42f1fa30b0f0e5c44af4ef103e1 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Helper\Connection;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A helper class for maintaining connection statistics, no instance is
  * required to use this class.
index dcd58ca3725a23042a590b12d07579c1ef632167..8ac84ef2d6fafe09ec227c9437b500bd787ffe71 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Stream\Input\Raw;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A class for handling incoming (encoded) raw data with start and end markers.
  * The "stream" is being verified by its length (if modulo 4 of it is always
index 8525941b5e11cc326f12f077038af8e7eca0c16c..15fc68a7f01a55b605b660bed47ea728313c07a9 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Tag;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * A general Tags class
  *
index 6fca12e7c526343a41a45200314f22d69deaef5a..2894b511b0667be90a2d7778063ed6e2c7fa5e0f 100644 (file)
@@ -321,6 +321,3 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine {
                call_user_func_array(array($this, $methodName), array());
        }
 }
-
-// [EOF]
-?>
index 37636f29c74a8c67303b3437039c1ea5246a20ef..6293e22fe02f17936552798b79f682014ef21a64 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\Tools;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
 /**
  * This class contains static helper functions for our hub
  *
index 554d7a2659aad848c554473056aa8f68c896ebf5..e8f81fb5c739d6e43281708d71b8b2fbdf00116f 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+// Import framework stuff
+use CoreFramework\Configuration\FrameworkConfiguration;
+
 /**
  * Local configuration entries which you can customize. Please keep the
  * comments starting with CFG: as-is or else, the later configuration wizard
index 9f6b3ec6de05e0ff6ecbd2f16a1ab7aef3f7f512..6d62de9189ccecb9d80fa2b4560a8ae5cbcc335f 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+// Import framework stuff
+use CoreFramework\Configuration\FrameworkConfiguration;
+
 /**
  * Configuration entries for this application only
  *
@@ -1585,6 +1588,3 @@ $cfg->setConfigEntry('hub_console_cmd_fuse_resolver_class', 'ConsoleCommandResol
 
 // CFG: ENABLE-FEATURE-FUSE
 $cfg->setConfigEntry('enable_feature_fuse', 'N');
-
-// [EOF]
-?>
index 8ba4cff742a21a01827f95c2353f037065d85457..7d6dceec926b2c790d8a6cc64b29a822d57f79e9 100644 (file)
@@ -1,43 +1,2 @@
 <?php
-/**
- * Application data
- *
- * Please remember that this include file is being loaded *before* the class
- * loader is loading classes from "exceptions", "interfaces" and "main"!
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.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/>.
- */
-
-// Get config instance
-$cfg = FrameworkConfiguration::getSelfInstance();
-
-// Get an instance of the helper
-$app = call_user_func_array(
-       array($cfg->getConfigEntry('app_helper_class'), 'getSelfInstance'),
-       array()
-);
-
-// Set application name and version
-$app->setAppName('Generic Object Sharing Hub');
-$app->setAppVersion('0.0.0');
-$app->setAppShortName('hub');
-
-// [EOF]
-?>
+// @DEPRECATED
index 636f4f933b6f5b4c57bfa099e9f5c70f94b123c4..7fe826b60f84ae86ce567911fd9e9c377d5bb472 100644 (file)
@@ -23,6 +23,3 @@
 
 // Set error reporting
 error_reporting(E_ALL | E_STRICT);
-
-// [EOF]
-?>
index 8eefa5ea554366f8fac8de19fb38fe3620982521..d027c51e2cc538441092a70ed579c57ad4fdee4e 100644 (file)
@@ -1,10 +1,14 @@
 <?php
+// Import framework stuff
+use CoreFramework\Generic\FrameworkException;
+use CoreFramework\Object\BaseFrameworkSystem;
+
 /**
- * An include file for setting up the exception handler of the hub
+ * An include file for setting up the exception handler of test suite
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0
- * @copyright  Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  *
  * This program is free software: you can redistribute it and/or modify
@@ -24,7 +28,7 @@
 // The node's own exception handler
 function hub_exception_handler ($exceptionInstance) {
        // Is it an object and a valid instance?
-       if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof FrameworkException)) {
+       if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof Exception)) {
                // Init variable
                $backTrace = '';
 
@@ -33,14 +37,11 @@ function hub_exception_handler ($exceptionInstance) {
                        // Init argument string
                        $argsString = '';
 
-                       // Any arguments?
-                       if ((isset($traceArray['args'])) && (is_array($traceArray['args'])) && (count($traceArray['args']) > 0)) {
-                               // Convert arguments type into human-readable
-                               foreach ($traceArray['args'] as $arg) {
-                                       $argsString .= ', ' . gettype($arg);
-                               } // END - foreach
-                               $argsString = substr($argsString, 2);
-                       } // END - if
+                       // Convert arguments type into human-readable
+                       foreach ($traceArray['args'] as $arg) {
+                               $argsString .= ', ' . gettype($arg);
+                       } // END - foreach
+                       $argsString = substr($argsString, 2);
 
                        // Set missing file/line
                        if (!isset($traceArray['file']))  $traceArray['file']  = 'unknown';
@@ -76,9 +77,9 @@ Backtrace:
 --------------------------------------------------------------------------------
 %s
 --------------------------------------------------------------------------------\n",
-                       trim(html_entity_decode(strip_tags($exceptionInstance->__toString()))),
+                       trim(html_entity_decode(strip_tags(get_class($exceptionInstance)))),
                        trim(html_entity_decode(strip_tags($exceptionInstance->getMessage()))),
-                       $exceptionInstance->getHexCode(),
+                       ($exceptionInstance instanceof FrameworkException ? $exceptionInstance->getHexCode() : '0x' . bin2hex($exceptionInstance->getCode())),
                        $exceptionInstance->getFile(),
                        $exceptionInstance->getLine(),
                        trim($backTrace)
@@ -86,18 +87,21 @@ Backtrace:
 
                // Output the message
                print($message);
+       } elseif (is_object($exceptionInstance)) {
+               // Output more details
+               printf('exceptionInstance=%s', print_r($exceptionInstance, true));
        } else {
                /*
                 * Invalid exception instance detected! Do *only* throw exceptions that
                 * extends our own exception 'FrameworkException' to get such nice
                 * outputs like above.
                 */
-               print('exceptionInstance[]=' . gettype($exceptionInstance) . ' is invalid! Please inform the core developer team.');
+               printf('exceptionInstance[]=%s is invalid! Please inform the core developer team.' . PHP_EOL, gettype($exceptionInstance));
        }
 }
 
 // Error handler
-function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) {
+function hub_error_handler ($errno, $errstr, $errfile, $errline, array $errcontext) {
        // Construct the message
        $message = sprintf('File: %s, Line: %s, Code: %s, Message: %s',
                basename($errfile),
@@ -111,7 +115,7 @@ function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext)
 } // END - function
 
 // Assertion handler
-function __assertHandler ($file, $line, $code) {
+function hub_assert_handler ($file, $line, $code) {
        // Empty code?
        if ($code === '') {
                $code = '<em>Unknown</em>';
@@ -125,7 +129,6 @@ function __assertHandler ($file, $line, $code) {
        );
 
        // Log assert
-       die($message . PHP_EOL);
        syslog(LOG_WARNING, $message);
 
        // Throw an exception here
@@ -133,19 +136,14 @@ function __assertHandler ($file, $line, $code) {
 } // END - function
 
 // Set error handler
-//set_error_handler('__errorHandler');
+//set_error_handler('hub_error_handler');
 
-// Set the exception handler
+// Set the new handler
 set_exception_handler('hub_exception_handler');
 
 // Init assert handling
-assert_options(ASSERT_ACTIVE    , TRUE);
-assert_options(ASSERT_WARNING   , FALSE);
-assert_options(ASSERT_BAIL      , TRUE);
-assert_options(ASSERT_QUIET_EVAL, FALSE);
-
-// Set assertion handler
-assert_options(ASSERT_CALLBACK  , '__assertHandler');
-
-// [EOF]
-?>
+assert_options(ASSERT_ACTIVE    , true);
+assert_options(ASSERT_WARNING   , false);
+assert_options(ASSERT_BAIL      , true);
+assert_options(ASSERT_QUIET_EVAL, false);
+assert_options(ASSERT_CALLBACK  , 'hub_assert_handler');
index 548d5172ed4c5ba112e3357e7699d5736079ddc4..7d6dceec926b2c790d8a6cc64b29a822d57f79e9 100644 (file)
@@ -1,41 +1,2 @@
 <?php
-/**
- * Application initializer
- *
- * Please remember that this include file is being loaded *before* the class
- * loader is loading classes from "exceptions", "interfaces" and "main"!
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0
- * @copyright  Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- *
- * 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/>.
- */
-
-// Get config instance
-$cfg = FrameworkConfiguration::getSelfInstance();
-
-// Initialize output system
-ApplicationHelper::createDebugInstance('ApplicationHelper');
-
-// This application needs a database connection then we have to simply include
-// the inc/database.php script
-require($cfg->getConfigEntry('base_path') . 'inc/database.php');
-
-// Get own internal address and set it in config
-$cfg->setConfigEntry('internal_address', HubTools::determineOwnInternalAddress());
-
-// [EOF]
-?>
+// @DEPRECATED
index 0cf80532eb4a96370714ed6be914b11b8d188833..7d6dceec926b2c790d8a6cc64b29a822d57f79e9 100644 (file)
@@ -1,28 +1,2 @@
 <?php
-/**
- * The application's class loader
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0
- * @copyright  Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- *
- * 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/>.
- */
-
-// Scan for application's classes, exceptions and interfaces
-ClassLoader::scanApplicationClasses();
-
-// [EOF]
-?>
+// @DEPRECATED
index 6abc2e6168124c0950cba17e15562ecf3499cc06..7d6dceec926b2c790d8a6cc64b29a822d57f79e9 100644 (file)
@@ -1,57 +1,2 @@
 <?php
-/**
- * The application launcher
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.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/>.
- */
-
-// Is there an application helper instance? We need the method main() for
-// maining the application
-$app = call_user_func_array(
-       array(
-               FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class'), 'getSelfInstance'
-       ), array()
-);
-
-// Some sanity checks
-if ((empty($app)) || (is_null($app))) {
-       // Something went wrong!
-       ApplicationEntryPoint::app_exit(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the helper class <span class="class_name">%s</span> is not loaded.',
-               $application,
-               FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class')
-       ));
-} elseif (!is_object($app)) {
-       // No object!
-       ApplicationEntryPoint::app_exit(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because &#39;app&#39; is not an object.',
-               $application
-       ));
-} elseif (!method_exists($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method'))) {
-       // Method not found!
-       ApplicationEntryPoint::app_exit(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the method <span class="method_name">%s</span> is missing.',
-               $application,
-               FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method')
-       ));
-}
-
-// Call user function
-call_user_func_array(array($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method')), array());
-
-// [EOF]
-?>
+// @DEPRECATED
index 4544db4b21ba6a407923e9939f1fb8cc07335f63..997b5ad5f0740699221fecb3bc4d8e024f64f7bb 100644 (file)
@@ -163,5 +163,3 @@ while (count($clients) > 0) {
 
 // close the listening socket
 socket_close($main_sock);
-
-?>
index 41061d39e0424f52bb046c55e7bdea7587af5da8..ed44183f04c1e27220548fee80eec33a24da97e0 100644 (file)
@@ -63,5 +63,3 @@ asort($timers);
 
 print 'Result from mhash() benchmark (in seconds per hasher):' . "\r\n";
 print_r($timers) . "\n";
-
-?>
index d5dd3610e269cdb537cd9fe2441569aa7c5288f5..a260db09d8083c3f464f387b80cf936870e32a8e 100644 (file)
@@ -171,5 +171,3 @@ if (count($data) > 0) {
 out(__FILE__, __LINE__, 'MIN/AVG/MAX=' . $min . '/' . $avg . '/' . $max . '');
 out(__FILE__, __LINE__, 'INVALID=' . $invalid . '');
 out(__FILE__, __LINE__, 'FAILED=' . $failed . '');
-
-?>
index 47f2607bfcef32037dabc6215214d819f640dc71..86e2f076b0cddc6c21e5412dd37e14014ea4aafa 100644 (file)
@@ -7,5 +7,3 @@ function out ($file, $line, $message, $displayDouble = FALSE) {
                $GLOBALS['last_message'] = $message;
        }
 }
-
-?>
index 55d58efa17e2e3c01c6c239af62ebf62e072cda0..c4bf936a8015c028ca19f35e7ddd27bf1a901aec 100644 (file)
@@ -65,5 +65,3 @@ do {
        // Sleep a little
        if (function_exists('time_nanosleep')) time_nanosleep(0, 500000);
 } while ($pkt !== FALSE);
-
-?>
diff --git a/core b/core
index 1893995b39b02c07012c5f3795654fb9251b5ebd..afe4936b8a55f38736e1af5191a964a926d7255a 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 1893995b39b02c07012c5f3795654fb9251b5ebd
+Subproject commit afe4936b8a55f38736e1af5191a964a926d7255a
diff --git a/inc b/inc
deleted file mode 120000 (symlink)
index a13f35c..0000000
--- a/inc
+++ /dev/null
@@ -1 +0,0 @@
-core/inc/
\ No newline at end of file
index 0a3ef741158afd0be661a3d36b0c1b63d8e4c89b..f0f02f6df124b1ce00ac8d4c18ab96d35d9b7310 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,4 +1,19 @@
 <?php
+// Own namespace (watch out: core)
+namespace CoreFramework\EntryPoint;
+
+// Import framework stuff
+use CoreFramework\Bootstrap\FrameworkBootstrap;
+use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Helper\Application\ApplicationHelper;
+use CoreFramework\Localization\LanguageSystem;
+use CoreFramework\Loader\ClassLoader;
+use CoreFramework\Generic\FrameworkException;
+
+// Import SPL stuff
+use \Exception;
+
 /**
  * The main class with the entry point to the whole application. This class
  * "emulates" Java's entry point call. Additionally it covers local
@@ -28,9 +43,9 @@
  */
 final class ApplicationEntryPoint {
        /**
-        * Core path
+        * Framework path
         */
-       private static $corePath = '';
+       private static $frameworkPath = '';
 
        /**
         * The application's emergency exit
@@ -42,7 +57,7 @@ final class ApplicationEntryPoint {
         * @return      void
         * @todo        This method is old code and needs heavy rewrite and should be moved to ApplicationHelper
         */
-       public static final function app_exit ($message = '', $code = FALSE, $extraData = '', $silentMode = FALSE) {
+       public static final function app_exit ($message = '', $code = false, $extraData = '', $silentMode = false) {
                // Is this method already called?
                if (isset($GLOBALS['app_die_called'])) {
                        // Then output the text directly
@@ -50,7 +65,7 @@ final class ApplicationEntryPoint {
                } // END - if
 
                // This method shall not be called twice
-               $GLOBALS['app_die_called'] = TRUE;
+               $GLOBALS['app_die_called'] = true;
 
                // Is a message set?
                if (empty($message)) {
@@ -62,13 +77,13 @@ final class ApplicationEntryPoint {
                $configInstance = FrameworkConfiguration::getSelfInstance();
 
                // Do we have debug installation?
-               if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === TRUE)) {
+               if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === true)) {
                        // Abort here
                        exit();
                } // END - if
 
                // Get some instances
-               $tpl = FrameworkConfiguration::getSelfInstance()->getConfigEntry('html_template_class');
+               $tpl = $configInstance->getConfigEntry('html_template_class');
                $languageInstance = LanguageSystem::getSelfInstance();
 
                // Initialize template instance here to avoid warnings in IDE
@@ -84,7 +99,7 @@ final class ApplicationEntryPoint {
                                // Get the template instance from our object factory
                                $templateInstance = ObjectFactory::createObjectByName($tpl);
                        } catch (FrameworkException $e) {
-                               exit(sprintf("[Main:] Could not initialize template engine for reason: <span class=\"exception_reason\">%s</span>",
+                               exit(sprintf('[Main:] Could not initialize template engine for reason: <span class="exception_reason">%s</span>',
                                        $e->getMessage()
                                ));
                        }
@@ -105,7 +120,7 @@ final class ApplicationEntryPoint {
                                } // END - if
 
                                // Add the traceback path to the final output
-                               $backtrace .= sprintf("<span class=\"backtrace_file\">%s</span>:%d, <span class=\"backtrace_function\">%s(%d)</span><br />\n",
+                               $backtrace .= sprintf('<span class="backtrace_file">%s</span>:%d, <span class="backtrace_function">%s(%d)</span><br />' . PHP_EOL,
                                        basename($trace['file']),
                                        $trace['line'],
                                        $trace['function'],
@@ -117,7 +132,7 @@ final class ApplicationEntryPoint {
                        $applicationInstance = NULL;
 
                        // Is the class there?
-                       if (class_exists('ApplicationHelper')) {
+                       if (class_exists('CoreFramework\Helper\Application\ApplicationHelper')) {
                                // Get application instance
                                $applicationInstance = ApplicationHelper::getSelfInstance();
 
@@ -166,52 +181,109 @@ final class ApplicationEntryPoint {
        }
 
        /**
-        * Determines the correct absolute path for all includes only once per run.
-        * Other calls of this method are being "cached".
+        * Determines the correct absolute path for the framework. A set of common
+        * paths is being tested (first most common for applications, second when
+        * core tests are being executed and third/forth if the framework has been
+        * cloned there).
         *
-        * @return      $corePath       Base path (core) for all includes
+        * @return      $frameworkPath  Path for framework
         */
-       protected static final function detectCorePath () {
+       public static final function detectFrameworkPath () {
                // Is it not set?
-               if (empty(self::$corePath)) {
-                       // Auto-detect our core path
-                       self::$corePath = str_replace("\\", '/', dirname(__FILE__));
+               if (empty(self::$frameworkPath)) {
+                       // Auto-detect core path (first application-common)
+                       foreach (array('core', '.', '/usr/local/share/php/core', '/usr/share/php/core') as $possiblePath) {
+                               // Create full path for testing
+                               $realPath = realpath($possiblePath);
+
+                               // Debug message
+                               //* NOISY-DEBUG: */ printf('[%s:%d]: realPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($realPath), $realPath);
+
+                               // Is it false?
+                               if ($realPath === false) {
+                                       // Then, not found.
+                                       continue;
+                               } // END - if
+
+                               // First create full-qualified file name (FQFN) to framework/config-global.php
+                               $fqfn = sprintf(
+                                       '%s%sframework%sconfig-global.php',
+                                       $realPath,
+                                       DIRECTORY_SEPARATOR,
+                                       DIRECTORY_SEPARATOR,
+                                       $possiblePath
+                               );
+
+                               // Debug message
+                               //* NOISY-DEBUG: */ printf('[%s:%d]: fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fqfn);
+
+                               // Is it readable?
+                               if (is_readable($fqfn)) {
+                                       // Found one
+                                       self::$frameworkPath = $realPath . '/framework/';
+
+                                       // Abort here
+                                       break;
+                               } // END - if
+                       } // END - foreach
+
+                       // Able to find?
+                       if (!is_dir(self::$frameworkPath)) {
+                               // Is no directory
+                               throw new Exception('Cannot find framework.');
+                       } // END - if
                } // END - if
 
                // Return it
-               return self::$corePath;
+               return self::$frameworkPath;
        }
 
        /**
-        * The application's main entry point. This class isolates some local
+        * Getter for root path
+        *
+        * @return      $rootPath       Root path
+        */
+       public static function getRootPath () {
+               // Get __DIR__, really simple and no detection
+               return __DIR__;
+       }
+
+       /**
+        * The framework's main entry point. This class isolates some local
         * variables which shall not become visible to outside because of security
-        * concerns. We are doing this here to "emulate" the well-known entry
-        * point in Java.
+        * concerns. This is done here to "emulate" the well-known entry point in
+        * Java.
         *
         * @return      void
         */
        public static final function main () {
-               // Load config file
-               require(self::detectCorePath() . '/inc/config.php');
+               // Load bootstrap file
+               require sprintf('%sbootstrap%sbootstrap.inc.php', self::detectFrameworkPath(), DIRECTORY_SEPARATOR);
 
-               // Load all include files
-               require($cfg->getConfigEntry('base_path') . 'inc/includes.php');
+               /*
+                * Initial bootstrap is done, continue with initialization of
+                * framework.
+                */
+               FrameworkBootstrap::initFramework();
 
-               // Include the application selector
-               require($cfg->getConfigEntry('base_path') . 'inc/selector.php');
-       } // END - main()
-} // END - class
+               // Next initialize the detected application
+               FrameworkBootstrap::prepareApplication();
+
+               /*
+                * Last step is to start the application, this will also initialize and
+                * register the application instance in registry.
+                */
+               FrameworkBootstrap::startApplication();
+       }
+}
 
 // Developer mode active? Comment out if no dev!
-define('DEVELOPER', TRUE);
+define('DEVELOPER', true);
 
 // Log all exceptions (only debug! This option can create large error logs)
-//define('LOG_EXCEPTIONS', TRUE);
+//define('LOG_EXCEPTIONS', true);
 
 //xdebug_start_trace();
 
-// Do not remove the following line:
+// Call above main() method
 ApplicationEntryPoint::main();
-
-// [EOF]
-?>