| Package | org.springextensions.actionscript.context.support |
| SVN browsing | AbstractApplicationContext.as |
| Fisheye | AbstractApplicationContext.as |
| Class | public class AbstractApplicationContext |
| Inheritance | AbstractApplicationContext DefaultListableObjectFactory AbstractObjectFactory flash.events.EventDispatcher |
| Implements | IConfigurableApplicationContext |
| Subclasses | MXMLApplicationContext, XMLApplicationContext |
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 | |
![]() | explicitSingletonNames : Array
The names of the explicit singletons registered in this factory.
| 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 | |
![]() | parent : IObjectFactory
| AbstractObjectFactory | |
| parentContext : IApplicationContext
[read-only]
Returns the parent application context or
null if no parent is set. | AbstractApplicationContext | ||
![]() | properties : Properties | AbstractObjectFactory | |
![]() | typeConverter : ITypeConverter
The current type converter implementation
| AbstractObjectFactory | |
| Method | Defined by | ||
|---|---|---|---|
|
AbstractApplicationContext(parent:IApplicationContext = null)
Creates a new AbstractApplicationContext
| AbstractApplicationContext | ||
|
addObjectFactoryPostProcessor(objectFactoryPostProcessor:IObjectFactoryPostProcessor, index:int = -1):void
Adds an
IObjectFactoryPostProcessor instance to the current XMLApplicationContext
| AbstractApplicationContext | ||
![]() |
addObjectPostProcessor(objectPostProcessor:IObjectPostProcessor):void
If the specified | 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 | |
![]() |
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 | |
![]() |
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 | |
![]() |
getObjectNamesForType(type:Class):Array
Returns the names of all object definitions and explicit singletons in this factory that are of
the given type.
| DefaultListableObjectFactory | |
![]() |
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 | |
![]() |
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 | |
![]() |
resolveReference(property:Object):Object
Resolves a property in an object definition.
| AbstractObjectFactory | |
![]() |
wire(object:*, objectDefinition:IObjectDefinition, objectName:String = null):void
| AbstractObjectFactory | |
| Method | Defined 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 | |
|
Invokes all object factory post processors.
| AbstractApplicationContext | ||
|
loadComplete():void
TODO
| AbstractApplicationContext | ||
|
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 | ||
| parentContext | property |
parentContext:IApplicationContext [read-only]
Returns the parent application context or null if no parent is set.
public function get parentContext():IApplicationContext
| AbstractApplicationContext | () | constructor |
public function AbstractApplicationContext(parent:IApplicationContext = null)Creates a new AbstractApplicationContext
Parametersparent:IApplicationContext (default = null) |
| addObjectFactoryPostProcessor | () | method |
public function addObjectFactoryPostProcessor(objectFactoryPostProcessor:IObjectFactoryPostProcessor, index:int = -1):void
Adds an IObjectFactoryPostProcessor instance to the current XMLApplicationContext
objectFactoryPostProcessor:IObjectFactoryPostProcessor — An IObjectFactoryPostProcessor instance which is allowed to read the configuration metadata and potentially change it before the container has actually instantiated any other objects.
|
|
index:int (default = -1) — An optional index for the objectFactoryPostProcessor list that the specified IObjectFactoryPostProcessor will be inserted at
|
| invokeObjectFactoryPostProcessors | () | method |
protected function invokeObjectFactoryPostProcessors():voidInvokes all object factory post processors.
| load | () | method |
public function load():void
| loadComplete | () | method |
protected function loadComplete():voidTODO
| prepareApplicationContext | () | method |
protected function prepareApplicationContext():void
Hook method defined in XmlObjectFactory to add the ApplicationContextAwareProcessor.
See also
| registerObjectFactoryPostProcessors | () | method |
protected function registerObjectFactoryPostProcessors():voidLooks for implementations of IObjectFactoryPostProcessor in the object definition of this context and add an instance of each one as a object factory post processor.
| registerObjectPostProcessors | () | method |
protected function registerObjectPostProcessors():voidWill search all object definitions for implementations of IObjectPostProcessor.
If they are found they will be added using addObjectPostProcessor.
If the implementation also implements IObjectFactoryAware, it will receive a reference to the XMLApplicationContext.See also
| registerSingleton | () | method |
public override function registerSingleton(name:String, object:Object):voidParameters
name:String |
|
object:Object |