Packageorg.springextensions.actionscript.ioc.factory.support
SVN browsingAbstractObjectFactory.as
FisheyeAbstractObjectFactory.as
Classpublic class AbstractObjectFactory
InheritanceAbstractObjectFactory Inheritance flash.events.EventDispatcher
ImplementsIAutowireProcessorAware, IConfigurableObjectFactory
SubclassesDefaultListableObjectFactory

This is the basic implementation of IConfigurableObjectFactory. Manages object definitions and creates and configures new objects based on those definitions.

See also

IConfigurableObjectFactory


Documentation reference: instantiating a container


Public Properties
 PropertyDefined by
  applicationDomain : ApplicationDomain
AbstractObjectFactory
  autowireProcessor : IAutowireProcessor
AbstractObjectFactory
  explicitSingletonNames : Array
[read-only] The names of the explicit singletons registered in this factory.
AbstractObjectFactory
  numObjectPostProcessors : int
[read-only] Returns the number of object post processors.
AbstractObjectFactory
  objectDefinitions : Object
[read-only]
AbstractObjectFactory
  parent : IObjectFactory
AbstractObjectFactory
  properties : Properties
[read-only]
AbstractObjectFactory
  typeConverter : ITypeConverter
The current type converter implementation
AbstractObjectFactory
Protected Properties
 PropertyDefined by
  earlySingletonCache : Object
Cache of early cached singletons for circular references
AbstractObjectFactory
  explicitSingletonCache : Object
Cache of singleton objects registered without object definition
AbstractObjectFactory
  objectPostProcessors : Array
Object post processors to apply when creating objects
AbstractObjectFactory
  referenceResolvers : Array
Reference resolvers used when creating objects
AbstractObjectFactory
  singletonCache : Object
Cache of created singleton objects via an object definition
AbstractObjectFactory
Public Methods
 MethodDefined by
  
Constructs a new AbstractObjectFactory.
AbstractObjectFactory
  
addObjectPostProcessor(objectPostProcessor:IObjectPostProcessor):void

If the specified IObjectPostProcessor implements IApplicationDomainAware the current AbstractObjectFactory.applicationDomain will be injected.

Adds an object postprocessor to this object factory.
AbstractObjectFactory
  
addReferenceResolver(referenceResolver:IReferenceResolver):void
This method adds a reference resolver that will be used to resolve property references.
AbstractObjectFactory
  
canCreate(objectName:String):Boolean
Determines if the object factory is able to create the object with the given name.
AbstractObjectFactory
  
clearObjectFromInternalCache(name:String):Object
Removes an object from the internal object definition cache.
AbstractObjectFactory
  
containsObject(objectName:String):Boolean
Determines if the object factory contains a definition with the given name.
AbstractObjectFactory
  
createInstance(clazz:Class, constructorArguments:Array = null):*
Creates an instance of the specified Class, wires the instance and returns it.
AbstractObjectFactory
  
getClassForInstance(object:Object):Class
AbstractObjectFactory
  
getClassForName(className:String):Class
AbstractObjectFactory
  
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.
AbstractObjectFactory
  
getType(objectName:String):Class
Returns the type that is defined on the object definition.
AbstractObjectFactory
  
isFactoryObject(objectName:String):Boolean
Determines if an object is a IFactoryObject implementation.
AbstractObjectFactory
  
isPrototype(objectName:String):Boolean
Determines if the definition with the given name is a prototype.
AbstractObjectFactory
  
isSingleton(objectName:String):Boolean
Determines if the definition with the given name is a singleton.
AbstractObjectFactory
  
registerCustomEditor(requiredType:Class, propertyEditor:IPropertyEditor):void
Registers a custom property editor.
AbstractObjectFactory
  
registerSingleton(name:String, object:Object):void
Registers a singleton object in the factory.
AbstractObjectFactory
  
resolveReference(property:Object):Object
Resolves a property in an object definition.
AbstractObjectFactory
  
wire(object:*, objectDefinition:IObjectDefinition, objectName:String = null):void
AbstractObjectFactory
Protected Methods
 MethodDefined by
  
buildObject(name:String, constructorArguments:Array = null):*
Builds an object for the given name and returns it.
AbstractObjectFactory
  
createObjectViaInstanceFactoryMethod(objectName:String, methodName:String, args:Array = null):*
AbstractObjectFactory
  
createObjectViaStaticFactoryMethod(clazz:Class, applicationDomain:ApplicationDomain, factoryMethodName:String, args:Array = null):*
AbstractObjectFactory
Public Constants
 ConstantDefined by
  OBJECT_FACTORY_PREFIX : String = "&"
[static] Used to dereference an IFactoryObject instance and distinguish it from objects created by the IFactoryObject.
AbstractObjectFactory
  THIS : String = "this"
[static]
AbstractObjectFactory
Property detail
applicationDomainproperty
applicationDomain:ApplicationDomain  [read-write]

Implementation
    public function get applicationDomain():ApplicationDomain
    public function set applicationDomain(value:ApplicationDomain):void
autowireProcessorproperty 
autowireProcessor:IAutowireProcessor  [read-write]

