SlideShare a Scribd company logo
Spring ActionScriptbyChristopheHerremanFlex Consultant at Boulevart
Overall presentationIntroduction to Spring ActionScript:whatit does andhowyou benefit fromusingit
AgendaWhat is Spring ActionScriptThe IoC containerConfigurationMVC ArchitectureDemoQ&A
Speaker’squalificationsCertifiedAdobeFlex & AIR expert10 yearsplayingwith Flash technologyFounder and leaddeveloper of AS3Commons & Spring ActionScriptTech reviewerforFoED/Apress
What is Spring ActionScript(1/2)Inversion of Control (IoC) forActionScript 3.0Flash/Flex/AIR/Pure AS3IoC containerMVC?
What is Spring ActionScript(2/2)Started as anin-houselibraryFormerlyknown as the PranaframeworkIncubated as a Spring Extension projectUpcoming release 0.9AS3Commons: Lang, Logging, Reflect, …
The IoC Container (1/3)= Object FactoryCreates and assembles objectsCentralizeddependency managementSpring AS: configuration via XML or MXML
The IoC Container (2/3)Object (bean): object managed and/orcreatedby the containerObject Factory: factorythatcreates and managesobjectsfactory.getObject(“myObject”)Object Definition: blueprintforan objectApplication Context: smarter Object Factory
The IoC Container (3/3)Object ScopesSingleton: onlyoneinstance in the containerNotlinked to the Singleton Design PatternThe default scopefactory.getObject(“obj”) == factory.getObject(“obj”)Prototype: newinstancecreatedoneachrequestfactory.getObject(“obj”) != factory.getObject(“obj”)
Configuration(1/9)MXML Configuration// AppContext.mxml file, compiledinto the application<Objects>	<app:ApplicationModelid=“appModel” />	<app:ApplicationControllerid=“appController” 		applicationModel=“{appModel}”/></Objects>
Configuration(2/9)MXML Configuration: loadingvarcontext:MXMLApplicationContext = newMXMLApplicationContext();context.addConfig(AppContext);context.addEventListener(Event.COMPLETE, context_completeHandler);context.load();function context_completeHandler(event:Event):void {varappModel:ApplicationModel = context.getObject(“appModel”);varappController:ApplicationController = 					  		context.getObject(“appController”);}
Configuration(3/9)MXML Configuration: alternativeapproach// AppContext.mxml file, compiledinto the application<Objects>	<Object id=“appModel” clazz=“{ApplicationModel}”/>	<Object id=“appController” clazz=“{ApplicationController}”>			<Property name=“applicationModel” ref=“appModel”/>	</Object></objects>
Configuration(4/9)MXML Configuration: prosEditor supportSimple to use
Configuration(5/9)MXML Configuration: consCompiledinto the applicationExplicitdeclaration: limited to singletons, noexternalreferences, no prototypes -> use Spring AS MXML dialect
Configuration(6/9)XML Configuration// externalcontext.xml, loadedonapplicationstartup<objects>	<object id=“appModel” class=“com.domain.app.ApplicationModel”/>	<object id=“appController” class=“com.domain.app.ApplicationController”>			<property name=“applicationModel” ref=“appModel”/>	</object></objects>
Configuration(7/9)XML Configuration: loadingvarcontext:XMLApplicationContext = newXMLApplicationContext();context.addConfigLocation(“context.xml”);context.addEventListener(Event.COMPLETE, context_completeHandler);context.load();function context_completeHandler(event:Event):void {	var appModel:ApplicationModel = context.getObject(“appModel”);	var appController:ApplicationController = 					  		context.getObject(“appController”);}
Configuration(8/9)XML Configuration: prosRicher dialect than MXML configUsablefornon-FlexprojectsNo need to recompile (in some cases)Familiar to Spring Java users
Configuration(9/9)XML Configuration: consClasses need to becompiledinto the app, noclassloading (!)No editor support, only XSD
MVC Architecture(1/2)No realprescriptivearchitectureDo youreallyneedone?Rollyourownbecauseone does NOT fit allMany MVC architectures out there:Cairngorm, PureMVC, Mate, …… Spring AS wants to support them
MVC Architecture(2/2)Spring AS MVC ingredientsOperation API Event BusAutowiringRecommendationsPresentation Model (Fowler)LayeredArchitecture (DDD – Evans)
The Operation API (1/7)Asynchronousbehavior in Flash Player: loadingexternal resources, RMI, sqlite, Webservices, HTTPServices, …No threading APIMany different APIs: AsyncToken, Responders, Callbacks, Events… we need a unifiedapproach!
The Operation API (2/7)Problem: a user repository (or service)interface IUserRepository {functiongetUser(id:int): ???}What does the getUsermethod return? AsyncToken (Flex/RemoteObject), User (In memory), void (events)
The Operation API (3/7)Spring AS solution: return a IOperationinterface IUserRepository {functiongetUser(id:int):IOperation;}Cannowbeused in anyActionScript 3 context and easilymockedfortesting
The Operation API (4/7)In Spring AS, an “operation” is used to indicateanasynchronousexecutionIOperation interface with “complete” and “error” eventsIProgressOperationwith “progress” eventOperationQueuebundlesoperations (a compositeoperation)
The Operation API (5/7)Defininganoperation:publicclassGetUserOperationextendsAbstractOperation {functionGetUserOperation(remoteObject:RemoteObject, id:String) {vartoken:AsyncToken = remoteObject.getUser(id);token.addResponder(newResponder(resultHandler, faultHandler));	}	private functionresultHandler(event:ResultEvent):void {dispatchCompleteEvent(User(event.result));	}	private functionfaultHandler(event:FaultEvent):void {dispatchErrorEvent(event.fault);	}}
The Operation API (6/7)Usage:varoperation:IOperation = newGetUserOperation(remoteObject, 13);operation.addCompleteListener(function(event:OperationEvent):void {varuser:User = event.result;});operation.addErrorListener(function(event:OperationEvent):void {Alert.show(event.error, “Error”);});
The Operation API (7/7)A progressoperation:varoperation:IOperation = newSomeProgressOperation(param1, param2);operation.addCompleteListener(function(event:OperationEvent):void {});operation.addErrorListener(function(event:OperationEvent):void {});operation.addProgressListener(function(event:OperationEvent):void {	var op:IProgressOperation = IProgressOperation(event.operation);trace(“Progress:” + op.progress + “, total: “ + op.total);});
The Event Bus (1/3)Publish/subscribeevent systemUsedforglobalapplicationeventsPromotesloosecouplingWorks withstandard Flash Events
The Event Bus (2/3)Listening/subscribing to events:// listen for all eventsEventBus.addListener(listener:IEventBusListener);functiononEvent(event:Event):void {}// listen forspecificeventsEventBus.addEventListener(“anEvent”, handler);functionhandler(event:Event):void {}
The Event Bus (3/3)Dispatching/publishingevents:// dispatchstandardeventEventBus.dispatchEvent(newEvent(“someEvent”));// dispatchcustomeventclassUserEventextendsEvent {	... }EventBus.dispatchEvent(newUserEvent(UserEvent.DELETE, user));
Autowiring(1/2)Auto DependencyInjection via metadataAutowireby type, name, constructor, autodetectWorks forobjectsmanagedby the container and for view componentsBe careful: magic happens, noexplicitconfiguration
Autowiring(2/2)Annotate a propertywith [Autowired]classUserController {	[Autowired]	public var userRepository:IUserRepository;}[Autowired(name=“myObject“, property=“prop”)]
SummaryDependency ManagementLoosecoupling, type to interfacesUsewithotherframeworksSpring mentality: provide choicePromote best practices
DEMOA sample application
Thanksforyourattention!www.herrodius.cominfo@herrodius.comwww.springactionscript.orgwww.as3commons.org

