SlideShare uma empresa Scribd logo
1 de 47
Baixar para ler offline
Giorgio Natili
Blaze DS connectivity
   Blog: www.mxml.it
   twitter: http://twitter.com/giorgionatili
During the session

I. Introduction
II. Blaze DS and Live Cycle DS
III. How to invoke Java from Flex
  I.      Setting up the environment
  II.     Create a simple script
IV. A centralized approach
  I.      Service Connector (part of the nabiro class set)
        I.    The ActionScript classes involved
        II.   The analysis of the class
  II.     Model View Presenter
V. Demo
It’s RIA time

• The adoption of Rich Internet Applications is increasing in a
  very different range of contexts

   - Business
   - Education
   - Entertainment

• If your software has an architecture where the business logic
  is clearly separated from other layers, then you can use one
  of the available technologies (or mix all the best features of
  each technology) and develop a RIA
RIA solutions

• The main solution you can find on the market today for the
  front end implementation of a RIA are

   –   Java FX
   –   Silverlight
   –   Ajax
   –   Flash

• Accordingly to your choice people can say:
   -   He’s a real programmer
   -   He’s good guy but too much related to MS
   -   He’s a scripter
   -   He’s a graphic designer, he can’t do a software
The snapshot
   Java Programmer




     .NET Programmer

                        Ajax Programmer




     Flash Programmer
And then comes Flex...

• I totally agree with the first reaction of people with Flash, the
  skip intro nightmare is still live in my mind!

• But I have to be honest in my experience with the Flex
  framework you can get great cross platform result and reach
  a wide range of users because the Flash Player is omni
  present and a de facto standard in the web development

• The use of the Flash Player is not only related to Flex, each
  Flash application may be a good one or a bad one
  accordingly to the way you design it
Blaze DS and Live Cycle DS

• Blaze DS and Live Cycle DS (LCDS) represent today the
  two main choices developers can do when they are planning
  a new RIA connected with Java or Coldfusion

• The first one is open source (great!) and the second one is a
  close source (less great but a very good tool!) product with a
  greater set of functionalities

• There are obviously a lot of difference between the two
  solutions but the choice depends only on your needs
AMF communication

• One of the key point of these software is the communication
  over AMF

• Action Message Format (AMF) is a compact binary format
  that is used to serialize ActionScript object graphs

• Once serialized an AMF encoded object graph may be used
  to persist and retrieve the public state of an application across
  sessions or allow two endpoints to communicate through the
  exchange of strongly typed data
AMF 10 times faster, how?

• Is a compact binary format for data serialization / de-
  serialization and remote method invocation

• Object encoding controls how objects are represented in
  Action Message Format (AMF)

• Representation can be transferred over HTTP/HTTPS

• As data size increases the performance benefits of using
  Blaze DS increase exponentially

• Objects casting is performed on the server side part
Features comparison
                                        Features                                      Blaze
DS   LCDS
Data
management
Services                  Client‐Server
synchroniza3on                            x
                                          Conflict
resolu3on                                       x
                                          Data
paging                                             x
                                          SQL
adapter                                             x
                                          Hibernate
adapter                                       x
Document
Services                         Live
Cycle
remo3ng                                      x
                                          RIA‐to‐PDF
conversion                                   x
Enterprise‐Class
Flex
applica;on
services Data
access/remo3ng                            x        x
                                          Proxy
service                                  x        x
                                          Automated
tes3ng
support                                x
                                          SoFware
clustering                             x        x
                                          Web
3er
compiler                                        x
Enterprise
Integra;on                    WSRP
genera3on                                           x
                                         Ajax
data
services                              x        x
                                         Flex‐Ajax
bridge                                x        x
                                         Run3me
configura3on                              x        x
                                         Open
adapter
architecture                       x        x
                                         JMS
adapter                                     x        x
                                         Server‐side
component
framework
integra3on      x        x
                                         ColdFusion
integra3on                                    x
Features comparison
                           Features                            Blaze
DS   LCDS
Offline
Applica;on
Support    Offline
data
cache                               x
                            Local
message
queuing                          x
Real
‐
Time
Data            Publish
and
Subscribe
messaging       x        x
                            Real‐3me
data
quality
of
service               x
                            RTMP
tunneling                                 x
And the performance?

• Accordingly to the features you are planning to use the
  performance can change

   - RPC services over an AMF Channel -> NO difference
   - Data pushing -> A LOT of difference

                                       LCDS
  Blaze DS
Why this difference?

• The reason why is that Blaze DS supports long-polling and
  streaming over HTTP to push data to the client but it
  manages this through the Servlet API which has the
  restriction right now of mandating blocking IO

• LCDS provides support for the RTMPChannel (direct duplex
  socket connection between the client and server) as well as
  non-blocking long-polling and streaming support over HTTP
  that bypasses the Servlet API and its blocking IO limitation

•   All of these options in LCDS are built on top of the Java NIO
    APIs
Blaze benefits

• Blaze DS is open source and it’s extendable so you can add
  your modules or functionalities

• Supports the main Java servers
   –   Tomcat
   –   Jboss
   –   Glassfish
   –   Others…

• Blaze DS is shipped in bundle with Tomcat so it’s easy to start
  also without a Java background
Blaze effect

Java developers and Flash developers became friends and start
                      to work together….
How to invoke Java from Flex

• In order to start with Java and Flex you can download and
  setup Blaze DS on your system from Adobe Labs http://
  labs.adobe.com/technologies/blazeds/

• In order to invoke Java methods from Flex application

   I.     Add a mapping to the Java class to services-config.xml
   II.    Map your RemoteObject (provided with Flex SDK) on the client side
          to the destination configured in services-config.xml
   III.   Invoke the method in your Java class using the RemoteObject
          instance
