Packagecom.developmentarc.framework.utils
Classpublic class SingletonFactory
InheritanceSingletonFactory Inheritance InstanceFactory

A Singleton Class that enables any item to be used as a Singleton reference. This Class creates a new instance of the requested Class type and then stores the reference in a static table. When an instance of a previously requested Class is made, the perviously generated instance is returned.

This class acts as a Singlton facade to the InstanceFactory Class.



Protected Properties
 PropertyDefined by
  instance : SingletonFactory
[static][read-only] Returns the current instance of the SingletonFactory.
SingletonFactory
 InheritedinstanceTable : HashTable
Stores the local instances for the factory.
InstanceFactory
  lock : Class
[static][read-only] Enables extended Classes to access the lock.
SingletonFactory
Public Methods
 MethodDefined by
 Inherited
Used to remove all current instances from the Factory.
InstanceFactory
  
[static] Used to remove all current instances from the Factory.
SingletonFactory
 Inherited
clearInstance(type:Class):void
Used to remove a specific instance type from the factory.
InstanceFactory
  
clearSingletonInstance(type:Class):void
[static] Used to remove a specific instance type from the factory.
SingletonFactory
 Inherited
getInstance(type:Class):*
Used to get access to an instance of the Class type requested.
InstanceFactory
  
getSingletonInstance(type:Class):*
[static] Used to get access to an instance of the Class type requested.
SingletonFactory
Property detail
instanceproperty
instance:SingletonFactory  [read-only]

Returns the current instance of the SingletonFactory.

Implementation
    protected static function get instance():SingletonFactory
lockproperty 
lock:Class  [read-only]

Enables extended Classes to access the lock.

Implementation
    protected static function get lock():Class
Method detail
clearAllSingletonInstances()method
public static function clearAllSingletonInstances():void

Used to remove all current instances from the Factory.

clearSingletonInstance()method 
public static function clearSingletonInstance(type:Class):void

Used to remove a specific instance type from the factory. This method checks to see if the requeted type has an intance in the table, and if so the instance is removed. This enables getInstance() to create a new instance the next time the method is called. If the instance type does not exist, nothing occurs.

Parameters
type:Class — The type of instance to look for and remove.
getSingletonInstance()method 
public static function getSingletonInstance(type:Class):*

Used to get access to an instance of the Class type requested. This method first determines if the Class type has been requested before. If the Class has never been requested, the method creates a new instance of the Class, stores it in a table and then returns a reference to the Class.

If the Class type has been requested previously, the method returns the previously generated instance.

Parameters
type:Class — The Class of the instance to return.

Returns
* — The generated instance of the Class.