* @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($type . '_file_stack_index_class', array($fileName));
+
+ // Add check for interface
+ assert($indexInstance instanceof IndexableStack);
+
+ // Add it to the registry
+ Registry::getRegistry()->addInstance($type . '_index', $indexInstance);
+ }
// Return the instance
return $indexInstance;