This is the basic implementation of
IConfigurableObjectFactory. Manages object
definitions and creates and configures new objects based on those definitions.
applicationDomain:ApplicationDomain [read-write]
Implementation
public function get applicationDomain():ApplicationDomain
public function set applicationDomain(value:ApplicationDomain):void
autowireProcessor:IAutowireProcessor [read-write]
Implementation
public function get autowireProcessor():IAutowireProcessor
public function set autowireProcessor(value:IAutowireProcessor):void
protected var earlySingletonCache:Object Cache of early cached singletons for circular references
protected var explicitSingletonCache:Object Cache of singleton objects registered without object definition
explicitSingletonNames:Array [read-only]
The names of the explicit singletons registered in this factory.
Implementation
public function get explicitSingletonNames():Array
hasDestructionAwareObjectPostProcessors:Boolean [read-only]Implementation
public function get hasDestructionAwareObjectPostProcessors():Boolean
isDisposed:Boolean [read-only]Implementation
public function get isDisposed():Boolean
numObjectPostProcessors:int [read-only]
Returns the number of object post processors.
Implementation
public function get numObjectPostProcessors():int
objectDefinitions:Object [read-only]Implementation
public function get objectDefinitions():Object
objectPostProcessors:Array [read-only]Implementation
public function get objectPostProcessors():Array
parent:IObjectFactory [read-write]
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
properties:Properties [read-only]
Implementation
public function get properties():Properties
protected var referenceResolvers:Array Reference resolvers used when creating objects
protected var singletonCache:Object Cache of created singleton objects via an object definition
typeConverter:ITypeConverter [read-write]
The current type converter implementation
Implementation
public function get typeConverter():ITypeConverter
public function set typeConverter(value:ITypeConverter):void
public function AbstractObjectFactory()
Constructs a new AbstractObjectFactory.
The following post processors are added by default:
- ObjectFactoryAwarePostProcessor
- ApplicationDomainAwarePostProcessor
The following reference resolvers are added by default:
- ObjectReferenceResolver
- ArrayReferenceResolver
- DictionaryReferenceResolver
- VectorReferenceResolver
See also
public function addObjectPostProcessor(objectPostProcessor:IObjectPostProcessor):void
If the specified IObjectPostProcessor implements IApplicationDomainAware the
current AbstractObjectFactory.applicationDomain will be injected.
Adds the specified
IObjectPostProcessor to the current object factory.
Parameters
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
|
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
Throws
| ObjectContainerError — ObjectContainerError if the class for the specified ObjectDefinition isn't found
|
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
|
protected function clearFromCache(cache:Object, name:String):ObjectParameters
Returns
public function clearObjectFromExplicitInternalCache(name:String):ObjectParameters
Returns
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
|
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
|
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.
|
protected function createObjectViaInstanceFactoryMethod(objectName:String, methodName:String, args:Array = null):*Parameters
| objectName:String |
| |
| methodName:String |
| |
| args:Array (default = null) |
Returns
protected function createObjectViaStaticFactoryMethod(clazz:Class, applicationDomain:ApplicationDomain, factoryMethodName:String, args:Array = null):*Parameters
| clazz:Class |
| |
| applicationDomain:ApplicationDomain |
| |
| factoryMethodName:String |
| |
| args:Array (default = null) |
Returns
public function dispose():void
public function getClassForInstance(object:Object):ClassParameters
Returns
public function getClassForName(className:String):ClassParameters
Returns
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:
IInitializingObject: The method defined by the interface will called after the
properties have been set.
IFactoryObject: The actual object will be retrieved using the getObject method.
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
|
public function getObjectPostProcessors(objectPostProcessorClass:Class):Array
Retrieves the object processors of the specified Class.
Parameters
| objectPostProcessorClass:Class — The specified Class.
|
Returns
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
|
protected function init():void
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
|
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
|
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
|
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
|
public function registerSingleton(name:String, object:Object):void
Parameters
| name:String |
| |
| object:Object |
public function removeObjectPostProcessor(objectPostProcessor:IObjectPostProcessor):void
Removes the specified IObjectPostProcessor from the current object factory.
Parameters
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
public function wire(object:*, objectDefinition:IObjectDefinition = null, objectName:String = null):void
Parameters
| object:* |
| |
| objectDefinition:IObjectDefinition (default = null) |
| |
| objectName:String (default = null) |
Event object type: org.springextensions.actionscript.ioc.factory.support.event.ObjectFactoryEvent
Dispatched after an object has been instantiated and wired by the current object factory
Event object type: org.springextensions.actionscript.ioc.factory.support.event.ObjectFactoryEvent
Dispatched right before an object is returned by the current object factory
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.
public static const THIS:String = "this"
Copyright 2007-2010 Spring Actionscript.