From 89467fb582896e18a9ce6376b70ab95cd0fe4f4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 4 Jan 2018 00:44:41 +0100 Subject: [PATCH] Continued: - ported crawler sub project to new 'core' framework - had to copy some setter/getter to base classes where BaseHubSystem was not inherited from 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 | 100 ++++++++++++++++++ .../communicator/class_BaseCommunicator.php | 1 + .../crawler/class_CrawlerNodeCommunicator.php | 4 + .../miner/class_MinerNodeCommunicator.php | 4 + application/hub/classes/crawler/class_ | 4 +- .../classes/crawler/class_BaseNodeCrawler.php | 1 + .../console/class_NodeConsoleCrawler.php | 4 +- .../class_CommunicatorFactory.php | 2 +- .../source/units/class_UnitSourceFactory.php | 2 +- .../url/class_UrlSourceObjectFactory.php | 2 +- .../class_CommunicatorStateFactory.php | 7 +- .../crawler/class_CrawlerStateFactory.php | 2 +- ...ss_CrawlerTaskHandlerInitializerFilter.php | 4 +- .../hub/classes/scanner/class_BaseScanner.php | 2 +- .../class_CrawlerUploadedListScanner.php | 4 + .../hub/classes/source/class_BaseSource.php | 4 +- .../classes/source/class_BaseUrlSource.php | 9 ++ .../source/units/class_TestUnitSource.php | 7 +- .../urls/class_CrawlerFoundRssUrlSource.php | 10 +- .../urls/class_CrawlerLocalStartUrlSource.php | 10 +- .../urls/class_CrawlerRssStartUrlSource.php | 10 +- .../class_CrawlerUploadedListUrlSource.php | 6 +- .../active/class_CommunicatorActiveState.php | 9 +- .../class_BaseCommunicatorState.php | 27 +++++ .../init/class_CommunicatorInitState.php | 6 ++ .../active/class_CrawlerActiveState.php | 3 + .../booting/class_CrawlerBootingState.php | 3 + .../crawler/init/class_CrawlerInitState.php | 5 + .../tasks/crawler/class_BaseUrlSourceTask.php | 31 +++++- .../class_CrawlerNodeCommunicatorTask.php | 3 + .../crawler/ping/class_CrawlerPingTask.php | 2 +- .../class_CrawlerUrlSourceFoundRssTask.php | 14 ++- .../class_CrawlerUrlSourceLocalStartTask.php | 14 ++- .../class_CrawlerUrlSourceRssStartTask.php | 14 ++- ...class_CrawlerUrlSourceUploadedListTask.php | 14 ++- .../class_MinerNodeCommunicatorTask.php | 3 + application/hub/config.php | 10 +- .../hub/interfaces/scanner/class_Scanner.php | 4 +- .../hub/interfaces/source/class_Source.php | 5 +- .../source/units/class_UnitSource.php | 10 +- .../source/urls/class_UrlSource.php | 10 +- core | 2 +- 42 files changed, 318 insertions(+), 70 deletions(-) diff --git a/application/hub/classes/class_BaseHubSystem.php b/application/hub/classes/class_BaseHubSystem.php index 2129629d1..db93dde02 100644 --- a/application/hub/classes/class_BaseHubSystem.php +++ b/application/hub/classes/class_BaseHubSystem.php @@ -3,7 +3,11 @@ namespace Org\Shipsimu\Hub\Generic; // Import application-specific stuff +use Org\ShipSimu\Hub\Communicator\Communicator; use Org\Shipsimu\Hub\Container\Socket\StorableSocket; +use Org\Shipsimu\Hub\Crawler\Crawler; +use Org\Shipsimu\Hub\Crawler\Source\Source; +use Org\Shipsimu\Hub\Crawler\Source\Url\UrlSource; use Org\Shipsimu\Hub\Handler\Protocol\HandleableProtocol; use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData; use Org\Shipsimu\Hub\Information\ShareableInfo; @@ -119,6 +123,26 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface */ private $universalNodeLocatorInstance = NULL; + /** + * An instance of a communicator + */ + private $communicatorInstance = NULL; + + /** + * An instance of a Source class + */ + private $sourceInstance = NULL; + + /** + * An instance of a UrlSource class + */ + private $urlSourceInstance = NULL; + + /** + * An instance of a Crawler class + */ + private $crawlerInstance = NULL; + /** * Name of used protocol */ @@ -445,4 +469,80 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface return $this->universalNodeLocatorInstance; } + /** + * Getter for communicator instance + * + * @return $communicatorInstance An instance of a Communicator class + */ + public final function getCommunicatorInstance () { + return $this->communicatorInstance; + } + + /** + * Setter for communicator instance + * + * @param $communicatorInstance An instance of a Communicator class + * @return void + */ + protected final function setCommunicatorInstance (Communicator $communicatorInstance) { + $this->communicatorInstance = $communicatorInstance; + } + + /** + * Setter for a Source instance + * + * @param $sourceInstance An instance of a Source class + * @return void + */ + protected final function setSourceInstance (Source $sourceInstance) { + $this->sourceInstance = $sourceInstance; + } + + /** + * Getter for a Source instance + * + * @return $sourceInstance An instance of a Source class + */ + protected final function getSourceInstance () { + return $this->sourceInstance; + } + + /** + * Setter for a UrlSource instance + * + * @param $urlSourceInstance An instance of a UrlSource class + * @return void + */ + public final function setUrlSourceInstance (UrlSource $urlSourceInstance) { + $this->urlSourceInstance = $urlSourceInstance; + } + + /** + * Getter for a UrlSource instance + * + * @return $urlSourceInstance An instance of a UrlSource class + */ + public final function getUrlSourceInstance () { + return $this->urlSourceInstance; + } + + /** + * Setter for a Crawler instance + * + * @param $crawlerInstance An instance of a Crawler class + * @return void + */ + protected final function setCrawlerInstance (Crawler $crawlerInstance) { + $this->crawlerInstance = $crawlerInstance; + } + + /** + * Getter for a Crawler instance + * + * @return $crawlerInstance An instance of a Crawler class + */ + protected final function getCrawlerInstance () { + return $this->crawlerInstance; + } + } diff --git a/application/hub/classes/communicator/class_BaseCommunicator.php b/application/hub/classes/communicator/class_BaseCommunicator.php index 7fc14d84a..242a32c74 100644 --- a/application/hub/classes/communicator/class_BaseCommunicator.php +++ b/application/hub/classes/communicator/class_BaseCommunicator.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\Communicator; // Import application-specific stuff +use Org\Shipsimu\Hub\Factory\State\Communicator\CommunicatorStateFactory; use Org\Shipsimu\Hub\Generic\BaseHubSystem; // Import framework stuff diff --git a/application/hub/classes/communicator/crawler/class_CrawlerNodeCommunicator.php b/application/hub/classes/communicator/crawler/class_CrawlerNodeCommunicator.php index 9f9583e95..ac1cdd8a9 100644 --- a/application/hub/classes/communicator/crawler/class_CrawlerNodeCommunicator.php +++ b/application/hub/classes/communicator/crawler/class_CrawlerNodeCommunicator.php @@ -2,6 +2,10 @@ // Own namespace namespace Org\Shipsimu\Hub\Crawler\Communicator\Node; +// Import application-specific stuff +use Org\Shipsimu\Hub\Communicator\BaseCommunicator; +use Org\ShipSimu\Hub\Communicator\Communicator; + // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; diff --git a/application/hub/classes/communicator/miner/class_MinerNodeCommunicator.php b/application/hub/classes/communicator/miner/class_MinerNodeCommunicator.php index e392d6676..cc6e29caa 100644 --- a/application/hub/classes/communicator/miner/class_MinerNodeCommunicator.php +++ b/application/hub/classes/communicator/miner/class_MinerNodeCommunicator.php @@ -2,6 +2,10 @@ // Own namespace namespace Org\Shipsimu\Hub\Miner\Communicator\Node; +// Import application-specific stuff +use Org\Shipsimu\Hub\Communicator\BaseCommunicator; +use Org\ShipSimu\Hub\Communicator\Communicator; + // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; diff --git a/application/hub/classes/crawler/class_ b/application/hub/classes/crawler/class_ index 3c1267a85..c4b09bcc4 100644 --- a/application/hub/classes/crawler/class_ +++ b/application/hub/classes/crawler/class_ @@ -82,7 +82,5 @@ class Node???Crawler extends BaseNodeCrawler implements Crawler { public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { $this->partialStub('Please implement this method.'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/crawler/class_BaseNodeCrawler.php b/application/hub/classes/crawler/class_BaseNodeCrawler.php index 57ca8fa3d..37c11b957 100644 --- a/application/hub/classes/crawler/class_BaseNodeCrawler.php +++ b/application/hub/classes/crawler/class_BaseNodeCrawler.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\Crawler; // Import application-specific stuff +use Org\Shipsimu\Hub\Crawler\Factory\State\CrawlerStateFactory; use Org\Shipsimu\Hub\Generic\BaseHubSystem; // Import framework stuff diff --git a/application/hub/classes/crawler/console/class_NodeConsoleCrawler.php b/application/hub/classes/crawler/console/class_NodeConsoleCrawler.php index a783a12b1..de8c4845b 100644 --- a/application/hub/classes/crawler/console/class_NodeConsoleCrawler.php +++ b/application/hub/classes/crawler/console/class_NodeConsoleCrawler.php @@ -95,7 +95,5 @@ class NodeConsoleCrawler extends BaseNodeCrawler implements Crawler, Registerabl public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { $this->partialStub('Please implement this method.'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/factories/communicator/class_CommunicatorFactory.php b/application/hub/classes/factories/communicator/class_CommunicatorFactory.php index 994075955..6f751fa92 100644 --- a/application/hub/classes/factories/communicator/class_CommunicatorFactory.php +++ b/application/hub/classes/factories/communicator/class_CommunicatorFactory.php @@ -46,7 +46,7 @@ class CommunicatorFactory extends ObjectFactory { * * @param $configEntry A configuration entry naming the real class' name * @parasm $communicatorType Type of the communicator, can currently be 'node' - * @return $communicatorInstance A communicator instance + * @return $communicatorInstance An instance of a Communicator class */ public static final function createCommunicatorInstance ($configEntry, $communicatorType) { // If there is no communicator? diff --git a/application/hub/classes/factories/source/units/class_UnitSourceFactory.php b/application/hub/classes/factories/source/units/class_UnitSourceFactory.php index 6a6eff462..cb9687cf5 100644 --- a/application/hub/classes/factories/source/units/class_UnitSourceFactory.php +++ b/application/hub/classes/factories/source/units/class_UnitSourceFactory.php @@ -1,6 +1,6 @@ getInstance('crawler'); + $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); // Get a new task handler instance $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); @@ -120,7 +120,7 @@ class CrawlerTaskHandlerInitializerFilter extends BaseCrawlerFilter implements F // 10) URL sources foreach (explode(':', $this->getConfigInstance()->getConfigEntry('crawler_url_stacks')) as $stack) { // Init task instance - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_url_source_' . $stack . '_task_class'); + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_url_source_' . $stack . '_task_class', array($crawlerInstance)); // And register it $handlerInstance->registerTask('crawler_url_source_' . $stack, $taskInstance); diff --git a/application/hub/classes/scanner/class_BaseScanner.php b/application/hub/classes/scanner/class_BaseScanner.php index 95de43636..b940f6ed4 100644 --- a/application/hub/classes/scanner/class_BaseScanner.php +++ b/application/hub/classes/scanner/class_BaseScanner.php @@ -6,7 +6,7 @@ namespace Org\Shipsimu\Hub\Scanner; use Org\Shipsimu\Hub\Generic\BaseHubSystem; /** - * A general Scanner class + * A general scanner class * * @author Roland Haeder * @version 0.0.0 diff --git a/application/hub/classes/scanner/crawler/uploaded_list/class_CrawlerUploadedListScanner.php b/application/hub/classes/scanner/crawler/uploaded_list/class_CrawlerUploadedListScanner.php index 60ceaf4dd..0a09b066e 100644 --- a/application/hub/classes/scanner/crawler/uploaded_list/class_CrawlerUploadedListScanner.php +++ b/application/hub/classes/scanner/crawler/uploaded_list/class_CrawlerUploadedListScanner.php @@ -2,6 +2,10 @@ // Own namespace namespace Org\Shipsimu\Hub\Crawler\Scanner\UploadedList; +// Import application-specific stuff +use Org\Shipsimu\Hub\Scanner\BaseScanner; +use Org\Shipsimu\Hub\Scanner\Scanner; + // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; diff --git a/application/hub/classes/source/class_BaseSource.php b/application/hub/classes/source/class_BaseSource.php index 17a0d75a2..1d4957829 100644 --- a/application/hub/classes/source/class_BaseSource.php +++ b/application/hub/classes/source/class_BaseSource.php @@ -1,12 +1,12 @@ * @version 0.0.0 diff --git a/application/hub/classes/source/class_BaseUrlSource.php b/application/hub/classes/source/class_BaseUrlSource.php index a246a5c4e..26ae79894 100644 --- a/application/hub/classes/source/class_BaseUrlSource.php +++ b/application/hub/classes/source/class_BaseUrlSource.php @@ -1,4 +1,13 @@ partialStub('Please implement this method.'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/source/urls/class_CrawlerLocalStartUrlSource.php b/application/hub/classes/source/urls/class_CrawlerLocalStartUrlSource.php index c17a152f3..32c0de07e 100644 --- a/application/hub/classes/source/urls/class_CrawlerLocalStartUrlSource.php +++ b/application/hub/classes/source/urls/class_CrawlerLocalStartUrlSource.php @@ -2,6 +2,10 @@ // Own namespace namespace Org\Shipsimu\Hub\Crawler\Source\LocalStart; +// Import application-specific stuff +use Org\Shipsimu\Hub\Crawler\Source\Url\BaseUrlSource; +use Org\Shipsimu\Hub\Crawler\Source\Url\UrlSource; + // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -41,7 +45,7 @@ class CrawlerLocalStartUrlSource extends BaseUrlSource implements UrlSource, Reg /** * Creates an instance of this class * - * @return $sourceInstance An instance of a Source class + * @return $sourceInstance An instance of an UrlSource class */ public final static function createCrawlerLocalStartUrlSource () { // Get new instance @@ -63,7 +67,5 @@ class CrawlerLocalStartUrlSource extends BaseUrlSource implements UrlSource, Reg public function fillUrlStack () { $this->partialStub('Please implement this method.'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/source/urls/class_CrawlerRssStartUrlSource.php b/application/hub/classes/source/urls/class_CrawlerRssStartUrlSource.php index 518557724..5ea203620 100644 --- a/application/hub/classes/source/urls/class_CrawlerRssStartUrlSource.php +++ b/application/hub/classes/source/urls/class_CrawlerRssStartUrlSource.php @@ -2,6 +2,10 @@ // Own namespace namespace Org\Shipsimu\Hub\Crawler\Source\RssStart; +// Import application-specific stuff +use Org\Shipsimu\Hub\Crawler\Source\Url\BaseUrlSource; +use Org\Shipsimu\Hub\Crawler\Source\Url\UrlSource; + // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -41,7 +45,7 @@ class CrawlerRssStartUrlSource extends BaseUrlSource implements UrlSource, Regis /** * Creates an instance of this class * - * @return $sourceInstance An instance of a Source class + * @return $sourceInstance An instance of an UrlSource class */ public final static function createCrawlerRssStartUrlSource () { // Get new instance @@ -63,7 +67,5 @@ class CrawlerRssStartUrlSource extends BaseUrlSource implements UrlSource, Regis public function fillUrlStack () { $this->partialStub('Please implement this method.'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php b/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php index daa2bb8a8..214cd2209 100644 --- a/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php +++ b/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php @@ -2,6 +2,10 @@ // Own namespace namespace Org\Shipsimu\Hub\Crawler\Source\Url\UploadList; +// Import application-specific stuff +use Org\Shipsimu\Hub\Crawler\Source\Url\BaseUrlSource; +use Org\Shipsimu\Hub\Crawler\Source\Url\UrlSource; + // Import framework stuff use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Generic\NullPointerException; @@ -144,7 +148,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R /** * Creates an instance of this class * - * @return $sourceInstance An instance of a Source class + * @return $sourceInstance An instance of an UrlSource class */ public final static function createCrawlerUploadedListUrlSource () { // Get new instance diff --git a/application/hub/classes/states/communicator/active/class_CommunicatorActiveState.php b/application/hub/classes/states/communicator/active/class_CommunicatorActiveState.php index f24b9562e..64f15cc66 100644 --- a/application/hub/classes/states/communicator/active/class_CommunicatorActiveState.php +++ b/application/hub/classes/states/communicator/active/class_CommunicatorActiveState.php @@ -2,6 +2,11 @@ // Own namespace namespace Org\Shipsimu\Hub\State\Communicator; +// Import application-specific stuff +use Org\Shipsimu\Hub\Communicator\BaseCommunicator; +use Org\ShipSimu\Hub\Communicator\Communicator; +use Org\Shipsimu\Hub\Communicator\State\BaseCommunicatorState; + // Import framework stuff use Org\Mxchange\CoreFramework\State\Stateable; @@ -57,7 +62,5 @@ class CommunicatorActiveState extends BaseCommunicatorState implements Stateable // Return the prepared instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/communicator/class_BaseCommunicatorState.php b/application/hub/classes/states/communicator/class_BaseCommunicatorState.php index a717f1e04..3e0140865 100644 --- a/application/hub/classes/states/communicator/class_BaseCommunicatorState.php +++ b/application/hub/classes/states/communicator/class_BaseCommunicatorState.php @@ -2,6 +2,9 @@ // Own namespace namespace Org\Shipsimu\Hub\Communicator\State; +// Import application-specific stuff +use Org\ShipSimu\Hub\Communicator\Communicator; + // Import framework stuff use Org\Mxchange\CoreFramework\State\BaseState; @@ -28,6 +31,11 @@ use Org\Mxchange\CoreFramework\State\BaseState; * along with this program. If not, see . */ abstract class BaseCommunicatorState extends BaseState { + /** + * An instance of a communicator + */ + private $communicatorInstance = NULL; + /** * Protected constructor * @@ -54,4 +62,23 @@ abstract class BaseCommunicatorState extends BaseState { } // END - if } + /** + * Getter for communicator instance + * + * @return $communicatorInstance An instance of a Communicator class + */ + public final function getCommunicatorInstance () { + return $this->communicatorInstance; + } + + /** + * Setter for communicator instance + * + * @param $communicatorInstance An instance of a Communicator class + * @return void + */ + protected final function setCommunicatorInstance (Communicator $communicatorInstance) { + $this->communicatorInstance = $communicatorInstance; + } + } diff --git a/application/hub/classes/states/communicator/init/class_CommunicatorInitState.php b/application/hub/classes/states/communicator/init/class_CommunicatorInitState.php index e192260c4..d30c0c86a 100644 --- a/application/hub/classes/states/communicator/init/class_CommunicatorInitState.php +++ b/application/hub/classes/states/communicator/init/class_CommunicatorInitState.php @@ -2,6 +2,11 @@ // Own namespace namespace Org\Shipsimu\Hub\State\Communicator; +// Import application-specific stuff +use Org\Shipsimu\Hub\Communicator\BaseCommunicator; +use Org\ShipSimu\Hub\Communicator\Communicator; +use Org\Shipsimu\Hub\Communicator\State\BaseCommunicatorState; + // Import framework stuff use Org\Mxchange\CoreFramework\Executor\Executor; use Org\Mxchange\CoreFramework\State\Stateable; @@ -68,4 +73,5 @@ class CommunicatorInitState extends BaseCommunicatorState implements Stateable { */ public function executeState (Executor $executorInstance) { } + } diff --git a/application/hub/classes/states/crawler/active/class_CrawlerActiveState.php b/application/hub/classes/states/crawler/active/class_CrawlerActiveState.php index 18f56ac47..1c67f0463 100644 --- a/application/hub/classes/states/crawler/active/class_CrawlerActiveState.php +++ b/application/hub/classes/states/crawler/active/class_CrawlerActiveState.php @@ -2,6 +2,9 @@ // Own namespace namespace Org\Shipsimu\Hub\State\Crawler; +// Import application-specific stuff +use Org\Shipsimu\Hub\Crawler\State\BaseCrawlerState; + // Import framework stuff use Org\Mxchange\CoreFramework\Executor\Executor; use Org\Mxchange\CoreFramework\State\Stateable; diff --git a/application/hub/classes/states/crawler/booting/class_CrawlerBootingState.php b/application/hub/classes/states/crawler/booting/class_CrawlerBootingState.php index 0c6d1f9ac..5e2ef07ca 100644 --- a/application/hub/classes/states/crawler/booting/class_CrawlerBootingState.php +++ b/application/hub/classes/states/crawler/booting/class_CrawlerBootingState.php @@ -2,6 +2,9 @@ // Own namespace namespace Org\Shipsimu\Hub\State\Crawler; +// Import application-specific stuff +use Org\Shipsimu\Hub\Crawler\State\BaseCrawlerState; + // Import framework stuff use Org\Mxchange\CoreFramework\Executor\Executor; use Org\Mxchange\CoreFramework\State\Stateable; diff --git a/application/hub/classes/states/crawler/init/class_CrawlerInitState.php b/application/hub/classes/states/crawler/init/class_CrawlerInitState.php index da4840c01..07661498b 100644 --- a/application/hub/classes/states/crawler/init/class_CrawlerInitState.php +++ b/application/hub/classes/states/crawler/init/class_CrawlerInitState.php @@ -2,6 +2,10 @@ // Own namespace namespace Org\Shipsimu\Hub\State\Crawler; +// Import application-specific stuff +use Org\Shipsimu\Hub\Crawler\State\BaseCrawlerState; +use Org\Shipsimu\Hub\Crawler\Factory\State\CrawlerStateFactory; + // Import framework stuff use Org\Mxchange\CoreFramework\Executor\Executor; use Org\Mxchange\CoreFramework\State\Stateable; @@ -79,4 +83,5 @@ class CrawlerInitState extends BaseCrawlerState implements Stateable { // Change state to 'booting' CrawlerStateFactory::createCrawlerStateInstanceByName('booting'); } + } diff --git a/application/hub/classes/tasks/crawler/class_BaseUrlSourceTask.php b/application/hub/classes/tasks/crawler/class_BaseUrlSourceTask.php index a340757ba..a92d4c955 100644 --- a/application/hub/classes/tasks/crawler/class_BaseUrlSourceTask.php +++ b/application/hub/classes/tasks/crawler/class_BaseUrlSourceTask.php @@ -1,9 +1,10 @@ . */ abstract class BaseUrlSourceTask extends BaseTask { + /** + * An instance of a Crawler class + */ + private $crawlerInstance = NULL; + /** * Protected constructor * @@ -52,7 +58,26 @@ abstract class BaseUrlSourceTask extends BaseTask { $sourceInstance = UrlSourceObjectFactory::createUrlSourceInstance($this); // And set it here - $this->setUrlSourceInstance($sourceInstance); + $this->getCrawlerInstance()->setUrlSourceInstance($sourceInstance); + } + + /** + * Setter for a Crawler instance + * + * @param $crawlerInstance An instance of a Crawler class + * @return void + */ + protected final function setCrawlerInstance (Crawler $crawlerInstance) { + $this->crawlerInstance = $crawlerInstance; + } + + /** + * Getter for a Crawler instance + * + * @return $crawlerInstance An instance of a Crawler class + */ + protected final function getCrawlerInstance () { + return $this->crawlerInstance; } } diff --git a/application/hub/classes/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php b/application/hub/classes/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php index d7296a41e..c9466c45e 100644 --- a/application/hub/classes/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php +++ b/application/hub/classes/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php @@ -2,6 +2,9 @@ // Own namespace namespace Org\Shipsimu\Hub\Crawler\Task\Communicator\Node; +// Import application-specific stuff +use Org\Shipsimu\Hub\Factory\Communicator\CommunicatorFactory; + // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registry; use Org\Mxchange\CoreFramework\Task\BaseTask; diff --git a/application/hub/classes/tasks/crawler/ping/class_CrawlerPingTask.php b/application/hub/classes/tasks/crawler/ping/class_CrawlerPingTask.php index 8dfb590b3..5ce32065e 100644 --- a/application/hub/classes/tasks/crawler/ping/class_CrawlerPingTask.php +++ b/application/hub/classes/tasks/crawler/ping/class_CrawlerPingTask.php @@ -1,6 +1,6 @@ setCrawlerInstance($crawlerInstance); + // Return the prepared instance return $taskInstance; } @@ -72,7 +80,7 @@ class CrawlerUrlSourceFoundRssTask extends BaseUrlSourceTask implements Taskable */ public function executeTask () { // Get source instance - $sourceInstance = $this->getUrlSourceInstance(); + $sourceInstance = $this->getCrawlerInstance()->getUrlSourceInstance(); // Is it not set? if (is_null($sourceInstance)) { @@ -80,7 +88,7 @@ class CrawlerUrlSourceFoundRssTask extends BaseUrlSourceTask implements Taskable $this->initUrlSourceTask(); // And re-get it - $sourceInstance = $this->getUrlSourceInstance(); + $sourceInstance = $this->getCrawlerInstance()->getUrlSourceInstance(); } // END - if // Get the URL source instance and fill the stack with crawl entries diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php index a71e3bc9c..7eabde2df 100644 --- a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php @@ -2,6 +2,10 @@ // Own namespace namespace Org\Shipsimu\Hub\Crawler\Task\Source\LocalStart; +// Import application-specific stuff +use Org\Shipsimu\Hub\Crawler\Crawler; +use Org\Shipsimu\Hub\Crawler\Task\Source\Url\BaseUrlSourceTask; + // Import framework stuff use Org\Mxchange\CoreFramework\Task\Taskable; use Org\Mxchange\CoreFramework\Visitor\Visitable; @@ -43,12 +47,16 @@ class CrawlerUrlSourceLocalStartTask extends BaseUrlSourceTask implements Taskab /** * Creates an instance of this class * + * @param $crawlerInstance An instance of a Crawler class * @return $taskInstance An instance of a Visitable class */ - public final static function createCrawlerUrlSourceLocalStartTask () { + public final static function createCrawlerUrlSourceLocalStartTask (Crawler $crawlerInstance) { // Get new instance $taskInstance = new CrawlerUrlSourceLocalStartTask(); + // Set crawler instance here + $taskInstance->setCrawlerInstance($crawlerInstance); + // Return the prepared instance return $taskInstance; } @@ -72,7 +80,7 @@ class CrawlerUrlSourceLocalStartTask extends BaseUrlSourceTask implements Taskab */ public function executeTask () { // Get source instance - $sourceInstance = $this->getUrlSourceInstance(); + $sourceInstance = $this->getCrawlerInstance()->getUrlSourceInstance(); // Is it not set? if (is_null($sourceInstance)) { @@ -80,7 +88,7 @@ class CrawlerUrlSourceLocalStartTask extends BaseUrlSourceTask implements Taskab $this->initUrlSourceTask(); // And re-get it - $sourceInstance = $this->getUrlSourceInstance(); + $sourceInstance = $this->getCrawlerInstance()->getUrlSourceInstance(); } // END - if // Get the URL source instance and fill the stack with crawl entries diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php index d8d274a09..0f07ba11f 100644 --- a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php @@ -2,6 +2,10 @@ // Own namespace namespace Org\Shipsimu\Hub\Crawler\Task\Source\RssStart; +// Import application-specific stuff +use Org\Shipsimu\Hub\Crawler\Crawler; +use Org\Shipsimu\Hub\Crawler\Task\Source\Url\BaseUrlSourceTask; + // Import framework stuff use Org\Mxchange\CoreFramework\Task\Taskable; use Org\Mxchange\CoreFramework\Visitor\Visitable; @@ -43,12 +47,16 @@ class CrawlerUrlSourceRssStartTask extends BaseUrlSourceTask implements Taskable /** * Creates an instance of this class * + * @param $crawlerInstance An instance of a Crawler class * @return $taskInstance An instance of a Visitable class */ - public final static function createCrawlerUrlSourceRssStartTask () { + public final static function createCrawlerUrlSourceRssStartTask (Crawler $crawlerInstance) { // Get new instance $taskInstance = new CrawlerUrlSourceRssStartTask(); + // Set crawler instance here + $taskInstance->setCrawlerInstance($crawlerInstance); + // Return the prepared instance return $taskInstance; } @@ -72,7 +80,7 @@ class CrawlerUrlSourceRssStartTask extends BaseUrlSourceTask implements Taskable */ public function executeTask () { // Get source instance - $sourceInstance = $this->getUrlSourceInstance(); + $sourceInstance = $this->getCrawlerInstance()->getUrlSourceInstance(); // Is it not set? if (is_null($sourceInstance)) { @@ -80,7 +88,7 @@ class CrawlerUrlSourceRssStartTask extends BaseUrlSourceTask implements Taskable $this->initUrlSourceTask(); // And re-get it - $sourceInstance = $this->getUrlSourceInstance(); + $sourceInstance = $this->getCrawlerInstance()->getUrlSourceInstance(); } // END - if // Get the URL source instance and fill the stack with crawl entries diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php index cf73c3f7b..15a6960c4 100644 --- a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php @@ -2,6 +2,10 @@ // Own namespace namespace Org\Shipsimu\Hub\Crawler\Task\Source\UploadedList; +// Import application-specific stuff +use Org\Shipsimu\Hub\Crawler\Crawler; +use Org\Shipsimu\Hub\Crawler\Task\Source\Url\BaseUrlSourceTask; + // Import framework stuff use Org\Mxchange\CoreFramework\Task\Taskable; use Org\Mxchange\CoreFramework\Visitor\Visitable; @@ -43,12 +47,16 @@ class CrawlerUrlSourceUploadedListTask extends BaseUrlSourceTask implements Task /** * Creates an instance of this class * + * @param $crawlerInstance An instance of a Crawler class * @return $taskInstance An instance of a Visitable class */ - public final static function createCrawlerUrlSourceUploadedListTask () { + public final static function createCrawlerUrlSourceUploadedListTask (Crawler $crawlerInstance) { // Get new instance $taskInstance = new CrawlerUrlSourceUploadedListTask(); + // Set cralwer instance here + $taskInstance->setCrawlerInstance($crawlerInstance); + // Return the prepared instance return $taskInstance; } @@ -72,7 +80,7 @@ class CrawlerUrlSourceUploadedListTask extends BaseUrlSourceTask implements Task */ public function executeTask () { // Get source instance - $sourceInstance = $this->getUrlSourceInstance(); + $sourceInstance = $this->getCrawlerInstance()->getUrlSourceInstance(); // Is it not set? if (is_null($sourceInstance)) { @@ -80,7 +88,7 @@ class CrawlerUrlSourceUploadedListTask extends BaseUrlSourceTask implements Task $this->initUrlSourceTask(); // And re-get it - $sourceInstance = $this->getUrlSourceInstance(); + $sourceInstance = $this->getCrawlerInstance()->getUrlSourceInstance(); } // END - if // Get the URL source instance and fill the stack with crawl entries diff --git a/application/hub/classes/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php b/application/hub/classes/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php index 9e8a11590..737a051a1 100644 --- a/application/hub/classes/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php +++ b/application/hub/classes/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php @@ -2,6 +2,9 @@ // Own namespace namespace Org\Shipsimu\Hub\Miner\Task\Communicator\Node; +// Import application-specific stuff +use Org\Shipsimu\Hub\Factory\Communicator\CommunicatorFactory; + // Import framework stuff use Org\Mxchange\CoreFramework\Task\BaseTask; use Org\Mxchange\CoreFramework\Task\Taskable; diff --git a/application/hub/config.php b/application/hub/config.php index bd33cc0dd..0509ddfff 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -1317,16 +1317,16 @@ $cfg->setConfigEntry('crawler_url_stacks', 'local_start:uploaded_list:rss_start: $cfg->setConfigEntry('crawler_node_communicator_task_class', 'Org\Shipsimu\Hub\Crawler\Task\Communicator\Node\CrawlerNodeCommunicatorTask'); // CFG: CRAWLER-URL-LOCAL-START-STACK-CLASS -$cfg->setConfigEntry('crawler_url_local_start_stack_class', 'Org\Mxchange\CoreFramework\Stack\Filesystem\FiFoFileStack'); +$cfg->setConfigEntry('crawler_url_local_start_stack_class', 'Org\Mxchange\CoreFramework\Stacker\Filesystem\FiFoFileStack'); // CFG: CRAWLER-URL-UPLOADED-LIST-STACK-CLASS -$cfg->setConfigEntry('crawler_url_uploaded_list_stack_class', 'Org\Mxchange\CoreFramework\Stack\Filesystem\FiFoFileStack'); +$cfg->setConfigEntry('crawler_url_uploaded_list_stack_class', 'Org\Mxchange\CoreFramework\Stacker\Filesystem\FiFoFileStack'); // CFG: CRAWLER-URL-RSS-START-STACK-CLASS -$cfg->setConfigEntry('crawler_url_rss_start_stack_class', 'Org\Mxchange\CoreFramework\Stack\Filesystem\FiFoFileStack'); +$cfg->setConfigEntry('crawler_url_rss_start_stack_class', 'Org\Mxchange\CoreFramework\Stacker\Filesystem\FiFoFileStack'); // CFG: CRAWLER-URL-FOUND-RSS-STACK-CLASS -$cfg->setConfigEntry('crawler_url_found_rss_stack_class', 'Org\Mxchange\CoreFramework\Stack\Filesystem\FiFoFileStack'); +$cfg->setConfigEntry('crawler_url_found_rss_stack_class', 'Org\Mxchange\CoreFramework\Stacker\Filesystem\FiFoFileStack'); // CFG: CRAWLER-URL-LOCAL-START-FILE-STACK-INDEX-CLASS $cfg->setConfigEntry('crawler_url_local_start_file_stack_index_class', 'Org\Mxchange\CoreFramework\Index\Stack\FileStackIndex'); @@ -1443,7 +1443,7 @@ $cfg->setConfigEntry('task_crawler_snippet_extractor_interval_delay', 250); $cfg->setConfigEntry('task_crawler_snippet_extractor_max_runs', 0); // CFG: CRAWLER-PING-TASK-CLASS -$cfg->setConfigEntry('crawler_ping_task_class', 'CrawlerPingTask'); +$cfg->setConfigEntry('crawler_ping_task_class', 'Org\Shipsimu\Hub\Crawler\Task\Ping\CrawlerPingTask'); // CFG: TASK-CRAWLER-PING-STARTUP-DELAY $cfg->setConfigEntry('task_crawler_ping_startup_delay', 1500); diff --git a/application/hub/interfaces/scanner/class_Scanner.php b/application/hub/interfaces/scanner/class_Scanner.php index 7c7673ced..65183e719 100644 --- a/application/hub/interfaces/scanner/class_Scanner.php +++ b/application/hub/interfaces/scanner/class_Scanner.php @@ -34,7 +34,5 @@ interface Scanner extends HubInterface { * @return void */ function execute (); -} -// [EOF] -?> +} diff --git a/application/hub/interfaces/source/class_Source.php b/application/hub/interfaces/source/class_Source.php index be647ffb9..d0b15f676 100644 --- a/application/hub/interfaces/source/class_Source.php +++ b/application/hub/interfaces/source/class_Source.php @@ -1,6 +1,6 @@ diff --git a/application/hub/interfaces/source/units/class_UnitSource.php b/application/hub/interfaces/source/units/class_UnitSource.php index 70ce96beb..08099d07d 100644 --- a/application/hub/interfaces/source/units/class_UnitSource.php +++ b/application/hub/interfaces/source/units/class_UnitSource.php @@ -1,4 +1,10 @@ +} diff --git a/application/hub/interfaces/source/urls/class_UrlSource.php b/application/hub/interfaces/source/urls/class_UrlSource.php index 8f30d0a5f..db1ca56f8 100644 --- a/application/hub/interfaces/source/urls/class_UrlSource.php +++ b/application/hub/interfaces/source/urls/class_UrlSource.php @@ -1,4 +1,10 @@ +} diff --git a/core b/core index ee94e79ac..bb121094b 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit ee94e79ac63d2c612ca96ba1928f9400026ce4c0 +Subproject commit bb121094b0c87c1ed028dfb5f86565b782742e6d -- 2.39.5