Packageorg.springextensions.actionscript.ioc.factory
Interfacepublic interface IObjectFactory extends IObjectDefinitionRegistryAware, flash.events.IEventDispatcher
Implementors DefaultObjectFactory

Describes an object that is capable of creating and configuring instances of other classes.



Public Properties
 PropertyDefined By
  applicationDomain : ApplicationDomain
The ApplicationDomain that is associated with the current IObjectFactory
IObjectFactory
  cache : IInstanceCache
[read-only] An IInstanceCache instance used to hold the singletons created by the current IObjectFactory.
IObjectFactory
  dependencyInjector : IDependencyInjector
IObjectFactory
  isReady : Boolean
Returns true when the current IObjectFactory is fully initialized and ready for use.
IObjectFactory
 InheritedobjectDefinitionRegistry : IObjectDefinitionRegistry
IObjectDefinitionRegistryAware
  objectDestroyer : IObjectDestroyer
IObjectFactory
  objectPostProcessors : Vector.<IObjectPostProcessor>
[read-only]
IObjectFactory
  parent : IObjectFactory
Optional parent factory that can be used to create objects that can't be created by the current instance.
IObjectFactory
  propertiesProvider : IPropertiesProvider
IObjectFactory
  referenceResolvers : Vector.<IReferenceResolver>
[read-only]
IObjectFactory
  skipMetadata : Boolean
If false, the current IObjectFactory will not process any metadata annotations.
IObjectFactory
Public Methods
 MethodDefined By
  
IObjectFactory
  
IObjectFactory
  
canCreate(objectName:String):Boolean
Determines if the current ObjectFactory is able to create the object for the sepcified object name.
IObjectFactory
  
createInstance(clazz:Class, constructorArguments:Array = null):*
Creates an instance of the specified Class, wires the instance and returns it.
IObjectFactory
  
destroyObject(instance:Object):void
IObjectFactory
  
getObject(name:String, constructorArguments:Array = null):*
Will retrieve an object by it's name/id If the definition is a singleton it will be retrieved from cache if possible.
IObjectFactory
  
IObjectFactory
  
manage(instance:*, objectName:String = null):*
IObjectFactory
  
resolveReference(reference:*):*
IObjectFactory
  
resolveReferences(references:Vector.<ArgumentDefinition>):Array
IObjectFactory
  
wire(instance:*, objectDefinition:IObjectDefinition = null, constructorArguments:Vector.<ArgumentDefinition> = null, objectName:String = null):*
IObjectFactory
Events
 Event Summary Defined By
  IObjectFactory
  IObjectFactory
  IObjectFactory
Property Detail
applicationDomainproperty
applicationDomain:ApplicationDomain

The ApplicationDomain that is associated with the current IObjectFactory


Implementation
    public function get applicationDomain():ApplicationDomain
    public function set applicationDomain(value:ApplicationDomain):void
cacheproperty 
cache:IInstanceCache  [read-only]

An IInstanceCache instance used to hold the singletons created by the current IObjectFactory.


Implementation
    public function get cache():IInstanceCache
dependencyInjectorproperty 
dependencyInjector:IDependencyInjector


Implementation
    public function get dependencyInjector():IDependencyInjector
    public function set dependencyInjector(value:IDependencyInjector):void
isReadyproperty 
isReady:Boolean

Returns true when the current IObjectFactory is fully initialized and ready for use.


Implementation
    public function get isReady():Boolean
    public function set isReady(value:Boolean):void
objectDestroyerproperty 
objectDestroyer:IObjectDestroyer


Implementation
    public function get objectDestroyer():IObjectDestroyer
    public function set objectDestroyer(value:IObjectDestroyer):void
objectPostProcessorsproperty 
objectPostProcessors:Vector.<IObjectPostProcessor>  [read-only]


Implementation
    public function get objectPostProcessors():Vector.<IObjectPostProcessor>
parentproperty 
parent:IObjectFactory

Optional parent factory that can be used to create objects that can't be created by the current instance.


Implementation
    public function get parent():IObjectFactory
    public function set parent(value:IObjectFactory):void
propertiesProviderproperty 
propertiesProvider:IPropertiesProvider


Implementation
    public function get propertiesProvider():IPropertiesProvider
    public function set propertiesProvider(value:IPropertiesProvider):void
referenceResolversproperty 
referenceResolvers:Vector.<IReferenceResolver>  [read-only]


Implementation
    public function get referenceResolvers():Vector.<IReferenceResolver>
