Packageorg.springextensions.actionscript.context.support
SVN browsingMXMLApplicationContext.as
FisheyeMXMLApplicationContext.as
Classpublic class MXMLApplicationContext
InheritanceMXMLApplicationContext Inheritance AbstractApplicationContext Inheritance DefaultListableObjectFactory Inheritance AbstractObjectFactory Inheritance flash.events.EventDispatcher
ImplementsIOwnerModuleAware, IStageProcessorRegistryAware, mx.core.IMXMLObject

Application context that enables configuration to be defined in MXML.

Configurations are defined in one or more MXML files. Each MXML config that needs to be loaded, should be added to an MXMLApplicationContext instance via the addConfig() method. Once all configurations are added, invoking the load() method will (asynchronously) load and initialize the application context.

Objects can either be defined explicitly (e.g. <mx:RemoteObject/>) or implicitly via a object definition.

The MXMLApplicationContext also allows property placeholders (that resolve externally loaded properties) inside both explicit and implicit object definitions.


Example
  <Objects
   xmlns="http://www.springactionscript.org/mxml/config"
   xmlns:mx="http://www.adobe.com/2006/mxml"
   xmlns:context="org.springextensions.actionscript.ioc.factory.config.>
    <mx:Script>
    import mx.rpc.remoting.mxml.RemoteObject;
  </mx:Script>
    <context:PropertyPlaceholderConfigurer locations="{['properties.properties.txt', 'server.properties.txt']}"/>
    <Object id="string1" clazz="{String}">
  <ConstructorArg>$(property1)</ConstructorArg>
  </Object>
    <mx:Array id="propertiesArray">
  <mx:String>$(property1)</mx:String>
  <mx:String>$(property2)</mx:String>
  <mx:String>$(property3)</mx:String>
  </mx:Array>
    <mx:RemoteObject endpoint="http://$(host):$(port)/$(context-root)/messagebroker/amf"/>
    <mx:RemoteObject id="remoteObject1" endpoint="http://$(host):$(port)/$(context-root)/messagebroker/amf"/>
    <mx:RemoteObject id="remoteObject2">
  <mx:endpoint>http://$(host):$(port)/$(context-root)/messagebroker/amf</mx:endpoint>
  </mx:RemoteObject>
    <Object id="remoteObjectDefinitionWithPlaceHolders" clazz="{RemoteObject}">
  <Property name="endpoint" value="http://$(host):$(port)/$(context-root)/messagebroker/amf"/>
  </Object>
  </Objects>
  



Documentation reference: composing mxml based configuration metadata


Public Properties
 PropertyDefined by
 InheritedallowObjectDefinitionOverriding : Boolean
Set whether it should be allowed to override object definitions by registering a different definition with the same name, automatically replacing the former.
DefaultListableObjectFactory
 InheritedapplicationDomain : ApplicationDomain
AbstractObjectFactory
 InheritedautowireProcessor : IAutowireProcessor
AbstractObjectFactory
 InheritedexplicitSingletonNames : Array
The names of the explicit singletons registered in this factory.
AbstractObjectFactory
 InheritedhasDestructionAwareObjectPostProcessors : Boolean
AbstractObjectFactory
 InheritedisDisposed : Boolean
AbstractObjectFactory
 InheritednumObjectDefinitions : uint
The number of object definitions in this registry.
DefaultListableObjectFactory
 InheritednumObjectPostProcessors : int
Returns the number of object post processors.
AbstractObjectFactory
 InheritedobjectDefinitionNames : Array
The names of the registered object definitions.
DefaultListableObjectFactory
 InheritedobjectDefinitions : Object
AbstractObjectFactory
 InheritedobjectFactoryPostProcessors : Array
AbstractApplicationContext
 InheritedobjectPostProcessors : Array
AbstractObjectFactory
  ownerModule : Module
The Module that will act as the owner of the current IOwnerModuleAware instance.
MXMLApplicationContext
 Inheritedparent : IObjectFactory
Optional parent factory that can be used to create objects that can't be created by the current instance.
AbstractObjectFactory
 InheritedparentContext : IApplicationContext
Returns the parent application context or null if no parent is set.
AbstractApplicationContext
 Inheritedproperties : Properties
AbstractObjectFactory
  stageProcessorRegistry : IStageProcessorRegistry
MXMLApplicationContext
 InheritedtypeConverter : ITypeConverter
The current type converter implementation
AbstractObjectFactory
 InheriteduseParentObjectFactoryPostProcessors : Boolean
AbstractApplicationContext
Protected Properties
 PropertyDefined by
 InheritedearlySingletonCache : Object
Cache of early cached singletons for circular references
AbstractObjectFactory
 InheritedexplicitSingletonCache : Object