It’s so simple

• In your Flex application use MXML in order to invoke a
  remote method you can use the following snippet of code

  <mx:RemoteObject id=”remoteObj” destination=”testRpc”
      result=”Alert.show(event.result.toString());”
      fault=”Alert.show(event.fault.faultString);” />
  <mx:Button label=”Remote Service”

       click=”remoteObj.testRemoteMethod();”/>


• The destination is defined in your services-config.xml and the
  testRemoteMethod() is defined in your java class on the
  server and you can handle the result and fault event via
  MXML or via ActionScript for each remote object
Nothing against simple, but…

I totally agree with you, it seems to be the typical script
approach, the first questions that can came out probably are

   I.  And what happens in a large application?
   II. How long is the equivalent code in ActionScript?
   III.Why I have to learn this if I’m not sure of the results?
   IV. How many killer application really use it?
   V.  Is it an application that use MXML to handle the
       communication with the business logic really scalable?
   VI. Even more…
J2EE configuration (server)

• Start Eclipse and select the “Java EE” perspective
• In the bottom panel, select the “Servers” tab
• Right click on the panel and select “New->Server”
• Select the server settings and point them to your newly
  installed tomcat server. The installation directory should be
  “<base turnkey installation dir>tomcat” (in my case this is “C:
  tomcat”)
• Click Finish
J2EE configuration (Web Project)

• Create a new “Dynamic Web Project” with the following
  settings:
   – Project name: myBlazeProject
   – Target Runtime: “Apache Tomcat x.x” (this is the server
      you created in the last section)
   – Configuration: Default Configuration for Apache Tomcat
      x.x
• Click “Finish”
J2EE configuration (BlazeDS Configuration)

• Overwrite the contents of your “WebContent” directory with
  the BlazeDS directory structure “<base turnkey installation
  dir>tomcatwebappsblazeds
• Right click on your newly created “myBlazeProject” project
  and select “Properties”
• Select “Java Build Path” from the list in the left hand panel.
• Set the “Default output folder” to “myBlazeProject/
  WebContent/WEB-INF/classes”, this will cause your web
  server to automatically update every time you rebuild your
  project.
So complex?

                       Are you lost?




  Simply unzip the Blaze DS distribution archive and use it as
                your server, it’s enough to start….
Hello world!




               Demo
A centralized approach

• The development of enterprise application involves actually a
  large number of server side calls

• You can work with remote objects defined in each component
  handling the result and the fault event in each component or
  you can work in a centralized way with only one class that
  handle for you all the remote operations

• There is not a native solution in Flex, you have tor write down
  your own solution
The Service Connector

• The ServiceConnector class is not part of the Flex
  framework, it’s part of a set of utilities I created for my
  projects
• The packaging structure

   –   Events
   –   Remote
   –   Utils
   –   Main classes
Service Connector features

• The ServiceConnector class is a Singleton in order to
  avoid multiple instances of the class in the same application
  and provides the public methods a developer needs in order
  to perform authenticated and anonymous call against java
  services deployed under Blaze DS
• The ServiceConnector class is also able to perform the
  login and the logout of a user, to handle the queue of multiple
  calls following a FIFO style and to recover a service using the
  name of the method you need to call
• The ServiceConnector class implements the
  IEventDispatcher interface and therefore is the
  responsible of the notification of all the events fired during the
  server side interaction
Used classes

  –               AMFChannel and SecureAMFChannel; provides the AMF
      support for messaging. You can configure this Channel to poll the
      server at an interval to approximate server push
  –               Channel; is the base message channel class that all
      channels in the messaging system must extend
  –               ChannelSet; is a set of Channels that are used to send
      messages to a target destination
  –               AbstractOperation; represents an individual method on
      a service
  –               AbstractService; is the base class for the WebService
      and RemoteObject classes
  –               AsyncResponder; allows the creator to associate data (a
      token) and methods that should be called when a request is completed
  –               AsyncToken; provides a place to set additional or token-
      level data for asynchronous RPC operations
Service Connector UML diagram
Service Connector dependencies

The dependencies of this outside the flex framework are:

   –   RemoteObjectWrapperEvent
   –   IRemoteMethod
   –   RemoteMethod
   –   MethodsQueue
   –   MethodsQueueElement
   –   ServerSideCallEvent
The RemoteObjectWrapperEvent

• The RemoteObjectWrapperEvent class is a custom
  Event that uses two public static constants in order to
  define the FAULT and RESULT type of the event

• It’s the one that bring the data recovered out from the
  ServiceConnector to your application

• It’s the one that has the knowledge of the remote
  method (with an instance of the AbstractService)
  invoked that is used to notify the appropriate control that
  data are coming
The IRemoteMethod interface

The IRemoteMethod is the interface implemented by the remote
method called trough the ServiceConnector class, each method needs to
define the following accessor methods (getters not shown for brevity)

        function   set   name(value:String):void;
        function   set   arguments(value:Array):void;
        function   set   source(value:String):void;
        function   set   destination(value:String):void;
        function   set   returnObject(value:Class):void;
        function   set   isList(value:Boolean):void;
The IRemoteMethod interface

• The source and the destination are used in order to
  define the service to call

• The returnObject is the class type of the object /
  objects returned from the method invocation

• The isList is used in order to understand if the
  remote method returns a single value or an Array of
  values

• arguments is self explanatory
The RemoteMethod class

The RemoteMethod implements the IRemoteMethod
interface, the use of an interface here is due to possible
future enhancement of the micro architecture we use for
the server side communication
The MethodQueue class

