| Package | org.pranaframework.context.support |
| Class | public class XMLApplicationContext |
| Inheritance | XMLApplicationContext XMLObjectFactory DefaultListableObjectFactory AbstractObjectFactory flash.events.EventDispatcher |
| Implements | IConfigurableApplicationContext |
| Subclasses | FlexXMLApplicationContext |
XMLApplicationContext is the object factory used in ActionScript projects, in Flex projects
you want to use the FlexXMLApplicationContext class.
Important: the schemeLocation within the application context xml file (in the example
http://www.pranaframework.org/schema/objects/prana-objects-0.6.xsd)
should contain the version of prana 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.pranaframework.org/objects"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.pranaframework.org/objects http://www.pranaframework.org/schema/objects/prana-objects-0.6.xsd"
>
<object id="someObject" class="package.SomeClass" />
</objects>
<object class="org.pranaframework.factory.config.SpecialObjectPostProcessor" />
XMLApplicationContext will automatically add them if they implement the
IObjectPostProcessor interface.
See also
| Method | Defined by | ||
|---|---|---|---|
|
XMLApplicationContext(source:* = null)
Creates a new XMLApplicationContext
| XMLApplicationContext | ||
![]() |
addConfig(config:XML):void
Use this method to add xml versions of configurations
| XMLObjectFactory | |
![]() |
addConfigLocation(configLocation:String):void
Use this method to add aditional configuration locations.
| XMLObjectFactory | |
![]() |
addObjectPostProcessor(objectPostProcessor:IObjectPostProcessor):void
Adds an object postprocessor to this object factory.
| AbstractObjectFactory | |
![]() |
addReferenceResolver(referenceResolver:IReferenceResolver):void
This method adds a reference resolver that will be used to resolve property
references.
| 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 | |
![]() |
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 all object definitions names that implement the given type.
| DefaultListableObjectFactory | |
![]() |
getObjectsOfType(type:Class):Dictionary
Returns all object definitions that implement 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
Instructs the object factory to start loading the available configuration(s)
| XMLObjectFactory | |
![]() |
preInstantiateSingletons():void
Instantiates all definitions that are defined as singleton and are not lazy.
| DefaultListableObjectFactory | |
![]() |
registerCustomEditor(requiredType:Class, propertyEditor:IPropertyEditor):void
Registers a custom property editor.
| AbstractObjectFactory | |
![]() |
registerObjectDefinition(objectName:String, objectDefinition:IObjectDefinition):void
Will register the given objectDefinition with the given name.
| DefaultListableObjectFactory | |
![]() |
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 | |
| Method | Defined by | ||
|---|---|---|---|
|
afterParse():void
Hook method defined in XmlObjectFactory overridden to invoke
application context specific logic.
| XMLApplicationContext | ||
|
beforeParse():void
Hook method defined in XmlObjectFactory to add the
ApplicationContextAwareProcessor. | XMLApplicationContext | ||
![]() |
loadConfigLocation(configLocation:String):void
Will load a configLocation
| XMLObjectFactory | |
|
registerObjectPostProcessors():void
Will search all object definitions for implementations of IObjectPostProcessor.
| XMLApplicationContext | ||
| XMLApplicationContext | () | constructor |
public function XMLApplicationContext(source:* = null)Creates a new XMLApplicationContext
Parameterssource:* (default = null) |
| afterParse | () | method |
protected override function afterParse():voidHook method defined in XmlObjectFactory overridden to invoke application context specific logic.
| beforeParse | () | method |
protected override function beforeParse():void
Hook method defined in XmlObjectFactory to add the ApplicationContextAwareProcessor.
See also
| 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