From: Roland Häder Date: Sun, 22 Nov 2020 17:58:49 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bae1ac4a11606166cd5430e4b552c4f0e38cf59f;p=hub.git Continued: - moved $listInstance from monothlithic BaseFrameworkSystem to proper classes - NodePingTask had compared to all other tasks a parameter in factory method, now this is initialized within the factory method - updated core framework Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/discovery/recipient/class_BaseRecipientDiscovery.php b/application/hub/classes/discovery/recipient/class_BaseRecipientDiscovery.php index aada8e838..0591f214f 100644 --- a/application/hub/classes/discovery/recipient/class_BaseRecipientDiscovery.php +++ b/application/hub/classes/discovery/recipient/class_BaseRecipientDiscovery.php @@ -2,11 +2,14 @@ // Own namespace namespace Org\Shipsimu\Hub\Discovery\Recipient; -// Import framework stuff +// Import application-specific stuff use Org\Shipsimu\Hub\Discovery\Node\BaseNodeDiscovery; use Org\Shipsimu\Hub\Discovery\Recipient\DiscoverableRecipient; use Org\Shipsimu\Hub\Factory\Lists\Recipient\RecipientListFactory; +// Import framework stuff +use Org\Mxchange\CoreFramework\Lists\Listable; + /** * A PackageRecipient discovery class * @@ -30,6 +33,11 @@ use Org\Shipsimu\Hub\Factory\Lists\Recipient\RecipientListFactory; * along with this program. If not, see . */ abstract class BaseRecipientDiscovery extends BaseNodeDiscovery implements DiscoverableRecipient { + /** + * Instance of the list + */ + private $listInstance = NULL; + /** * Protected constructor * @@ -48,6 +56,25 @@ abstract class BaseRecipientDiscovery extends BaseNodeDiscovery implements Disco $this->setListInstance($listInstance); } + /** + * Setter for the list instance + * + * @param $listInstance A list of Listable + * @return void + */ + protected final function setListInstance (Listable $listInstance) { + $this->listInstance = $listInstance; + } + + /** + * Getter for the list instance + * + * @return $listInstance A list of Listable + */ + protected final function getListInstance () { + return $this->listInstance; + } + /** * "Getter" for recipient iterator * diff --git a/application/hub/classes/filter/task/node/class_NodeTaskHandlerInitializerFilter.php b/application/hub/classes/filter/task/node/class_NodeTaskHandlerInitializerFilter.php index dd980171d..d9ae4421d 100644 --- a/application/hub/classes/filter/task/node/class_NodeTaskHandlerInitializerFilter.php +++ b/application/hub/classes/filter/task/node/class_NodeTaskHandlerInitializerFilter.php @@ -151,11 +151,8 @@ class NodeTaskHandlerInitializerFilter extends BaseNodeFilter implements Filtera // Register it $handlerInstance->registerTask('update_check', $taskInstance); - // Get list instance here - $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); - // Prepare a ping task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_ping_task_class', array($listInstance)); + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_ping_task_class'); // Register it $handlerInstance->registerTask('ping', $taskInstance); diff --git a/application/hub/classes/tasks/node/ping/class_NodePingTask.php b/application/hub/classes/tasks/node/ping/class_NodePingTask.php index 7d952ee28..c16243450 100644 --- a/application/hub/classes/tasks/node/ping/class_NodePingTask.php +++ b/application/hub/classes/tasks/node/ping/class_NodePingTask.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\Node\Ping; // Import application-specific stuff +use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; use Org\Shipsimu\Hub\Task\BaseHubTask; // Import framework stuff @@ -27,7 +28,7 @@ use Org\Mxchange\CoreFramework\Visitor\Visitor; * (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 + * but WITHOUT ANY WARRANTY; without even the6 implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * @@ -35,6 +36,11 @@ use Org\Mxchange\CoreFramework\Visitor\Visitor; * along with this program. If not, see . */ class NodePingTask extends BaseHubTask implements Taskable, Visitable { + /** + * Instance of the list + */ + private $listInstance = NULL; + /** * Protected constructor * @@ -48,26 +54,44 @@ class NodePingTask extends BaseHubTask implements Taskable, Visitable { /** * Creates an instance of this class * - * @param $listInstance A Listable instance * @return $taskInstance An instance of a Taskable/Visitable class */ - public static final function createNodePingTask (Listable $listInstance) { + public static final function createNodePingTask () { // Get new instance $taskInstance = new NodePingTask(); - // Se the list instance in this task - $taskInstance->setListInstance($listInstance); + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); - // Init ping iterator instance - $iteratorInstance = $listInstance->getListIterator(); + // Get list instance from it + $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); - // Set it as well - $taskInstance->setIteratorInstance($iteratorInstance); + // Set the list instance in this task + $taskInstance->setListInstance($listInstance); // Return the prepared instance return $taskInstance; } + /** + * Setter for the list instance + * + * @param $listInstance A list of Listable + * @return void + */ + protected final function setListInstance (Listable $listInstance) { + $this->listInstance = $listInstance; + } + + /** + * Getter for the list instance + * + * @return $listInstance A list of Listable + */ + protected final function getListInstance () { + return $this->listInstance; + } + /** * Accepts the visitor to process the visitor * diff --git a/core b/core index df3701b72..8c96c0cfa 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit df3701b7230349ee2bc711caba98809ac943363c +Subproject commit 8c96c0cfa128e4d536788feec87d60719db198fa