• The MethodsQueue class follows the Singleton design
  pattern, when the application calls more than one
  method from different components is trough this class
  that the queue of results is handled and the results are
  sent to the appropriate component

• Each item stored in the MethodQueue
  class is an instance of the class
  MethodsQueueElement
  that defines the method
  and abstract operation performed
The ServerSideCallEvent

• The ServerSideCallEvent is a bubbling event that
  in the Flex architecture (actually in the Flash Player) is
  able to reach an upper level component
• The ServerSideCallEvent is the one that drives to
  the ServiceConnector the method to call
The ServiceConnector in 5 steps (1/5)

• Create the ServiceConnector instance and specify which
  is the object that needs to receive the events dispatched
  from the class
   sc = ServiceConnector.getConnector(this);

• Set the default services for the ServiceConnector
  instance
   sc.defaultSource = quot;com.gnstudio.services.Adminquot;;
   sc.defaultDestination = quot;Adminquot;;

• Define the listeners for the events
   sc.addEventListener(RemoteObjectWrapperEvent.FAULT, onFault)
   sc.addEventListener(RemoteObjectWrapperEvent.RESULT,
     onResult)
The ServiceConnector in 5 steps (2/5)

• Define the listeners for the event that will generate the
  server side calls

   addEventListener(ServerSideCallEvent.ANONYMOUS_CALL,
     onAnonymousCall);

   addEventListener(ServerSideCallEvent.LOGGED_CALL,
     onLoggedCall);


• Create the hash map used to handle the queue of the
  server side calls, the map is the one used also to send
  the data to a specific component

   hash = new HashMap();
The ServiceConnector in 5 steps (3/5)

Define the listener to anonymous calls, it initialize the
connector, perform the call and add the caller to the hash
map (@param e ServerSideCallEvent)
private function onAnonymousCall(e:ServerSideCallEvent):void{

   var obj:AbstractService;
   try{
        obj = sc.makeAnonymousCall(e.fakeObject as IRemoteMethod);
   }catch(err:Error){
        sc.initializeConnector(baseUrl + SERVICES[0], connectorKind);
        obj = sc.makeAnonymousCall(e.fakeObject as IRemoteMethod);
   }

   hash.addItem({service: obj, target: IPresenter(e.target),    nameSpace:
   e.nameSpace})

   }
The ServiceConnector in 5 steps (4/5)

Define the listener to logged calls, it initialize the connector,
perform the call and add the caller to the hash map (@param e
ServerSideCallEvent)
private function onLoggedCall(e:ServerSideCallEvent):void{

try{

obj = sc.makeLoggedCall(e.fakeObject as RemoteMethod);
                          hash.addItem({service: obj, target:
   IPresenter(e.target), nameSpace: e.nameSpace});

    }catch(err:Error){

         Alert.show(quot;You need to be logged on the systemquot;, quot;Attention!quot;);
    }
}
The ServiceConnector in 5 steps (5/5)

• Define the Listener to the general result event, it's able to
  update the UI component that performed the request
  (@param e RemoteObjectWrapperEvent)

private function onResult(e:RemoteObjectWrapperEvent):void{
var tg:IPresenter;

if(hash.getItem(quot;servicequot;, e.currentService)){
tg = hash.getItem(quot;servicequot;, e.currentService).target as IPresenter;
var ns:Namespace;
if(hash.getItem(quot;servicequot;, e.currentService).nameSpace){
   ns = hash.getItem(quot;servicequot;, e.currentService).nameSpace;
   }
tg.setDataSet(e.eventData, ns);
hash.remove(quot;servicequot;, e.currentService);
}}
How to put everything in action

• Use the Model View Presenter for your component
• Make a comparison between Model View Presenter and
  Model View Controller
• Understand why in an UI context the MVP is the best choice
  with external data
• Make a simple implementation
The MVP pattern

• The original implementation of the MVP is born in the 1979,
  its name was Thing Model View Editor and during these
  years there were a lot of different implementations between
  them the Taligent’s one (1996) was for sure the more
  sophisticated and the more powerful
•   The Model-View-Presenter pattern is a variation on the Model-
    View-Controller pattern, and similarly separates the concerns of an
    application’s data, presentation, and user input into specialized
    components
The MVP diagram
The MVP actors

•   The Model refers to the data and business functionality of the
    application
•   Selections are components which specify what portion of the data
    within the Model is to be operated upon
•   Commands are classes which define the operations which can be
    performed on the data
•   The View is the visual representation of the Model and is comprised
    of the screens and widgets used within an application
•   Interactors are classes which address how user events are
    mapped onto operations performed on the Model
•   The Presenter is a component which orchestrates the overall
    interaction of the other components within the application
MVP and MVC (1/2)
                  MVC                                          MVP

UI Presentation Pattern focus on             Based on MVC (UI Presentation Pattern)
separation of view with Model

Separation of responsibility between three   Separation of responsibility between four
components:                                  components:
1. View - responsible for rendering UI       1. View - responsible for rendering UI
   elements                                     elements
2. Controller - responsible for              2. View Interface - responsible for loose
   responding to view actions                   coupling between view and model
3. Model - responsible for business          3. Presenter - responsible for view and
   behavior and state management                model interaction
                                             4. Model - responsible for business
                                                behavior and state management
MVP and MVC (2/2)
                   MVC                                      MVP

 The three components would interact      Presenter can also interact with View to
 with each other, Controller would        access Model
 sometime also be responsible to update
 view (like Front Controller Pattern)




 Controller is behavior based and           Usually one view have one presenter
 multiple views can share single controller (1-1 mapping), multiple presenters
                                            would be associated with a complex view



 Identifies which view to update          Presenter will update its associated view
Let’s start with a demo!

