Adobe Flex Data Services 2 (FDS) provides the Data Management Service that assists in data synchronization and data replication between the Flex front end and your back end. The back end could be written in Java or ColdFusion, for example. In this lesson, you will use ColdFusion and take advantage of some wizards built into Flex Builder that automatically create the required ColdFusion components needed for the Data Management Service.
The Data Management Service greatly eases your work when you're creating applications that use distributed data. A client-side DataService component, instantiated in MXML or ActionScript, calls methods on a server-side destination to perform such activities as providing data to client-side data collections and synchronizing changes at the client to the server. Notice the sentence said the "DataService component," not "you the developer writing code," calls methods. The DataService component manages data at the client, and the Data Management Service manages the distribution of data among multiple clients and the server-side data resources.
A key factor in successfully implementing the Data Management Service is proper configuration. To configure the service properly, you need to know the vocabulary involved with the technology.
The first term to understand is a destination. A destination is an endpoint for a message (data) where the message will be acted upon. Destinations are configurable in the data-management-config.xml file. When configuring a simple ColdFusion destination, you specify, among other things, a destination name, the ColdFusion component (CFC) where method requests are sent, and the primary key value of the database table the CFC is working with.
Another item specified in the destination is the message channel that the destination should use to communicate. The message channels are part of the overall Flex messaging service. Possible channels to use are Action Message Format (AMF), HTTP, secure AMF, secure HTTP, and Real-Time Messaging Protocol (RTMP). The basic communication model of the Data Management Service is shown in the following example:
When a message hits the destination on the client side, it is processed. On the server side, the Data Management Service often interacts with a data store.
The data adapter controls how Flex Data Services works with a particular interface, like a CFC or Java object. The data adapter updates the persistent data store. By default, three adapters are included with Flex Data Services: the Java adapter, the ActionScript adapter, and the Hibernate adapter. A ColdFusion adapter can be used simply by inserting it in a configuration file, which you will do in the first task in this lesson.
Once configured, you can then use methods of the DataService object to synchronize data between the Flex client and the back end.