From abd3e84ef7de5b332a6a19a2c5b1c4130298d1a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 7 Nov 2020 14:40:30 +0100 Subject: [PATCH] Continued: - monolithing BaseFrameworkSystem->getConfigInstance() is no more, best is to use FrameworkBootstrap::getConfigurationInstance() instead - updated core framework MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../hub/classes/class_BaseHubSystem.php | 18 ++++++----- .../classes/client/http/class_HttpClient.p | 4 +-- .../classes/client/http/class_HttpClient.ph | 6 ++-- .../classes/client/http/class_HttpClient.php | 11 ++++--- .../socket/class_SocketContainer.php | 9 +++--- .../cruncher/class_BaseHubCruncher.php | 5 ++-- .../openssl/class_HubOpenSslCruncher.php | 5 ++-- ...odeDistributedHashTableDatabaseWrapper.php | 4 +-- application/hub/classes/dht/class_BaseDht.php | 3 +- .../classes/dht/node/class_NodeDhtFacade.php | 3 +- .../node/class_NodeObjectFactory.php | 3 +- .../factories/socket/class_SocketFactory.php | 2 +- .../class_HubcoinRewardFeature.php | 3 +- .../class_CruncherInitializationFilter.php | 3 +- .../miner/class_MinerInitializationFilter.php | 9 +++--- .../class_MinerPhpRequirementsFilter.php | 13 ++++---- .../node/class_NodePhpRequirementsFilter.php | 9 +++--- ...ss_CrawlerTaskHandlerInitializerFilter.php | 3 +- .../classes/handler/class_BaseHubHandler.php | 28 ++++++++++++++++- ...lass_NodeAnnouncementAnswerOkayHandler.php | 5 ++-- .../class_NodeMessageAnnouncementHandler.php | 13 ++++---- .../class_NodeMessageDhtBootstrapHandler.php | 17 ++++++----- ...lass_NodeMessageRequestNodeListHandler.php | 13 ++++---- .../connection/class_BaseConnectionHelper.php | 3 +- .../ipv4/class_BaseIpV4ConnectionHelper.php | 5 +++- .../ipv4/tcp/class_TcpConnectionHelper.php | 5 ++-- .../info/connection/class_ConnectionInfo.php | 2 +- .../class_TestUnitKeyProducerIterator.php | 7 ++--- .../classes/listener/class_BaseListener.php | 30 +++++++++++++++++-- .../miner/chash/class_HubCoinMiner.php | 5 ++-- .../hub/classes/miner/class_BaseHubMiner.php | 5 ++-- .../classes/nodes/boot/class_HubBootNode.php | 2 +- .../hub/classes/nodes/class_BaseHubNode.php | 8 ++--- .../fragmenter/class_PackageFragmenter.php | 3 +- .../classes/producer/class_BaseProducer.php | 5 ++-- .../direct/class_DirectRecipient.php | 3 +- .../recipient/upper/class_UpperRecipient.php | 7 +++-- .../hub/classes/resolver/protocol/class_ | 9 +++--- .../tcp/class_TcpProtocolResolver.php | 5 ++-- .../source/units/class_TestUnitSource.php | 5 ++-- .../class_CrawlerUploadedListUrlSource.php | 5 ++-- .../class_ConnectionStatisticsHelper.php | 5 +++- .../template/class_BaseXmlTemplateEngine.php | 10 +++---- .../hub/classes/tools/hub/class_HubTools.php | 4 +-- core | 2 +- 45 files changed, 205 insertions(+), 119 deletions(-) diff --git a/application/hub/classes/class_BaseHubSystem.php b/application/hub/classes/class_BaseHubSystem.php index db95f3288..3e4c41e1c 100644 --- a/application/hub/classes/class_BaseHubSystem.php +++ b/application/hub/classes/class_BaseHubSystem.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\Generic; // Import application-specific stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Shipsimu\Hub\Container\Socket\StorableSocket; use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData; use Org\Shipsimu\Hub\Network\Delivery\Deliverable; @@ -91,6 +92,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface ); // ... and return it + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: isset=%d - EXIT!', intval($isset))); return $isset; } @@ -102,7 +104,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface */ protected final function setNodeId ($nodeId) { // Set it config now - $this->getConfigInstance()->setConfigEntry('node_id', (string) $nodeId); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('node_id', (string) $nodeId); } /** @@ -112,7 +114,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface */ public final function getNodeId () { // Get it from config - return $this->getConfigInstance()->getConfigEntry('node_id'); + return FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_id'); } /** @@ -123,7 +125,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface */ protected final function setPrivateKey (string $privateKey) { // Set it config now - $this->getConfigInstance()->setConfigEntry('private_key', (string) $privateKey); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('private_key', (string) $privateKey); } /** @@ -133,7 +135,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface */ public final function getPrivateKey () { // Get it from config - return $this->getConfigInstance()->getConfigEntry('private_key'); + return FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('private_key'); } /** @@ -144,7 +146,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface */ protected final function setNodePrivateKeyHash (string $privateKeyHash) { // Set it config now - $this->getConfigInstance()->setConfigEntry('private_key_hash', $privateKeyHash); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('private_key_hash', $privateKeyHash); } /** @@ -154,7 +156,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface */ public final function getNodePrivateKeyHash () { // Get it from config - return $this->getConfigInstance()->getConfigEntry('private_key_hash'); + return FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('private_key_hash'); } /** @@ -164,7 +166,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface * @return void */ protected final function setSessionId (string $sessionId) { - $this->getConfigInstance()->setConfigEntry('session_id', $sessionId); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('session_id', $sessionId); } /** @@ -173,7 +175,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface * @return $sessionId Current session id */ public final function getSessionId () { - return $this->getConfigInstance()->getConfigEntry('session_id'); + return FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('session_id'); } /** diff --git a/application/hub/classes/client/http/class_HttpClient.p b/application/hub/classes/client/http/class_HttpClient.p index bfc535d33..d61eab153 100644 --- a/application/hub/classes/client/http/class_HttpClient.p +++ b/application/hub/classes/client/http/class_HttpClient.p @@ -5,12 +5,12 @@ // Open connection if ($helperInstance->isProxyUsed() === true) { // Resolve hostname into IP address - $ip = ConsoleTools::resolveIpAddress($helperInstance->getConfigInstance()->getConfigEntry('proxy_host')); + $ip = ConsoleTools::resolveIpAddress(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_host')); // @TODO Handle $ip = false // Connect to host through proxy connection - $socketResource = fsockopen($ip, $helperInstance->getConfigInstance()->getConfigEntry('proxy_port'), $errorNo, $errorStr, 30); + $socketResource = fsockopen($ip, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_port'), $errorNo, $errorStr, 30); } else { // Connect to host directly $socketResource = fsockopen('188.138.90.169', 80, $errorNo, $errorStr, 30); diff --git a/application/hub/classes/client/http/class_HttpClient.ph b/application/hub/classes/client/http/class_HttpClient.ph index cdd80f719..3c7605d77 100644 --- a/application/hub/classes/client/http/class_HttpClient.ph +++ b/application/hub/classes/client/http/class_HttpClient.ph @@ -24,12 +24,12 @@ // Open connection if ($helperInstance->isProxyUsed() === true) { // Resolve hostname into IP address - $ip = ConsoleTools::resolveIpAddress($helperInstance->getConfigInstance()->getConfigEntry('proxy_host')); + $ip = ConsoleTools::resolveIpAddress(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_host')); // @TODO Handle $ip = false // Connect to host through proxy connection - $socketResource = fsockopen($ip, $helperInstance->getConfigInstance()->getConfigEntry('proxy_port'), $errorNo, $errorStr, 30); + $socketResource = fsockopen($ip, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_port'), $errorNo, $errorStr, 30); } else { // Connect to host directly $socketResource = fsockopen('188.138.90.169', 80, $errorNo, $errorStr, 30); @@ -50,7 +50,7 @@ // Do we use proxy? if ($helperInstance->isProxyUsed() === true) { // CONNECT method? - if ($helperInstance->getConfigInstance()->getConfigEntry('proxy_connect_method') == 'Y') { + if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_connect_method') == 'Y') { // Setup proxy tunnel $response = $helperInstance->setupProxyTunnel('shipsimu.org', 80, $socketResource); diff --git a/application/hub/classes/client/http/class_HttpClient.php b/application/hub/classes/client/http/class_HttpClient.php index 78b4cf7cc..cf713c9cf 100644 --- a/application/hub/classes/client/http/class_HttpClient.php +++ b/application/hub/classes/client/http/class_HttpClient.php @@ -2,6 +2,9 @@ // Own namespace namespace Org\Mxchange\CoreFramework\Client\Http; +// Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; + /** * A HTTP client class * @@ -66,9 +69,9 @@ class HttpClient extends BaseClient implements Client { // Determine it $GLOBALS[__METHOD__] = ( ( - $this->getConfigInstance()->getConfigEntry('proxy_host') != '' + FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_host') != '' ) && ( - $this->getConfigInstance()->getConfigEntry('proxy_port') > 0 + FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_port') > 0 ) ); } // END - if @@ -115,9 +118,9 @@ class HttpClient extends BaseClient implements Client { $rawRequest .= 'Host: ' . $host . ':' . $port . self::HTTP_EOL; // Use login data to proxy? (username at least) - if ($this->getConfigInstance()->getConfigEntry('proxy_username') != '') { + if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_username') != '') { // Add it as well - $encodedAuth = base64_encode($this->getConfigInstance()->getConfigEntry('proxy_username') . ':' . $this->getConfigInstance()->getConfigEntry('proxy_password')); + $encodedAuth = base64_encode(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_username') . ':' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_password')); $rawRequest .= 'Proxy-Authorization: Basic ' . $encodedAuth . self::HTTP_EOL; } // END - if diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index 8c4de84a6..db96217db 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -15,6 +15,7 @@ use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -123,7 +124,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita parent::__construct(__CLASS__); // Init value - $this->socketSelectTimeout = $this->getConfigInstance()->getConfigEntry('socket_select_timeout_usec'); + $this->socketSelectTimeout = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('socket_select_timeout_usec'); // Init array of connection types $this->connectionTypes = array( @@ -798,7 +799,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita * PHP_NORMAL_READ, this line will endless block. This script does only * provide simultanous or faked threads, not real. */ - $rawData = socket_read($this->getSocketResource(), $this->getConfigInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ); + $rawData = socket_read($this->getSocketResource(), FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ); // Return it /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s,rawData[%s]=%s - EXIT!', strtoupper($this->getSocketProtocol()), $this->getSocketResource(), gettype($rawData), $rawData)); @@ -843,9 +844,9 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $result = $this->setSocketOption(SOL_SOCKET, SO_RCVTIMEO, [ // Seconds - 'sec' => $this->getConfigInstance()->getConfigEntry($this->getSocketProtocol() . '_socket_accept_wait_sec'), + 'sec' => FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($this->getSocketProtocol() . '_socket_accept_wait_sec'), // Milliseconds - 'usec' => $this->getConfigInstance()->getConfigEntry($this->getSocketProtocol() . '_socket_accept_wait_usec'), + 'usec' => FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($this->getSocketProtocol() . '_socket_accept_wait_usec'), ]); // Return result diff --git a/application/hub/classes/cruncher/class_BaseHubCruncher.php b/application/hub/classes/cruncher/class_BaseHubCruncher.php index 7aba23ca4..cf0762825 100644 --- a/application/hub/classes/cruncher/class_BaseHubCruncher.php +++ b/application/hub/classes/cruncher/class_BaseHubCruncher.php @@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Factory\State\Cruncher\CruncherStateFactory; use Org\Shipsimu\Hub\Generic\BaseHubSystem; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Database\Updateable; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -113,7 +114,7 @@ abstract class BaseHubCruncher extends BaseHubSystem implements Updateable { */ protected function isInBufferQueueFilled () { // Determine it - $isFilled = ($this->bufferInstance->getStackCount(self::STACKER_NAME_IN_QUEUE) > $this->getConfigInstance()->getConfigEntry('cruncher_in_buffer_min_threshold')); + $isFilled = ($this->bufferInstance->getStackCount(self::STACKER_NAME_IN_QUEUE) > FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('cruncher_in_buffer_min_threshold')); // And return the result return $isFilled; @@ -198,7 +199,7 @@ abstract class BaseHubCruncher extends BaseHubSystem implements Updateable { $this->fillInBufferQueueWithWorkUnits(); // Is the buffer still not filled and are test-packages allowed? - if ((!$this->isInBufferQueueFilled()) && ($this->getConfigInstance()->getConfigEntry('cruncher_test_units_enabled') == 'Y')) { + if ((!$this->isInBufferQueueFilled()) && (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('cruncher_test_units_enabled') == 'Y')) { // Then fill the in-buffer with (one) test-unit(s) $this->fillInBufferQueueWithTestUnits(); } // END - if diff --git a/application/hub/classes/cruncher/openssl/class_HubOpenSslCruncher.php b/application/hub/classes/cruncher/openssl/class_HubOpenSslCruncher.php index 455ee4e1b..43327051a 100644 --- a/application/hub/classes/cruncher/openssl/class_HubOpenSslCruncher.php +++ b/application/hub/classes/cruncher/openssl/class_HubOpenSslCruncher.php @@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Cruncher\BaseHubCruncher; use Org\Shipsimu\Hub\Helper\Cruncher\CruncherHelper; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -74,7 +75,7 @@ class HubOpenSslCruncher extends BaseHubCruncher implements CruncherHelper, Regi */ protected function fillInBufferQueueWithTestUnits () { // Are test units enabled? - if ($this->getConfigInstance()->getConfigEntry('cruncher_test_units_enabled') == 'N') { + if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('cruncher_test_units_enabled') == 'N') { // They are disabled, so skip any further steps return; } elseif ($this->getStateInstance()->isCruncherStateVirgin()) { @@ -86,7 +87,7 @@ class HubOpenSslCruncher extends BaseHubCruncher implements CruncherHelper, Regi $generatorInstance = ObjectFactory::createObjectByConfiguredName('cruncher_test_unit_generator_class'); // We don't need an iterator here because we just need to generate some test units - for ($idx = 0; $idx < $this->getConfigInstance()->getConfigEntry('cruncher_max_text_unit_amount'); $idx++) { + for ($idx = 0; $idx < FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('cruncher_max_text_unit_amount'); $idx++) { // Get a test unit from it $unitInstance = $generatorInstance->generateNextUnitInstance(); diff --git a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php index aec61b504..353786137 100644 --- a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php @@ -643,7 +643,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Get max recipients - $maxRecipients = $this->getConfigInstance()->getConfigEntry('max_dht_recipients'); + $maxRecipients = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('max_dht_recipients'); // First creata a search instance $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); @@ -682,7 +682,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp } // Get max recipients - $maxRecipients = $this->getConfigInstance()->getConfigEntry('max_dht_recipients'); + $maxRecipients = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('max_dht_recipients'); // First creata a search instance $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); diff --git a/application/hub/classes/dht/class_BaseDht.php b/application/hub/classes/dht/class_BaseDht.php index 20432b4a1..5bbf61d7a 100644 --- a/application/hub/classes/dht/class_BaseDht.php +++ b/application/hub/classes/dht/class_BaseDht.php @@ -9,6 +9,7 @@ use Org\Shipsimu\Hub\Generic\BaseHubSystem; use Org\Shipsimu\Hub\Helper\Dht\HelpableDht; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; @@ -100,7 +101,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { */ public function updateDhtData () { // Set some dummy configuration entries, e.g. dht_status - $this->getConfigInstance()->setConfigEntry('dht_status', $this->getStateInstance()->getStateName()); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('dht_status', $this->getStateInstance()->getStateName()); } /** diff --git a/application/hub/classes/dht/node/class_NodeDhtFacade.php b/application/hub/classes/dht/node/class_NodeDhtFacade.php index 0eb971241..9ccb7920e 100644 --- a/application/hub/classes/dht/node/class_NodeDhtFacade.php +++ b/application/hub/classes/dht/node/class_NodeDhtFacade.php @@ -11,6 +11,7 @@ use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet; @@ -322,7 +323,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { $searchInstance->addExcludeCriteria(str_replace('my-', '', $excludeKey), $messageData[$excludeKey]); // Only X entries are fine - $searchInstance->setLimit($this->getConfigInstance()->getConfigEntry('node_dht_list_limit')); + $searchInstance->setLimit(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_dht_list_limit')); // Run the query $resultInstance = $this->getWrapperInstance()->doSelectByCriteria($searchInstance); diff --git a/application/hub/classes/factories/node/class_NodeObjectFactory.php b/application/hub/classes/factories/node/class_NodeObjectFactory.php index a08b7d21b..0118b1f99 100644 --- a/application/hub/classes/factories/node/class_NodeObjectFactory.php +++ b/application/hub/classes/factories/node/class_NodeObjectFactory.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\Factory\Node; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; @@ -63,7 +64,7 @@ class NodeObjectFactory extends ObjectFactory { } elseif (($requestInstance instanceof Requestable) && ($responseInstance instanceof Responseable)) { // The default node-mode is from our configuration //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-FACTORY: requestInstance and responseInstance are both set.'); - $nodeMode = $factoryInstance->getConfigInstance()->getConfigEntry('node_default_mode'); + $nodeMode = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_default_mode'); // Is the node 'mode' parameter set? //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-FACTORY: nodeMode=%s - from CONFIG', $nodeMode)); diff --git a/application/hub/classes/factories/socket/class_SocketFactory.php b/application/hub/classes/factories/socket/class_SocketFactory.php index 3219a1877..cbe224401 100644 --- a/application/hub/classes/factories/socket/class_SocketFactory.php +++ b/application/hub/classes/factories/socket/class_SocketFactory.php @@ -107,7 +107,7 @@ class SocketFactory extends ObjectFactory { */ public static final function createListenFileSocket (Listenable $listenerInstance) { // Create SplFileInfo - $fileInfo = new SplFileInfo($listenerInstance->getConfigInstance()->getConfigEntry('ipc_socket_file_name')); + $fileInfo = new SplFileInfo(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('ipc_socket_file_name')); // Create file name $socketFile = self::createTempPathForFile($fileInfo); diff --git a/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php b/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php index 34410e81a..6f188dd6a 100644 --- a/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php +++ b/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\Feature\CoinReward; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Feature\BaseFeature; use Org\Mxchange\CoreFramework\Feature\Feature; use Org\Mxchange\CoreFramework\Feature\FrameworkFeature; @@ -64,7 +65,7 @@ class HubcoinRewardFeature extends BaseFeature implements Feature { public function isFeatureAvailable () { // Testing this feature is pretty simple: //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: CALLED!', __METHOD__, __LINE__)); - $isAvailable = (($this->getConfigInstance()->getConfigEntry('extension_scrypt_loaded') === TRUE) && (extension_loaded('scrypt')) && (is_callable('scrypt'))); + $isAvailable = ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('extension_scrypt_loaded') === TRUE) && (extension_loaded('scrypt')) && (is_callable('scrypt'))); // Return status //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: isAvailable=%d - EXIT!', __METHOD__, __LINE__, intval($isAvailable))); diff --git a/application/hub/classes/filter/cruncher/class_CruncherInitializationFilter.php b/application/hub/classes/filter/cruncher/class_CruncherInitializationFilter.php index 2457a7f5f..167964314 100644 --- a/application/hub/classes/filter/cruncher/class_CruncherInitializationFilter.php +++ b/application/hub/classes/filter/cruncher/class_CruncherInitializationFilter.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Cruncher\Filter\Initialization; use Org\Shipsimu\Hub\Cruncher\Filter\BaseCruncherFilter; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Filter\Filterable; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -68,7 +69,7 @@ class CruncherInitializationFilter extends BaseCruncherFilter implements Filtera */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // The default cruncher-mode is from our configuration - $cruncherMode = $this->getConfigInstance()->getConfigEntry('cruncher_default_mode'); + $cruncherMode = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('cruncher_default_mode'); // Is the cruncher 'mode' parameter set? if ($requestInstance->isRequestElementSet('mode')) { diff --git a/application/hub/classes/filter/miner/class_MinerInitializationFilter.php b/application/hub/classes/filter/miner/class_MinerInitializationFilter.php index 74f7d3b60..b14646918 100644 --- a/application/hub/classes/filter/miner/class_MinerInitializationFilter.php +++ b/application/hub/classes/filter/miner/class_MinerInitializationFilter.php @@ -2,16 +2,17 @@ // Own namespace namespace Org\Shipsimu\Hub\Miner\Filter\Initialization; +// Import application-specific stuff +use Org\Shipsimu\Hub\Miner\Filter\BaseMinerFilter; + // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Filter\Filterable; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Response\Responseable; -// Import application-specific stuff -use Org\Shipsimu\Hub\Miner\Filter\BaseMinerFilter; - /** * A Initialization filter for miners * @@ -68,7 +69,7 @@ class MinerInitializationFilter extends BaseMinerFilter implements Filterable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // The default miner-mode is from our configuration - $minerMode = $this->getConfigInstance()->getConfigEntry('miner_default_mode'); + $minerMode = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('miner_default_mode'); // Is the miner 'mode' parameter set? if ($requestInstance->isRequestElementSet('mode')) { diff --git a/application/hub/classes/filter/miner/class_MinerPhpRequirementsFilter.php b/application/hub/classes/filter/miner/class_MinerPhpRequirementsFilter.php index 05d7a7d60..2ac4b90e6 100644 --- a/application/hub/classes/filter/miner/class_MinerPhpRequirementsFilter.php +++ b/application/hub/classes/filter/miner/class_MinerPhpRequirementsFilter.php @@ -2,14 +2,15 @@ // Own namespace namespace Org\Shipsimu\Hub\Miner\Filter\Requirements; +// Import application-specific stuff +use Org\Shipsimu\Hub\Miner\Filter\BaseMinerFilter; + // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Filter\Filterable; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Response\Responseable; -// Import application-specific stuff -use Org\Shipsimu\Hub\Miner\Filter\BaseMinerFilter; - /** * A PhpRequirements filter for miners * @@ -81,7 +82,7 @@ class MinerPhpRequirementsFilter extends BaseMinerFilter implements Filterable { if ((extension_loaded('scrypt')) && (is_callable('scrypt'))) { // Mark it as working self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILTER: ext-scrypt and a callable scrypt() function found. "Hubcoin reward" feature possible.'); - $this->getConfigInstance()->setConfigEntry('extension_scrypt_loaded', TRUE); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('extension_scrypt_loaded', TRUE); } else { // Not working (not all have ext-scrypt installed self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILTER: ext-scrypt not found or scrypt() function not found. "Hubcoin reward" feature disabled.'); @@ -93,7 +94,5 @@ class MinerPhpRequirementsFilter extends BaseMinerFilter implements Filterable { throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); } // END - if } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/node/class_NodePhpRequirementsFilter.php b/application/hub/classes/filter/node/class_NodePhpRequirementsFilter.php index 1db2afe79..c4eee7dbc 100644 --- a/application/hub/classes/filter/node/class_NodePhpRequirementsFilter.php +++ b/application/hub/classes/filter/node/class_NodePhpRequirementsFilter.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Filter\Node\Requirements; use Org\Shipsimu\Hub\Filter\Node\BaseNodeFilter; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Filter\Filterable; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Response\Responseable; @@ -81,7 +82,7 @@ class NodePhpRequirementsFilter extends BaseNodeFilter implements Filterable { if ((extension_loaded('scrypt')) && (is_callable('scrypt'))) { // Mark it as working self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILTER: ext-scrypt and a callable scrypt() function found. "Hubcoin reward" feature possible.'); - $this->getConfigInstance()->setConfigEntry('extension_scrypt_loaded', TRUE); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('extension_scrypt_loaded', TRUE); } else { // Not working (not all have ext-scrypt installed self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILTER: ext-scrypt not found or scrypt() function not found. "Hubcoin reward" feature disabled.'); @@ -91,7 +92,7 @@ class NodePhpRequirementsFilter extends BaseNodeFilter implements Filterable { if ((extension_loaded('uuid')) && (is_callable('uuid_create'))) { // Mark it as working self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILTER: ext-uuid and a callable uuid_create() function found. UUID "entropy" available.'); - $this->getConfigInstance()->setConfigEntry('extension_uuid_loaded', TRUE); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('extension_uuid_loaded', TRUE); } else { // Not working (not all have ext-uuid installed self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILTER: ext-uuid not found or uuid_create() function not found. UUID "entropy" disabled.'); @@ -103,7 +104,5 @@ class NodePhpRequirementsFilter extends BaseNodeFilter implements Filterable { throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); } // END - if } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php b/application/hub/classes/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php index 46a41ad06..245447f0e 100644 --- a/application/hub/classes/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php +++ b/application/hub/classes/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Filter\Initializer\Crawler\Handler\Task; use Org\Shipsimu\Hub\Crawler\Filter\BaseCrawlerFilter; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Filter\Filterable; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -115,7 +116,7 @@ class CrawlerTaskHandlerInitializerFilter extends BaseCrawlerFilter implements F $handlerInstance->registerTask('crawler_ping', $taskInstance); // 10) URL sources - foreach (explode(':', $this->getConfigInstance()->getConfigEntry('crawler_url_stacks')) as $stack) { + foreach (explode(':', FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('crawler_url_stacks')) as $stack) { // Init task instance $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_url_source_' . $stack . '_task_class'); diff --git a/application/hub/classes/handler/class_BaseHubHandler.php b/application/hub/classes/handler/class_BaseHubHandler.php index 76f3903d4..9d7a6a607 100644 --- a/application/hub/classes/handler/class_BaseHubHandler.php +++ b/application/hub/classes/handler/class_BaseHubHandler.php @@ -16,6 +16,7 @@ use Org\Shipsimu\Hub\Pool\Poolable; use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; use Org\Mxchange\CoreFramework\Handler\BaseHandler; use Org\Mxchange\CoreFramework\Handler\Handleable; +use Org\Mxchange\CoreFramework\Registry\Register; /** * A general hub handler @@ -70,6 +71,11 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte */ private $assemblerInstance = NULL; + /** + * Registry instance (implementing Register) + */ + private $registryInstance = NULL; + /** * Protected constructor * @@ -89,12 +95,13 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte */ public final function ifStartEndMarkersSet ($data) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-HANDLER: data()=%d - CALLED!', strlen($data))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-HANDLER: data(%d)=%s - CALLED!', strlen($data), $data)); // Determine it $isset = ((substr($data, 0, strlen(HandleableRawData::STREAM_START_MARKER)) == HandleableRawData::STREAM_START_MARKER) && (substr($data, -1 * strlen(HandleableRawData::STREAM_END_MARKER), strlen(HandleableRawData::STREAM_END_MARKER)) == HandleableRawData::STREAM_END_MARKER)); // ... and return it + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-HANDLER: isset=%d - EXIT!', intval($isset))); return $isset; } @@ -280,4 +287,23 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte return $this->assemblerInstance; } + /** + * Setter for registry instance + * + * @param $registryInstance An instance of a Register class + * @return void + */ + protected final function setRegistryInstance (Register $registryInstance) { + $this->registryInstance = $registryInstance; + } + + /** + * Getter for registry instance + * + * @return $registryInstance The debug registry instance + */ + protected final function getRegistryInstance () { + return $this->registryInstance; + } + } diff --git a/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php b/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php index 13ef618f1..809c9ff48 100644 --- a/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php +++ b/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php @@ -13,6 +13,7 @@ use Org\Shipsimu\Hub\Node\BaseHubNode; use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Announcement\XmlAnnouncementAnswerTemplateEngine; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -133,7 +134,7 @@ class NodeAnnouncementAnswerOkayHandler extends BaseAnswerStatusHandler implemen $objectList = $nodeInstance->getListFromAcceptedObjectTypes(); // Add missing (temporary) configuration 'accepted_object_types' - $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList)); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList)); } /** @@ -145,7 +146,7 @@ class NodeAnnouncementAnswerOkayHandler extends BaseAnswerStatusHandler implemen */ protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) { // Remove temporay configuration - $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS); + FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS); } } diff --git a/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php b/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php index d583bfd6c..4da7d4b78 100644 --- a/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php +++ b/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php @@ -14,6 +14,7 @@ use Org\Shipsimu\Hub\Template\Engine\Xml\Announcement\XmlAnnouncementTemplateEng use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Announcement\XmlAnnouncementAnswerTemplateEngine; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -165,7 +166,7 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]); // Set the element in configuration - $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry($configKey, $messageData[$messageKey]); } // END - foreach // "Walk" throught the config-copy array @@ -174,14 +175,14 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...'); // Copy from source to targetKey - $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey)); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry($targetKey, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($sourceKey)); } // END - foreach // Translate last exception into a status code $statusCode = $this->getTranslatedStatusFromLastException(); // Set it in configuration (temporarily) - $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); } /** @@ -195,17 +196,17 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl // "Walk" throught the translation array again foreach ($this->messageToConfig as $dummy => $configKey) { // Now unset this configuration entry (to save some memory) - $this->getConfigInstance()->unsetConfigEntry($configKey); + FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry($configKey); } // END - foreach // "Walk" throught the config-copy array again foreach ($this->configCopy as $configKey => $dummy) { // Now unset this configuration entry (to save some memory again) - $this->getConfigInstance()->unsetConfigEntry($configKey); + FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry($configKey); } // END - foreach // Remove NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS as well - $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); + FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); } } diff --git a/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php index f4950bf57..e7c3da706 100644 --- a/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php +++ b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php @@ -14,6 +14,7 @@ use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Dht\Bootstrap\XmlDhtBootstrapAns use Org\Shipsimu\Hub\Template\Engine\Xml\Dht\Bootstrap\XmlDhtBootstrapTemplateEngine; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -153,7 +154,7 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl foreach ($this->messageToConfig as $messageKey => $configKey) { // Set the element in configuration /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]); - $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry($configKey, $messageData[$messageKey]); } // END - foreach // "Walk" throught the config-copy array @@ -162,14 +163,14 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...'); // Copy from source to target key - $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey)); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry($targetKey, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($sourceKey)); } // END - foreach // Translate last exception into a status code $statusCode = $this->getTranslatedStatusFromLastException(); // Set it in configuration (temporarily) - $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); /* * Use the DHT instance to get a list of recipients. This means that all @@ -183,7 +184,7 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl assert(count($nodeList) > 0); // Set it in configuration - $this->getConfigInstance()->setConfigEntry('dht_nodes', base64_encode(json_encode($nodeList))); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('dht_nodes', base64_encode(json_encode($nodeList))); } /** @@ -197,18 +198,18 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl // "Walk" throught the translation array again foreach ($this->messageToConfig as $dummy => $configKey) { // Now unset this configuration entry (to save some memory) - $this->getConfigInstance()->unsetConfigEntry($configKey); + FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry($configKey); } // END - foreach // "Walk" throught the config-copy array again foreach ($this->configCopy as $configKey => $dummy) { // Now unset this configuration entry (to save some memory again) - $this->getConfigInstance()->unsetConfigEntry($configKey); + FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry($configKey); } // END - foreach // Remove temporary "special" values as well - $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); - $this->getConfigInstance()->unsetConfigEntry('dht_nodes'); + FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); + FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry('dht_nodes'); } } diff --git a/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php index 9c08b8c5a..45f89edea 100644 --- a/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php +++ b/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php @@ -14,6 +14,7 @@ use Org\Shipsimu\Hub\Node\BaseHubNode; use Org\Shipsimu\Hub\Template\Engine\Xml\Request\NodeList\XmlRequestNodeListTemplateEngine; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -146,7 +147,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...'); // Copy from source to targetKey - $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey)); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry($targetKey, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($sourceKey)); } // END - foreach // Query local DHT for nodes except given session id @@ -162,13 +163,13 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: Got a node list of ' . count($nodeList) . ' entry/-ies back.'); // Set it serialized in configuration (temporarily) - $this->getConfigInstance()->setConfigEntry('node_list', base64_encode(json_encode($nodeList))); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('node_list', base64_encode(json_encode($nodeList))); // Translate last exception into a status code $statusCode = $this->getTranslatedStatusFromLastException(); // Set it in configuration (temporarily) - $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); } /** @@ -182,12 +183,12 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha // "Walk" throught the config-copy array again foreach ($this->configCopy as $configKey => $dummy) { // Now unset this configuration entry (to save some memory again) - $this->getConfigInstance()->unsetConfigEntry($configKey); + FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry($configKey); } // END - foreach // Remove answer status/node list as well - $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); - $this->getConfigInstance()->unsetConfigEntry('node_list'); + FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); + FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry('node_list'); } } diff --git a/application/hub/classes/helper/connection/class_BaseConnectionHelper.php b/application/hub/classes/helper/connection/class_BaseConnectionHelper.php index f31006a58..03f258e39 100644 --- a/application/hub/classes/helper/connection/class_BaseConnectionHelper.php +++ b/application/hub/classes/helper/connection/class_BaseConnectionHelper.php @@ -15,6 +15,7 @@ use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; use Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\Fragmentable; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -351,7 +352,7 @@ abstract class BaseConnectionHelper extends BaseHubSystemHelper implements Visit // Calculate buffer size /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: rawData()=%d - after loop ...', strlen($rawData))); - $bufferSize = $this->getConfigInstance()->getConfigEntry($this->getProtocolName() . '_buffer_length'); + $bufferSize = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($this->getProtocolName() . '_buffer_length'); // Encode the raw data with our output-stream /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: bufferSize=%d', $bufferSize)); diff --git a/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php b/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php index 09b253748..1c39b7fb5 100644 --- a/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php +++ b/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php @@ -7,6 +7,9 @@ use Org\Shipsimu\Hub\Factory\State\Peer\PeerStateFactory; use Org\Shipsimu\Hub\Helper\Connection\BaseConnectionHelper; use Org\Shipsimu\Hub\Locator\Node\LocateableNode; +// Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; + /** * A ??? connection helper class * @@ -62,7 +65,7 @@ abstract class BaseIpV4ConnectionHelper extends BaseConnectionHelper { assert($this->isInitialized()); // "Cache" socket resource and timeout config - $timeout = $this->getConfigInstance()->getConfigEntry('socket_timeout_seconds'); + $timeout = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('socket_timeout_seconds'); // Debug output self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: Trying to connect to %s with socketResource[%s]=%s ...', $this->getSocketInstance()->getSocketRecipient(), gettype($this->getSocketInstance()->getSocketResource()), $this->getSocketInstance()->getSocketResource())); diff --git a/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php b/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php index 27d8b751b..6d005b289 100644 --- a/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php +++ b/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php @@ -13,6 +13,7 @@ use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; use Org\Shipsimu\Hub\Tools\HubTools; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; /** * A TCP connection helper class @@ -87,7 +88,7 @@ class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements Connection self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Failed to resolve ' . $packageInstance->getRecipientUnl() . ':' . $e->getMessage()); // Is the recipient equal as configured UNL? - if (substr($packageInstance->getRecipientUnl(), 0, strlen($helperInstance->getConfigInstance()->getConfigEntry('external_address'))) == $helperInstance->getConfigInstance()->getConfigEntry('external_address')) { + if (substr($packageInstance->getRecipientUnl(), 0, strlen(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('external_address'))) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('external_address')) { // This may connect to shipsimu.org and requests 'ip.php' which will return our external IP address $unlAddress = HubTools::determineExternalAddress(); @@ -115,7 +116,7 @@ class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements Connection __METHOD__, __LINE__, $packageInstance->getRecipientUnl(), - $helperInstance->getConfigInstance()->getConfigEntry('external_address') + FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('external_address') )); } } diff --git a/application/hub/classes/info/connection/class_ConnectionInfo.php b/application/hub/classes/info/connection/class_ConnectionInfo.php index 851d2098b..1410062d8 100644 --- a/application/hub/classes/info/connection/class_ConnectionInfo.php +++ b/application/hub/classes/info/connection/class_ConnectionInfo.php @@ -196,7 +196,7 @@ class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable { */ public function fillWithConnectionHelperInformation (ConnectionHelper $helperInstance) { // Fill the generic array with several data from the listener: - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: protocolName=%s,helperInstance=%s,socketResource=%s - CALLED!', $helperInstance->getProtocolName(), $helperInstance->__toString(), $helperInstance->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: protocolName=%s,helperInstance=%s - CALLED!', $helperInstance->getProtocolName(), $helperInstance->__toString())); $this->setProtocolName($helperInstance->getSocketInstance()->getSocketProtocol()); $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_ADDRESS, $helperInstance->getSocketInstance()->getSocketRecipientAddress()); $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_PORT , $helperInstance->getSocketInstance()->getSocketRecipientPort()); diff --git a/application/hub/classes/iterator/producer/keys/class_TestUnitKeyProducerIterator.php b/application/hub/classes/iterator/producer/keys/class_TestUnitKeyProducerIterator.php index d5a709903..26efe5d2d 100644 --- a/application/hub/classes/iterator/producer/keys/class_TestUnitKeyProducerIterator.php +++ b/application/hub/classes/iterator/producer/keys/class_TestUnitKeyProducerIterator.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\Iterator\Producer\Key\TestUnit; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; use Org\Mxchange\CoreFramework\Iterator\BaseIterator; @@ -57,7 +58,7 @@ class TestUnitKeyProducerIterator extends BaseIterator implements Iterator { parent::__construct(__CLASS__); // Get key length - $this->keyLength = $this->getConfigInstance()->getConfigEntry('test_unit_random_secret_key_length'); + $this->keyLength = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('test_unit_random_secret_key_length'); // Make sure the key length isn't getting to big (32 byte = 256 bit is really, really a lot!) assert($this->keyLength <= (8 * 32)); @@ -141,7 +142,5 @@ class TestUnitKeyProducerIterator extends BaseIterator implements Iterator { public function valid () { return ($this->currentIteration <= $this->maxBits); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/listener/class_BaseListener.php b/application/hub/classes/listener/class_BaseListener.php index 3134a9661..d4131f38f 100644 --- a/application/hub/classes/listener/class_BaseListener.php +++ b/application/hub/classes/listener/class_BaseListener.php @@ -16,9 +16,11 @@ use Org\Shipsimu\Hub\Pool\Peer\PoolablePeer; use Org\Shipsimu\Hub\Pool\Poolable; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Factory\Registry\Socket\SocketRegistryFactory; use Org\Mxchange\CoreFramework\Generic\NullPointerException; +use Org\Mxchange\CoreFramework\Registry\Register; use Org\Mxchange\CoreFramework\Socket\InvalidServerSocketException; use Org\Mxchange\CoreFramework\Socket\SocketAlreadyRegisteredException; use Org\Mxchange\CoreFramework\Visitor\Visitable; @@ -81,6 +83,11 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { */ private $protocolName = 'invalid'; + /** + * Registry instance (implementing Register) + */ + private $registryInstance = NULL; + /** * Protected constructor * @@ -158,7 +165,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { * @return void */ public final function setListenAddressByConfiguration (string $configEntry) { - $this->setListenAddress($this->getConfigInstance()->getConfigEntry($configEntry)); + $this->setListenAddress(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry)); } /** @@ -168,7 +175,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { * @return void */ public final function setListenPortByConfiguration (string $configEntry) { - $this->setListenPort($this->getConfigInstance()->getConfigEntry($configEntry)); + $this->setListenPort(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry)); } /** @@ -209,6 +216,25 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { $this->protocolName = $protocolName; } + /** + * Setter for registry instance + * + * @param $registryInstance An instance of a Register class + * @return void + */ + protected final function setRegistryInstance (Register $registryInstance) { + $this->registryInstance = $registryInstance; + } + + /** + * Getter for registry instance + * + * @return $registryInstance The debug registry instance + */ + protected final function getRegistryInstance () { + return $this->registryInstance; + } + /** * Registeres the given socket resource for "this" listener instance. This * will be done in a seperate class to allow package writers to use it diff --git a/application/hub/classes/miner/chash/class_HubCoinMiner.php b/application/hub/classes/miner/chash/class_HubCoinMiner.php index 51dceb09f..79316bddd 100644 --- a/application/hub/classes/miner/chash/class_HubCoinMiner.php +++ b/application/hub/classes/miner/chash/class_HubCoinMiner.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Miner; use Org\Shipsimu\Hub\Helper\Miner\MinerHelper; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -73,7 +74,7 @@ class HubCoinMiner extends BaseHubMiner implements MinerHelper, Registerable { */ protected function fillInBufferQueueWithTestUnits () { // Are test units enabled? - if ($this->getConfigInstance()->getConfigEntry('miner_test_units_enabled') == 'N') { + if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('miner_test_units_enabled') == 'N') { // They are disabled, so skip any further steps return; } elseif ($this->getStateInstance()->isMinerStateVirgin()) { @@ -85,7 +86,7 @@ class HubCoinMiner extends BaseHubMiner implements MinerHelper, Registerable { $generatorInstance = ObjectFactory::createObjectByConfiguredName('miner_test_unit_generator_class'); // We don't need an iterator here because we just need to generate some test units - for ($idx = 0; $idx < $this->getConfigInstance()->getConfigEntry('miner_max_text_unit_amount'); $idx++) { + for ($idx = 0; $idx < FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('miner_max_text_unit_amount'); $idx++) { // Get a test unit from it $unitInstance = $generatorInstance->generateNextUnitInstance(); diff --git a/application/hub/classes/miner/class_BaseHubMiner.php b/application/hub/classes/miner/class_BaseHubMiner.php index 3215bde1e..c0a72a836 100644 --- a/application/hub/classes/miner/class_BaseHubMiner.php +++ b/application/hub/classes/miner/class_BaseHubMiner.php @@ -9,6 +9,7 @@ use Org\Shipsimu\Hub\Helper\Miner\MinerHelper; use Org\Shipsimu\Hub\Producer\Block\BlockProducer; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Database\Updateable; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -125,7 +126,7 @@ abstract class BaseHubMiner extends BaseHubSystem implements Updateable { */ protected function isInBufferQueueFilled () { // Determine it - $isFilled = ($this->bufferInstance->getStackCount(self::STACKER_NAME_IN_QUEUE) > $this->getConfigInstance()->getConfigEntry('miner_in_buffer_min_threshold')); + $isFilled = ($this->bufferInstance->getStackCount(self::STACKER_NAME_IN_QUEUE) > FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('miner_in_buffer_min_threshold')); // And return the result return $isFilled; @@ -210,7 +211,7 @@ abstract class BaseHubMiner extends BaseHubSystem implements Updateable { $this->fillInBufferQueueWithWorkUnits(); // Is the buffer still not filled and are test-packages allowed? - if ((!$this->isInBufferQueueFilled()) && ($this->getConfigInstance()->getConfigEntry('miner_test_units_enabled') == 'Y')) { + if ((!$this->isInBufferQueueFilled()) && (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('miner_test_units_enabled') == 'Y')) { // Then fill the in-buffer with (one) test-unit(s) $this->fillInBufferQueueWithTestUnits(); } // END - if diff --git a/application/hub/classes/nodes/boot/class_HubBootNode.php b/application/hub/classes/nodes/boot/class_HubBootNode.php index d54b5ac14..78a3f6db2 100644 --- a/application/hub/classes/nodes/boot/class_HubBootNode.php +++ b/application/hub/classes/nodes/boot/class_HubBootNode.php @@ -78,7 +78,7 @@ class HubBootNode extends BaseHubNode implements Node, Registerable { // Now check if the IP address matches one of the bootstrap nodes if ($this->ifAddressMatchesBootstrapNodes($unl)) { // Get our port from configuration - $ourPort = $this->getConfigInstance()->getConfigEntry('node_listen_port'); + $ourPort = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_listen_port'); // Extract port $bootPort = substr($this->getBootUniversalNodeLocator(), -strlen($ourPort), strlen($ourPort)); diff --git a/application/hub/classes/nodes/class_BaseHubNode.php b/application/hub/classes/nodes/class_BaseHubNode.php index 2791199c7..dbb1adb9f 100644 --- a/application/hub/classes/nodes/class_BaseHubNode.php +++ b/application/hub/classes/nodes/class_BaseHubNode.php @@ -204,7 +204,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC $isFound = FALSE; // Run through all configured IPs - foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unl) { + foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unl) { // Does it match? if ($unl == $remoteAddr) { // Found it! @@ -218,7 +218,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC // Stop further searching break; - } elseif ($unl == $this->getConfigInstance()->getConfigEntry('node_listen_addr')) { + } elseif ($unl == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_listen_addr')) { /* * IP matches listen address. At this point we really don't care * if we can really listen on that address @@ -258,7 +258,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC } // END - if // There are 2 UNLs, internal and external. - if ($this->getConfigInstance()->getConfigEntry('allow_publish_internal_address') == 'N') { + if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('allow_publish_internal_address') == 'N') { // Public "external" UNL address $GLOBALS[__METHOD__] = $locatorInstance->getExternalUnl(); } else { @@ -800,7 +800,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC */ public function updateNodeData () { // Set some dummy configuration entries, e.g. node_status - $this->getConfigInstance()->setConfigEntry('node_status', $this->getStateInstance()->getStateName()); + FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('node_status', $this->getStateInstance()->getStateName()); } /** diff --git a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php index ac81171ee..5bfde6e7d 100644 --- a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php +++ b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php @@ -10,6 +10,7 @@ use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; // Import framework stuff use Org\Mxchange\CoreFramework\Assertion\AssertionException; +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -150,7 +151,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera // Load some configuration entries and "cache" them: //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: CALLED!'); // - Chunk size in bits - $this->chunkSize = $this->getConfigInstance()->getConfigEntry('package_chunk_size'); + $this->chunkSize = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('package_chunk_size'); // - Maximum serial number $this->maxSerialNumber = $this->hex2dec(str_repeat('f', self::MAX_SERIAL_LENGTH)); diff --git a/application/hub/classes/producer/class_BaseProducer.php b/application/hub/classes/producer/class_BaseProducer.php index d39dfba80..9525ba37d 100644 --- a/application/hub/classes/producer/class_BaseProducer.php +++ b/application/hub/classes/producer/class_BaseProducer.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Producer; use Org\Shipsimu\Hub\Generic\BaseHubSystem; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Stacker\Stackable; @@ -163,7 +164,7 @@ abstract class BaseProducer extends BaseHubSystem { * @return $isReached Whether the limit is reached */ protected function isOutgoingQueueLimitReached ($configEntry) { - return ($this->getConfigInstance()->getConfigEntry($configEntry) <= $this->getOutgoingQueueInstance()->getStackCount(self::STACKER_NAME_OUT_QUEUE)); + return (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry) <= $this->getOutgoingQueueInstance()->getStackCount(self::STACKER_NAME_OUT_QUEUE)); } /** @@ -192,7 +193,7 @@ abstract class BaseProducer extends BaseHubSystem { * @return $isReached Whether the limit is reached */ protected function isIncomingQueueLimitReached($configEntry) { - return ($this->getConfigInstance()->getConfigEntry($configEntry) <= $this->getIncomingQueueInstance()->getStackCount(self::STACKER_NAME_IN_QUEUE)); + return (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry) <= $this->getIncomingQueueInstance()->getStackCount(self::STACKER_NAME_IN_QUEUE)); } } diff --git a/application/hub/classes/recipient/direct/class_DirectRecipient.php b/application/hub/classes/recipient/direct/class_DirectRecipient.php index b82569b43..7a745b36e 100644 --- a/application/hub/classes/recipient/direct/class_DirectRecipient.php +++ b/application/hub/classes/recipient/direct/class_DirectRecipient.php @@ -10,6 +10,7 @@ use Org\Shipsimu\Hub\Network\Recipient\Recipient; use Org\Shipsimu\Hub\Tools\HubTools; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Lists\Listable; /** @@ -79,7 +80,7 @@ class DirectRecipient extends BaseRecipient implements Recipient { $recipients = explode(NetworkPackageHandler::PACKAGE_RECIPIENT_SEPARATOR, $recipientUnl); // Is maximum reached? - assert(count($recipients) <= $this->getConfigInstance()->getConfigEntry('package_recipient_max_count')); + assert(count($recipients) <= FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('package_recipient_max_count')); // Try it on all foreach ($recipients as $recipient) { diff --git a/application/hub/classes/recipient/upper/class_UpperRecipient.php b/application/hub/classes/recipient/upper/class_UpperRecipient.php index ade3da627..38da98e95 100644 --- a/application/hub/classes/recipient/upper/class_UpperRecipient.php +++ b/application/hub/classes/recipient/upper/class_UpperRecipient.php @@ -10,6 +10,7 @@ use Org\Shipsimu\Hub\Network\Recipient\BaseRecipient; use Org\Shipsimu\Hub\Network\Recipient\Recipient; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Lists\Listable; /** @@ -79,11 +80,11 @@ class UpperRecipient extends BaseRecipient implements Recipient { assert($recipientUnl == NetworkPackageHandler::RECIPIENT_TYPE_UPPER); // Get all bootstrap nodes - foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unlData) { + foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unlData) { // Is maximum reached? - if ($listInstance->count() == $this->getConfigInstance()->getConfigEntry('package_recipient_max_count')) { + if ($listInstance->count() == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('package_recipient_max_count')) { // Then stop adding more - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UPPER-RECIPIENT: Going to abort at maximum of ' . $this->getConfigInstance()->getConfigEntry('package_recipient_max_count') . ' recipients!'); + /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UPPER-RECIPIENT: Going to abort at maximum of ' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('package_recipient_max_count') . ' recipients!'); break; } // END - if diff --git a/application/hub/classes/resolver/protocol/class_ b/application/hub/classes/resolver/protocol/class_ index 27f7d38e4..3fa7c0689 100644 --- a/application/hub/classes/resolver/protocol/class_ +++ b/application/hub/classes/resolver/protocol/class_ @@ -7,6 +7,9 @@ use Org\Mxchange\Hub\Node\Node; use Org\Mxchange\Hub\Resolver\Protocol\BaseProtocolResolver; use Org\Mxchange\Hub\Resolver\Protocol\ProtocolResolver; +// Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; + /** * A !!! protocol resolver class * @@ -76,7 +79,7 @@ class !!!ProtocolResolver extends BaseProtocolResolver implements ProtocolResolv // Put all together $unl = sprintf('%s://%s', $this->getProtocolName(), - $this->getConfigInstance()->getConfigEntry($configKey . '_address') + FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configKey . '_address') ); /* @@ -86,7 +89,5 @@ class !!!ProtocolResolver extends BaseProtocolResolver implements ProtocolResolv */ return $unl; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php b/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php index 3c69aef0f..705da8921 100644 --- a/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php +++ b/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php @@ -10,6 +10,7 @@ use Org\Shipsimu\Hub\Resolver\Protocol\BaseProtocolResolver; use Org\Shipsimu\Hub\Resolver\Protocol\ProtocolResolver; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Console\Tools\ConsoleTools; use Org\Mxchange\CoreFramework\Criteria\Search\SearchCriteria; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; @@ -112,7 +113,7 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv */ public function resolveUniversalNodeLocatorFromConfigKey ($configKey) { // Get address - $address = $this->getConfigInstance()->getConfigEntry($configKey . '_address'); + $address = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configKey . '_address'); // Is the address empty? if (empty($address)) { @@ -132,7 +133,7 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv $unl = sprintf('%s://%s:%s', $this->getProtocolName(), $address, - $this->getConfigInstance()->getConfigEntry('node_listen_port') + FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_listen_port') ); /* diff --git a/application/hub/classes/source/units/class_TestUnitSource.php b/application/hub/classes/source/units/class_TestUnitSource.php index 5a16e714e..93f716ece 100644 --- a/application/hub/classes/source/units/class_TestUnitSource.php +++ b/application/hub/classes/source/units/class_TestUnitSource.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Crawler\Source\Unit; use Org\Shipsimu\Hub\Crawler\Source\BaseSource; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -70,10 +71,10 @@ class TestUnitSource extends BaseSource implements UnitSource, Registerable { */ public function generateMessageFromSource () { // Get a very secret message by encoding and random string with BASE64 - $secretMessage = base64_encode($this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('random_secret_message_length'))); + $secretMessage = base64_encode($this->getRngInstance()->randomString(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('random_secret_message_length'))); // Get a random, secret key - $secretKey = $this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('test_unit_random_secret_key_length') / 8); + $secretKey = $this->getRngInstance()->randomString(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('test_unit_random_secret_key_length') / 8); // Now encrypt the message with our key and a good (strong) cipher $encryptedMessage = base64_encode($this->getCryptoInstance()->encryptString($secretMessage, $secretKey)); diff --git a/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php b/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php index 0f23b5ed1..764288f4d 100644 --- a/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php +++ b/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php @@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Crawler\Source\Url\BaseUrlSource; use Org\Shipsimu\Hub\Crawler\Source\Url\UrlSource; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -92,7 +93,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R parent::__construct(__CLASS__); // "Cache" CSV path for faster usage - $this->csvFilePath = $this->getConfigInstance()->getConfigEntry('root_base_path') . $this->getConfigInstance()->getConfigEntry('crawler_csv_file_path'); + $this->csvFilePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('root_base_path') . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('crawler_csv_file_path'); // Initialize directory instance /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CRAWLER-UPLOADED-LIST-URL-SOURCE: this->csvFilePath=%s', $this->csvFilePath)); @@ -115,7 +116,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R } // "Cache" column separator - $this->columnSeparator = $this->getConfigInstance()->getConfigEntry('crawler_url_list_column_separator'); + $this->columnSeparator = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('crawler_url_list_column_separator'); // Trace message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-UPLOADED-LIST-URL-SOURCE: Finished contructing object.'); diff --git a/application/hub/classes/statistics/connection/class_ConnectionStatisticsHelper.php b/application/hub/classes/statistics/connection/class_ConnectionStatisticsHelper.php index 46e0b05d9..fa48628e1 100644 --- a/application/hub/classes/statistics/connection/class_ConnectionStatisticsHelper.php +++ b/application/hub/classes/statistics/connection/class_ConnectionStatisticsHelper.php @@ -6,6 +6,9 @@ namespace Org\Shipsimu\Hub\Helper\Connection; use Org\Shipsimu\Hub\Generic\BaseHubSystem; use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper; +// Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; + /** * A helper class for maintaining connection statistics, no instance is * required to use this class. @@ -74,7 +77,7 @@ class ConnectionStatisticsHelper extends BaseHubSystem { ( isset(self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count']) ) && ( - self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'] >= $helperInstance->getConfigInstance()->getConfigEntry($configEntry) + self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'] >= FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry) ) ); diff --git a/application/hub/classes/template/class_BaseXmlTemplateEngine.php b/application/hub/classes/template/class_BaseXmlTemplateEngine.php index 1a6c627ed..06c7715a3 100644 --- a/application/hub/classes/template/class_BaseXmlTemplateEngine.php +++ b/application/hub/classes/template/class_BaseXmlTemplateEngine.php @@ -104,7 +104,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine { $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Determine base path - $templateBasePath = $this->getConfigInstance()->getConfigEntry('application_base_path') . FrameworkBootstrap::getRequestInstance()->getRequestElement('app') . '/'; + $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . FrameworkBootstrap::getRequestInstance()->getRequestElement('app') . '/'; // Is the base path valid? if (empty($templateBasePath)) { @@ -125,13 +125,13 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine { $this->setTemplateBasePath($templateBasePath); // Set template extensions - $this->setRawTemplateExtension($this->getConfigInstance()->getConfigEntry('raw_template_extension')); - $this->setCodeTemplateExtension($this->getConfigInstance()->getConfigEntry($typePrefix . '_message_template_extension')); + $this->setRawTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('raw_template_extension')); + $this->setCodeTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($typePrefix . '_message_template_extension')); // Absolute output path for compiled templates $this->setCompileOutputPath(sprintf('%s%s', $templateBasePath, - $this->getConfigInstance()->getConfigEntry('compile_output_path') + FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('compile_output_path') )); // Init a variable stacker @@ -164,7 +164,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine { } // END - if // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry($templateName)); + $this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($templateName)); // Load the special template $this->loadTemplate($this->xmlTemplateType); diff --git a/application/hub/classes/tools/hub/class_HubTools.php b/application/hub/classes/tools/hub/class_HubTools.php index 8f48342b9..0e0f71110 100644 --- a/application/hub/classes/tools/hub/class_HubTools.php +++ b/application/hub/classes/tools/hub/class_HubTools.php @@ -69,7 +69,7 @@ class HubTools extends BaseHubSystem { parent::__construct(__CLASS__); // Init salt length - $this->sessionIdLength = 32 + $this->getConfigInstance()->getConfigEntry('salt_length'); + $this->sessionIdLength = 32 + FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('salt_length'); } /** @@ -132,7 +132,7 @@ class HubTools extends BaseHubSystem { // Is the session id the same? if ($nodeInstance->getSessionId() == $sessionId) { // Then get an instance of a LocateableNode class from it, assume TCP by default - $recipientUnl = self::determineOwnExternalAddress() . ':' . $nodeInstance->getConfigInstance()->getConfigEntry('node_listen_port'); + $recipientUnl = self::determineOwnExternalAddress() . ':' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_listen_port'); } // END - if } diff --git a/core b/core index c1aadb61b..9128348f9 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit c1aadb61b45c15273c07c366887c8f58c53155e3 +Subproject commit 9128348f96854b318a9bf8884b1ee035f3f94e6c -- 2.39.5