Mais conteúdo relacionado

Semelhante a Giorgio Natilli - Blaze DS Connectivity Framework

ArcReady - Architecting For The Client Tier
ArcReady - Architecting For The Client TierArcReady - Architecting For The Client Tier
ArcReady - Architecting For The Client TierMicrosoft ArcReady
 
Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"
Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"
Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"Fwdays
 
E g innovations overview
E g innovations overviewE g innovations overview
E g innovations overviewNuno Alves
 
JSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph PicklJSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph PicklChristoph Pickl
 
Netscaler for mobility and secure remote access
Netscaler for mobility and secure remote accessNetscaler for mobility and secure remote access
Netscaler for mobility and secure remote accessCitrix
 
Practical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter SvenssonPractical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter Svenssonrajivmordani
 
Bee brief-intro-q42016
Bee brief-intro-q42016Bee brief-intro-q42016
Bee brief-intro-q42016wahyu prayudo
 
X Aware Ajax World V1
X Aware Ajax World V1X Aware Ajax World V1
X Aware Ajax World V1rajivmordani
 
Practical Thin Server Architecture With Dojo Sapo Codebits 2008
Practical Thin Server Architecture With Dojo Sapo Codebits 2008Practical Thin Server Architecture With Dojo Sapo Codebits 2008
Practical Thin Server Architecture With Dojo Sapo Codebits 2008codebits
 
Using LCDS to Power Live REAs
Using LCDS to Power Live REAsUsing LCDS to Power Live REAs
Using LCDS to Power Live REAsShailesh Mangal
 
Zimbra Collaboration Suite Vs Microsoft Exchange 2008
Zimbra Collaboration Suite Vs Microsoft Exchange 2008Zimbra Collaboration Suite Vs Microsoft Exchange 2008
Zimbra Collaboration Suite Vs Microsoft Exchange 2008agileware
 
Services Oriented Infrastructure in a Web2.0 World
Services Oriented Infrastructure in a Web2.0 WorldServices Oriented Infrastructure in a Web2.0 World
Services Oriented Infrastructure in a Web2.0 WorldLexumo
 
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...confluent
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010Tim Clark
 
Keeping Pace with Citrix XenApp and XenDesktop 7.x Evolution
Keeping Pace with Citrix XenApp and XenDesktop 7.x EvolutionKeeping Pace with Citrix XenApp and XenDesktop 7.x Evolution
Keeping Pace with Citrix XenApp and XenDesktop 7.x EvolutioneG Innovations
 
QCon Shanghai: Trends in Application Development
QCon Shanghai: Trends in Application DevelopmentQCon Shanghai: Trends in Application Development
QCon Shanghai: Trends in Application DevelopmentChris Bailey
 

Semelhante a Giorgio Natilli - Blaze DS Connectivity Framework (20)

ArcReady - Architecting For The Client Tier
ArcReady - Architecting For The Client TierArcReady - Architecting For The Client Tier
ArcReady - Architecting For The Client Tier
 
Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"
Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"
Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"
 
E g innovations overview
E g innovations overviewE g innovations overview
E g innovations overview
 
JSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph PicklJSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph Pickl
 
Netscaler for mobility and secure remote access
Netscaler for mobility and secure remote accessNetscaler for mobility and secure remote access
Netscaler for mobility and secure remote access
 
Practical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter SvenssonPractical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter Svensson
 
Bee brief-intro-q42016
Bee brief-intro-q42016Bee brief-intro-q42016
Bee brief-intro-q42016
 
Karunakar Kondam
Karunakar KondamKarunakar Kondam
Karunakar Kondam
 
X Aware Ajax World V1
X Aware Ajax World V1X Aware Ajax World V1
X Aware Ajax World V1
 
Practical Thin Server Architecture With Dojo Sapo Codebits 2008
Practical Thin Server Architecture With Dojo Sapo Codebits 2008Practical Thin Server Architecture With Dojo Sapo Codebits 2008
Practical Thin Server Architecture With Dojo Sapo Codebits 2008
 
Laszlo PyCon 2005
Laszlo PyCon 2005Laszlo PyCon 2005
Laszlo PyCon 2005
 
Twelve Factor App
Twelve Factor AppTwelve Factor App
Twelve Factor App
 
Using LCDS to Power Live REAs
Using LCDS to Power Live REAsUsing LCDS to Power Live REAs
Using LCDS to Power Live REAs
 
Zimbra Collaboration Suite Vs Microsoft Exchange 2008
Zimbra Collaboration Suite Vs Microsoft Exchange 2008Zimbra Collaboration Suite Vs Microsoft Exchange 2008
Zimbra Collaboration Suite Vs Microsoft Exchange 2008
 
Services Oriented Infrastructure in a Web2.0 World
Services Oriented Infrastructure in a Web2.0 WorldServices Oriented Infrastructure in a Web2.0 World
Services Oriented Infrastructure in a Web2.0 World
 
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...
 
Linked Process
Linked ProcessLinked Process
Linked Process
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010
 
Keeping Pace with Citrix XenApp and XenDesktop 7.x Evolution
Keeping Pace with Citrix XenApp and XenDesktop 7.x EvolutionKeeping Pace with Citrix XenApp and XenDesktop 7.x Evolution
Keeping Pace with Citrix XenApp and XenDesktop 7.x Evolution
 
QCon Shanghai: Trends in Application Development
QCon Shanghai: Trends in Application DevelopmentQCon Shanghai: Trends in Application Development
QCon Shanghai: Trends in Application Development
 

Mais de 360|Conferences

Metaio Mobile Augmented Reality
Metaio Mobile Augmented RealityMetaio Mobile Augmented Reality
Metaio Mobile Augmented Reality360|Conferences
 
