Packageorg.springextensions.actionscript.ioc.factory
Interfacepublic interface IObjectFactory extends flash.events.IEventDispatcher
SubinterfacesIConfigurableObjectFactory, IListableObjectFactory
ImplementorsRequiredMetadataObjectPostProcessor

Defines the most basic object factory. Most object factories will implement the IConfigurableObjectFactory interface.

Authors: Christophe Herreman, Erik Westra
Version: $Revision: 21 $, $Date: 2008-11-01 22:58:42 +0100 (za, 01 nov 2008) $, $Author: dmurat $
Since: 0.1

See also

org.springextensions.actionscript.ioc.factory.config.IConfigurableObjectFactory


Public Methods
 MethodDefined by
  
addReferenceResolver(referenceResolver:IReferenceResolver):void
This method adds a reference resolver that will be used to resolve property references.
IObjectFactory
  
clearObjectFromInternalCache(name:String):Object
Removes an object from the internal object definition cache.
IObjectFactory
  
containsObject(objectName:String):Boolean
Determines if the object factory contains a definition with the given name.
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
  
getType(objectName:String):Class
Returns the type that is defined on the object definition.
IObjectFactory
  
isPrototype(objectName:String):Boolean
Determines if the definition with the given name is a prototype.
IObjectFactory
  
isSingleton(objectName:String):Boolean
Determines if the definition with the given name is a singleton.
IObjectFactory
  
resolveReference(property:Object):Object
Resolves a property in an object definition.
IObjectFactory
Method detail
addReferenceResolver()method
public function addReferenceResolver(referenceResolver:IReferenceResolver):void

This method adds a reference resolver that will be used to resolve property references.

Parameters
referenceResolver:IReferenceResolver — The implementation of IReferenceResolver that should be added

See also

clearObjectFromInternalCache()method 
public function clearObjectFromInternalCache(name:String):Object

Removes an object from the internal object definition cache. This cache is used to cache singletons.

Parameters
name:String — The name/id of the object to remove

Returns
Object — the removed object
containsObject()method 
public function containsObject(objectName:String):Boolean

Determines if the object factory contains a definition with the given name.

Parameters
objectName:String — The name/id of the object definition

Returns
Boolean — true if a definition with that name exists

See also

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
ObjectDefinitionNotFoundError — The name of the given object should be present as an object definition
 
— An object definition that is not lazy can not be given constructor arguments
 
PropertyTypeError — The type of a property definition should match the type of property on the instance
 
ClassNotFoundError — The class set on the definition should be compiled into the application
 
ResolveReferenceError — Indicating a problem resolving the references of a certain property

See also


Example
The following code retrieves an object from the object factory:
       var myPerson:Person = objectFactory.getObject("myPerson") as Person;
     

getType()method 
public function getType(objectName:String):Class

Returns the type that is defined on the object definition.

Parameters
objectName:String — The name/id of the object definition

Returns
Class — the class that is used to construct the object

See also

isPrototype()method 
public function isPrototype(objectName:String):Boolean

Determines if the definition with the given name is a prototype.

Parameters
objectName:String — The name/id of the object definition

Returns
Boolean — true if the definitions is defined as a prototype

See also

isSingleton()method 
public function isSingleton(objectName:String):Boolean

Determines if the definition with the given name is a singleton.

Parameters
objectName:String — The name/id of the object definition

Returns
Boolean — true if the definitions is defined as a singleton

See also

resolveReference()method 
public function resolveReference(property:Object):Object

Resolves a property in an object definition. If the property could not be resolved, the given property is returned. This means that the property will be checked against all reference resolvers. If a reference resolver can process it, it will do so.

This method is used to resolve implementations of IObjectReference. In order to capture nested references container types like Array and Dictionary are checked as well.

Parameters
property:Object — the property that possibly that might contain references

Returns
Object

See also