| Package | com.lafabrick.reflex.ioc |
| Class | public class ApplicationContext |
Structuralization of the XML configuration file: example of definition of a RemoteObject
<?xml version="1.0" encoding="UTF-8"?>
<objects>
<object id="remotingUser" className="mx.rpc.remoting.mxml.RemoteObject">
<property name="destination" className="String">javaFacadeUser</property>
<property name="showBusyCursor" className="Boolean">true</property>
</object>
</objects>
Load the context of configuration
ApplicationContext.addEventListener( ContextEvent.CONTEXT_LOADED, onLoaded );
ApplicationContext.load( "application-config.xml", "adminContexte" ) as User;
private function onLoaded( e:ContextEvent ) : void
{
trace(e.contextName);
// --
}
Recovery of an instance of the object defines in the context
var myObject:RemoteObject = ApplicationContext.getObject( "remotingUser", "adminContexte" ) as RemoteObject;
See also
| Method | Defined by | ||
|---|---|---|---|
|
addEventListener(type:String, listener:Function):void
[static]
Add a Listener
| ApplicationContext | ||
|
getObject(objectId:String, contextKey:String = "default"):Object
[static]
Find and generates the object defines in the context of configuration.
| ApplicationContext | ||
|
load(xmlConfigUrl:String, contextKey:String = "default"):void
[static]
Load a context of configuration.
| ApplicationContext | ||
|
pushServiceClass(className:Class):void
[static]
Add your own service (based on AbstractService), for use with the application configuration file
| ApplicationContext | ||
|
removeEventListener(type:String, listener:Function):void
[static]
destruction of a listener
| ApplicationContext | ||
| addEventListener | () | method |
public static function addEventListener(type:String, listener:Function):voidAdd a Listener
Parameterstype:String — the name of the event
|
|
listener:Function — function activated by the event.
|
| getObject | () | method |
public static function getObject(objectId:String, contextKey:String = "default"):ObjectFind and generates the object defines in the context of configuration.
ParametersobjectId:String — Id of the object contained in the configuration
|
|
contextKey:String (default = "default") — The name of the XML context on which to get recover (by defaut " default ")
|
Object — An object strongly typified
ApplicationContext.getObject( "value" ) use XMLObjectConverter for the generation of object var myObject:User = ApplicationContext.getObject( "userId" ) as User; |
See also
| load | () | method |
public static function load(xmlConfigUrl:String, contextKey:String = "default"):voidLoad a context of configuration.
ParametersxmlConfigUrl:String — Url of the XML configuration file to load.
|
|
contextKey:String (default = "default") — Function to be activated when the load of the file of configuration is loaded.
|
Structuralization of the XML configuration file: example of definition of a RemoteObject
<?xml version="1.0" encoding="UTF-8"?>
<objects>
<object id="remotingUser" className="mx.rpc.remoting.mxml.RemoteObject">
<property name="destination" className="String">javaFacadeUser</property>
<property name="showBusyCursor" className="Boolean">true</property>
</object>
</objects>
Load the context of configuration
ApplicationContext.addEventListener( ContextEvent.CONTEXT_LOADED, onLoaded );
ApplicationContext.load( "application-config.xml", "adminContexte" );
private function onLoaded( e:ContextEvent ) : void
{
trace(e.contextName);
// --
}
| pushServiceClass | () | method |
public static function pushServiceClass(className:Class):voidAdd your own service (based on AbstractService), for use with the application configuration file
ParametersclassName:Class — the Class used for your own service
|
| removeEventListener | () | method |
public static function removeEventListener(type:String, listener:Function):voiddestruction of a listener
Parameterstype:String — the name of the event
|
|
listener:Function — function activated by the event.
|