Packageorg.springextensions.actionscript.ioc.autowire.impl
Classpublic class DefaultAutowireProcessor
InheritanceDefaultAutowireProcessor Inheritance Object
Implements IAutowireProcessor, IObjectFactoryAware, org.as3commons.lang.IApplicationDomainAware, org.as3commons.lang.IDisposable

Default IAutowireProcessor implementation used by the AbstractObjectFactory.

See also

AbstractObjectFactory


Public Properties
 PropertyDefined By
  applicationDomain : ApplicationDomain
[write-only]
DefaultAutowireProcessor
  autowireMetadataNames : Vector.<String>
DefaultAutowireProcessor
  isDisposed : Boolean
[read-only]
DefaultAutowireProcessor
  objectFactory : IObjectFactory
DefaultAutowireProcessor
Public Methods
 MethodDefined By
  
Creates a new DefaultAutowireProcessor instance.
DefaultAutowireProcessor
  
autoWire(object:Object, objectDefinition:IObjectDefinition = null, objectName:String = null):void
Method called during object creation.
DefaultAutowireProcessor
  
dispose():void
DefaultAutowireProcessor
  
findAutowireCandidateName(clazz:Class):String
DefaultAutowireProcessor
  
Performs AUTODETECT and CONSTRUCTOR checks. Method that can be invoked by an IObjectFactory implementation for any type of pre-processing of the IObjectDefinition associated with the object that needs to be created. Typically this method can be used to do some kind of constructor configuration.
DefaultAutowireProcessor
Protected Methods
 MethodDefined By
  
assignField(object:Object, field:Field, metadata:Metadata, objectName:String):void
DefaultAutowireProcessor
  
autoWireByName(object:Object, objectDefinition:IObjectDefinition):void
Called by autoWire method in case of autowire by name.
DefaultAutowireProcessor
  
autoWireByType(object:Object, objectDefinition:IObjectDefinition):void
Called by autoWire method in case of autowire by type.
DefaultAutowireProcessor
  
autoWireField(object:Object, field:Field, objectName:String):void
Checks of the specified Field instance contains any autowiring metadata, abd based on this class the appropriate wiring methods.
DefaultAutowireProcessor
  
autoWireFieldByName(object:Object, field:Field, metadata:Metadata, objectName:String):void
Takes the field name or the value of the AUTOWIRED_ARGUMENT_NAME metadata argument, retrieves the object with that name form the objectFactory and injects it into the specified field.
DefaultAutowireProcessor
  
autoWireFieldByPropertyName(object:Object, field:Field, metadata:Metadata, objectName:String):void
Takes the value of the AUTOWIRED_ARGUMENT_EXTERNALPROPERTY metadata argument, looks up the key in the objectFactory's Properties array and injects it into the specified field.
DefaultAutowireProcessor
  
autoWireFieldByType(object:Object, field:Field, metadata:Metadata, objectName:String):void
Tries to retrieve an autowire candidate based on the type of the specified field, and when found injects the candidate into the specified field.
DefaultAutowireProcessor
  
bindField(object:Object, field:Field, metadata:Metadata, objectName:String):void
DefaultAutowireProcessor
  
containsObject(objectName:String):Boolean
DefaultAutowireProcessor
  
determinePrimaryCandidate(candidateNames:Vector.<String>):String
DefaultAutowireProcessor
  
findAutowireCandidateNames(clazz:Class):Vector.<String>
Called by autoWireByType to get all object names that could be used to autowire an object property
DefaultAutowireProcessor
  
getApplicationDomain(object:Object):ApplicationDomain
Returns the application domain for the given object.
DefaultAutowireProcessor
  
getAutowireSpecificMetadata(field:Field):Array
Checks if any of the metadata names defined by the autowireMetadataNames are present in the specified Field.
DefaultAutowireProcessor
  
DefaultAutowireProcessor
  
DefaultAutowireProcessor
  
getUnclaimedSimpleObjectProperties(object:Object, objectDefinition:IObjectDefinition):Vector.<Field>
Used by autowire system in order to find fields eligible for autowiring
DefaultAutowireProcessor
  