Cache of singleton objects registered without object definition
AbstractObjectFactory
 InheritedreferenceResolvers : Array
Reference resolvers used when creating objects
AbstractObjectFactory
 InheritedsingletonCache : Object
Cache of created singleton objects via an object definition
AbstractObjectFactory
Public Methods
 MethodDefined by
  
MXMLApplicationContext(config:* = null, ownerModule:Module = null)
Creates a new MXMLApplicationContext instance.
MXMLApplicationContext
  
addConfig(configClass:Class):void
Adds a single MXML configuration Class object to the application context.
MXMLApplicationContext
 Inherited
addObjectFactoryPostProcessor(objectFactoryPostProcessor:IObjectFactoryPostProcessor, index:int = -1):void
Adds an IObjectFactoryPostProcessor instance to the current XMLApplicationContext
AbstractApplicationContext
 Inherited
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.
AbstractObjectFactory
 Inherited
addReferenceResolver(referenceResolver:IReferenceResolver):void
This method adds a reference resolver that will be used to resolve property references.
AbstractObjectFactory
 Inherited
canCreate(objectName:String):Boolean
Determines if the object factory is able to create the object with the given name.
AbstractObjectFactory
 Inherited
AbstractObjectFactory
 Inherited
clearObjectFromInternalCache(name:String):Object
Removes an object from the internal object definition cache.
AbstractObjectFactory
 Inherited
containsObject(objectName:String):Boolean
Determines if the object factory contains a definition with the given name.
AbstractObjectFactory
 Inherited
containsObjectDefinition(objectName:String):Boolean
Determines if an object definition with the given name exists
DefaultListableObjectFactory
 Inherited
createInstance(clazz:Class, constructorArguments:Array = null):*
Creates an instance of the specified Class, wires the instance and returns it.
AbstractObjectFactory
  
Sets the stageProcessorRegistry.enabled property to false.
MXMLApplicationContext
  
dispose():void
MXMLApplicationContext
  
Sets the stageProcessorRegistry.enabled property to true.
MXMLApplicationContext
 Inherited
getClassForInstance(object:Object):Class
AbstractObjectFactory
 Inherited
getClassForName(className:String):Class
AbstractObjectFactory
 Inherited
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
 Inherited
Returns the object definition registered with the given name.
DefaultListableObjectFactory
 Inherited
getObjectDefinitionsOfType(type:Class):Array
Returns the object definitions in this registry that are of the specified Class.
DefaultListableObjectFactory
 Inherited
getObjectNamesForType(type:Class):Array
Returns the names of all object definitions and explicit singletons in this factory that are of the given type.
DefaultListableObjectFactory
 Inherited
getObjectPostProcessors(objectPostProcessorClass:Class):Array
Retrieves the object processors of the specified Class.
AbstractObjectFactory
 Inherited
getObjectsOfType(type:Class):Object
Returns all object definitions and explicit singletons that are of the given type.
DefaultListableObjectFactory
 Inherited
getType(objectName:String):Class
Returns the type that is defined on the object definition.
AbstractObjectFactory
 Inherited
getUsedTypes():Array
Returns a unique list of all Classes that are used by the IObjectDefinitions in the current IObjectDefinitionRegistry.
DefaultListableObjectFactory
  
initialized(document:Object, id:String):void

Checks if the document parameter is of type Module and if so sets it as the ownerModule property.

MXMLApplicationContext
 Inherited
isFactoryObject(objectName:String):Boolean
Determines if an object is a IFactoryObject implementation.
AbstractObjectFactory
 Inherited
isPrototype(objectName:String):Boolean
Determines if the definition with the given name is a prototype.
AbstractObjectFactory
 Inherited
isSingleton(objectName:String):Boolean
Determines if the definition with the given name is a singleton.
AbstractObjectFactory
 Inherited
load():void
AbstractApplicationContext
 Inherited

Checks if the objectdefinition is an implementation of IFactoryObject, if so the factory will be pre-instantiated, not the result of the factory.

Instantiates all definitions that are defined as singleton and are not lazy.
DefaultListableObjectFactory
 Inherited
registerCustomEditor(requiredType:Class, propertyEditor:IPropertyEditor):void
Registers a custom property editor.
AbstractObjectFactory
 Inherited
registerObjectDefinition(objectName:String, objectDefinition:IObjectDefinition):void
Registers the given objectDefinition under the given name.
DefaultListableObjectFactory
 Inherited
registerSingleton(name:String, object:Object):void
AbstractApplicationContext
 Inherited
removeObjectDefinition(objectName:String):void
Removes the definition with the given name from the registry
DefaultListableObjectFactory
 Inherited
