Jax2010 adobe lcds

Post on 20-May-2015

1.021 views 0 download

Tags:

description

Slides presented at JAX2010 in Germany. Technical session on advanced communications between Java and Flex.

Transcript of Jax2010 adobe lcds

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

Advanced Communications between Java and FlexMichaël Chaize | Flash Platform Evangelist

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

Feel free to contact me

2

Michaël ChaizeFlash Platform Evangelist

My blog: www.RIAgora.com

@mchaize

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

Flash Platform - A complete system for web innovation

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

Flash Platform - A complete system for web innovation

97%Flash Player 10 (March 2010)

ADOBE FLEX 4

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

What is Flex and how it works

Flash Builder IDE

Flex SDK

Flex Class Library

MXML ActionScript

Compile

SOAP HTTP/S AMF/S RTMP/S

Web Server

Existing Applications & Infrastructure

J2EE Application Server

LC Data ServicesXML/HTTP

REST

SOAP Web Services

Browser

Flash Player

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

RIA and technical challenges

• Be�er response time• Light bandwidth• Less load on the server side• Less tests on the client side

Web 1.0 application Rich Internet Application

<page>

<page>

<page>

<page>

<page>

<page>

<page><application>

<data>

ADOBE FLEX 4

HTTP Request

2008 Adobe Systems Incorporated. All Rights Reserved.

Flex/JSP architecture

UI LAYER

SERVERPRESENTATION/SERVICES/DAOLAYER

DATABASE/STORAGE LAYER

catalog.jsp

Java servlet container (tomcat, WAS…)

JDBC

Web browser

JAVA classes/services

Webapp (WAR)

ProductService.java public getProducts()

WSDL

XML on HTTP(s)

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

! Same with PHP, Ruby, Perl, ASP...

! Returns XML, text, tabulated text, JSON...

! Use send() to launch the request

! Result and Fault events

! New data-services wizard in Flash Builder 4 to generate a STUB on the client side

Flex and <HTTPRequest>

ADOBE FLEX 4

Web services

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

! Web Services Description Language 1.1 (WSDL 1.1) document

! �e Flex web service API generally supports Simple Object Access Protocol (SOAP) 1.1, XML Schema 1.0 (versions 1999, 2000, and 2001), and WSDL 1.1 RPC-encoded, RPC-literal, and document-literal (bare and wrapped style parameters).

! Flex supports web service requests and results that are forma�ed as SOAP messages

Flex and <Webservice>

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

! By default, applications that are loaded from a di�erent web domain are untrusted, and applications that are loaded from the same web domain are trusted. You can, however, make a cross-domain application trusted.

! To load a cross-domain application and access its data, the target server that hosts the remote sub-application must have a policy �le called crossdomain.xml on it.

! NB: Using BLAZE DS as a proxy can help you to reach cross-domain services without the need of this XML �le.

crossdomain.xml

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

Two approaches for Client/Server development

Loosely coupled: Document Based Protocols (XML, SOAP, …)

! Language neutral, easy to debug + document

! Parsing and formatting code is harder to build and maintain as complexity grows

! Runtime overhead also grows with complexity

! Easier to develop server and client independently

Tightly coupled: Object Model Based Protocols (RMI, AMF, …)

! Adding languages is hard

! Faster for client and server and less bandwidth required

! Easier to share code or use code gen for centralizing the domain model

! Scales to much more complicated application models e�ciently

! Less design, code and fewer dependencies on the “over the wire” format

! Keeps client and server implementation in sync - if you can refresh both at the same time (easy with RIAs)

AMFPublished in December 2007

!Copyright 2008 Adobe Systems Incorporated. All rights reserved.

REMOTING AMF

XML vs AMF

ADOBE FLEX 4

Remoting AMF

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

LiveCycle Data Services ES

LiveCycle Data Services is a set of Java EE components and APIs used to:

Create data-intensive RIAs with less code, less risk, and accelerated time to market due to an innovative client-server programming model

Integrate RIAs with existing applications, back-end data, and JEE infrastructure

Easily integrate RIAs with LiveCycle document and process services

Enable collaboration, o�ine AIR and real-time data streaming applications to be built in a scalable and reliable manner with robust publish and subscribe messaging

Generate PDF documents from RIAs that include graphical assets

LiveCycle Data Services ES

Data Management

RPC Services

Messaging

ServiceAdapters

Data Synchronization

O�-line Applications

Data Paging

Web Service

HTTP Service

Remote Object Service

Publish & Subscribe

Collaboration

Real Time Data Push

Proxy Service

Web-tier Compiler

Portal Deployment

RIA-PDF Generation

LiveCycle

ColdFusion

Hibernate

SQL

JMS

Java

Custom…

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

Blaze DS

BlazeDS is a set of Java EE components and APIs, and a subset of LiveCycle Data Services:

- Free and open source.

- High performance data transfer for more responsive applications using AMF

- Real-time server push over standard HTTP

- Full pub/sub messaging that extends existing messaging infrastructure

LiveCycle Data Services ES

Data Management

RPC Services

Messaging

ServiceAdapters

Data Synchronization

O�-line Applications

Data Paging

Web Service

HTTP Service

Remote Object Service

Publish & Subscribe

Collaboration

Real Time Data Push

Proxy Service

Web-tier Compiler

Portal Deployment

RIA-PDF Generation

LiveCycle

ColdFusion

Hibernate

SQL

JMS

Java

Custom…

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

Java and ActionScript types

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

Java and ActionScript value objects

Java VO ActionScript VO

2008 Adobe Systems Incorporated. All Rights Reserved.

Flex/Java classic architecture

UI LAYER

SERVERPRESENTATION/SERVICES/DAOLAYER

DATABASE/STORAGE LAYER

LiveCycle Data Services

Java servlet container (tomcat, WAS…)

JDBC

Web browser

JAVA classes/services

Webapp (WAR)

RPC services Messaging Data Mgt ProductService.java public getProducts()

WSDL

AMF sur HTTPs

JAVA <-> AMF

ADOBE FLEX 4

Spring BlazeDS Integration

ADOBE FLEX 4

Messaging

2008 Adobe Systems Incorporated. All Rights Reserved.

Publish/Subscribe Messaging

44

Message

Service

LiveCycle DS / Blaze DS

Endpoint

PublisherSubscriber

!RTMP

!AMF

!HTTP

!Client A

!Client B

!Client C

2008 Adobe Systems Incorporated. All Rights Reserved. 45

Messaging - Data Push

Message

Services

LiveCycle DS / Blaze DS

Adapter Y

Adapter X

Messaging

System Y

Messaging

System X

EndpointJMS

ProviderJMS Adapter

PublisherSubscriber

!RTMP

!AMF

!HTTP

2008 Adobe Systems Incorporated. All Rights Reserved.

Channels of LiveCycle Data Services ES

46

ADOBE FLEX 4

Data ManagementServices

2005 Adobe Systems Incorporated. All Rights Reserved.75

Working with DataTraditional Page-Centric HTML Model

data data

! Client mostly used as a data capture and display device

! Client doesn’t own a version of the data

! No client side data manipulation

! Data needs to be synchronized between middle-tier and data store

Persistence Solutions:

Hibernate

JDOs

EJB 3

Others…

2005 Adobe Systems Incorporated. All Rights Reserved.76

RIA Model

data data data

! Client owns a version of the data

! Rich client-side data manipulation

! Data needs to be synchronized between client-tier and middle-tier and between middle-tier and data store

2005 Adobe Systems Incorporated. All Rights Reserved.77

RPC Approach

data

RPCServices

data

Developer’s Responsibilities:

! Flag changes (create, update, delete)

! Maintain original version of data for appropriate locking strategy