More Related Content

What's hot (20)

PPTX
Introduction to OWIN
Saran Doraiswamy
 
PPTX
Building web applications with Java & Spring
David Kiss
 
PPTX
25+ Reasons to use OmniFaces in JSF applications
Anghel Leonard
 
ODP
Spring Portlet MVC
John Lewis
 
PPTX
Introduction to spring boot
Santosh Kumar Kar
 
PDF
Spring Framework - AOP
Dzmitry Naskou
 
PPTX
Spring boot 3g
vasya10
 
PPT
Spring MVC
yuvalb
 
PDF
Spring MVC
Aaron Schram
 
PPTX
OWIN and Katana Project - Not Only IIS - NoIIS
Bilal Haidar
 
PDF
Architecting ActionScript 3 applications using PureMVC
marcocasario
 
PDF
Jinal desai .net
rohitkumar1987in
 
PDF
Spring MVC Framework
Hùng Nguyễn Huy
 
PDF
Titanium - Making the most of your single thread
Ronald Treur
 
PDF
Spring aop
Hamid Ghorbani
 
PPTX
Java Server Faces + Spring MVC Framework
Guo Albert
 
ODP
Annotation-Based Spring Portlet MVC
John Lewis
 
PPT
ASP.NET AJAX with Visual Studio 2008
Caleb Jenkins
 