Mobile Apps- Business Toolkit for the Manager
Mobile Apps- Business Toolkit for the ManagerMobile Apps- Business Toolkit for the Manager
Mobile Apps- Business Toolkit for the Manager360|Conferences
 
Making Real Money with Mobile Apps
Making Real Money with Mobile AppsMaking Real Money with Mobile Apps
Making Real Money with Mobile Apps360|Conferences
 
Inside Mobile Widgets Publish
Inside Mobile Widgets PublishInside Mobile Widgets Publish
Inside Mobile Widgets Publish360|Conferences
 
Ignite Denver 4 Master Deck
Ignite Denver 4 Master DeckIgnite Denver 4 Master Deck
Ignite Denver 4 Master Deck360|Conferences
 
Chad Udell - Developers are from Mars, Designers are from Venus
Chad Udell - Developers are from Mars, Designers are from VenusChad Udell - Developers are from Mars, Designers are from Venus
Chad Udell - Developers are from Mars, Designers are from Venus360|Conferences
 
Wes Leonardo - Putting AIR into your Application
Wes Leonardo - Putting AIR into your ApplicationWes Leonardo - Putting AIR into your Application
Wes Leonardo - Putting AIR into your Application360|Conferences
 
Samuel Asher Rivello - PureMVC Hands On Part 1
Samuel Asher Rivello - PureMVC Hands On Part 1Samuel Asher Rivello - PureMVC Hands On Part 1
Samuel Asher Rivello - PureMVC Hands On Part 1360|Conferences
 
Adrian Pomilio - Flex Ajax Bridge and Legacy Applications
Adrian Pomilio - Flex Ajax Bridge and Legacy ApplicationsAdrian Pomilio - Flex Ajax Bridge and Legacy Applications
Adrian Pomilio - Flex Ajax Bridge and Legacy Applications360|Conferences
 
Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2360|Conferences
 
Ryan Fishberg and Joan Lafferty - ItemsRenderers
Ryan Fishberg and Joan Lafferty - ItemsRenderersRyan Fishberg and Joan Lafferty - ItemsRenderers
Ryan Fishberg and Joan Lafferty - ItemsRenderers360|Conferences
 
Ryan Campbell - OpenFlux and Flex 4
Ryan Campbell - OpenFlux and Flex 4Ryan Campbell - OpenFlux and Flex 4
Ryan Campbell - OpenFlux and Flex 4360|Conferences
 
Ben Elmore - Do You Speak Flex
Ben Elmore - Do You Speak FlexBen Elmore - Do You Speak Flex
Ben Elmore - Do You Speak Flex360|Conferences
 
Francisco Inchauste - RIA Mojo - Making your Flex application standout with a...
Francisco Inchauste - RIA Mojo - Making your Flex application standout with a...Francisco Inchauste - RIA Mojo - Making your Flex application standout with a...
Francisco Inchauste - RIA Mojo - Making your Flex application standout with a...360|Conferences
 
Joe Johnston - FLEXperience - putting the Flex in UX
Joe Johnston - FLEXperience - putting the Flex in UXJoe Johnston - FLEXperience - putting the Flex in UX
Joe Johnston - FLEXperience - putting the Flex in UX360|Conferences
 
Bryc Barrand - The art of project management in large-scale Flex projects
Bryc Barrand - The art of project management in large-scale Flex projectsBryc Barrand - The art of project management in large-scale Flex projects
Bryc Barrand - The art of project management in large-scale Flex projects360|Conferences
 

Mais de 360|Conferences (20)

InsideMobile Keynote
InsideMobile KeynoteInsideMobile Keynote
InsideMobile Keynote
 
Metaio Mobile Augmented Reality
Metaio Mobile Augmented RealityMetaio Mobile Augmented Reality
Metaio Mobile Augmented Reality
 
Web Os Hands On
Web Os Hands OnWeb Os Hands On
Web Os Hands On
 
Mobile Apps- Business Toolkit for the Manager
Mobile Apps- Business Toolkit for the ManagerMobile Apps- Business Toolkit for the Manager
Mobile Apps- Business Toolkit for the Manager
 
Making Real Money with Mobile Apps
Making Real Money with Mobile AppsMaking Real Money with Mobile Apps
Making Real Money with Mobile Apps
 
Unlocking Android
Unlocking AndroidUnlocking Android
Unlocking Android
 
Inside Mobile Widgets Publish
Inside Mobile Widgets PublishInside Mobile Widgets Publish
Inside Mobile Widgets Publish
 
You Know WebOS
You Know WebOSYou Know WebOS
You Know WebOS
 
Ignite Denver 4 Master Deck
Ignite Denver 4 Master DeckIgnite Denver 4 Master Deck
Ignite Denver 4 Master Deck
 
Chad Udell - Developers are from Mars, Designers are from Venus
Chad Udell - Developers are from Mars, Designers are from VenusChad Udell - Developers are from Mars, Designers are from Venus
Chad Udell - Developers are from Mars, Designers are from Venus
 
Wes Leonardo - Putting AIR into your Application
Wes Leonardo - Putting AIR into your ApplicationWes Leonardo - Putting AIR into your Application
Wes Leonardo - Putting AIR into your Application
 
Samuel Asher Rivello - PureMVC Hands On Part 1
Samuel Asher Rivello - PureMVC Hands On Part 1Samuel Asher Rivello - PureMVC Hands On Part 1
Samuel Asher Rivello - PureMVC Hands On Part 1
 
Adrian Pomilio - Flex Ajax Bridge and Legacy Applications
Adrian Pomilio - Flex Ajax Bridge and Legacy ApplicationsAdrian Pomilio - Flex Ajax Bridge and Legacy Applications
Adrian Pomilio - Flex Ajax Bridge and Legacy Applications
 
Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2
 
