* @param $stackName Name of the stack's file
* @return $indexInstance An instance of a IndexableStack class
*/
- public static final function createFileStackIndexInstance ($fileName) {
- // Call parent factory
- $indexInstance self::createObjectByConfiguredName('file_stack_index_class', array($fileName));
+ public static final function createFileStackIndexInstance ($fileName, $type) {
+ // If there is no handler?
+ if (Registry::getRegistry()->instanceExists($type . '_index')) {
+ // Get handler from registry
+ $indexInstance = Registry::getRegistry()->getInstance($type . '_index');
+ } else {
+ // Get the handler instance
+ $indexInstance = self::createObjectByConfiguredName('file_stack_' . $type . '_index_class', array($fileName));
+
+ // Add it to the registry
+ Registry::getRegistry()->addInstance($type . '_index', $indexInstance);
+ }
// Return the instance
return $indexInstance;
$stackInstance = Registry::getRegistry()->getInstance($stackName . '_stack');
} else {
// Get the handler instance
- $stackInstance = self::createObjectByConfiguredName($prefix . '_' . $stackName . '_stack_class', array($stackFileName));
+ $stackInstance = self::createObjectByConfiguredName($prefix . '_' . $stackName . '_stack_class', array($stackFileName, $prefix));
// Add it to the registry
Registry::getRegistry()->addInstance($stackName . '_stack', $stackInstance);
* Initializes this file-based stack.
*
* @param $fileName File name of this stack
+ * @param $type Type of this stack (e.g. url_source for URL sources)
* @return void
*/
- protected function initFileStack ($fileName) {
+ protected function initFileStack ($fileName, $type) {
// Get a file i/o pointer instance for stack file
$pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($fileName));
* Get stack index instance. This can be used for faster
* "defragmentation" and startup.
*/
- $indexInstance = FileStackIndexFactory::createFileStackIndex($fileName);
+ $indexInstance = FileStackIndexFactory::createFileStackIndexInstance($fileName, $type);
// And set it here
$this->setIndexInstance($indexInstance);
* Creates an instance of this class
*
* @param $fileName Absolute Name of stack file
+ * @param $type Type of this stack (e.g. url_source for URL sources)
* @return $stackInstance An instance of a Stackable class
*/
- public final static function createFiFoFileStack ($fileName) {
+ public final static function createFiFoFileStack ($fileName, $type) {
// Get new instance
$stackInstance = new FiFoFileStack();
// Init this stack
- $stackInstance->initFileStack($fileName);
+ $stackInstance->initFileStack($fileName, $type);
// Return the prepared instance
return $stackInstance;