PDF
JavaFX Enterprise (JavaOne 2014)
Hendrik Ebbers
 
PPT
Tumbleweed intro
Rich Helton
 
Introduction to OWIN
Saran Doraiswamy
 
Building web applications with Java & Spring
David Kiss
 
25+ Reasons to use OmniFaces in JSF applications
Anghel Leonard
 
Spring Portlet MVC
John Lewis
 
Introduction to spring boot
Santosh Kumar Kar
 
Spring Framework - AOP
Dzmitry Naskou
 
Spring boot 3g
vasya10
 
Spring MVC
yuvalb
 
Spring MVC
Aaron Schram
 
OWIN and Katana Project - Not Only IIS - NoIIS
Bilal Haidar
 
Architecting ActionScript 3 applications using PureMVC
marcocasario
 
Jinal desai .net
rohitkumar1987in
 
Spring MVC Framework
Hùng Nguyễn Huy
 
Titanium - Making the most of your single thread
Ronald Treur
 
Spring aop
Hamid Ghorbani
 
Java Server Faces + Spring MVC Framework
Guo Albert
 
Annotation-Based Spring Portlet MVC
John Lewis
 
ASP.NET AJAX with Visual Studio 2008
Caleb Jenkins
 
JavaFX Enterprise (JavaOne 2014)
Hendrik Ebbers
 
Tumbleweed intro
Rich Helton
 

Viewers also liked (20)

PPT
Spring ActionScript
Christophe Herreman
 
PPT
Actionscript
saad_darwish
 
PDF
Quick Step by Step Flash Tutorial
Su Yuen Chin
 
PPT
What is an Effective Layout?
Kern Learning Solution
 
ODP
HTML5 Mobile Game Development Workshop - Module 1 - HTML5 Developer Conferenc...
Pablo Farías Navarro
 
PPTX
Mobile Game Development using Adobe Flash
chall3ng3r
 
PPTX
TCH Technology Consulting Group forging success with Account Payable Recovery
TCH Technology Consulting Group / TCH International Group
 
PPTX
Learn ActionScript programming myassignmenthelp.net
www.myassignmenthelp.net
 
PPT
Account payable manager
hughjackman261
 
PPT
Account receivable manager
hughjackman261
 
PDF
Lessons learned maintaining Open Source ActionScript projects
Zeh Fernando
 
PPTX
Top 8 account payable clerk resume samples
martinwilson397
 
PPT
Account receivable clerk kpi
gkatgutos
 
PDF
Can secwest2011 flash_actionscript
Craft Symbol
 
DOCX
Account Recievable and Account Payable
Habeeb Rahman
 
PDF
Creative Programming in ActionScript 3.0
Peter Elst
 
DOCX
SAP FICO Collection
Pavan Alapati
 
PDF
Less Verbose ActionScript 3.0 - Write less and do more!
Arul Kumaran
 
PPTX
Account payable
Winda Rizkyfa
 
PPT
Actionscript 3 - Session 2 Getting Started Flash IDE
OUM SAOKOSAL
 
Spring ActionScript
Christophe Herreman
 
Actionscript
saad_darwish
 
Quick Step by Step Flash Tutorial
Su Yuen Chin
 
What is an Effective Layout?
Kern Learning Solution
 
HTML5 Mobile Game Development Workshop - Module 1 - HTML5 Developer Conferenc...
Pablo Farías Navarro
 
Mobile Game Development using Adobe Flash
chall3ng3r
 