handlePropertyName(object:Object, field:Field, metadata:Metadata, objectName:String):void
DefaultAutowireProcessor
  
isFactoryObjectForClass(factoryObjectClass:Class, objectName:String, objectClass:Class):Boolean
Returns true if the given factoryObjectClass is a factory object that creates object of the type of objectClass.
DefaultAutowireProcessor
  
isFieldAutowireRequired(field:Field):Boolean
DefaultAutowireProcessor
  
isPropertyUnclaimed(objectDefinition:IObjectDefinition, field:Field):Boolean
Determines if a property is unclaimed by an object definition.
DefaultAutowireProcessor
  
processAutowireAnnotations(objectDefinition:IObjectDefinition, object:Object, objectName:String):void
DefaultAutowireProcessor
  
setField(object:Object, objectName:String, fieldName:String, objectDefinitionName:String):void
DefaultAutowireProcessor
Public Constants
 ConstantDefined By
  AUTOWIRED_ANNOTATION : String = Autowired
[static] The name of the metadata that determines whether a field needs to be autowired
DefaultAutowireProcessor
  AUTOWIRED_ARGUMENT_EXTERNALPROPERTY : String = externalProperty
[static] The name of the metadata argument that determines the name of a property in the container that needs to be injected into the specified field
DefaultAutowireProcessor
  AUTOWIRED_ARGUMENT_MODE : String = mode
[static] The name of the metadata argument that determines the autowiring strategy, possibles values are 'autodetect', 'byName', 'byType', 'constructor' or 'no'
DefaultAutowireProcessor
  AUTOWIRED_ARGUMENT_NAME : String = name
[static] The name of the metadata argument that determines the name of the object in the container that needs to be injected into the specified field
DefaultAutowireProcessor
  AUTOWIRED_ARGUMENT_REQUIRED : String = required
[static] The name of the metadata argument that determines whether the dependency is required or not.
DefaultAutowireProcessor
  AUTOWIRED_PROPERTY_NAME : String = property
[static] Metadata argument key used for bindings, the value of this key determines the host object's property chain.
DefaultAutowireProcessor
  INJECT_ANNOTATION : String = Inject
[static] The name of the metadata that determines whether a field needs to be autowired
DefaultAutowireProcessor
  TRUE_VALUE : String = true
[static]
DefaultAutowireProcessor
Property Detail
applicationDomainproperty
applicationDomain:ApplicationDomain  [write-only]


Implementation
    public function set applicationDomain(value:ApplicationDomain):void
autowireMetadataNamesproperty 
autowireMetadataNames:Vector.<String>


Implementation
    public function get autowireMetadataNames():Vector.<String>
    public function set autowireMetadataNames(value:Vector.<String>):void
isDisposedproperty 
isDisposed:Boolean  [read-only]


Implementation
    public function get isDisposed():Boolean
objectFactoryproperty 
objectFactory:IObjectFactory


Implementation
    public function get objectFactory():IObjectFactory
    public function set objectFactory(value:IObjectFactory):void
Constructor Detail
DefaultAutowireProcessor()Constructor
public function DefaultAutowireProcessor(objectFactory:IObjectFactory)

Creates a new DefaultAutowireProcessor instance.

Parameters
objectFactory:IObjectFactory
Method Detail
assignField()method
protected function assignField(object:Object, field:Field, metadata:Metadata, objectName:String):void

Parameters

object:Object
 
field:Field
 
metadata:Metadata
 
objectName:String

autoWire()method 
public function autoWire(object:Object, objectDefinition:IObjectDefinition = null, objectName:String = null):void

Method called during object creation. Will autowire unclaimed non simple properties by type or by name if required by the object definition. Performs autowiring on the specified object instance, the specified IObjectDefinition can optionally be used to retrieve autowiring information from.

Parameters

object:Object — The instance that needs to be autowired.
 
objectDefinition:IObjectDefinition (default = null) — The IObjectDefinition associated with the object that needs to be created.
 
objectName:String (default = null) — The name of the object as it is registered in a container.