! Make Remote Procedure Calls for creating, updating, deleting items

! Identify and handle con�icts / concurrency issues

2005 Adobe Systems Incorporated. All Rights Reserved.78

Data Services Approach

data

DataService

data

Client-Side API:

! Flags changes (create, update, delete)

! Maintains original version of data for appropriate locking strategy

! Sends list of changes to Data Service as a set of messages

! Handle con�icts / concurrency issues

2005 Adobe Systems Incorporated. All Rights Reserved.79

Data Services Approach

data data

JDBC

Object

Hibernate

ColdFusion

DataService

Custom

Data Service:

! Deserializes list of changes coming from client

! Serializes data before sending to client

! Passes list of changes to con�gured adapter

! Noti�es clients who subscribed to destination

Adapter:

! Processes changes

! Identi�es con�icts

! Passes results to Data Service

2005 Adobe Systems Incorporated. All Rights Reserved.80

Flex Enterprise Services

Data Services

DataService

DAOObjectAdapter

HibernateAdapter

JDBCAdapter

Hibernate

RDBMS

CFCAdapter ColdFusion

Endpoint

Client A

Client B

Client C

!Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Data Management Bene�ts

1. Automatic Client to Middle-Tier Synchronization

! Change Tracking

! Automatic invocation of remote services

2. Highlander Principle: there is only one instance of a given entity in memory at any given time

3. Con�ict resolution

4. O�ine Synchronization

5. Lazy loading

6. Paging

7. Cross-client synchronization

ADOBE FLEX 4

Model driven development

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Code •UI controls / formatters / styles• Calculated �elds• Validation Rules• Variants (conditional properties)• Localization• Security• Data Retrieval Logic (paging, lazy loading)• Data Synchronization Logic

Code-Driven Development

Model •Basic Data Description

Model Server-side code Client-side code

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Code• Ad-hoc customization• View composition• External business/validation logic

Fiber: LCDS Model-Driven Development

Model • Rich data model (data and behaviors)• Calculated �elds• Validation Rules• Variants (conditional properties)• Localization• Security• UI hints/defaults: controls, formatters, styles

Model includes enough information to derive data retrieval, persistence, and synchronization logic

Model Server-side code Client-side code

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

!"#$%&'(')$*)+,-./$0*0+11")-*#2,'/.3*/"#$%*.,-$)1)$-'-.",*4,"*3"#$*5$,*,$$#$#6

!"#$%*'+-7").,5*',#*#$1%"2/$,-!"#$%&'(')$*5$0-+)$0*',#*')-.8'3-0*4.$9*!"#$%&#).:$,*8")/06

LCDS Model-Driven Development

;"#$*5$,*"8*<".%$)1%'-$*3"#$*4:'%+$*"<=$3-0>*0-+<0>*$-396

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

LCDS Model Driven Development Bene�ts

Productivity: Less code to write

! No persistence code or data sync code

! Value objects and service stubs are automatically generated

Maintainability: Less code to maintain

! Changes to the model are automatically propagated

Consistency

! Between client and server (for example, constraints and validation rules are de�ned in the model, not duplicated using di�erent languages in the client and the server)

! Across views (for example, UI controls, styles, and validation rules are de�ned in the model, not duplicated across di�erent views)

Approachability

! No code to write to implement complex capabilities such as persistence, synchronization, paging, lazy loading, o�ine, etc.

Innovation:

! O�ine and client synchronization capabilities

! Model is language independent and can be leveraged by di�erent client technologies and tools (Flex, PDF, etc)

&

Christophe Coenraetshttp://coenraets.org/

Flex & Java tutorialshttp://www.adobe.com/devnet/flex/flex_java.html

Start with Flexhttp://www.flex.org

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

Flash Platform - A complete system for web innovation

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con�dential.

Feel free to contact me

44

Michaël ChaizeFlash Platform Evangelist

My blog: www.RIAgora.com

@mchaize