SlideShare ist ein Scribd-Unternehmen logo
1 von 45
[ Spring en Flash Platform ]




                           1
Nosotros



           Ivan Alvarez
            Adobe Certi ed Expert Flex & AIR
            Senior RIA Developer


           @Ivanhoe

           email
           ivan.alvarez@tidyslice.com




                                               2
Nosotros



           Daniel Ramos
            Adobe Certi ed Instructor Flex & AIR
            Senior RIA Developer


           @dannyGeek

           email
           daniel.ramos@tidyslice.com




                                                   3
Descripción



     Eliminating Enterprise Java Complexity.
     Made programming painless
     Become a Superstar



       IoC: Es un principio abstracto que describe un aspecto
       de algunos diseños de arquitectura de software en el
       que se invierte el ujo de control de un sistema en
       comparación con la programación procedimental .
                                                                4
Descripción




      Principio de Hollywood, “No nos llames, nosotros te
      llamamos”




                                                            5
Quién inicio IOC ?

• Mar)n
Fowler
  Books
• Pa2erns
of
Enterprise
Applica)on
Architecture
• Domain
Specific
Languages
• Analysis
Pa2erns:
Reusable
Object
Models




                                                  6
Por qué IOC ?




      Te permite ensamblar un sistema a partir de sus partes.




      In the Java community there's been a rush of lightweight containers that help to assemble
      components from different projects into a cohesive application. Underlying these containers is a
      common pattern to how they perform the wiring, a concept they refer under the very generic name
      of "Inversion of Control". Martin Fowler. ref http://martinfowler.com/articles/injection.html


                                                                                                         7
Por qué IOC ?




      Las partes no se preocupan por encontrarse unas a otras




      In the Java community there's been a rush of lightweight containers that help to assemble
      components from different projects into a cohesive application. Underlying these containers is a
      common pattern to how they perform the wiring, a concept they refer under the very generic name
      of "Inversion of Control". I dig into how this pattern works, under the more specific name of
      "Dependency Injection" ref http://martinfowler.com/articles/injection.html
                                                                                                         8
Por qué IOC ?




      Cualquier parte puede ser fácilmente sustituida




                                                        9
10

Applica)on
Context:


     •   Definición de Beans y sus dependencias

     •   Beans de infraestructura

     •   Definido en uno o más archivos .xml




                                                 11
•      Contenedor IoC (Inversión de Control) usando Inyección de Dependencias.




“There are three main styles of dependency injection. The names I'm using for them are Constructor Injection, Setter Injection, and
Interface Injection.” Martin Fowler http://martinfowler.com/articles/injection.html#InversionOfControl


                                                                                                                     12
•   Spring se encarga de crear los objetos e inyectar sus dependencias.

•   Constructor o setter injection

•   Los objetos son creados en el orden correcto basados en sus
    dependencias




                                                                    13
•   Spring se encarga de crear los objetos e inyectar sus dependencias.

•   Constructor o setter injection

•   Los objetos son creados en el orden correcto basados en sus
    dependencias




                                                                    13
•   Spring se encarga de crear los objetos e inyectar sus dependencias.

•   Constructor o setter injection

•   Los objetos son creados en el orden correcto basados en sus
    dependencias




                                      Bean B
                                                                    13
•   Spring se encarga de crear los objetos e inyectar sus dependencias.

•   Constructor o setter injection

•   Los objetos son creados en el orden correcto basados en sus
    dependencias




                                      Bean B
                                                                    13
•   Spring se encarga de crear los objetos e inyectar sus dependencias.

•   Constructor o setter injection

•   Los objetos son creados en el orden correcto basados en sus
    dependencias




                  Bean A              Bean B
                                                                    13
•   Spring se encarga de crear los objetos e inyectar sus dependencias.

•   Constructor o setter injection

•   Los objetos son creados en el orden correcto basados en sus
    dependencias




                  Bean A              Bean B
                                                                    13
La inyección con Spring vía Constructor:

package x.y;

public class Foo {

      public Foo(Bar bar, Baz baz) {
          // ...
      }
}
Configuracion Spring via XML

<beans>
    <bean id="foo" class="x.y.Foo">
        <constructor-arg ref="bar"/>
        <constructor-arg ref="baz"/>
    </bean>

      <bean id="bar" class="x.y.Bar"/>
      <bean id="baz" class="x.y.Baz"/>