Implementation
    public function get autowireProcessor():IAutowireProcessor
    public function set autowireProcessor(value:IAutowireProcessor):void
earlySingletonCacheproperty 
protected var earlySingletonCache:Object

Cache of early cached singletons for circular references

explicitSingletonCacheproperty 
protected var explicitSingletonCache:Object

Cache of singleton objects registered without object definition

explicitSingletonNamesproperty 
explicitSingletonNames:Array  [read-only]

The names of the explicit singletons registered in this factory.

Implementation
    public function get explicitSingletonNames():Array
numObjectPostProcessorsproperty 
numObjectPostProcessors:int  [read-only]

Returns the number of object post processors.

Implementation
    public function get numObjectPostProcessors():int
objectDefinitionsproperty 
objectDefinitions:Object  [read-only]Implementation
    public function get objectDefinitions():Object
objectPostProcessorsproperty 
protected var objectPostProcessors:Array

Object post processors to apply when creating objects

parentproperty 
parent:IObjectFactory  [read-write]

Implementation
    public function get parent():IObjectFactory
    public function set parent(value:IObjectFactory):void
propertiesproperty 
properties:Properties  [read-only]Implementation
    public function get properties():Properties
referenceResolversproperty 
protected var referenceResolvers:Array

Reference resolvers used when creating objects

singletonCacheproperty 
protected var singletonCache:Object

Cache of created singleton objects via an object definition

typeConverterproperty 
typeConverter:ITypeConverter  [read-write]

The current type converter implementation

Implementation
    public function get typeConverter():ITypeConverter
    public function set typeConverter(value:ITypeConverter):void
Constructor detail
AbstractObjectFactory()constructor
public function AbstractObjectFactory()

Constructs a new AbstractObjectFactory.

The following post processors are added by default:

The following reference resolvers are added by default:

See also

Method detail
addObjectPostProcessor()method
public function addObjectPostProcessor(objectPostProcessor:IObjectPostProcessor):void

If the specified IObjectPostProcessor implements IApplicationDomainAware the current AbstractObjectFactory.applicationDomain will be injected.

Adds an object postprocessor to this object factory. Parameters
objectPostProcessor:IObjectPostProcessor — the object postprocessor to add
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
buildObject()method 
protected function buildObject(name:String, constructorArguments:Array = null):*

Builds an object for the given name and returns it.

Parameters
name:String
 
constructorArguments:Array (default = null)

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

Determines if the object factory is able to create the object with the given name. This does not necesarrily mean that the current IObjectFactory contains an object definition for the given name. If a parent factory is assigned this will be checked as well if the current factory does not contain the necessary object definition.

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

Returns
Boolean — true if the current IObjectFactory is able to create the object with the given name
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
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.
createObjectViaInstanceFactoryMethod()method 
protected function createObjectViaInstanceFactoryMethod(objectName:String, methodName:String, args:Array = null):*Parameters
objectName:String
 
methodName:String
 
args:Array (default = null)

Returns
*
createObjectViaStaticFactoryMethod()method 
protected function createObjectViaStaticFactoryMethod(clazz:Class, applicationDomain:ApplicationDomain, factoryMethodName:String, args:Array = null):*Parameters
clazz:Class
 
applicationDomain:ApplicationDomain
 
factoryMethodName:String
 
args:Array (default = null)

Returns
*
getClassForInstance()method 
public function getClassForInstance(object:Object):ClassParameters
object:Object

Returns
Class
getClassForName()method 
public function getClassForName(className:String):ClassParameters
className:String

Returns
Class
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
— ObjectContainerError if the class for the specified ObjectDefinition isn't found
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
isFactoryObject()method 
public function isFactoryObject(objectName:String):Boolean

Determines if an object is a IFactoryObject implementation.

Parameters
objectName:String — The name of the object that should be tested

Returns
Boolean — true if the corresponding object is an IFactoryObject implementation
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
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
registerCustomEditor()method 
public function registerCustomEditor(requiredType:Class, propertyEditor:IPropertyEditor):void

Registers a custom property editor. This method will only have effect if the typeConverter is an implementation of IPropertyEditorRegistry.

Parameters
requiredType:Class — the type of the property
 
propertyEditor:IPropertyEditor — the property editor to register
registerSingleton()method 
public function registerSingleton(name:String, object:Object):void

Registers a singleton object in the factory. This is an object that needs to be managed by the container but does not have an object definition.

Parameters
name:String
 
object:Object
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
wire()method 
public function wire(object:*, objectDefinition:IObjectDefinition, objectName:String = null):void

Parameters
object:*
 
objectDefinition:IObjectDefinition
 
objectName:String (default = null)
Constant detail
OBJECT_FACTORY_PREFIXconstant
public static const OBJECT_FACTORY_PREFIX:String = "&"

Used to dereference an IFactoryObject instance and distinguish it from objects created by the IFactoryObject. For example, if the object named myDataType is a IFactoryObject, getting &myDataType will return the factory, not the instance returned by the factory.

THISconstant 
public static const THIS:String = "this"