ColdFusion and FDS

Download Report

Transcript ColdFusion and FDS

ColdFusion 8 & LiveCycle Data Services
Faster, Better and Cooler than ever!
Tom Jordahl
ColdFusion Architect
June 27, 2007
Copyright 2007 Adobe Systems Incorporated.
1
Introduction

Architect - Adobe ColdFusion Team

Primary implementer of LiveCycle Data Services
integration
Copyright 2007 Adobe Systems Incorporated.
2
Topics

What's new for ColdFusion 8

Overview - LiveCycle Data Services

RPC

Messaging

Data Management
Copyright 2007 Adobe Systems Incorporated.
3
Integrated LCDS Install for ColdFusion 8

Integrated installation option for LiveCycle Data
Services

No need to use RMI for communication
Copyright 2007 Adobe Systems Incorporated.
4
LiveCycle Data Services – Connection to CF
ColdFusion
Data Services
CFC
CF Adapters:
Messaging
Data Service
RMI
Messaging Gateway
Assembler Service
ColdFusion 8
CFC
CF Adapters:
Messaging
Data Service
Copyright 2007 Adobe Systems Incorporated.
Messaging Gateway
Assembler Service
5
LiveCycle Data Services
LiveCycle Data Services
Message Service
Copyright 2007 Adobe Systems Incorporated.
6
Web-Tier Compiler
Paging
OCC
Data Management
Data Sync
Pub/Sub
Data Push
Messaging
Collaboration
HTTP Service
Remote Object
Web Service
RPC Services
Topics

Overview of FDS

RPC

Flex Messaging

Flex Data Management
Copyright 2007 Adobe Systems Incorporated.
7
RPC: Flash Remoting Update

High Performance Binary Protocol

AMF3

Built in to ColdFusion – even if you don’t install LCDS

New features (since CFMX 7.0.2)

Value Objects

Data type translations

Performance improvements in AMF3
Copyright 2007 Adobe Systems Incorporated.
8
ColdFusion and Flash Remoting Update

No Flex Server involved when using Flash Remoting
AMF 3
ColdFusion
ColdFusion
Adapter
MessageBroker
Servlet
Copyright 2007 Adobe Systems Incorporated.
9
CFC
Topics

Overview of LCDS

RPC

Messaging

Data Management
Copyright 2007 Adobe Systems Incorporated.
10
LCDS Messaging

Publish & Subscribe

Producer and Consumer

Asynchronous communication

Messages have header and body


Values can be complex types

Values are converted to/from CFML and Actionscript types
ColdFusion can be both a Producer and Consumer

Publish – sendGatewayMessage()

Subscribe – Event Gateway CFC
Copyright 2007 Adobe Systems Incorporated.
11
What’s new in ColdFusion 8

Performance enhancements

Default operation now uses Java API instead of RMI

Must specify host/gatewayhost in configuration for
RMI operation

Default in CFMX 7.0.2 was assumed to be localhost

Must specify localhost if not using integrated LCDS
Copyright 2007 Adobe Systems Incorporated.
12
Messaging – Connection to CF
ColdFusion
Data Services
CFC
RMI
Event Gateway
Adapter
Flex Messaging
Gateway
ColdFusion
CFC
Event Gateway
Adapter
Copyright 2007 Adobe Systems Incorporated.
Flex Messaging
Gateway
13
Messaging: Client-Initiated Message
LiveCycle
Data Services
ColdFusion
Message
Service
Endpoint
RTMP
AMF
HTTP
Copyright 2007 Adobe Systems Incorporated.
Publisher
Subscriber
14
ColdFusion
Adapter
Messaging: Push
LiveCycle
Data Services
Message
Services
Endpoint
RTMP
AMF
HTTP
Copyright 2007 Adobe Systems Incorporated.
Publisher
Subscriber
15
ColdFusion
Gateway
ColdFusion
ColdFusion
Messaging – LCDS Configuration

Flex uses Destinations as a basic configuration
concept


There are destinations for RPC, Messaging and Data Management
Messaging configuration is found in messagingconfig.xml

C:\ColdFusion8\wwwroot\WEB-INF\flex\messaging-config.xml

Clients publish to or consume from a destination

The “ColdFusionGateway” destination pre-configured
by default
Copyright 2007 Adobe Systems Incorporated.
16
Messaging – LCDS Configuration