Ryan Fishberg and Joan Lafferty - ItemsRenderers
Ryan Fishberg and Joan Lafferty - ItemsRenderersRyan Fishberg and Joan Lafferty - ItemsRenderers
Ryan Fishberg and Joan Lafferty - ItemsRenderers
 
Ryan Campbell - OpenFlux and Flex 4
Ryan Campbell - OpenFlux and Flex 4Ryan Campbell - OpenFlux and Flex 4
Ryan Campbell - OpenFlux and Flex 4
 
Ben Elmore - Do You Speak Flex
Ben Elmore - Do You Speak FlexBen Elmore - Do You Speak Flex
Ben Elmore - Do You Speak Flex
 
Francisco Inchauste - RIA Mojo - Making your Flex application standout with a...
Francisco Inchauste - RIA Mojo - Making your Flex application standout with a...Francisco Inchauste - RIA Mojo - Making your Flex application standout with a...
Francisco Inchauste - RIA Mojo - Making your Flex application standout with a...
 
Joe Johnston - FLEXperience - putting the Flex in UX
Joe Johnston - FLEXperience - putting the Flex in UXJoe Johnston - FLEXperience - putting the Flex in UX
Joe Johnston - FLEXperience - putting the Flex in UX
 
Bryc Barrand - The art of project management in large-scale Flex projects
Bryc Barrand - The art of project management in large-scale Flex projectsBryc Barrand - The art of project management in large-scale Flex projects
Bryc Barrand - The art of project management in large-scale Flex projects
 

Último

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Último (20)

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Giorgio Natilli - Blaze DS Connectivity Framework

  • 1. Giorgio Natili Blaze DS connectivity Blog: www.mxml.it twitter: http://twitter.com/giorgionatili
  • 2. During the session I. Introduction II. Blaze DS and Live Cycle DS III. How to invoke Java from Flex I. Setting up the environment II. Create a simple script IV. A centralized approach I. Service Connector (part of the nabiro class set) I. The ActionScript classes involved II. The analysis of the class II. Model View Presenter V. Demo
  • 3. It’s RIA time • The adoption of Rich Internet Applications is increasing in a very different range of contexts - Business - Education - Entertainment • If your software has an architecture where the business logic is clearly separated from other layers, then you can use one of the available technologies (or mix all the best features of each technology) and develop a RIA
  • 4. RIA solutions • The main solution you can find on the market today for the front end implementation of a RIA are – Java FX – Silverlight – Ajax – Flash • Accordingly to your choice people can say: - He’s a real programmer - He’s good guy but too much related to MS - He’s a scripter - He’s a graphic designer, he can’t do a software
  • 5. The snapshot Java Programmer .NET Programmer Ajax Programmer Flash Programmer
  • 6. And then comes Flex... • I totally agree with the first reaction of people with Flash, the skip intro nightmare is still live in my mind! • But I have to be honest in my experience with the Flex framework you can get great cross platform result and reach a wide range of users because the Flash Player is omni present and a de facto standard in the web development • The use of the Flash Player is not only related to Flex, each Flash application may be a good one or a bad one accordingly to the way you design it
  • 7. Blaze DS and Live Cycle DS • Blaze DS and Live Cycle DS (LCDS) represent today the two main choices developers can do when they are planning a new RIA connected with Java or Coldfusion • The first one is open source (great!) and the second one is a close source (less great but a very good tool!) product with a greater set of functionalities • There are obviously a lot of difference between the two solutions but the choice depends only on your needs
  • 8. AMF communication • One of the key point of these software is the communication over AMF • Action Message Format (AMF) is a compact binary format that is used to serialize ActionScript object graphs • Once serialized an AMF encoded object graph may be used to persist and retrieve the public state of an application across sessions or allow two endpoints to communicate through the exchange of strongly typed data
  • 9. AMF 10 times faster, how? • Is a compact binary format for data serialization / de- serialization and remote method invocation • Object encoding controls how objects are represented in Action Message Format (AMF) • Representation can be transferred over HTTP/HTTPS • As data size increases the performance benefits of using Blaze DS increase exponentially • Objects casting is performed on the server side part
  • 10. Features comparison Features Blaze
DS LCDS Data
management
Services Client‐Server
synchroniza3on x Conflict
resolu3on x Data
paging x SQL
adapter x Hibernate
adapter x Document
Services Live
Cycle
remo3ng x RIA‐to‐PDF
conversion x Enterprise‐Class
Flex
applica;on
services Data
access/remo3ng x x Proxy
service x x Automated
tes3ng
support x SoFware
clustering x x Web
3er
compiler x Enterprise
Integra;on WSRP
genera3on x Ajax
data
services x x Flex‐Ajax
bridge x x Run3me
configura3on x x Open
adapter
architecture x x JMS
adapter x x Server‐side
component
framework
integra3on x x ColdFusion
integra3on x
  • 11. Features comparison Features Blaze