</beans>
                                                14
La inyección con Spring vía setter:

class MovieLister...
   public MovieLister(MovieFinder finder) {
      this.finder = finder;
}

class ColonMovieFinder...
   public ColonMovieFinder(String filename) {
      this.filename = filename;
   }

Configuracion Spring via XML
    <beans>
    <bean id="MovieLister" class="spring.MovieLister">
       <property name="finder">
         <ref local="MovieFinder"/>
       </property>
    </bean>
    <bean id="MovieFinder" class="spring.ColonMovieFinder">
       <property name="filename">
         <value>movies1.txt</value>
       </property>
    </bean>
  </beans>
                                                              15
Flash Platform




                 16
Flash Platform
        Videos          Aplicaciones Ricas Internet   Juegos




  Visualización Datos    Experiencias Interactivas    Música




                                                           17
18
Evolución


   Generación
1.0   Cairngorm    Obsoleto


                    Spring
AS

                    PureMVC
   Generación
1.5                Madurez
                    Mate


                    Swiz         Estado
del
arte
   Generación
2.0
                    Parsley

                     Robotlegs



                                             19
Plataformas


      Flex
&
Flash   Flex
      Spring
AS      Mate
      PureMVC        Swiz
      Parsley
      RobotLegs
      Cairngorm




                            20
Spring AS

• Contenedor
IOC
para
AS3.

• Flash/Flex/AIR/AS3
puro.

• Christophe
Herreman.

• Prana
Framework.

                             21
Contenedor IOC

• Fábrica
de
objetos.

• Crea
y
ensambla
objetos.

• Centraliza
el
manejo
de
dependencias.

• Configuración
via
XML
o
MXML.

                                          22
Contenedor IOC
• Object.

• Object
Factory:
Crea
y
administra
los
objetos
  –factory.getObject("myObject").


• Object
Defini)on

• Applica)on
Context:
Fábrica
de
objetos

  inteligente.
                                             23
Contenedor IOC
• Object
Scopes

 –
Singleton:
Solo
una
instancia
en
el
contenedor.
   • Default
   • factory.getObject(“obj”)
==
factory.getObject(“obj”)


 –
Prototype
   • Nueva
instancia
por
cada
request.
   • factory.getObject(“obj”)
!=
factory.getObject(“obj”)



                                                            24
Con guración
• MXML
 –
Compilado
como
parte
de
la
aplicación.
 –
AppContext.mxml.


       <Objects>
          <app:Applica)onModel
id=“appModel”
/>
          <app:Applica)onController
id=“appController”

          applica)onModel=“{appModel}”/>

       </Objects>


                                                          25
Con guración
• XML
 –
Configuración
externa.
 –
Ejecutada
al
inicio
de
la
aplicación.


        <objects>
          <object
id=“appModel”

          class=“com.domain.app.Applica)onModel”/>
<object

          id=“appController”

          class=“com.domain.app.Applica)onController”>

          <property
name=“applica)onModel”
ref=“appModel”/>

        <objects>
                                                         26
Con guración
• XML
Pros

–
Diálecto
mas
rico
que
la
configuración
en
MXML.
–
Flash/Flex/Air/AS3
–
No
es
necesario
recompilar.
–
Familiar
a
usuarios
de
Spring





                                                   27
Arquitectura MVC

• Ninguna
en
par)cular.

• Realmente
es
necesaria?

• Alterna)vas:
Cairngorm,
PureMVC,
Mate.




                                           28
Arquitectura MVC
• Estructura:
  –
Opera)on
API.
  –
Event
Bus.
  –
Autowiring.



• Recomendaciones
  –
Presenta)on
Model(Fowler).



                                 29
Operation API

• Comportamiento
asíncrono
en
el
Flash
Player:
   • Carga
de
recursos
externos
   • WebServices
   • H2pServices

• Unifica
los
APIS:

    ‐ AsyncToken,
Responders,
Callbacks,
Events

                                           30
Operation API
• Problema:
obtener
un
usuario.


       interface
IUserRepository
{

       

























func)on
getUser(id:int):
???
       }