TCH Technology Consulting Group forging success with Account Payable Recovery
TCH Technology Consulting Group / TCH International Group
 
Learn ActionScript programming myassignmenthelp.net
www.myassignmenthelp.net
 
Account payable manager
hughjackman261
 
Account receivable manager
hughjackman261
 
Lessons learned maintaining Open Source ActionScript projects
Zeh Fernando
 
Top 8 account payable clerk resume samples
martinwilson397
 
Account receivable clerk kpi
gkatgutos
 
Can secwest2011 flash_actionscript
Craft Symbol
 
Account Recievable and Account Payable
Habeeb Rahman
 
Creative Programming in ActionScript 3.0
Peter Elst
 
SAP FICO Collection
Pavan Alapati
 
Less Verbose ActionScript 3.0 - Write less and do more!
Arul Kumaran
 
Account payable
Winda Rizkyfa
 
Actionscript 3 - Session 2 Getting Started Flash IDE
OUM SAOKOSAL
 
Ad

Similar to Spring Actionscript at Devoxx (20)

PPTX
Christophe Spring Actionscript Flex Java Exchange
Skills Matter
 
ODP
Sprint Portlet MVC Seminar
John Lewis
 
PDF
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Codemotion
 
PPT
Developing Java Web Applications
hchen1
 
PDF
Effective JavaFX architecture with FxObjects
Srikanth Shenoy
 
PPTX
Introduction to JQuery, ASP.NET MVC and Silverlight
Peter Gfader
 
PDF
Spring Boot: a Quick Introduction
Roberto Casadei
 
PDF
Intro to Laravel 4
Singapore PHP User Group
 
PPTX
Eclipse RCP Overview @ Rheinjug
Lars Vogel
 
PPT
Eclipse - Single Source;Three Runtimes
Suresh Krishna Madhuvarsu
 
PPT
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Svetlin Nakov
 
PPTX
Developing Agile Java Applications using Spring tools
Sathish Chittibabu
 
PPTX
Rits Brown Bag - Salesforce Lightning
Right IT Services
 
PPT
Asp.net mvc
Phuc Le Cong
 
ODP
Spring framework
srmelody
 
PPT
FraSCAti Adaptive and Reflective Middleware of Middleware
philippe_merle
 
PPT
Introduction To Adobe Flex And Semantic Resources
keith_sutton100
 
ODP
Spring User Guide
Muthuselvam RS
 
PPT
Eclipse RCP
Vijay Kiran
 
PPT
javagruppen.dk - e4, the next generation Eclipse platform
Tonny Madsen
 
Christophe Spring Actionscript Flex Java Exchange
Skills Matter
 
Sprint Portlet MVC Seminar
John Lewis
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Codemotion
 
Developing Java Web Applications
hchen1
 
Effective JavaFX architecture with FxObjects
Srikanth Shenoy
 
Introduction to JQuery, ASP.NET MVC and Silverlight
Peter Gfader
 
Spring Boot: a Quick Introduction
Roberto Casadei
 
Intro to Laravel 4
Singapore PHP User Group
 
Eclipse RCP Overview @ Rheinjug
Lars Vogel
 
Eclipse - Single Source;Three Runtimes
Suresh Krishna Madhuvarsu
 
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Svetlin Nakov
 
Developing Agile Java Applications using Spring tools
Sathish Chittibabu
 
Rits Brown Bag - Salesforce Lightning
Right IT Services
 
Asp.net mvc
Phuc Le Cong
 
Spring framework
srmelody
 
FraSCAti Adaptive and Reflective Middleware of Middleware
philippe_merle
 
Introduction To Adobe Flex And Semantic Resources
keith_sutton100
 
Spring User Guide
Muthuselvam RS
 
Eclipse RCP
Vijay Kiran
 
javagruppen.dk - e4, the next generation Eclipse platform
Tonny Madsen
 
Ad

More from Christophe Herreman (6)

PDF
De kathedraal en de bazaar
Christophe Herreman
 
PDF
Stuff you didn't know about action script
Christophe Herreman
 
PDF
How to build an AOP framework in ActionScript
Christophe Herreman
 
PPTX
GradleFX
Christophe Herreman
 