Destination must specify the CF Event Gateway ID


“*” means to look in the message for the target Event Gateway
Preconfigured Destination:
<destination id="ColdFusionGateway">
<adapter ref="cfgateway" />
<properties>
<gatewayid>*</gatewayid>
</properties>
<channels>
<channel ref="cf-polling-amf"/>
</channels>
</destination>
Copyright 2007 Adobe Systems Incorporated.
17
Messaging – ColdFusion Configuration

Configure a new ColdFusion Event Gateway

Configuration file is optional

Simple property file

Destination – Which Flex destination to send messages

Host – Where is Data Services running?

By default we look for the integrated LC Data Services

allowedIPs – Which remote machines are allowed to talk this gateway

Actionscript conversion options:

Force-cfc-lowercase

Force-query-lowercase

Force-struct-lowercase
Copyright 2007 Adobe Systems Incorporated.
18
Messaging with CF

Example – send message from CFML

Example – receive message in CFC
Copyright 2007 Adobe Systems Incorporated.
19
Topics

Overview of FDS

RPC

Flex Messaging

Flex Data Management
Copyright 2007 Adobe Systems Incorporated.
20
Data Management

Manages distributed data in Flex Applications

Data Replication & Synchronization

Data provided to clients

Changes reflected on all clients

Server manages changes to the underlying data resource

Manage large collections of data

Nested data relationships


One-to-one

One-to-many
Occasionally Connected Clients
Copyright 2007 Adobe Systems Incorporated.
21
Updates in ColdFusion 8

Performance improvements

CFC creation is much faster (value object mapping goes faster)

Can return a ColdFusion Query directly instead of creating an
array of CFCs

Can choose to use structures instead of CFCs to map to
ActionScript objects


Use “__type__” key in structure to provide Actionscript type
Data Management notification gateway added

ColdFusion can notify LCDS that data it is managing has
changed

Individual and batch notifications supported
Copyright 2007 Adobe Systems Incorporated.
22
Data Management
LiveCycle Data Services
Data
Service
Endpoint
Copyright 2007 Adobe Systems Incorporated.
23
CFC
Adapter
ColdFusion
Data Management – Connection to CF
ColdFusion
Data Services
CFC
RMI
CF Data Service
Adapter
Flex Assembler
Service
ColdFusion
CFC
CF Data Service
Adapter
Copyright 2007 Adobe Systems Incorporated.
Flex Assembler
Service
24
Data Management - Assemblers

The code that actually manages the data is
called an “Assembler”

Assemblers can be written as ColdFusion
Components

A basic assembler has four methods:

Fill

Get

Sync

Count
Copyright 2007 Adobe Systems Incorporated.
25
CFC Assemblers


Fill

Returns a data set when called, can have optional parameters

Data is returned as an array of CFCs or a query
Get


Sync


Returns a single item (row) when passed in an identity value
Takes a list of changes and applies them to the data
Count

Returns the number of records that fill would return
Copyright 2007 Adobe Systems Incorporated.
26
Creating an Assembler CFC

Show Eclipse Wizard
Copyright 2007 Adobe Systems Incorporated.
27
Configuring Data Management

Must define channels


Flex configuration file: services-config.xml


Channels are how Flash communicates to LCDS
C:\ColdFusion8\wwwroot\WEB-IN\flex\services-config.xml
ColdFusion requires a special flag on its
channels
<serialization>
<instantiate-types>false</instantiate-types>
</serialization>

Turn on debugging to see what is going on
<logging>
<target class="flex.messaging.log.ConsoleTarget" level="Debug">
Copyright 2007 Adobe Systems Incorporated.
28
Configuring Data Management

Again we use destinations

Configuration file: data-management-config.xml


C:\ColdFusion8\wwwroot\WEB-INF\flex\data-management-config.xml
“Contact” application sample destination configured
Copyright 2007 Adobe Systems Incorporated.
29
Configuring Data Management


Specify special ColdFusion channels

cf-polling-amf – Polling over HTTP, scalable and works through
firewalls

cf-rtmp – Disabled by default, uncomment and add to destination to
use
Specify the CFC used as the Assembler


Use dot notation or path
Specify the scope

Application – Single CFC instance created and cached