• Que
debe
devolver
el
método
getUser?
  AsyncToken(Flex/RemoteObject),
User,
Void
                                                                31
Operation API
• Spring
AS:
devolver
un
IOpera)on.

       interface
IUserRepository
{

       

























func)on
getUser(id:int):
IOpera)on
       }



• Una
“operacion”
es
u)lizada
para
denotar
un

  comportamiento
asíncrono.
• IOpera)on
es
una
interfaz
con
métodos

  “complete”
y
“error”
cuando

                                                                      32
Event Bus

• Sistema
de
publicación/subscripción.

• Promueve
el
bajo
acoplamiento.

• Eventos
standard
de
Flash(flash.events.Event)




                                           33
Event Bus
• Subscripción
a
eventos.

  –
Escuchar
todos
los
eventos.
    • 
EventBus.addListener(listener:IEventBusListener);
    • 
func)on
onEvent(event:Event):void
{
}


  –
Escuchar
solo
ciertos
eventos.
    • 
EventBus.addEventListener(“anEvent”,
handler);
    • 
func)on
handler(event:Event):void
{
}



                                                           34
Event Bus
• Publicación
de
eventos.

  –
Disparar
eventos
standart.
    • 
EventBus.dispatchEvent(new
Event(“someEvent”));



  –
Dispara
eventos
personalizados.

    • class
UserEvent
extends
Event
{
...}
    • EventBus.dispatchEvent(new
UserEvent(UserEvent.DELETE,

      user));


                                                     35
Autowiring
• Inyección
de
dependencias
via
Metadata.

• Alambrado
por
)po,
nombre,
constructor,

  autodección.

• Disponible
para
objetos
manejados
por
el

  contenedor.



                                              36
Autowiring
• Anotar
una
propiedad
con
[Autowired]


       class
UserController

       {
       




[Autowired]

       




public
var
userRepository:IUserRepository;
       }


       [Autowired(name=“myObject“,
property=“prop”)]




                                                         37
Resumen

• Manejo
de
dependencias.

• Codificar
hacia
interfaces,
bajo
acoplamiento.

• Filosoya
Spring.

• Promueva
buenas
prac)cas.

                                            38
Enlaces
• h2p://www.springac)onscript.org/docs/reference/html/springac)onscript.html
• h2p://www.richardlord.net/blog/is‐the‐flash‐plazorm‐wai)ng‐for‐a‐spring‐moment
• h2p://sta)c.springsource.org/spring/docs/3.0.x/spring‐framework‐reference/html/
• h2p://mar)nfowler.com/ar)cles/injec)on.html
• h2p://www.robotlegs.org/
• h2p://www.springac)onscript.org/
• h2p://swizframework.org/
• h2p://www.springsource.org/spring‐flex
•




                                                                            39
Q &A


       40

Weitere ähnliche Inhalte

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

SpringIO - SpringActionScript

  • 1. [ Spring en Flash Platform ] 1
  • 2. Nosotros Ivan Alvarez Adobe Certi ed Expert Flex & AIR Senior RIA Developer @Ivanhoe email ivan.alvarez@tidyslice.com 2
  • 3. Nosotros Daniel Ramos Adobe Certi ed Instructor Flex & AIR Senior RIA Developer @dannyGeek email daniel.ramos@tidyslice.com 3
  • 4. Descripción Eliminating Enterprise Java Complexity. Made programming painless Become a Superstar IoC: Es un principio abstracto que describe un aspecto de algunos diseños de arquitectura de software en el que se invierte el ujo de control de un sistema en comparación con la programación procedimental . 4
  • 5. Descripción Principio de Hollywood, “No nos llames, nosotros te llamamos” 5
  • 6. Quién inicio IOC ? • Mar)n
Fowler Books • Pa2erns
of
Enterprise
Applica)on
Architecture • Domain
Specific
Languages • Analysis
Pa2erns:
Reusable
Object
Models 6
  • 7. Por qué IOC ? Te permite ensamblar un sistema a partir de sus partes. In the Java community there's been a rush of lightweight containers that help to assemble components from different projects into a cohesive application. Underlying these containers is a common pattern to how they perform the wiring, a concept they refer under the very generic name of "Inversion of Control". Martin Fowler. ref http://martinfowler.com/articles/injection.html 7
  • 8. Por qué IOC ? Las partes no se preocupan por encontrarse unas a otras In the Java community there's been a rush of lightweight containers that help to assemble components from different projects into a cohesive application. Underlying these containers is a common pattern to how they perform the wiring, a concept they refer under the very generic name of "Inversion of Control". I dig into how this pattern works, under the more specific name of "Dependency Injection" ref http://martinfowler.com/articles/injection.html 8
  • 9. Por qué IOC ? Cualquier parte puede ser fácilmente sustituida 9
  • 10. 10
  • 11. 
