- added BaseUrlSource class with generic file-based stack initialization.
- added missing configuration entries.
Signed-off-by: Roland Haeder <roland@mxchange.org>
// Crawler Configuration
///////////////////////////////////////////////////////////////////////////////
+// CFG: BASE-FILE-STACKS-PATH
+$cfg->setConfigEntry('base_file_stacks_path', 'data/stacks');
+
+// CFG: FILE-STACKS-EXTENSION
+$cfg->setConfigEntry('file_stacks_extension', 'stack');
+
// CFG: HUBCONSOLE-CMD-CHAT-RESOLVER-CLASS
$cfg->setConfigEntry('hubconsole_cmd_crawler_resolver_class', 'HubConsoleCommandResolver');
// CFG: CRAWLER-NODE-COMMUNICATOR-TASK-CLASS
$cfg->setConfigEntry('crawler_node_communicator_task_class', 'CrawlerNodeCommunicatorTask');
+// CFG: CRAWLER-URL-LOCAL-START-STACK-CLASS
+$cfg->setConfigEntry('crawler_url_local_start_stack_class', 'FiFoFileStack');
+
+// CFG: CRAWLER-URL-UPLOADED-LIST-STACK-CLASS
+$cfg->setConfigEntry('crawler_url_uploaded_list_stack_class', 'FiFoFileStack');
+
+// CFG: CRAWLER-URL-RSS-START-STACK-CLASS
+$cfg->setConfigEntry('crawler_url_rss_start_stack_class', 'FiFoFileStack');
+
+// CFG: CRAWLER-URL-FOUND-RSS-STACK-CLASS
+$cfg->setConfigEntry('crawler_url_found_rss_stack_class', 'FiFoFileStack');
+
// CFG: TASK-CRAWLER-NODE-COMMUNICATOR-STARTUP-DELAY
$cfg->setConfigEntry('task_crawler_node_communicator_startup_delay', 500);
--- /dev/null
+<?php
+/**
+ * A general URL source class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseUrlSource extends BaseSource {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Initalizes this source
+ *
+ * @param $prefix Prefix for this source
+ * @param $sourceName Name of this source
+ * @return void
+ */
+ protected function initSource ($prefix, $sourceName) {
+ // Construct file stack name
+ $stackFileName = sprintf('%s/%s.%s',
+ $this->getConfigInstance()->getConfigEntry('base_file_stacks_path'),
+ $sourceName,
+ $this->getConfigInstance()->getConfigEntry('file_stacks_extension')
+ );
+
+ // Get file-based stack
+ $stackInstance = ObjectFactory::createObjectByConfiguredName($prefix . '_url_' . $sourceName . '_stack_class', array($stackFileName));
+
+ // Set stack here
+ $this->setStackerInstance($stackInstance);
+ }
+}
+
+// [EOF]
+?>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class CrawlerUrlSource??? extends BaseSource implements UrlSource, Registerable {
+class CrawlerUrlSource??? extends BaseUrlSource implements UrlSource, Registerable {
/**
* Protected constructor
*
// Get new instance
$sourceInstance = new CrawlerUrlSource???();
+ // Init source
+ $sourceInstance->initSource('crawler', '!!!');
+
// Return the prepared instance
return $sourceInstance;
}
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class CrawlerUrlSourceFoundRss extends BaseSource implements UrlSource, Registerable {
+class CrawlerUrlSourceFoundRss extends BaseUrlSource implements UrlSource, Registerable {
/**
* Protected constructor
*
// Get new instance
$sourceInstance = new CrawlerUrlSourceFoundRss();
+ // Init source
+ $sourceInstance->initSource('crawler', 'found_rss');
+
// Return the prepared instance
return $sourceInstance;
}
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class CrawlerUrlSourceLocalStart extends BaseSource implements UrlSource, Registerable {
+class CrawlerUrlSourceLocalStart extends BaseUrlSource implements UrlSource, Registerable {
/**
* Protected constructor
*
// Get new instance
$sourceInstance = new CrawlerUrlSourceLocalStart();
+ // Init source
+ $sourceInstance->initSource('crawler', 'local_start');
+
// Return the prepared instance
return $sourceInstance;
}
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class CrawlerUrlSourceRssStart extends BaseSource implements UrlSource, Registerable {
+class CrawlerUrlSourceRssStart extends BaseUrlSource implements UrlSource, Registerable {
/**
* Protected constructor
*
// Get new instance
$sourceInstance = new CrawlerUrlSourceRssStart();
+ // Init source
+ $sourceInstance->initSource('crawler', 'rss_start');
+
// Return the prepared instance
return $sourceInstance;
}
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class CrawlerUrlSourceUploadedList extends BaseSource implements UrlSource, Registerable {
+class CrawlerUrlSourceUploadedList extends BaseUrlSource implements UrlSource, Registerable {
/**
* Protected constructor
*
// Get new instance
$sourceInstance = new CrawlerUrlSourceUploadedList();
+ // Init source
+ $sourceInstance->initSource('crawler', 'uploaded_list');
+
// Return the prepared instance
return $sourceInstance;
}