Christophe Herreman www.herrodius.com <Flex:Camp/> Belgium 11 December 2008 Prana goes Spring Introducing Spring ActionScr...
<ul><li>What is Spring ActionScript ? </li></ul><ul><li>An Inversion of Control (IoC) Container for ActionScript 3.0 </li>...
<ul><li>What is Spring ActionScript ? </li></ul><ul><li>Cairngorm support </li></ul><ul><li>PureMVC support </li></ul><ul>...
<ul><li>What is Inversion of Control ? </li></ul><ul><li>Inversion of Control, also known as IOC, is an object-oriented pr...
<ul><li>Types of Inversion of Control ? </li></ul><ul><li>Dependency Lookup </li></ul><ul><ul><li>Dependency Pull </li></u...
<ul><li>Constructor Injection </li></ul><ul><li>Class MyClass { </li></ul><ul><li>public function MyClass(dependency:IDepe...
<ul><li>Setter Injection </li></ul><ul><li>Class MyClass { </li></ul><ul><li>private var dependency:IDependency; </li></ul...
<ul><li>Inversion of Control? </li></ul><ul><li>Prefer setter injection </li></ul><ul><li>Type to interfaces !!! </li></ul...
What is an IoC Container ? Creates and assembles components/objects and manages their lifecycle. Spring ActionScript uses ...
The Application Context // setter injection <objects> <object id=“instance” class=“MyClass”> <property name=“dependency” r...
The Application Context // constructor injection <objects> <object id=“instance” class=“MyClass”> <constructor-arg ref=“de...
Working with the IoC container <mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;  creationComplete=&quot...
<ul><li>Application Contexts </li></ul><ul><li>XMLApplicationContext  </li></ul><ul><ul><li>AS3 compatible </li></ul></ul>...
<ul><li>IoC Container Conclusion </li></ul><ul><li>Objects defined in external XML file </li></ul><ul><li>Loaded at runtim...
<ul><li>Resources </li></ul><ul><li>www.pranaframework.org </li></ul><ul><li>www.herrodius.com </li></ul><ul><li>Objects R...
Questions?
Upcoming SlideShare
Loading in …5
×

Spring ActionScript

11,247 views

Published on

Spring ActionScript presentation files from FlexCamp 2008 in Antwerp (Belgium)

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
11,247
On SlideShare
0
From Embeds
0
Number of Embeds
3,613
Actions
Shares
0
Downloads
115
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Spring ActionScript

  1. 1. Christophe Herreman www.herrodius.com <Flex:Camp/> Belgium 11 December 2008 Prana goes Spring Introducing Spring ActionScript
  2. 2. <ul><li>What is Spring ActionScript ? </li></ul><ul><li>An Inversion of Control (IoC) Container for ActionScript 3.0 </li></ul><ul><li>Based on Java Spring </li></ul><ul><li>Current release 0.6 </li></ul><ul><li>Incubated as a Spring extension, working towards a 1.0 release </li></ul>June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
  3. 3. <ul><li>What is Spring ActionScript ? </li></ul><ul><li>Cairngorm support </li></ul><ul><li>PureMVC support </li></ul><ul><li>Reflection API </li></ul><ul><li>Several Utilities (Assert, FlexUnitTestCase, …) </li></ul><ul><li>Domain base classes (Entity, ValueObject, …) </li></ul><ul><li>AOP, MVCS, … </li></ul>June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
  4. 4. <ul><li>What is Inversion of Control ? </li></ul><ul><li>Inversion of Control, also known as IOC, is an object-oriented programming principle that can be used to reduce coupling inherent in computer programs. </li></ul>June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
  5. 5. <ul><li>Types of Inversion of Control ? </li></ul><ul><li>Dependency Lookup </li></ul><ul><ul><li>Dependency Pull </li></ul></ul><ul><ul><li>Contextualized Dependency Lookup </li></ul></ul><ul><li>Dependency Injection </li></ul><ul><ul><li>Constructor Injection </li></ul></ul><ul><ul><li>Setter Injection (see MXML) </li></ul></ul>June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
  6. 6. <ul><li>Constructor Injection </li></ul><ul><li>Class MyClass { </li></ul><ul><li>public function MyClass(dependency:IDependency) { </li></ul><ul><li>this.dependency = dependency; </li></ul><ul><li>} </li></ul><ul><li>public function doSomething():* { </li></ul><ul><li>var somethingDone:* = dependency.getSomethingDone(); </li></ul><ul><li>return markAsDone(somethingDone); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>var instance:MyClass = new MyClass(new ConcreteDependency()); </li></ul><ul><li>instance.doSomething(); </li></ul>June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
  7. 7. <ul><li>Setter Injection </li></ul><ul><li>Class MyClass { </li></ul><ul><li>private var dependency:IDependency; </li></ul><ul><li>public function set dependency(value:IDependency):void { </li></ul><ul><li>this.dependency = value; </li></ul><ul><li>} </li></ul><ul><li>public function doSomething():* { </li></ul><ul><li>var somethingDone:* = dependency.getSomethingDone(); </li></ul><ul><li>return markAsDone(somethingDone); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>var instance:MyClass = new MyClass(); </li></ul><ul><li>instance.dependency = new ConcreteDependency(); </li></ul><ul><li>instance.doSomething(); </li></ul>June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
  8. 8. <ul><li>Inversion of Control? </li></ul><ul><li>Prefer setter injection </li></ul><ul><li>Type to interfaces !!! </li></ul><ul><li>Centralized configuration </li></ul><ul><li>Maintainability </li></ul><ul><li>Reusability </li></ul><ul><li>Testability </li></ul><ul><li>... </li></ul><ul><li>Though counter-intuitive at first ! </li></ul>June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
  9. 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. 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. 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. 12. Working with the IoC container <mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; creationComplete=&quot;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
  13. 13. <ul><li>Application Contexts </li></ul><ul><li>XMLApplicationContext </li></ul><ul><ul><li>AS3 compatible </li></ul></ul><ul><li>FlexXMLApplicationContext </li></ul><ul><ul><li>Flex specific: adds support for ArrayCollection, … </li></ul></ul>June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
  14. 14. <ul><li>IoC Container Conclusion </li></ul><ul><li>Objects defined in external XML file </li></ul><ul><li>Loaded at runtime </li></ul><ul><li>Centralized dependency management </li></ul><ul><li>Managed by container </li></ul><ul><li>Deploy your application with different configurations without recompiling! </li></ul>June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
  15. 15. <ul><li>Resources </li></ul><ul><li>www.pranaframework.org </li></ul><ul><li>www.herrodius.com </li></ul><ul><li>Objects Reference (the IoC container): http://static.springframework.org/spring/docs/2.5.x/reference/beans.html </li></ul><ul><li>Forum: http://forum.springframework.org/forumdisplay.php?f=60 </li></ul><ul><li>SVN: https://src.springframework.org/svn/se-springactionscript-as </li></ul><ul><li>FishEye: https://fisheye.springframework.org/browse/se-springactionscript-as </li></ul><ul><li>Jira: http://jira.springframework.org/browse/SESPRINGACTIONSCRIPTAS </li></ul><ul><li>WTP: http://download.eclipse.org/webtools/updates/ </li></ul>June 6, 2009 Spring ActionScript | <flex:camp/> Belgium
  16. 16. Questions?

×