Applica)on
Context:
 • Definición de Beans y sus dependencias • Beans de infraestructura • Definido en uno o más archivos .xml 11
  • 12. Contenedor IoC (Inversión de Control) usando Inyección de Dependencias. “There are three main styles of dependency injection. The names I'm using for them are Constructor Injection, Setter Injection, and Interface Injection.” Martin Fowler http://martinfowler.com/articles/injection.html#InversionOfControl 12
  • 13. Spring se encarga de crear los objetos e inyectar sus dependencias. • Constructor o setter injection • Los objetos son creados en el orden correcto basados en sus dependencias 13
  • 14. Spring se encarga de crear los objetos e inyectar sus dependencias. • Constructor o setter injection • Los objetos son creados en el orden correcto basados en sus dependencias 13
  • 15. Spring se encarga de crear los objetos e inyectar sus dependencias. • Constructor o setter injection • Los objetos son creados en el orden correcto basados en sus dependencias Bean B 13
  • 16. Spring se encarga de crear los objetos e inyectar sus dependencias. • Constructor o setter injection • Los objetos son creados en el orden correcto basados en sus dependencias Bean B 13
  • 17. Spring se encarga de crear los objetos e inyectar sus dependencias. • Constructor o setter injection • Los objetos son creados en el orden correcto basados en sus dependencias Bean A Bean B 13
  • 18. Spring se encarga de crear los objetos e inyectar sus dependencias. • Constructor o setter injection • Los objetos son creados en el orden correcto basados en sus dependencias Bean A Bean B 13
  • 19. La inyección con Spring vía Constructor: package x.y; public class Foo { public Foo(Bar bar, Baz baz) { // ... } } Configuracion Spring via XML <beans> <bean id="foo" class="x.y.Foo"> <constructor-arg ref="bar"/> <constructor-arg ref="baz"/> </bean> <bean id="bar" class="x.y.Bar"/> <bean id="baz" class="x.y.Baz"/> </beans> 14
  • 20. La inyección con Spring vía setter: class MovieLister... public MovieLister(MovieFinder finder) { this.finder = finder; } class ColonMovieFinder... public ColonMovieFinder(String filename) { this.filename = filename; } Configuracion Spring via XML <beans> <bean id="MovieLister" class="spring.MovieLister"> <property name="finder"> <ref local="MovieFinder"/> </property> </bean> <bean id="MovieFinder" class="spring.ColonMovieFinder"> <property name="filename"> <value>movies1.txt</value> </property> </bean> </beans> 15
  • 22. Flash Platform Videos Aplicaciones Ricas Internet Juegos Visualización Datos Experiencias Interactivas Música 17
  • 23. 18
  • 24. Evolución Generación
1.0 Cairngorm Obsoleto Spring
AS PureMVC Generación
1.5 Madurez Mate Swiz Estado
del
arte Generación
2.0 Parsley Robotlegs 19
  • 25. Plataformas Flex
&
Flash Flex Spring
AS Mate PureMVC Swiz Parsley RobotLegs Cairngorm 20
  • 26. Spring AS • Contenedor
IOC
para
AS3. • Flash/Flex/AIR/AS3
puro. • Christophe
Herreman. • Prana
Framework. 21
  • 27. Contenedor IOC • Fábrica
de
objetos. • Crea
y
ensambla
objetos. • Centraliza
el
manejo
de
dependencias. • Configuración
via
XML
o
MXML. 22
  • 28. Contenedor IOC • Object. • Object
Factory:
Crea
y
administra
los
objetos –factory.getObject("myObject"). • Object
Defini)on • Applica)on
Context:
Fábrica
de
objetos
 inteligente. 23
  • 29. Contenedor IOC • Object