Gotcha: making changes to CFC when cached has no effect!
Request – New CFC created for each operation

Use for development

Use for production now that CFC creation is faster
Copyright 2007 Adobe Systems Incorporated.
30
Configuring Data Management
<destination id="cfemployee">
<adapter ref="coldfusion-dao"/>
<properties>
<component>samples.crm.EmployeeAssembler</component>
<scope>application</scope>
<metadata>
<identity property="employeeId"/>
</metadata>
</properties>
<channels>
<channel ref="cf-polling-amf"/>
</channels>
</destination>
Copyright 2007 Adobe Systems Incorporated.
31
Flex Data Management with CF

Example – Contact application
Copyright 2007 Adobe Systems Incorporated.
32
Data Management Notification

ColdFusion 8 adds a new Event Gateway:
DataManagement.

Notifies LCDS of changes to data made outside of Flex


i.e. CFML page updates a record also displayed by a Flex application
Call SendGatewayMessage():
<cfscript>
update = StructNew();
update.destination = "cfcontact";
update.action = "update";
update.previousversion = oldContact;
update.newversion = newContact;
update.changes = "firstName,lastName";
r = SendGatewayMessage(“MyDataGateway", update);
</cfscript>
Copyright 2007 Adobe Systems Incorporated.
33
Flex Data Management with CF

Example – Notification
Copyright 2007 Adobe Systems Incorporated.
34
CFC Assemblers – optional function

Flex maintains the state of all the fill functions for all clients

When a change happens, it does an automatic refresh of each

fillContains method allows the assembler to indicate if a fill needs
to be updated


<fill-method>
<use-fill-contains>true</use-fill-contains>
<auto-refresh>true</auto-refresh>
<ordered>false</ordered>
</fill-method>
Define the method like this

<cffunction name="fillContains" returnType="boolean"
access="remote">
<cfargument name="fillArgs" type="array" required="yes">
<cfargument name="item" type="[CFC type object]"
required="yes">
<cfargument name="isCreate" type="boolean" required="yes">
Copyright 2007 Adobe Systems Incorporated.
36
MXML Tag

JSP tag library to compile MXML code inline or on disk

<cfimport prefix="flex" taglib="/WEB-INF/lib/cf-bootstrap-for-flex.jar">
<flex:mxml height="300" width="600">
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*">
app goes here
<cfif switch>
do something in mxml
<cfelse>
do something else in mxml
</cfif>
</mx:Application>
</flex:mxml>

You can compile files on disk as well


<flex:mxml source="app.mxml" height="300" width="600">
PERFORMANCE WARNING: You can really get in to trouble with
this!
Copyright 2007 Adobe Systems Incorporated.
37
Questions?
Copyright 2007 Adobe Systems Incorporated.
38
Resources

Flex coders yahoo group



http://groups.yahoo.com/group/flexcoders/
ColdFusion 7.0.2 Documentation

http://download.macromedia.com/pub/documentation/en/flex/2/using_cf_with_flex2.pdf

http://www.adobe.com/support/documentation/en/coldfusion/mx702/cf702_releasenotes.html
Flex Documentation

http://livedocs.adobe.com/flex/201/
Copyright 2007 Adobe Systems Incorporated.
39
Copyright 2007 Adobe Systems Incorporated.
40
Flex Messaging – Security

Integrated LCDS is the most secure – No network traffic

If allowedIPs not configured both LCDS and CF sides will only
accept connections from the same machine

You can configure a list of allowed IP addresses for both sides


Gateway configuration file

Flex Destination
If IP addresses don’t match, “Permission Denied” is returned.


No details for security reasons
Possible to have one side configured differently from the other!
Copyright 2007 Adobe Systems Incorporated.
41
Non-Integrated Configuration for Data Management

Enable Flex Data Management support


Identity


Make sure the service is enabled in the ColdFusion Administrator
Used when you have more than one ColdFusion instance on a machine
SSL encryption

The RMI connection between ColdFusion and Flex can be protected by SSL

You must configure a certificate in to ColdFusion (the “server” in this case)

You can use the Java “keytool” program to generate a certificate
ColdFusion
Flex
CFC
CF Data Service
Adapter
Copyright 2007 Adobe Systems Incorporated.
RMI
over SSL
43
Flex Assembler
Service