autoWireByName()method 
protected function autoWireByName(object:Object, objectDefinition:IObjectDefinition):void

Called by autoWire method in case of autowire by name.

Parameters

object:Object
 
objectDefinition:IObjectDefinition

autoWireByType()method 
protected function autoWireByType(object:Object, objectDefinition:IObjectDefinition):void

Called by autoWire method in case of autowire by type.

Parameters

object:Object
 
objectDefinition:IObjectDefinition

autoWireField()method 
protected function autoWireField(object:Object, field:Field, objectName:String):void

Checks of the specified Field instance contains any autowiring metadata, abd based on this class the appropriate wiring methods.

Parameters

object:Object — The object being autowired
 
field:Field — The field that will be examined for the necessary metadata
 
objectName:String — The name of the object in the objectFactory

autoWireFieldByName()method 
protected function autoWireFieldByName(object:Object, field:Field, metadata:Metadata, objectName:String):void

Takes the field name or the value of the AUTOWIRED_ARGUMENT_NAME metadata argument, retrieves the object with that name form the objectFactory and injects it into the specified field.

Parameters

object:Object — The object being autowired
 
field:Field — The field that will be injected
 
metadata:Metadata — The autowiring metadata
 
objectName:String — The name of the object in the objectFactory

autoWireFieldByPropertyName()method 
protected function autoWireFieldByPropertyName(object:Object, field:Field, metadata:Metadata, objectName:String):void

Takes the value of the AUTOWIRED_ARGUMENT_EXTERNALPROPERTY metadata argument, looks up the key in the objectFactory's Properties array and injects it into the specified field.

Parameters

object:Object — The object being autowired
 
field:Field — The field that will be injected
 
metadata:Metadata — The autowiring metadata
 
objectName:String — The name of the object in the objectFactory

autoWireFieldByType()method 
protected function autoWireFieldByType(object:Object, field:Field, metadata:Metadata, objectName:String):void

Tries to retrieve an autowire candidate based on the type of the specified field, and when found injects the candidate into the specified field.

Parameters

object:Object — The object being autowired
 
field:Field — The field that will be injected.
 
metadata:Metadata — The autowiring metadata
 
objectName:String — The name of the object in the objectFactory

bindField()method 
protected function bindField(object:Object, field:Field, metadata:Metadata, objectName:String):void

Parameters

object:Object
 
field:Field
 
metadata:Metadata
 
objectName:String

containsObject()method 
protected function containsObject(objectName:String):Boolean

Parameters

objectName:String

Returns
Boolean
determinePrimaryCandidate()method 
protected function determinePrimaryCandidate(candidateNames:Vector.<String>):String

Parameters

candidateNames:Vector.<String>

Returns
String
dispose()method 
public function dispose():void

findAutowireCandidateName()method 
public function findAutowireCandidateName(clazz:Class):String

Parameters

clazz:Class

Returns
String
findAutowireCandidateNames()method 
protected function findAutowireCandidateNames(clazz:Class):Vector.<String>

Called by autoWireByType to get all object names that could be used to autowire an object property

Parameters

clazz:Class — The class of the property that needs to get autowired.

Returns
Vector.<String> — an Array containing all autowire candidates names.
getApplicationDomain()method 
protected function getApplicationDomain(object:Object):ApplicationDomain

Returns the application domain for the given object.

Parameters

object:Object

Returns
ApplicationDomain
getAutowireSpecificMetadata()method 
protected function getAutowireSpecificMetadata(field:Field):Array

Checks if any of the metadata names defined by the autowireMetadataNames are present in the specified Field.

Parameters

field:Field

Returns
Array
getBindingUtilsBindPropertyFunction()method 
protected function getBindingUtilsBindPropertyFunction():Function

Returns
Function
getObjectDefinition()method 
protected function getObjectDefinition(objectName:String):IObjectDefinition

Parameters

objectName:String

Returns
IObjectDefinition
getUnclaimedSimpleObjectProperties()method 
protected function getUnclaimedSimpleObjectProperties(object:Object, objectDefinition:IObjectDefinition):Vector.<Field>