Scopes –
Singleton:
Solo
una
instancia
en
el
contenedor. • Default • factory.getObject(“obj”)
==
factory.getObject(“obj”) –
Prototype • Nueva
instancia
por
cada
request. • factory.getObject(“obj”)
!=
factory.getObject(“obj”) 24
  • 30. Con guración • MXML –
Compilado
como
parte
de
la
aplicación. –
AppContext.mxml. <Objects> <app:Applica)onModel
id=“appModel”
/> <app:Applica)onController
id=“appController”
 applica)onModel=“{appModel}”/> </Objects> 25
  • 31. Con guración • XML –
Configuración
externa. –
Ejecutada
al
inicio
de
la
aplicación. <objects> <object
id=“appModel”
 class=“com.domain.app.Applica)onModel”/>
<object
 id=“appController”
 class=“com.domain.app.Applica)onController”>
 <property
name=“applica)onModel”
ref=“appModel”/> <objects> 26
  • 33. Arquitectura MVC • Ninguna
en
par)cular. • Realmente
es
necesaria? • Alterna)vas:
Cairngorm,
PureMVC,
Mate. 28
  • 34. Arquitectura MVC • Estructura: –
Opera)on
API. –
Event
Bus. –
Autowiring. • Recomendaciones –
Presenta)on
Model(Fowler). 29
  • 35. Operation API • Comportamiento
asíncrono
en
el
Flash
Player: • Carga
de
recursos
externos • WebServices • H2pServices • Unifica
los
APIS:
 ‐ AsyncToken,
Responders,
Callbacks,
Events 30
  • 36. Operation API • Problema:
obtener
un
usuario. interface
IUserRepository
{
 

























func)on
getUser(id:int):
??? } • Que
debe
devolver
el
método
getUser? AsyncToken(Flex/RemoteObject),
User,
Void 31
  • 37. Operation API • Spring
AS:
devolver
un
IOpera)on. interface
IUserRepository
{
 

























func)on
getUser(id:int):
IOpera)on } • Una
“operacion”
es
u)lizada
para
denotar
un
 comportamiento
asíncrono. • IOpera)on
es
una
interfaz
con
métodos
 “complete”
y
“error”
cuando
 32
  • 38. Event Bus • Sistema
de
publicación/subscripción. • Promueve
el
bajo
acoplamiento. • Eventos
standard
de
Flash(flash.events.Event) 33
  • 39. Event Bus • Subscripción
a
eventos. –
Escuchar
todos
los
eventos. • 
EventBus.addListener(listener:IEventBusListener); • 
func)on
onEvent(event:Event):void
{
} –
Escuchar
solo
ciertos
eventos. • 
EventBus.addEventListener(“anEvent”,
handler); • 
func)on
handler(event:Event):void
{
} 34
  • 40. Event Bus • Publicación
de
eventos. –
Disparar
eventos
standart. • 
EventBus.dispatchEvent(new
Event(“someEvent”)); –
Dispara
eventos
personalizados.
 • class
UserEvent
extends
Event
{
...} • EventBus.dispatchEvent(new
UserEvent(UserEvent.DELETE,
 user)); 35
  • 41. Autowiring • Inyección
de
dependencias
via
Metadata. • Alambrado
por
)po,
nombre,
constructor,
 autodección. • Disponible
para
objetos
manejados
por
el
 contenedor. 36
  • 42. Autowiring • Anotar
una
propiedad
con
[Autowired] class
UserController
 { 




[Autowired]
 




public
var
userRepository:IUserRepository; }
 [Autowired(name=“myObject“,
property=“prop”)] 37
  • 44. Enlaces • h2p://www.springac)onscript.org/docs/reference/html/springac)onscript.html • h2p://www.richardlord.net/blog/is‐the‐flash‐plazorm‐wai)ng‐for‐a‐spring‐moment • h2p://sta)c.springsource.org/spring/docs/3.0.x/spring‐framework‐reference/html/ • h2p://mar)nfowler.com/ar)cles/injec)on.html • h2p://www.robotlegs.org/ • h2p://www.springac)onscript.org/ • h2p://swizframework.org/ • h2p://www.springsource.org/spring‐flex • 39
  • 45. Q &A 40

Hinweis der Redaktion