410 likes | 629 Views
ColdFusion 8 & LiveCycle Data Services Faster, Better and Cooler than ever!. Tom Jordahl ColdFusion Architect June 27, 2007. Introduction. Architect - Adobe ColdFusion Team Primary implementer of LiveCycle Data Services integration. Topics. What's new for ColdFusion 8
E N D
ColdFusion 8 & LiveCycle Data ServicesFaster, Better and Cooler than ever! Tom Jordahl ColdFusion Architect June 27, 2007
Introduction • Architect - Adobe ColdFusion Team • Primary implementer of LiveCycle Data Services integration
Topics • What's new for ColdFusion 8 • Overview - LiveCycle Data Services • RPC • Messaging • Data Management
Integrated LCDS Install for ColdFusion 8 • Integrated installation option for LiveCycle Data Services • No need to use RMI for communication
LiveCycle Data Services – Connection to CF ColdFusion Data Services CFC CF Adapters: Messaging Data Service Messaging Gateway Assembler Service RMI ColdFusion 8 CFC Messaging Gateway Assembler Service CF Adapters: Messaging Data Service
RPC Services Data Management Messaging Web Service Data Sync Collaboration Remote Object OCC Pub/Sub HTTP Service Paging Data Push LiveCycle Data Services LiveCycle Data Services Web-Tier Compiler Message Service
Topics • Overview of FDS • RPC • Flex Messaging • Flex Data Management
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
ColdFusion and Flash Remoting Update • No Flex Server involved when using Flash Remoting ColdFusion CFC AMF 3 ColdFusion Adapter MessageBroker Servlet
Topics • Overview of LCDS • RPC • Messaging • Data Management
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
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
Messaging – Connection to CF ColdFusion Data Services CFC Event Gateway Adapter Flex Messaging Gateway RMI ColdFusion CFC Event Gateway Adapter Flex Messaging Gateway
ColdFusion ColdFusion Adapter Messaging: Client-Initiated Message LiveCycle Data Services Message Service Endpoint RTMP AMF HTTP Publisher Subscriber
Messaging: Push LiveCycle Data Services ColdFusion ColdFusion Message Services Endpoint ColdFusion Gateway RTMP AMF HTTP Publisher Subscriber
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 messaging-config.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
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>
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
Messaging with CF • Example – send message from CFML • Example – receive message in CFC
Topics • Overview of FDS • RPC • Flex Messaging • Flex Data Management
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
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
Data Management LiveCycle Data Services ColdFusion Data Service Endpoint CFC Adapter
Data Management – Connection to CF CFC ColdFusion Data Services RMI CF Data Service Adapter Flex Assembler Service ColdFusion CFC CF Data Service Adapter Flex Assembler Service
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
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 • Returns a single item (row) when passed in an identity value • Sync • Takes a list of changes and applies them to the data • Count • Returns the number of records that fill would return
Creating an Assembler CFC • Show Eclipse Wizard
Configuring Data Management • Must define channels • Channels are how Flash communicates to LCDS • Flex configuration file: services-config.xml • 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">
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
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
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>
Flex Data Management with CF • Example – Contact application
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>
Flex Data Management with CF • Example – Notification
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">
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!
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/
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!
Non-Integrated Configuration for Data Management • Enable Flex Data Management support • Make sure the service is enabled in the ColdFusion Administrator • Identity • 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 CFC ColdFusion Flex CF Data Service Adapter Flex Assembler Service RMI over SSL