DS LCDS Offline
Applica;on
Support Offline
data
cache x Local
message
queuing x Real
‐
Time
Data Publish
and
Subscribe
messaging x x Real‐3me
data
quality
of
service x RTMP
tunneling x
  • 12. And the performance? • Accordingly to the features you are planning to use the performance can change - RPC services over an AMF Channel -> NO difference - Data pushing -> A LOT of difference LCDS Blaze DS
  • 13. Why this difference? • The reason why is that Blaze DS supports long-polling and streaming over HTTP to push data to the client but it manages this through the Servlet API which has the restriction right now of mandating blocking IO • LCDS provides support for the RTMPChannel (direct duplex socket connection between the client and server) as well as non-blocking long-polling and streaming support over HTTP that bypasses the Servlet API and its blocking IO limitation • All of these options in LCDS are built on top of the Java NIO APIs
  • 14. Blaze benefits • Blaze DS is open source and it’s extendable so you can add your modules or functionalities • Supports the main Java servers – Tomcat – Jboss – Glassfish – Others… • Blaze DS is shipped in bundle with Tomcat so it’s easy to start also without a Java background
  • 15. Blaze effect Java developers and Flash developers became friends and start to work together….
  • 16. How to invoke Java from Flex • In order to start with Java and Flex you can download and setup Blaze DS on your system from Adobe Labs http:// labs.adobe.com/technologies/blazeds/ • In order to invoke Java methods from Flex application I. Add a mapping to the Java class to services-config.xml II. Map your RemoteObject (provided with Flex SDK) on the client side to the destination configured in services-config.xml III. Invoke the method in your Java class using the RemoteObject instance
  • 17. It’s so simple • In your Flex application use MXML in order to invoke a remote method you can use the following snippet of code <mx:RemoteObject id=”remoteObj” destination=”testRpc” result=”Alert.show(event.result.toString());” fault=”Alert.show(event.fault.faultString);” /> <mx:Button label=”Remote Service” click=”remoteObj.testRemoteMethod();”/> • The destination is defined in your services-config.xml and the testRemoteMethod() is defined in your java class on the server and you can handle the result and fault event via MXML or via ActionScript for each remote object
  • 18. Nothing against simple, but… I totally agree with you, it seems to be the typical script approach, the first questions that can came out probably are I. And what happens in a large application? II. How long is the equivalent code in ActionScript? III.Why I have to learn this if I’m not sure of the results? IV. How many killer application really use it? V. Is it an application that use MXML to handle the communication with the business logic really scalable? VI. Even more…
  • 19. J2EE configuration (server) • Start Eclipse and select the “Java EE” perspective • In the bottom panel, select the “Servers” tab • Right click on the panel and select “New->Server” • Select the server settings and point them to your newly installed tomcat server. The installation directory should be “<base turnkey installation dir>tomcat” (in my case this is “C: tomcat”) • Click Finish
  • 20. J2EE configuration (Web Project) • Create a new “Dynamic Web Project” with the following settings: – Project name: myBlazeProject – Target Runtime: “Apache Tomcat x.x” (this is the server you created in the last section) – Configuration: Default Configuration for Apache Tomcat x.x • Click “Finish”
  • 21. J2EE configuration (BlazeDS Configuration) • Overwrite the contents of your “WebContent” directory with the BlazeDS directory structure “<base turnkey installation dir>tomcatwebappsblazeds • Right click on your newly created “myBlazeProject” project and select “Properties” • Select “Java Build Path” from the list in the left hand panel. • Set the “Default output folder” to “myBlazeProject/ WebContent/WEB-INF/classes”, this will cause your web server to automatically update every time you rebuild your project.
  • 22. So complex? Are you lost? Simply unzip the Blaze DS distribution archive and use it as your server, it’s enough to start….
  • 23. Hello world! Demo
  • 24. A centralized approach • The development of enterprise application involves actually a large number of server side calls • You can work with remote objects defined in each component handling the result and the fault event in each component or you can work in a centralized way with only one class that handle for you all the remote operations • There is not a native solution in Flex, you have tor write down your own solution
  • 25. The Service Connector • The ServiceConnector class is not part of the Flex framework, it’s part of a set of utilities I created for my projects • The packaging structure – Events – Remote – Utils – Main classes
  • 26. Service Connector features • The ServiceConnector class is a Singleton in order to avoid multiple instances of the class in the same application and provides the public methods a developer needs in order to perform authenticated and anonymous call against java services deployed under Blaze DS • The ServiceConnector class is also able to perform the login and the logout of a user, to handle the queue of multiple calls following a FIFO style and to recover a service using the name of the method you need to call • The ServiceConnector class implements the IEventDispatcher interface and therefore is the responsible of the notification of all the events fired during the server side interaction
  • 27. Used classes – AMFChannel and SecureAMFChannel; provides the AMF support for messaging. You can configure this Channel to poll the server at an interval to approximate server push – Channel; is the base message channel class that all channels in the messaging system must extend – ChannelSet; is a set of Channels that are used to send messages to a target destination – AbstractOperation; represents an individual method on a service – AbstractService; is the base class for the WebService and RemoteObject classes – AsyncResponder; allows the creator to associate data (a token) and methods that should be called when a request is completed – AsyncToken; provides a place to set additional or token- level data for asynchronous RPC operations
  • 29. Service Connector dependencies The dependencies of this outside the flex framework are: – RemoteObjectWrapperEvent – IRemoteMethod – RemoteMethod – MethodsQueue – MethodsQueueElement – ServerSideCallEvent
  • 30. The RemoteObjectWrapperEvent • The RemoteObjectWrapperEvent class is a custom Event that uses two public static constants in order to define the FAULT and RESULT type of the event • It’s the one that bring the data recovered out from the ServiceConnector to your application • It’s the one that has the knowledge of the remote method (with an instance of the AbstractService) invoked that is used to notify the appropriate control that data are coming
  • 31. The IRemoteMethod interface The IRemoteMethod is the interface implemented by the remote method called trough the ServiceConnector class, each method needs to define the following accessor methods (getters not shown for brevity) function set name(value:String):void; function set arguments(value:Array):void; function set source(value:String):void; function set destination(value:String):void; function set returnObject(value:Class):void; function set isList(value:Boolean):void;
  • 32. The IRemoteMethod interface • The source and the destination are used in order to define the service to call • The returnObject is the class type of the object / objects returned from the method invocation • The isList is used in order to understand if the remote method returns a single value or an Array of values • arguments is self explanatory
  • 33. The RemoteMethod class The RemoteMethod implements the IRemoteMethod interface, the use of an interface here is due to possible future enhancement of the micro architecture we use for the server side communication
  • 34. The MethodQueue class • The MethodsQueue class follows the Singleton design pattern, when the application calls more than one method from different components is trough this class that the queue of results is handled and the results are sent to the appropriate component • Each item stored in the MethodQueue class is an instance of the class MethodsQueueElement that defines the method and abstract operation performed
  • 35. The ServerSideCallEvent • The ServerSideCallEvent is a bubbling event that in the Flex architecture (actually in the Flash Player) is able to reach an upper level component • The ServerSideCallEvent is the one that drives to the ServiceConnector the method to call
  • 36. The ServiceConnector in 5 steps (1/5) • Create the ServiceConnector instance and specify which is the object that needs to receive the events dispatched from the class sc = ServiceConnector.getConnector(this); • Set the default services for the ServiceConnector instance sc.defaultSource = quot;com.gnstudio.services.Adminquot;; sc.defaultDestination = quot;Adminquot;; • Define the listeners for the events sc.addEventListener(RemoteObjectWrapperEvent.FAULT, onFault) sc.addEventListener(RemoteObjectWrapperEvent.RESULT, onResult)
  • 37. The ServiceConnector in 5 steps (2/5) • Define the listeners for the event that will generate the server side calls addEventListener(ServerSideCallEvent.ANONYMOUS_CALL, onAnonymousCall); addEventListener(ServerSideCallEvent.LOGGED_CALL, onLoggedCall); • Create the hash map used to handle the queue of the server side calls, the map is the one used also to send the data to a specific component hash = new HashMap();
  • 38. The ServiceConnector in 5 steps (3/5) Define the listener to anonymous calls, it initialize the connector, perform the call and add the caller to the hash map (@param e ServerSideCallEvent) private function onAnonymousCall(e:ServerSideCallEvent):void{ var obj:AbstractService; try{ obj = sc.makeAnonymousCall(e.fakeObject as IRemoteMethod); }catch(err:Error){ sc.initializeConnector(baseUrl + SERVICES[0], connectorKind); obj = sc.makeAnonymousCall(e.fakeObject as IRemoteMethod); } hash.addItem({service: obj, target: IPresenter(e.target), nameSpace: e.nameSpace}) }
  • 39. The ServiceConnector in 5 steps (4/5) Define the listener to logged calls, it initialize the connector, perform the call and add the caller to the hash map (@param e ServerSideCallEvent) private function onLoggedCall(e:ServerSideCallEvent):void{ try{ obj = sc.makeLoggedCall(e.fakeObject as RemoteMethod); hash.addItem({service: obj, target: IPresenter(e.target), nameSpace: e.nameSpace}); }catch(err:Error){ Alert.show(quot;You need to be logged on the systemquot;, quot;Attention!quot;); } }
  • 40. The ServiceConnector in 5 steps (5/5) • Define the Listener to the general result event, it's able to update the UI component that performed the request (@param e RemoteObjectWrapperEvent) private function onResult(e:RemoteObjectWrapperEvent):void{ var tg:IPresenter; if(hash.getItem(quot;servicequot;, e.currentService)){ tg = hash.getItem(quot;servicequot;, e.currentService).target as IPresenter; var ns:Namespace; if(hash.getItem(quot;servicequot;, e.currentService).nameSpace){ ns = hash.getItem(quot;servicequot;, e.currentService).nameSpace; } tg.setDataSet(e.eventData, ns); hash.remove(quot;servicequot;, e.currentService); }}
  • 41. How to put everything in action • Use the Model View Presenter for your component • Make a comparison between Model View Presenter and Model View Controller • Understand why in an UI context the MVP is the best choice with external data • Make a simple implementation
  • 42. The MVP pattern • The original implementation of the MVP is born in the 1979, its name was Thing Model View Editor and during these years there were a lot of different implementations between them the Taligent’s one (1996) was for sure the more sophisticated and the more powerful • The Model-View-Presenter pattern is a variation on the Model- View-Controller pattern, and similarly separates the concerns of an application’s data, presentation, and user input into specialized components
  • 44. The MVP actors • The Model refers to the data and business functionality of the application • Selections are components which specify what portion of the data within the Model is to be operated upon • Commands are classes which define the operations which can be performed on the data • The View is the visual representation of the Model and is comprised of the screens and widgets used within an application • Interactors are classes which address how user events are mapped onto operations performed on the Model • The Presenter is a component which orchestrates the overall interaction of the other components within the application
  • 45. MVP and MVC (1/2) MVC MVP UI Presentation Pattern focus on Based on MVC (UI Presentation Pattern) separation of view with Model Separation of responsibility between three Separation of responsibility between four components: components: 1. View - responsible for rendering UI 1. View - responsible for rendering UI elements elements 2. Controller - responsible for 2. View Interface - responsible for loose responding to view actions coupling between view and model 3. Model - responsible for business 3. Presenter - responsible for view and behavior and state management model interaction 4. Model - responsible for business behavior and state management
  • 46. MVP and MVC (2/2) MVC MVP The three components would interact Presenter can also interact with View to with each other, Controller would access Model sometime also be responsible to update view (like Front Controller Pattern) Controller is behavior based and Usually one view have one presenter multiple views can share single controller (1-1 mapping), multiple presenters would be associated with a complex view Identifies which view to update Presenter will update its associated view