Used by autowire system in order to find fields eligible for autowiring

Parameters

object:Object
 
objectDefinition:IObjectDefinition

Returns
Vector.<Field> — An Array containing the names of all public variables and readwrite / writeonly accessors.
handlePropertyName()method 
protected function handlePropertyName(object:Object, field:Field, metadata:Metadata, objectName:String):void

Parameters

object:Object
 
field:Field
 
metadata:Metadata
 
objectName:String

isFactoryObjectForClass()method 
protected function isFactoryObjectForClass(factoryObjectClass:Class, objectName:String, objectClass:Class):Boolean

Returns true if the given factoryObjectClass is a factory object that creates object of the type of objectClass.

Parameters

factoryObjectClass:Class
 
objectName:String
 
objectClass:Class

Returns
BooleanTrue if the given factoryObjectClass is a factory object that creates object of the type of objectClass.
isFieldAutowireRequired()method 
protected function isFieldAutowireRequired(field:Field):Boolean

Parameters

field:Field — The field to check for dependency requirement.

Returns
Booleantrue if autowired field dependency is required, false otherwise.
isPropertyUnclaimed()method 
protected function isPropertyUnclaimed(objectDefinition:IObjectDefinition, field:Field):Boolean

Determines if a property is unclaimed by an object definition. Returns true, if no object definition is passed, or if the object definition's properties map does not contain a reference to the passed in field.

Parameters

objectDefinition:IObjectDefinition — The object definition to inspect.
 
field:Field — The field to look for on the object definition.

Returns
Booleantrue if the field is unclaimed.
preprocessObjectDefinition()method 
public function preprocessObjectDefinition(objectDefinition:IObjectDefinition):void

Performs AUTODETECT and CONSTRUCTOR checks.

Method that can be invoked by an IObjectFactory implementation for any type of pre-processing of the IObjectDefinition associated with the object that needs to be created.

Typically this method can be used to do some kind of constructor configuration.

Parameters

objectDefinition:IObjectDefinition — The IObjectDefinition that describes the object that will be created.

See also

processAutowireAnnotations()method 
protected function processAutowireAnnotations(objectDefinition:IObjectDefinition, object:Object, objectName:String):void

Parameters

objectDefinition:IObjectDefinition
 
object:Object
 
objectName:String

setField()method 
protected function setField(object:Object, objectName:String, fieldName:String, objectDefinitionName:String):void

Parameters

object:Object
 
objectName:String
 
fieldName:String
 
objectDefinitionName:String

Constant Detail
AUTOWIRED_ANNOTATIONConstant
public static const AUTOWIRED_ANNOTATION:String = Autowired

The name of the metadata that determines whether a field needs to be autowired

AUTOWIRED_ARGUMENT_EXTERNALPROPERTYConstant 
public static const AUTOWIRED_ARGUMENT_EXTERNALPROPERTY:String = externalProperty

The name of the metadata argument that determines the name of a property in the container that needs to be injected into the specified field

AUTOWIRED_ARGUMENT_MODEConstant 
public static const AUTOWIRED_ARGUMENT_MODE:String = mode

The name of the metadata argument that determines the autowiring strategy, possibles values are 'autodetect', 'byName', 'byType', 'constructor' or 'no'

AUTOWIRED_ARGUMENT_NAMEConstant 
public static const AUTOWIRED_ARGUMENT_NAME:String = name

The name of the metadata argument that determines the name of the object in the container that needs to be injected into the specified field

AUTOWIRED_ARGUMENT_REQUIREDConstant 
public static const AUTOWIRED_ARGUMENT_REQUIRED:String = required

The name of the metadata argument that determines whether the dependency is required or not.

AUTOWIRED_PROPERTY_NAMEConstant 
public static const AUTOWIRED_PROPERTY_NAME:String = property

Metadata argument key used for bindings, the value of this key determines the host object's property chain.

INJECT_ANNOTATIONConstant 
public static const INJECT_ANNOTATION:String = Inject

The name of the metadata that determines whether a field needs to be autowired

TRUE_VALUEConstant 
public static const TRUE_VALUE:String = true