Upload
pardhulucky
View
226
Download
0
Embed Size (px)
Citation preview
8/3/2019 Data Services Basics
1/28
2005 Adobe Systems Incorporated. All Rights Reserved.1
Flex Data Services
Christophe Coenraets
Adobe Systems
8/3/2019 Data Services Basics
2/28
2005 Adobe Systems Incorporated. All Rights Reserved.2
Building Data-Rich Internet Applications
In current RIAs, the user interface is fluid,
but the data is not
Traditional limitations:
Lack of publish/subscribe messaging
Data synchronization between tiers is complex
8/3/2019 Data Services Basics
3/28
2005 Adobe Systems Incorporated. All Rights Reserved.3
Message
Service
Flex Data Services
Endpoint
Publisher
Subscriber
RTMP
AMF
HTTP
Flex 2.0 Publish/Subscribe MessagingSimple Use Case
Client A
Client B
Client C
8/3/2019 Data Services Basics
4/28
2005 Adobe Systems Incorporated. All Rights Reserved.4
Demo: Chat
8/3/2019 Data Services Basics
5/28
2005 Adobe Systems Incorporated. All Rights Reserved.5
Publishing a Message
Setting up a Producer
Sending the message
public function send():void
{
var message:AsyncMessage = new AsyncMessage();
message.body.userId = userId.text;
message.body.msg = msg.text;
producer.send(message);
}
8/3/2019 Data Services Basics
6/28
2005 Adobe Systems Incorporated. All Rights Reserved.6
Subscribing to a Destination
Setting up a Consumer
Handling messages
public function messageHandler(event:MessageEvent):void{
log.text += event.message.body.userId + ": " + event.message.body.msg + "\n";
}
8/3/2019 Data Services Basics
7/28
2005 Adobe Systems Incorporated. All Rights Reserved.7
Demo: Collaboration DashboardApplication Sharing
Johns session Lindas session
8/3/2019 Data Services Basics
8/28
2005 Adobe Systems Incorporated. All Rights Reserved.8
Message
Service
Flex Data Services
Adapter Y
Adapter X
Messaging
System Y
MessagingSystem X
EndpointJMS
ProviderJMS Adapter
Publisher
Subscriber
RTMPAMF
HTTP
Flex 2.0 Messaging
8/3/2019 Data Services Basics
9/28
2005 Adobe Systems Incorporated. All Rights Reserved.9
Demo: JMS Chat
8/3/2019 Data Services Basics
10/28
2005 Adobe Systems Incorporated. All Rights Reserved.10
Flex 2.0 MessagingData Push
Message
Services
Flex Data Services
Adapter Y
Adapter X
Messaging
System Y
MessagingSystem X
EndpointJMS
ProviderJMS Adapter
Publisher
Subscriber
RTMPAMF
HTTP
8/3/2019 Data Services Basics
11/28
2005 Adobe Systems Incorporated. All Rights Reserved.11
Demo: Real Time Data Feed (JMS)
8/3/2019 Data Services Basics
12/28
2005 Adobe Systems Incorporated. All Rights Reserved.12
Messaging Summary
Flex messaging enables new types of applications
Data push
Collaboration
Data Synchronization
Destinations are configured in xml file Messages and channels are decoupled
Destinations are available to Flex and non-flex applications
8/3/2019 Data Services Basics
13/28
2005 Adobe Systems Incorporated. All Rights Reserved.13
Flex Data Services
Data Services
W
eb
Se
rvice
RPC Services
Re
mote
Object
HTTP
Service
Message ServiceMessage Service
Dat
aSync
Data Management Services
Offline
Pa
ging
8/3/2019 Data Services Basics
14/28
2005 Adobe Systems Incorporated. All Rights Reserved.14
Working with DataTraditional Page-Centric HTML Model
data data
Persistence Solutions:Hibernate
JDOs
EJB 3Others
8/3/2019 Data Services Basics
15/28
2005 Adobe Systems Incorporated. All Rights Reserved.15
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
8/3/2019 Data Services Basics
16/28
2005 Adobe Systems Incorporated. All Rights Reserved.16
RPC Approach
data
RPC
Services
data
Developers Responsibilities:
Flag changes (create, update, delete)
Maintain original version of data for appropriate lockingstrategy
Make Remote Procedure Calls for creating, updating,deleting items
Identify and handle conflicts / concurrency issues
8/3/2019 Data Services Basics
17/28
2005 Adobe Systems Incorporated. All Rights Reserved.17
Data Services Approach
data
Data
Service
data
Client-Side API:
Flags changes (create, update, delete)
Maintains original version of data for appropriate lockingstrategy
Sends list of changes to Data Service as a set of messages
Handle conflicts / concurrency issues
8/3/2019 Data Services Basics
18/28
2005 Adobe Systems Incorporated. All Rights Reserved.18
Data Services Approach
data data
JDBC
ObjectHibernate
ColdFusion
Data
Service
Custom
Data Service:
Deserialize changes coming from client
Serializes data before sending to client
Passes list of changes to configured adapter
Notifies clients who subscribed to destination
Adapter:
Processes changes
Identifies conflicts
Passes results to Data Service
8/3/2019 Data Services Basics
19/28
2005 Adobe Systems Incorporated. All Rights Reserved.19
Flex Data Services
Data Services
Data
ServiceDAO
Object
Adapter
Hibernate
Adapter
JDBC
Adapter
Hibernate
RDBMS
CFCAdapter ColdFusion
Endpoint
Client A
Client B
Client C
8/3/2019 Data Services Basics
20/28
2005 Adobe Systems Incorporated. All Rights Reserved.20
Demo: A Simple Data Services Application
8/3/2019 Data Services Basics
21/28
2005 Adobe Systems Incorporated. All Rights Reserved.21
Demo: A Simple Data Services Application
public var ds:DataService;
[Bindable]public var contacts:ArrayCollection;
public function initApp() {
contacts = new ArrayCollection();
ds = new DataService("contact");
ds.fill(contacts);
}
8/3/2019 Data Services Basics
22/28
2005 Adobe Systems Incorporated. All Rights Reserved.22
Demo: Contact Application
8/3/2019 Data Services Basics
23/28
2005 Adobe Systems Incorporated. All Rights Reserved.23
flex-services.xml
samples.contact.ContactAssembler
loadContacts
syncContacts
8/3/2019 Data Services Basics
24/28
2005 Adobe Systems Incorporated. All Rights Reserved.24
ContactAssembler.java
public class ContactAssembler {
public List loadContacts() {
ContactDAO dao = new ContactDAO();
return dao.getContacts();
}
public List syncContacts(List changes) {
Iterator iterator = changes.iterator();
ChangeObject co;
while (iterator.hasNext()) {
co = (ChangeObject) iterator.next();
if (co.isCreate()) {// invoke logic to create item
} else if (co.isUpdate()) {
// invoke logic to update item
} else if (co.isDelete()) {
// invoke logic to delete item
}}
return changes;
}
}
8/3/2019 Data Services Basics
25/28
2005 Adobe Systems Incorporated. All Rights Reserved.25
Local Persistence Service
Allows offline data access
Provides common API for creating, reading, updating, and
deleting local data
Adapters are used for different types of local data storagedevices
Local Shared Objects adapter is available in Flex 2.0
Offline data synchronization supported through
combination of local persistence and messaging services
LSO
LSO
Adapter
Local Persistence
Service
8/3/2019 Data Services Basics
26/28
2005 Adobe Systems Incorporated. All Rights Reserved.26
Paging
Maximum message size can be specified on destination
If size exceeds maximum value, multiple message batches are used
Client reassembles separate messages
Enables asynchronous data paging across the network
User interface elements can display portions of the collection without waiting for the
entire collection to load
8/3/2019 Data Services Basics
27/28
2005 Adobe Systems Incorporated. All Rights Reserved.27
Summary
Flex Messaging enables new categories of applications including push and
collaboration
Data Services simplify the development and maintenance of data driven
application
8/3/2019 Data Services Basics
28/28
2005 Adobe Systems Incorporated. All Rights Reserved.28
Thank you.