skipMetadataproperty 
skipMetadata:Boolean

If false, the current IObjectFactory will not process any metadata annotations.


Implementation
    public function get skipMetadata():Boolean
    public function set skipMetadata(value:Boolean):void
Method Detail
addObjectPostProcessor()method
public function addObjectPostProcessor(objectPostProcessor:IObjectPostProcessor):IObjectFactory

Parameters

objectPostProcessor:IObjectPostProcessor

Returns
IObjectFactory
addReferenceResolver()method 
public function addReferenceResolver(referenceResolver:IReferenceResolver):IObjectFactory

Parameters

referenceResolver:IReferenceResolver

Returns
IObjectFactory
canCreate()method 
public function canCreate(objectName:String):Boolean

Determines if the current ObjectFactory is able to create the object for the sepcified object name.

Parameters

objectName:String — The specified object name

Returns
BooleanTrue if the current ObjectFactory is able to create the object for the sepcified object name.
createInstance()method 
public function createInstance(clazz:Class, constructorArguments:Array = null):*

Creates an instance of the specified Class, wires the instance and returns it. Useful for creating objects that have only been annotated with [Autowired] metadata and need no object definition.

Parameters

clazz:Class — The specified Class.
 
constructorArguments:Array (default = null) — Optional Array of constructor arguments to be used for the instance.

Returns
* — The created and wired instance of the specified Class.
destroyObject()method 
public function destroyObject(instance:Object):void

Parameters

instance:Object

getObject()method 
public function getObject(name:String, constructorArguments:Array = null):*

Will retrieve an object by it's name/id If the definition is a singleton it will be retrieved from cache if possible. If the definition defines an init method, the init method will be called after all properties have been set.

If any object post processors are defined they will be run against the newly created instance.

The class that is instantiated can implement the following interfaces for a special treatment:

Parameters

name:String — The name of the object as defined in the object definition
 
constructorArguments:Array (default = null) — The arguments that should be passed to the constructor. Note that the constructorArguments can only be passed if the object is defined as lazy.

Returns
* — An instance of the requested object

Throws
org.springextensions.actionscript.ioc:ObjectDefinitionNotFoundError — The name of the given object should be present as an object definition
 
flash.errors:IllegalOperationError — A singleton object definition that is not lazy can not be given constructor arguments
 
org.springextensions.actionscript.errors:PropertyTypeError — The type of a property definition should match the type of property on the instance
 
org.springextensions.actionscript.errors:ClassNotFoundError — The class set on the definition should be compiled into the application
 
org.springextensions.actionscript.errors:ResolveReferenceError — Indicating a problem resolving the references of a certain property

See also

resolveReference()
org.springextensions.actionscript.ioc.IObjectDefinition
org.springextensions.actionscript.ioc.factory.config.IObjectPostProcessor
org.springextensions.actionscript.ioc.factory.IInitializingObject
org.springextensions.actionscript.ioc.factory.IFactoryObject

Example
The following code retrieves an object named "myPerson" from the object factory:
           var myPerson:Person = objectFactory.getObject("myPerson");
         
getObjectDefinition()method 
public function getObjectDefinition(objectName:String):IObjectDefinition

Parameters

objectName:String

Returns
IObjectDefinition
manage()method 
public function manage(instance:*, objectName:String = null):*

Parameters

instance:*
 
objectName:String (default = null)

Returns
*
resolveReference()method 
public function resolveReference(reference:*):*

Parameters

reference:*

Returns
*
resolveReferences()method 
public function resolveReferences(references:Vector.<ArgumentDefinition>):Array

Parameters

references:Vector.<ArgumentDefinition>

Returns
Array
wire()method 
public function wire(instance:*, objectDefinition:IObjectDefinition = null, constructorArguments:Vector.<ArgumentDefinition> = null, objectName:String = null):*

Parameters

instance:*
 
objectDefinition:IObjectDefinition (default = null)
 
constructorArguments:Vector.<ArgumentDefinition> (default = null)
 
objectName:String (default = null)

Returns
*
Event Detail
objectCreated Event
Event Object Type: org.springextensions.actionscript.ioc.factory.event.ObjectFactoryEvent

objectRetrieved Event  
Event Object Type: org.springextensions.actionscript.ioc.factory.event.ObjectFactoryEvent

objectWired Event  
Event Object Type: org.springextensions.actionscript.ioc.factory.event.ObjectFactoryEvent