* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class UnitSourceFactory extends ObjectFactory {
- /**
- * Source instances
- */
- private static $sourceInstances = array();
-
/**
* Protected constructor
*
*/
public static final function createUnitSourceInstance ($unitType) {
// Do we have cache?
- if (!isset(self::$sourceInstances[$unitType])) {
+ if (!Registry::getRegistry()->instanceExists($unitType . '_unit_source')) {
// Then construct the class' configuraton entry
$className = '' . $unitType . '_unit_source_class';
// Get a class from that configuration entry
- self::$sourceInstances[$unitType] = self::createObjectByConfiguredName($className);
- } // END - if
+ $sourceInstance = self::createObjectByConfiguredName($className);
+
+ // Add it to the registry
+ Registry::getRegistry()->addInstance($unitType . '_unit_source', $sourceInstance);
+ } else {
+ // Get it from registry
+ $sourceInstance = Registry::getRegistry()->getInstance($unitType . '_unit_source');
+ }
// For any purposes, return the source instance
- return self::$sourceInstances[$unitType];
+ return $sourceInstance;
}
}