Packagecom.lafabrick.reflex.ioc
Classpublic class ApplicationContext

Management of the XML context configuration.


Example

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

com.lafabrick.reflex.ioc.XMLObjectConverter


Public Methods
 MethodDefined 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
Method detail
addEventListener()method
public static function addEventListener(type:String, listener:Function):void

Add a Listener

Parameters
type:String — the name of the event
 
listener:Function — function activated by the event.
getObject()method 
public static function getObject(objectId:String, contextKey:String = "default"):Object

Find and generates the object defines in the context of configuration.

Parameters
objectId: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 ")

Returns
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"):void

Load a context of configuration.

Parameters
xmlConfigUrl: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.

Example

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):void

Add your own service (based on AbstractService), for use with the application configuration file

Parameters
className:Class — the Class used for your own service
removeEventListener()method 
public static function removeEventListener(type:String, listener:Function):void

destruction of a listener

Parameters
type:String — the name of the event
 
listener:Function — function activated by the event.