Removes the specified IObjectPostProcessor from the current object factory.
AbstractObjectFactory
 Inherited
resolveReference(property:Object):Object
Resolves a property in an object definition.
AbstractObjectFactory
 Inherited
wire(object:*, objectDefinition:IObjectDefinition = null, objectName:String = null):void
AbstractObjectFactory
Protected Methods
 MethodDefined by
 Inherited
buildObject(name:String, constructorArguments:Array = null):*
Builds an object for the given name and returns it.
AbstractObjectFactory
 Inherited
clearFromCache(cache:Object, name:String):Object
AbstractObjectFactory
  
completeHandler(event:Event):void
Event.COMPLETE event handler added in context constructor.
MXMLApplicationContext
 Inherited
createObjectViaInstanceFactoryMethod(objectName:String, methodName:String, args:Array = null):*
AbstractObjectFactory
 Inherited
createObjectViaStaticFactoryMethod(clazz:Class, applicationDomain:ApplicationDomain, factoryMethodName:String, args:Array = null):*
AbstractObjectFactory
  
doLoad():void
MXMLApplicationContext
  
getParentDocument(object:Object):Module
MXMLApplicationContext
 Inherited
init():void
AbstractObjectFactory
 Inherited
Invokes all object factory post processors.
AbstractApplicationContext
 Inherited
loadComplete():void
AbstractApplicationContext
 Inherited
DefaultListableObjectFactory
 Inherited
Hook method defined in XmlObjectFactory to add the ApplicationContextAwareProcessor.
AbstractApplicationContext
 Inherited
Looks for implementations of IObjectFactoryPostProcessor in the object definition of this context and add an instance of each one as a object factory post processor.
AbstractApplicationContext
 Inherited
Will search all object definitions for implementations of IObjectPostProcessor.
AbstractApplicationContext
 Inherited
DefaultListableObjectFactory
Events
 EventSummaryDefined by
 Inherited Dispatched after an object has been instantiated and wired by the current object factory AbstractObjectFactory
 Inherited Dispatched right before an object is returned by the current object factory AbstractObjectFactory
Public Constants
 ConstantDefined by
 InheritedOBJECT_FACTORY_PREFIX : String = "&"
[static] Used to dereference an IFactoryObject instance and distinguish it from objects created by the IFactoryObject.
AbstractObjectFactory
 InheritedTHIS : String = "this"
[static]
AbstractObjectFactory
Property detail
ownerModuleproperty
ownerModule:Module  [read-write]

The Module that will act as the owner of the current IOwnerModuleAware instance.

Implementation
    public function get ownerModule():Module
    public function set ownerModule(value:Module):void
stageProcessorRegistryproperty 
stageProcessorRegistry:IStageProcessorRegistry  [read-write]

Implementation
    public function get stageProcessorRegistry():IStageProcessorRegistry
    public function set stageProcessorRegistry(value:IStageProcessorRegistry):void
Constructor detail
MXMLApplicationContext()constructor
public function MXMLApplicationContext(config:* = null, ownerModule:Module = null)

Creates a new MXMLApplicationContext instance.

This constructor will accept a Class object representing the MXML configuration or an Array representing multiple MXML configuration Class objects.

Parameters
config:* (default = null) — a Class object or an Array of Class objects representing MXML configurations
 
ownerModule:Module (default = null)
Method detail
addConfig()method
public function addConfig(configClass:Class):void

Adds a single MXML configuration Class object to the application context. If the configuration class was already added, it will be ignored.

Parameters
configClass:Class — the Class object representing an MXML configuration
completeHandler()method 
protected function completeHandler(event:Event):void

Event.COMPLETE event handler added in context constructor. Attempts to wire all the components that are already on the stage cache. Assigns the systemManager property with the current application's systemManager and adds the stageWireObjectHandler() method as an Event.ADDED listener on the systemManager.

Parameters
event:Event — The specified Event.COMPLETE event
disableStageProcessing()method 
public function disableStageProcessing():void

Sets the stageProcessorRegistry.enabled property to false. Useful during testing and object dispose.

See also

stageWireObjectHandler()
dispose()method 
public override function dispose():void
doLoad()method 
protected override function doLoad():void
enableStageProcessing()method 
public function enableStageProcessing():void

Sets the stageProcessorRegistry.enabled property to true. Useful during testing and object dispose.

See also

stageWireObjectHandler()
getParentDocument()method 
protected function getParentDocument(object:Object):ModuleParameters
object:Object

Returns
Module
initialized()method 
public function initialized(document:Object, id:String):void

Checks if the document parameter is of type Module and if so sets it as the ownerModule property.

Parameters
document:Object
 
id:String

See also