| Package | org.springextensions.actionscript.context.support |
| SVN browsing | XMLApplicationContext.as |
| Fisheye | XMLApplicationContext.as |
| Class | public class XMLApplicationContext |
| Inheritance | XMLApplicationContext AbstractApplicationContext DefaultListableObjectFactory AbstractObjectFactory flash.events.EventDispatcher |
| Implements | IConfigurableApplicationContext, IStageProcessorRegistryAware |
| Subclasses | FlexXMLApplicationContext |
XMLApplicationContext is the object factory used in ActionScript projects, in Flex projects
you want to use the FlexXMLApplicationContext class.
Important: the schemaLocation within the application context xml file (in the example
http://www.springactionscript.org/schema/objects/spring-actionscript-objects-1.0.xsd)
should contain the version of spring actionscript you are using.
public class MyApplication {
private var _xmlApplicationContext:XMLApplicationContext;
public function MyApplication() {
_xmlApplicationContext = new XMLApplicationContext("applicationContext.xml");
_xmlApplicationContext.addEventListener(Event.COMPLETE, _applicationContextCompleteHandler);
_xmlApplicationContext.load();
}
private function _applicationContextCompleteHandler(e:Event):void {
var someObject:SomeObject = _xmlApplicationContext.getObject("someObject");
}
}
applicationContext.xml could look something like this:
A simple application context xml file
An applicationcontext.xml file with one object defined
<?xml version="1.0" encoding="utf-8"?>
<objects xmlns="http://www.springactionscript.org/objects"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springactionscript.org/schema/objects/spring-actionscript-objects-1.0.xsd"
>
<object id="someObject" class="package.SomeClass" />
</objects>
<object class="org.springextensions.actionscript.factory.config.SpecialObjectPostProcessor" />
XMLApplicationContext will automatically add them if they implement the
IObjectPostProcessor 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
Documentation reference: instantiating a container
| Property | Defined by | ||
|---|---|---|---|
![]() | allowObjectDefinitionOverriding : 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 | |
![]() | applicationDomain : ApplicationDomain | AbstractObjectFactory | |
![]() | autowireProcessor : IAutowireProcessor
| AbstractObjectFactory | |
| configLocations : Array [read-only]
| XMLApplicationContext | ||
![]() | explicitSingletonNames : Array
The names of the explicit singletons registered in this factory.
| AbstractObjectFactory | |
![]() | hasDestructionAwareObjectPostProcessors : Boolean | AbstractObjectFactory | |
![]() | isDisposed : Boolean | AbstractObjectFactory | |
![]() | numObjectDefinitions : uint
The number of object definitions in this registry.
| DefaultListableObjectFactory | |
![]() | numObjectPostProcessors : int
Returns the number of object post processors.
| AbstractObjectFactory | |
![]() | objectDefinitionNames : Array
The names of the registered object definitions.
| DefaultListableObjectFactory | |
![]() | objectDefinitions : Object | AbstractObjectFactory | |
![]() | objectFactoryPostProcessors : Array | AbstractApplicationContext | |
![]() | objectPostProcessors : Array | AbstractObjectFactory | |
![]() | parent : IObjectFactory
Optional parent factory that can be used to create objects that can't be created by the current instance.
| AbstractObjectFactory | |
![]() | parentContext : IApplicationContext
Returns the parent application context or
null if no parent is set. | AbstractApplicationContext | |
| parser : XMLObjectDefinitionsParser
Contains the parser of the XML definitions.
| XMLApplicationContext | ||
![]() | properties : Properties | AbstractObjectFactory | |
| stageProcessorRegistry : IStageProcessorRegistry
| XMLApplicationContext | ||
![]() | typeConverter : ITypeConverter
The current type converter implementation
| AbstractObjectFactory | |
![]() | useParentObjectFactoryPostProcessors : Boolean | AbstractApplicationContext | |
| Property | Defined by | ||
|---|---|---|---|
| configurationCompleted : Boolean | XMLApplicationContext | ||
| currentConfigLocation : String = "" | XMLApplicationContext | ||
![]() | earlySingletonCache : Object Cache of early cached singletons for circular references
| AbstractObjectFactory | |
![]() | explicitSingletonCache : Object Cache of singleton objects registered without object definition
| AbstractObjectFactory | |
![]() | referenceResolvers : Array Reference resolvers used when creating objects
| AbstractObjectFactory | |
![]() | singletonCache : Object Cache of created singleton objects via an object definition
| AbstractObjectFactory | |
| _xml : XML | XMLApplicationContext | ||
| Method | Defined by | ||
|---|---|---|---|
|
XMLApplicationContext(source:* = null, parent:IApplicationContext = null)
Creates a new XMLApplicationContext
| XMLApplicationContext | ||
|
addConfig(config:XML):void
| XMLApplicationContext | ||
|
addConfigLocation(configLocation:String):void
| XMLApplicationContext | ||
|
addEmbeddedConfig(config:Class):void
| XMLApplicationContext | ||
|
addNamespaceHandler(handler:INamespaceHandler):void
Adds a namespace handler to the parser of this application context.
| XMLApplicationContext | ||
![]() |
addObjectFactoryPostProcessor(objectFactoryPostProcessor:IObjectFactoryPostProcessor, index:int = -1):void
Adds an
IObjectFactoryPostProcessor instance to the current XMLApplicationContext
| AbstractApplicationContext | |
![]() |
addObjectPostProcessor(objectPostProcessor:IObjectPostProcessor):void
If the specified IObjectPostProcessor to the current 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 | |
![]() |
clearObjectFromExplicitInternalCache(name:String):Object
| 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 | |
![]() |
containsObjectDefinition(objectName:String):Boolean
Determines if an object definition with the given name exists
| DefaultListableObjectFactory | |
![]() |
createInstance(clazz:Class, constructorArguments:Array = null):*
Creates an instance of the specified
Class, wires the instance and returns it. | AbstractObjectFactory | |
|
dispose():void
| XMLApplicationContext | ||
![]() |
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 | |
![]() |
getObjectDefinition(objectName:String):IObjectDefinition
Returns the object definition registered with the given name.
| DefaultListableObjectFactory | |
![]() |
getObjectDefinitionsOfType(type:Class):Array
Returns the object definitions in this registry that are of
the specified
Class. | DefaultListableObjectFactory | |
![]() |
getObjectNamesForType(type:Class):Array
Returns the names of all object definitions and explicit singletons in this factory that are of
the given type.
| DefaultListableObjectFactory | |
![]() |
getObjectPostProcessors(objectPostProcessorClass:Class):Array
Retrieves the object processors of the specified
Class. | AbstractObjectFactory | |
![]() |
getObjectsOfType(type:Class):Object
Returns all object definitions and explicit singletons that are of the given type.
| DefaultListableObjectFactory | |
![]() |
getType(objectName:String):Class
Returns the type that is defined on the object definition.
| AbstractObjectFactory | |
![]() |
getUsedTypes():Array
Returns a unique list of all
Classes that are used by the IObjectDefinitions
in the current IObjectDefinitionRegistry. | DefaultListableObjectFactory | |
![]() |
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 | |
![]() |
load():void
| AbstractApplicationContext | |
![]() |
preInstantiateSingletons():void
Checks if the objectdefinition is an implementation of | DefaultListableObjectFactory | |
![]() |
registerCustomEditor(requiredType:Class, propertyEditor:IPropertyEditor):void
Registers a custom property editor.
| AbstractObjectFactory | |
![]() |
registerObjectDefinition(objectName:String, objectDefinition:IObjectDefinition):void
Registers the given objectDefinition under the given name.
| DefaultListableObjectFactory | |
![]() |
registerSingleton(name:String, object:Object):void
| AbstractApplicationContext | |
![]() |
removeObjectDefinition(objectName:String):void
Removes the definition with the given name from the registry
| DefaultListableObjectFactory | |
![]() |
removeObjectPostProcessor(objectPostProcessor:IObjectPostProcessor):void
Removes the specified
IObjectPostProcessor from the current object factory. | AbstractObjectFactory | |
![]() |
resolveReference(property:Object):Object
Resolves a property in an object definition.
| AbstractObjectFactory | |
![]() |
wire(object:*, objectDefinition:IObjectDefinition = null, objectName:String = null):void
| AbstractObjectFactory | |
| Method | Defined by | ||
|---|---|---|---|
|
addImportLocationsIfAny(xml:XML):void
Checks if the given xml data contains any <import/> tags.
| XMLApplicationContext | ||
![]() |
buildObject(name:String, constructorArguments:Array = null):*
Builds an object for the given name and returns it.
| AbstractObjectFactory | |
|
cleanupLoader():void
If the
_loader variable is not null the onLoaderComplete
and onIOError event handlers are removed. | XMLApplicationContext | ||
![]() |
clearFromCache(cache:Object, name:String):Object
| AbstractObjectFactory | |
|
completeHandler(event:Event):void
Event.COMPLETE event handler added in context constructor. | XMLApplicationContext | ||
![]() |
createObjectViaInstanceFactoryMethod(objectName:String, methodName:String, args:Array = null):*
| AbstractObjectFactory | |
![]() |
createObjectViaStaticFactoryMethod(clazz:Class, applicationDomain:ApplicationDomain, factoryMethodName:String, args:Array = null):*
| AbstractObjectFactory | |
|
doLoad():void
This method will internally do the following:
| XMLApplicationContext | ||
|
getBaseURL(url:String):String
Returns the base url of the file this loading is loading.
| XMLApplicationContext | ||
![]() |
init():void
| AbstractObjectFactory | |
|
initXMLObjectFactory(source:*):void
Initializes the
XMLObjectFactoryInit instance
| XMLApplicationContext | ||
![]() |
Invokes all object factory post processors.
| AbstractApplicationContext | |
![]() |
loadComplete():void
| AbstractApplicationContext | |
|
loadConfigLocation(configLocation:String):void
Will load a configLocation
| XMLApplicationContext | ||
|
parse():void
Parses the xml.
| XMLApplicationContext | ||
![]() | DefaultListableObjectFactory | ||
![]() |
prepareApplicationContext():void
Hook method defined in XmlObjectFactory to add the
ApplicationContextAwareProcessor. | AbstractApplicationContext | |
![]() |
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 | |
![]() |
registerObjectPostProcessors():void
Will search all object definitions for implementations of IObjectPostProcessor.
| AbstractApplicationContext | |
![]() |
wireExplicitSingletons():void
| DefaultListableObjectFactory | |
| configLocations | property |
configLocations:Array [read-only]Implementation
public function get configLocations():Array
| configurationCompleted | property |
protected var configurationCompleted:Boolean
| currentConfigLocation | property |
protected var currentConfigLocation:String = ""
| parser | property |
public var parser:XMLObjectDefinitionsParserContains the parser of the XML definitions. The instance is created in the constructor if it does not exist already.
The default value is an instance of XMLObjectDefinitionsParser.
| stageProcessorRegistry | property |
stageProcessorRegistry:IStageProcessorRegistry [read-write]Implementation
public function get stageProcessorRegistry():IStageProcessorRegistry
public function set stageProcessorRegistry(value:IStageProcessorRegistry):void
| _xml | property |
protected var _xml:XML
| XMLApplicationContext | () | constructor |
public function XMLApplicationContext(source:* = null, parent:IApplicationContext = null)Creates a new XMLApplicationContext
Parameterssource:* (default = null) |
|
parent:IApplicationContext (default = null) |
| addConfig | () | method |
public function addConfig(config:XML):voidParameters
config:XML |
| addConfigLocation | () | method |
public function addConfigLocation(configLocation:String):voidParameters
configLocation:String |
| addEmbeddedConfig | () | method |
public function addEmbeddedConfig(config:Class):voidParameters
config:Class |
| addImportLocationsIfAny | () | method |
protected function addImportLocationsIfAny(xml:XML):voidChecks if the given xml data contains any <import/> tags. If any are found, their corresponding xml file is added to the load queue.
Parametersxml:XML |
| addNamespaceHandler | () | method |
public function addNamespaceHandler(handler:INamespaceHandler):voidAdds a namespace handler to the parser of this application context.
Parametershandler:INamespaceHandler |
| cleanupLoader | () | method |
protected function cleanupLoader():void
If the _loader variable is not null the onLoaderComplete
and onIOError event handlers are removed.
| 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.
event:Event — The specified Event.COMPLETE event
|
| dispose | () | method |
public override function dispose():void
| doLoad | () | method |
protected override function doLoad():voidThis method will internally do the following:
See also
| getBaseURL | () | method |
protected function getBaseURL(url:String):StringReturns the base url of the file this loading is loading.
Parametersurl:String |
String |
| initXMLObjectFactory | () | method |
protected function initXMLObjectFactory(source:*):void
Initializes the XMLObjectFactoryInit instance
source:* |
| loadConfigLocation | () | method |
protected function loadConfigLocation(configLocation:String):voidWill load a configLocation
ParametersconfigLocation:String |
| parse | () | method |
protected function parse():voidParses the xml.