• No results found

MAX 2006 Using ColdFusion w/ Flex Data Services

N/A
N/A
Protected

Academic year: 2021

Share "MAX 2006 Using ColdFusion w/ Flex Data Services"

Copied!
6
0
0

Loading.... (view fulltext now)

Full text

(1)

2006 Adobe Systems Incorporated. All Rights Reserved. 1

MAX 2006

Using ColdFusion

w/ Flex Data

Services

Tom Jordahl

Senior Computer Scientist/ ColdFusion Architect Adobe Systems Incorporated

2006 Adobe Systems Incorporated. All Rights Reserved. 2

Introduction

ƒ Architect - Adobe ColdFusion Team

ƒ Implementer of FDS Messaging and Data Management features in

ColdFusion 7.0.2

Topics

ƒ Overview - Flex Data Services

ƒ Messaging

ƒ Data Management

2006 Adobe Systems Incorporated. All Rights Reserved. 4

Flex Data Services in Flex 2

Flex Data Services

W eb S e rv ic e RPC Services R e mo te O b je ct HTTP Ser v ic e Message Service Message Service D a ta Sy n c Data Management OCC Pagi ng W e b-Ti er Compi le r W e b-Ti er Compi le r Col labor at io n Messaging Pub/ Sub D a ta P u sh

2006 Adobe Systems Incorporated. All Rights Reserved. 5

RPC: Flash Remoting Update

ƒ High Performance Binary Protocol

ƒAMF3

ƒ Built in to CF 7.0.2

ƒ No FDS required!

ƒ New features

ƒValue Object ƒData type translations ƒPerformance improvements in AMF3 ƒ Attend Mike Nimer’s session for more info

ƒWD001W – An Introduction to ColdFusion Powered Flex

ColdFusion and Flash Remoting Update

ƒ No Flex Server (FDS) involved when using FlashRemoting

ColdFusion MessageBroker Servlet ColdFusion Adapter CFC AMF 3

(2)

2006 Adobe Systems Incorporated. All Rights Reserved. 7

Flex 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

2006 Adobe Systems Incorporated. All Rights Reserved. 8 Message

Service

Flex Data Services

Adapter X JMS Adapter Messaging System X JMS Provider Endpoint Publisher Subscriber RTMP AMF HTTP

Flex 2 Messaging: Client-Initiated Message

ColdFusion Adapter

ColdFusion

Flex 2 Messaging: Push

Message Services

Flex Data Services

Endpoint ColdFusion

Gateway ColdFusion

2006 Adobe Systems Incorporated. All Rights Reserved. 10

ColdFusion

Flex Messaging – Connection to CF

Flex Event Gateway Adapter Flex Messaging Gateway CFC RMI

ƒ Event Gateway Adapter registers itself in the RMI registry

ƒ Event Gateway Name is unique key (gw1)

ƒ Flex Messaging Gateway also registers in the RMI registry

ƒ Destination name is unique key (destination1) rmi://cfeventgateway/gw1 rmi://cfeventadapter/destination1

RMI Registry

2006 Adobe Systems Incorporated. All Rights Reserved. 11

Flex Messaging – FDS Configuration

ƒ Flex uses Destinationsas a basic configuration concept

ƒThere are destinations for RPC, Messaging and Data Management

ƒ Messaging configuration is found in messaging-config.xml

ƒC:\fds2\jrun4\servers\samples\flex\WEB-INF\flex\messaging-config.xml

ƒ Clients publish toor consume froma destination

ƒ Find the “ColdFusion” destination in Flex sample configuration

directory

ƒC:\fds2\resources\config\messaging-config.xml

Flex Messaging – FDS Configuration

ƒ Destination must use the ColdFusion Adapter

ƒ <adapter-definition id="cfgateway"

class="coldfusion.flex.CFEventGatewayAdapter"/>

ƒ Destination must specify the CF Event Gateway ID

ƒ“*” means to look in the message for the target Event Gateway

ƒ Sample Destination:

<destination id="ColdFusionGateway">

<adapter ref="cfgateway"/> <properties>

<gatewayid>*</gatewayid> </properties>

(3)

2006 Adobe Systems Incorporated. All Rights Reserved. 13

Flex Messaging – FDS Configuration

ƒ Other configuration properties:

ƒgatewayhost

ƒHostname or IP address of the ColdFusion server ƒallowedIPs

ƒIP addresses (no hostnames!) allowed to connect to this destination ƒremote-username/remote-password

ƒCredentials to pass along to the gateway, if not already specified in Message ƒUse setRemoteCredentials()API on the client instead

ƒ Other Flex Messaging destination properties

ƒNetwork: session timeout, message throttling, etc ƒServer: time to live, durable, cache size, etc.

2006 Adobe Systems Incorporated. All Rights Reserved. 14

Flex Messaging – Security

ƒ By default, both Flex 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!

ƒ Configure a new ColdFusion Event Gateway

ƒ Configuration file is optional

ƒ Simple property file

ƒDestination– Which Flex destination to send messages ƒHost– Where is Flex running?

ƒallowedIPs– Which Flex machines are allowed to talk this gateway ƒActionscript conversion options:

ƒForce-cfc-lowercase

ƒForce-query-lowercase

ƒForce-struct-lowercase

Flex Messaging – ColdFusion Configuration

2006 Adobe Systems Incorporated. All Rights Reserved. 16

Flex Messaging with CF

ƒ Example – send message from CFML ƒ Example – receive message in CFC

2006 Adobe Systems Incorporated. All Rights Reserved. 17

Flex 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

Flex Data Services

Data Management

Data Service CFC Adapter Hibernate Adapter JDBC Adapter Hibernate RDBMS Endpoint ColdFusion

(4)

2006 Adobe Systems Incorporated. All Rights Reserved. 19

Data Management – Connection to CF

ƒ CF Data Service Adapter registers itself in the RMI registry ƒ Identity as configured in the ColdFusion Administrator

ColdFusion Flex CF Data Service Adapter Flex Assembler Service CFC RMI rmi://cfassembler/identity RMI Registry

2006 Adobe Systems Incorporated. All Rights Reserved. 20

Configuring FDS Data Management

ƒ Must define channels

ƒChannels are how Flash communicates to FDS

ƒ Flex configuration file: services-config.xml

ƒC:\fds2\jrun4\servers\default\samples\WEB-INF\flex\services-config.xml

ƒ ColdFusion requires a special flag on its channels

<!-- CF RTMP Channel -->

<channel-definition id="cf-dataservice-rtmp”class=...> <endpoint uri="rtmp://{server.name}:2048”class=... > <properties>

<idle-timeout-minutes>20</idle-timeout-minutes> <serialization>

<instantiate-types>false</instantiate-types>

</serialization> </properties </channel-definition>

Configuring FDS Data Management

ƒ Again we use destinations

ƒ Configuration file: data-management-config.xml

ƒC:\fds2\jrun4\servers\default\samples\WEB-INF\flex\data-management-config.xml

ƒ Use the ColdFusion examples:

ƒC:\fds2\resources\config\data-management-config.xml

2006 Adobe Systems Incorporated. All Rights Reserved. 22

Configuring FDS Data Management

ƒ Define the ColdFusion adapter

ƒ<adapter-definition id="coldfusion-dao" class="coldfusion.flex.CFDataServicesAdapter"/>

ƒ Define a destination:

<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-dataservice-rtmp"/> <channel ref="cf-polling-amf"/> </channels>

</destination>

2006 Adobe Systems Incorporated. All Rights Reserved. 23

Configuring FDS Data Management

ƒ Specify special ColdFusion channels

ƒcf-dataservice-rtmp, cf-polling-amf

ƒ Specify the CFC used as the Assembler

ƒUse dot notation or path

ƒ Specify the scope

ƒApplication – Single CFC instance created and cached ƒRequest – New CFC created for each operation

ColdFusion 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

ColdFusion Flex

(5)

2006 Adobe Systems Incorporated. All Rights Reserved. 25

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

2006 Adobe Systems Incorporated. All Rights Reserved. 26

CFC Assemblers

ƒ Fill

ƒReturns a data set when called with optional parameters ƒData is returned as an array of CFCs

ƒ 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

2006 Adobe Systems Incorporated. All Rights Reserved. 28

Flex Data Management with CF

ƒ Example – Contact application ƒ Example – FDS Sample application

2006 Adobe Systems Incorporated. All Rights Reserved. 29

Special considerations for CF destinations

ƒ <auto-refresh>

ƒDetermines if FDS will re-execute a fill on updates or creates ƒ <ordered>

ƒDetermines whether the order of the data is important for this filled collection ƒAllows for performance optimization when order doesn’t matter. ƒ <hostname>

ƒThe name or IP of the ColdFusion server ƒ <identity>

ƒWhich ColdFusion instance to talk to on a machine

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

ƒ Can be very expensive!

ƒ 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">

(6)

2006 Adobe Systems Incorporated. All Rights Reserved. 31

Questions?

2006 Adobe Systems Incorporated. All Rights Reserved. 32

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.macromedia.com/flex/2/

References

Related documents

If you’re going abroad for more than two months, whether for travel, work or study, you can also take out our Long Stay Abroad Insurance in addition to Annual Travel Insurance..

The proposed new solution is a double layer wideband 2×2 microstrip patch-array antenna excited by ridge gap waveguide, thus not depending on any substrate in the feed layer..

Amendments may be initiated either through a review or evaluation of an existing Planning Tool, through direction received from City Council or Committees of Council, or through

Figure 14: Example HSF Input File for Aeolus System (Asset2 Collapsed for Clarity) The output file for the HSF plugin is a typical input file for the Horizon Simulation

An evidence-based tool, the Casey-Fink Graduate Nurse Experience Survey (CFGNES), was utilized and administered to all ten new graduates on their first day of didactic.. The

Land Management and Natural Hazards Unit WOCAT/LADA Seminar 16/02/2010 2 WORLD ATLAS OF DESERTIFICATION Ne w Edi tio n Ne w Edi tio n.. Research on adapted methods for

(2014) studied the structure of the imidazolium ILs in the Fenton reaction, obtaining that the mineralization rate increased when the alkyl side chain