PPT
AS3Commons Introduction
Christophe Herreman
 
PPT
The Prana IoC Container
Christophe Herreman
 
De kathedraal en de bazaar
Christophe Herreman
 
Stuff you didn't know about action script
Christophe Herreman
 
How to build an AOP framework in ActionScript
Christophe Herreman
 
AS3Commons Introduction
Christophe Herreman
 
The Prana IoC Container
Christophe Herreman
 

Recently uploaded (20)

PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
Digital Circuits, important subject in CS
contactparinay1
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 

Spring Actionscript at Devoxx

  • 2. Overall presentationIntroduction to Spring ActionScript:whatit does andhowyou benefit fromusingit
  • 3. AgendaWhat is Spring ActionScriptThe IoC containerConfigurationMVC ArchitectureDemoQ&A
  • 4. Speaker’squalificationsCertifiedAdobeFlex & AIR expert10 yearsplayingwith Flash technologyFounder and leaddeveloper of AS3Commons & Spring ActionScriptTech reviewerforFoED/Apress
  • 5. What is Spring ActionScript(1/2)Inversion of Control (IoC) forActionScript 3.0Flash/Flex/AIR/Pure AS3IoC containerMVC?
  • 6. What is Spring ActionScript(2/2)Started as anin-houselibraryFormerlyknown as the PranaframeworkIncubated as a Spring Extension projectUpcoming release 0.9AS3Commons: Lang, Logging, Reflect, …
  • 7. The IoC Container (1/3)= Object FactoryCreates and assembles objectsCentralizeddependency managementSpring AS: configuration via XML or MXML
  • 8. The IoC Container (2/3)Object (bean): object managed and/orcreatedby the containerObject Factory: factorythatcreates and managesobjectsfactory.getObject(“myObject”)Object Definition: blueprintforan objectApplication Context: smarter Object Factory
  • 9. The IoC Container (3/3)Object ScopesSingleton: onlyoneinstance in the containerNotlinked to the Singleton Design PatternThe default scopefactory.getObject(“obj”) == factory.getObject(“obj”)Prototype: newinstancecreatedoneachrequestfactory.getObject(“obj”) != factory.getObject(“obj”)
  • 10. Configuration(1/9)MXML Configuration// AppContext.mxml file, compiledinto the application<Objects> <app:ApplicationModelid=“appModel” /> <app:ApplicationControllerid=“appController” applicationModel=“{appModel}”/></Objects>
  • 11. Configuration(2/9)MXML Configuration: loadingvarcontext:MXMLApplicationContext = newMXMLApplicationContext();context.addConfig(AppContext);context.addEventListener(Event.COMPLETE, context_completeHandler);context.load();function context_completeHandler(event:Event):void {varappModel:ApplicationModel = context.getObject(“appModel”);varappController:ApplicationController = context.getObject(“appController”);}
  • 12. Configuration(3/9)MXML Configuration: alternativeapproach// AppContext.mxml file, compiledinto the application<Objects> <Object id=“appModel” clazz=“{ApplicationModel}”/> <Object id=“appController” clazz=“{ApplicationController}”> <Property name=“applicationModel” ref=“appModel”/> </Object></objects>
  • 14. Configuration(5/9)MXML Configuration: consCompiledinto the applicationExplicitdeclaration: limited to singletons, noexternalreferences, no prototypes -> use Spring AS MXML dialect
  • 15. Configuration(6/9)XML Configuration// externalcontext.xml, loadedonapplicationstartup<objects> <object id=“appModel” class=“com.domain.app.ApplicationModel”/> <object id=“appController” class=“com.domain.app.ApplicationController”> <property name=“applicationModel” ref=“appModel”/> </object></objects>
  • 16. Configuration(7/9)XML Configuration: loadingvarcontext:XMLApplicationContext = newXMLApplicationContext();context.addConfigLocation(“context.xml”);context.addEventListener(Event.COMPLETE, context_completeHandler);context.load();function context_completeHandler(event:Event):void { var appModel:ApplicationModel = context.getObject(“appModel”); var appController:ApplicationController = context.getObject(“appController”);}
  • 17. Configuration(8/9)XML Configuration: prosRicher dialect than MXML configUsablefornon-FlexprojectsNo need to recompile (in some cases)Familiar to Spring Java users
  • 18. Configuration(9/9)XML Configuration: consClasses need to becompiledinto the app, noclassloading (!)No editor support, only XSD
  • 19. MVC Architecture(1/2)No realprescriptivearchitectureDo youreallyneedone?Rollyourownbecauseone does NOT fit allMany MVC architectures out there:Cairngorm, PureMVC, Mate, …… Spring AS wants to support them
  • 20. MVC Architecture(2/2)Spring AS MVC ingredientsOperation API Event BusAutowiringRecommendationsPresentation Model (Fowler)LayeredArchitecture (DDD – Evans)
  • 21. The Operation API (1/7)Asynchronousbehavior in Flash Player: loadingexternal resources, RMI, sqlite, Webservices, HTTPServices, …No threading APIMany different APIs: AsyncToken, Responders, Callbacks, Events… we need a unifiedapproach!
  • 22. The Operation API (2/7)Problem: a user repository (or service)interface IUserRepository {functiongetUser(id:int): ???}What does the getUsermethod return? AsyncToken (Flex/RemoteObject), User (In memory), void (events)
  • 23. The Operation API (3/7)Spring AS solution: return a IOperationinterface IUserRepository {functiongetUser(id:int):IOperation;}Cannowbeused in anyActionScript 3 context and easilymockedfortesting
  • 24. The Operation API (4/7)In Spring AS, an “operation” is used to indicateanasynchronousexecutionIOperation interface with “complete” and “error” eventsIProgressOperationwith “progress” eventOperationQueuebundlesoperations (a compositeoperation)
  • 25. The Operation API (5/7)Defininganoperation:publicclassGetUserOperationextendsAbstractOperation {functionGetUserOperation(remoteObject:RemoteObject, id:String) {vartoken:AsyncToken = remoteObject.getUser(id);token.addResponder(newResponder(resultHandler, faultHandler)); } private functionresultHandler(event:ResultEvent):void {dispatchCompleteEvent(User(event.result)); } private functionfaultHandler(event:FaultEvent):void {dispatchErrorEvent(event.fault); }}
  • 26. The Operation API (6/7)Usage:varoperation:IOperation = newGetUserOperation(remoteObject, 13);operation.addCompleteListener(function(event:OperationEvent):void {varuser:User = event.result;});operation.addErrorListener(function(event:OperationEvent):void {Alert.show(event.error, “Error”);});
  • 27. The Operation API (7/7)A progressoperation:varoperation:IOperation = newSomeProgressOperation(param1, param2);operation.addCompleteListener(function(event:OperationEvent):void {});operation.addErrorListener(function(event:OperationEvent):void {});operation.addProgressListener(function(event:OperationEvent):void { var op:IProgressOperation = IProgressOperation(event.operation);trace(“Progress:” + op.progress + “, total: “ + op.total);});
  • 28. The Event Bus (1/3)Publish/subscribeevent systemUsedforglobalapplicationeventsPromotesloosecouplingWorks withstandard Flash Events
  • 29. The Event Bus (2/3)Listening/subscribing to events:// listen for all eventsEventBus.addListener(listener:IEventBusListener);functiononEvent(event:Event):void {}// listen forspecificeventsEventBus.addEventListener(“anEvent”, handler);functionhandler(event:Event):void {}
  • 30. The Event Bus (3/3)Dispatching/publishingevents:// dispatchstandardeventEventBus.dispatchEvent(newEvent(“someEvent”));// dispatchcustomeventclassUserEventextendsEvent { ... }EventBus.dispatchEvent(newUserEvent(UserEvent.DELETE, user));
  • 31. Autowiring(1/2)Auto DependencyInjection via metadataAutowireby type, name, constructor, autodetectWorks forobjectsmanagedby the container and for view componentsBe careful: magic happens, noexplicitconfiguration
  • 32. Autowiring(2/2)Annotate a propertywith [Autowired]classUserController { [Autowired] public var userRepository:IUserRepository;}[Autowired(name=“myObject“, property=“prop”)]
  • 33. SummaryDependency ManagementLoosecoupling, type to interfacesUsewithotherframeworksSpring mentality: provide choicePromote best practices