| Package | system.ioc |
| Class | public class ObjectFactory |
| Inheritance | ObjectFactory ObjectDefinitionContainer CoreAction Task Object |
| Implements | IObjectFactory |
Example :
import flash.text.TextField ;
import flash.text.TextFormat ;
import system.ioc.ObjectFactory ;
var factory:ObjectFactory = new ObjectFactory();
var objects:Array =
[
{
id : "my_field" ,
type : "flash.text.TextField" ,
properties :
[
{ name:"defaultTextFormat" , value:new TextFormat("Verdana", 11) } ,
{ name:"selectable" , value:false } ,
{ name:"text" , value:"hello world" } ,
{ name:"textColor" , value:0xF7F744 } ,
{ name:"x" , value:100 } ,
{ name:"y" , value:100 }
]
}
];
factory.create( objects );
var field:TextField = factory.getObject("my_field") as TextField ;
addChild(field) ;
| Property | Defined By | ||
|---|---|---|---|
![]() | changeIt : Signaler
This signal emit when the notifyChanged method is invoked. | CoreAction | |
![]() | clearIt : Signaler
This signal emit when the notifyCleared method is invoked. | CoreAction | |
| config : ObjectConfig
Determinates the configuration object of the object factory. | ObjectFactory | ||
![]() | finishIt : Signaler
This signal emit when the notifyFinished method is invoked. | Task | |
![]() | infoIt : Signaler
This signal emit when the notifyInfo method is invoked. | CoreAction | |
![]() | logger : Logger
Determinates the internal Logger reference of this Loggable object. | Task | |
![]() | looping : Boolean
The flag to determinate if the Action object is looped. | CoreAction | |
![]() | loopIt : Signaler
This signal emit when the notifyLooped method is invoked. | CoreAction | |
![]() | numObjectDefinitions : uint [read-only]
Indicates the numbers of object definitions registered in the container. | ObjectDefinitionContainer | |
| objects : Array
This array contains objects to fill this factory with the run or create method. | ObjectFactory | ||
![]() | pauseIt : Signaler
This signal emit when the notifyPause method is invoked. | CoreAction | |
![]() | phase : String [read-only]
The current phase of the action. | Task | |
![]() | progressIt : Signaler
This signal emit when the notifyProgress method is invoked. | CoreAction | |
![]() | resumeIt : Signaler
This signal emit when the notifyResumed method is invoked. | CoreAction | |
![]() | running : Boolean [read-only]
Indicates true if the process is in progress. | Task | |
| singletons : HashMap [read-only]
Returns the Map representation of all singletons register in this factory. | ObjectFactory | ||
![]() | startIt : Signaler
This signal emit when the notifyStarted method is invoked. | Task | |
![]() | stopIt : Signaler
This signal emit when the notifyStopped method is invoked. | CoreAction | |
![]() | timeoutIt : Signaler
This signal emit when the notifyTimeOut method is invoked. | CoreAction | |
| Property | Defined By | ||
|---|---|---|---|
| bufferSingletons : Array
The internal buffer of no lazyInit singletons (id) to create it in the run method if the config.lazyInit property is false. | ObjectFactory | ||
| Method | Defined By | ||
|---|---|---|---|
ObjectFactory(config:ObjectConfig = null, objects:Array = null)
Creates a new ObjectFactory instance. | ObjectFactory | ||
![]() | addObjectDefinition(definition:IObjectDefinition):void
Registers a new object definition in the container. | ObjectDefinitionContainer | |
![]() | clearObjectDefinition():void
Removes all the object definitions register in the container. | ObjectDefinitionContainer | |
clone():* [override]
Returns a shallow copy of this object. | ObjectFactory | ||
![]() | containsObjectDefinition(id:String):Boolean
Returns true if the object defines with the specified id is register in the container. | ObjectDefinitionContainer | |
containsSingleton(id:String):Boolean
Indicates if a singleton reference is register in the factory with the specified id. | ObjectFactory | ||
getObject(id:String):*
This method returns an object with the specified id in argument. | ObjectFactory | ||
![]() | getObjectDefinition(id:String):IObjectDefinition
Returns the IObjectDefinition object register in the container with the specified id. | ObjectDefinitionContainer | |
isDirty():Boolean
Indicates if the factory is dirty, must flush this buffer of not lazy-init singleton object definitions. | ObjectFactory | ||
isLazyInit(id:String):Boolean
This method indicates if the specified object definition is lazy init. | ObjectFactory | ||
![]() | isLocked():Boolean
Returns true if the object is locked. | Task | |
isSingleton(id:String):Boolean
This method defined if the scope of the specified object definition is "singleton". | ObjectFactory | ||
![]() | lock():void
Locks the object. | Task | |
![]() | notifyChanged():void
Notify when the process is changed. | CoreAction | |
![]() | notifyCleared():void
Notify when the process is cleared. | CoreAction | |
![]() | notifyFinished():void
Notify an ActionEvent when the process is finished. | Task | |
![]() | notifyInfo(info:*):void
Notify a specific information when the process is changed. | CoreAction | |
![]() | notifyLooped():void
Notify when the process is looped. | CoreAction | |
![]() | notifyPaused():void
Notify when the process is paused. | CoreAction | |
![]() | notifyProgress():void
Notify when the process is in progress. | CoreAction | |
![]() | notifyResumed():void
Notify when the process is resumed. | CoreAction | |
![]() | notifyStarted():void
Notify an ActionEvent when the process is started. | Task | |
![]() | notifyStopped():void
Notify when the process is stopped. | CoreAction | |
![]() | notifyTimeOut():void
Notify when the process is out of time. | CoreAction | |
![]() | removeObjectDefinition(id:String):void
Unregisters an object definition in the container. | ObjectDefinitionContainer | |
removeSingleton(id:String):void
Removes and destroy a singleton in the container. | ObjectFactory | ||
run(... arguments):void [override]
Run the initialization of the factory with new object definitions and create the not lazy-init singleton objects. | ObjectFactory | ||
![]() | unlock():void
Unlocks the display. | Task | |
warn(... args):void
The custom warn method of this factory to log a warning message in the application. | ObjectFactory | ||
| Method | Defined By | ||
|---|---|---|---|
createArguments(args:Array = null):Array
Creates the arguments Array representation of the specified definition. | ObjectFactory | ||
createObjectWithStrategy(strategy:IObjectFactoryStrategy):*
Creates a new Object with a specified IObjectFactoryStrategy instance. | ObjectFactory | ||
dependsOn(definition:IObjectDefinition):void
Invoked to creates all object in the factory register in the dependsOn collection. | ObjectFactory | ||
eval(value:*, evaluators:Array):*
Evaluates a value with an Array of evaluators or Evaluable references in the factory. | ObjectFactory | ||
generates(definition:IObjectDefinition):void
Invoked to creates all object in the factory register in the generates collection. | ObjectFactory | ||
invokeDestroyMethod(o:*, definition:IObjectDefinition):void
Invokes the destroy method of the specified object, if the init method is define in the IDefinition object. | ObjectFactory | ||
invokeInitMethod(o:*, definition:IObjectDefinition = null):void
Invokes the init method of the specified object, if the init method is define in the IDefinition object. | ObjectFactory | ||
isLockable(o:*, definition:IObjectDefinition):Boolean
Indicates if the specified object is Lockable and must be locked during the initialization of the properties and methods when is created. | ObjectFactory | ||
populateIdentifiable(o:*, definition:IObjectDefinition):void
Populates the Identifiable singleton object, if the 'identify' flag is true the config of this factory and if specified the IObjectDefinition object scope is singleton. | ObjectFactory | ||
populateProperties(o:*, definition:IObjectDefinition):void
Populates all properties in the Map passed in argument. | ObjectFactory | ||
populateProperty(o:*, prop:ObjectProperty, id:*):void
Populates a property in the specified object with the passed-in ObjectProperty object. | ObjectFactory | ||
registerListeners(o:*, listeners:Array):void
Initialize the listener callback of the specified object. | ObjectFactory | ||
registerReceivers(o:*, receivers:Array):void
Initialize the receiver callback of the specified object. | ObjectFactory | ||
![]() | setRunning(b:Boolean):void
Changes the running property value. | Task | |
| bufferSingletons | property |
protected var bufferSingletons:ArrayThe internal buffer of no lazyInit singletons (id) to create it in the run method if the config.lazyInit property is false.
| config | property |
config:ObjectConfigDeterminates the configuration object of the object factory.
public function get config():ObjectConfig public function set config(value:ObjectConfig):void| objects | property |
public var objects:ArrayThis array contains objects to fill this factory with the run or create method.
| singletons | property |
singletons:HashMap [read-only] Returns the Map representation of all singletons register in this factory.
public function get singletons():HashMap| ObjectFactory | () | Constructor |
public function ObjectFactory(config:ObjectConfig = null, objects:Array = null)Creates a new ObjectFactory instance.
Parametersconfig:ObjectConfig (default = null) — The optional configuration object of the factory.
| |
objects:Array (default = null) — The optional Array contains generic objects to fill and initialize this factory.
|
| clone | () | method |
override public function clone():*Returns a shallow copy of this object.
Returns* — a shallow copy of this object.
|
| containsSingleton | () | method |
public function containsSingleton(id:String):BooleanIndicates if a singleton reference is register in the factory with the specified id.
Parameters
id:String — 'id' of the singleton.
|
Boolean — true if the singleton reference exist in the factory.
|
| createArguments | () | method |
protected function createArguments(args:Array = null):ArrayCreates the arguments Array representation of the specified definition.
Parameters
args:Array (default = null) |
Array — the arguments Array representation of the specified definition.
|
| createObjectWithStrategy | () | method |
protected function createObjectWithStrategy(strategy:IObjectFactoryStrategy):*Creates a new Object with a specified IObjectFactoryStrategy instance.
Parameters
strategy:IObjectFactoryStrategy |
* — A new Object with a specified IObjectFactoryStrategy instance.
|
| dependsOn | () | method |
protected function dependsOn(definition:IObjectDefinition):voidInvoked to creates all object in the factory register in the dependsOn collection.
All objects in the dependsOn collection are initialized before the initialization of the current object build in the factory.
Parameters
definition:IObjectDefinition |
| eval | () | method |
protected function eval(value:*, evaluators:Array):*Evaluates a value with an Array of evaluators or Evaluable references in the factory.
Parameters
value:* — The value to evaluate.
| |
evaluators:Array — The Array who contains IEvaluator objects or String ids who representing a IEvaluator in the factory.
|
* — The new value after evaluation.
|
| generates | () | method |
protected function generates(definition:IObjectDefinition):voidInvoked to creates all object in the factory register in the generates collection.
All objects in the generates collection are initialized after the initialization of the current object build in the factory.
Parameters
definition:IObjectDefinition |
| getObject | () | method |
public function getObject(id:String):*This method returns an object with the specified id in argument.
Parameters
id:String — The 'id' of the object to return.
|
* — the instance of the object with the id passed in argument.
|
| invokeDestroyMethod | () | method |
protected function invokeDestroyMethod(o:*, definition:IObjectDefinition):voidInvokes the destroy method of the specified object, if the init method is define in the IDefinition object.
Parameters
o:* | |
definition:IObjectDefinition |
| invokeInitMethod | () | method |
protected function invokeInitMethod(o:*, definition:IObjectDefinition = null):voidInvokes the init method of the specified object, if the init method is define in the IDefinition object.
Parameters
o:* | |
definition:IObjectDefinition (default = null) |
| isDirty | () | method |
public function isDirty():BooleanIndicates if the factory is dirty, must flush this buffer of not lazy-init singleton object definitions. The user must execute the run or create methods to flush this buffer.
ReturnsBoolean |
| isLazyInit | () | method |
public function isLazyInit(id:String):BooleanThis method indicates if the specified object definition is lazy init.
Parameters
id:String — The 'id' of the object definition to check..
|
Boolean — true if the specified object definition is lazy init.
|
| isLockable | () | method |
protected function isLockable(o:*, definition:IObjectDefinition):BooleanIndicates if the specified object is Lockable and must be locked during the initialization of the properties and methods when is created.
Parameters
o:* | |
definition:IObjectDefinition |
Boolean |
| isSingleton | () | method |
public function isSingleton(id:String):BooleanThis method defined if the scope of the specified object definition is "singleton".
Parameters
id:String — 'id' of the object.
|
Boolean — true if the object is a singleton.
|
| populateIdentifiable | () | method |
protected function populateIdentifiable(o:*, definition:IObjectDefinition):void
Populates the Identifiable singleton object, if the 'identify' flag is true the config of this factory and if specified the IObjectDefinition object scope is singleton.
Parameters
o:* | |
definition:IObjectDefinition |
| populateProperties | () | method |
protected function populateProperties(o:*, definition:IObjectDefinition):voidPopulates all properties in the Map passed in argument.
Parameters
o:* | |
definition:IObjectDefinition |
| populateProperty | () | method |
protected function populateProperty(o:*, prop:ObjectProperty, id:*):voidPopulates a property in the specified object with the passed-in ObjectProperty object.
Parameters
o:* — The object to populate.
| |
prop:ObjectProperty — The ObjectProperty used to populate the object.
| |
id:* — The id of the current IObjectDefinition.
|
| registerListeners | () | method |
protected function registerListeners(o:*, listeners:Array):voidInitialize the listener callback of the specified object.
Parameters
o:* | |
listeners:Array |
| registerReceivers | () | method |
protected function registerReceivers(o:*, receivers:Array):voidInitialize the receiver callback of the specified object.
Parameters
o:* | |
receivers:Array |
| removeSingleton | () | method |
public function removeSingleton(id:String):void
Removes and destroy a singleton in the container.
Invoke the 'destroy' method of this object is it's define in the IObjectDefinition of this singleton.
Parameters
id:String — The id of the singleton to remove.
|
| run | () | method |
override public function run(... arguments):voidRun the initialization of the factory with new object definitions and create the not lazy-init singleton objects.
Example :
import flash.text.TextField ;
import flash.text.TextFormat ;
import system.ioc.ObjectFactory ;
var factory:ObjectFactory = new ObjectFactory();
factory.objects =
[
{
id : "my_field" ,
type : "flash.text.TextField" ,
properties :
[
{ name:"defaultTextFormat" , value:new TextFormat("Verdana", 11) } ,
{ name:"selectable" , value:false } ,
{ name:"text" , value:"hello world" } ,
{ name:"textColor" , value:0xF7F744 } ,
{ name:"x" , value:100 } ,
{ name:"y" , value:100 }
]
}
];
factory.run();
var field:TextField = factory.getObject("my_field") as TextField ;
addChild(field) ;
Parameters
... arguments |
| warn | () | method |
public function warn(... args):voidThe custom warn method of this factory to log a warning message in the application. You can overrides this method, the prototype object is dynamic.
Parameters
... args |