9. What is an IoC Container ? Creates and assembles components/objects and manages their lifecycle. Spring ActionScript uses an XML dialect to define the “application context” (what objects are available and how they are related) June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
10. The Application Context // setter injection <objects> <object id=“instance” class=“MyClass”> <property name=“dependency” ref=“dependency”/> </object> <object id=“dependency” class=“ConcreteDependency”/> </objects> June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
11. The Application Context // constructor injection <objects> <object id=“instance” class=“MyClass”> <constructor-arg ref=“dependency”/> </object> <object id=“dependency” class=“ConcreteDependency”/> </objects> June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
12. Working with the IoC container <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()“> ... private function onCreationComplete():void { _applicationContext = new FlexXMLApplicationContext(“application-context.xml”); _applicationContext.addEventListener(Event.COMPLETE, onApplicationContextComplete); _applicationContext.load(); } private function onApplicationContextComplete(event:Event):void { var instance:MyClass = _applicationContext .getObject(“instance”); } ... </mx:Application> June 6, 2009 Spring ActionScript | <flex:camp/> Belgium