Adobe
Products

Top destinations

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • SiteCatalyst
  • Students
  • Elements family

Adobe Creative Cloud

  • What is Adobe Creative Cloud?
  • Design
  • Web
  • Photography
  • Video
  • Students
  • Teams
  • Enterprise
  • Educational institutions

Design and photography

  • Photoshop
  • Illustrator
  • InDesign
  • Adobe Muse
  • Lightroom

Video

  • Adobe Premiere
  • After Effects

Web development and HTML5

  • Edge Tools & Services [opens in a new window]
  • Dreamweaver
  • Gaming [opens in a new window]

Adobe Marketing Cloud

  • What is Adobe Marketing Cloud?
  • Digital analytics
  • Social marketing
  • Web experience management
  • Testing and targeting
  • Media optimization

Analytics

  • SiteCatalyst
  • Adobe Discover
  • Insight

Social

  • Adobe Social

Experience Manager

  • CQ
  • Scene7

Target

  • Test&Target
  • Recommendations
  • Search&Promote

Media Optimizer

  • AdLens
  • AudienceManager
  • AudienceResearch

Document services

  • Acrobat
  • EchoSign [opens in a new window]
  • FormsCentral [opens in a new window]
  • SendNow [opens in a new window]
  • Acrobat.com [opens in a new window]

Publishing

  • Digital Publishing Suite

  • See all products
Business solutions

By business need

  • Digital analytics
  • Digital publishing
  • Document management
  • Media optimization
  • Social marketing
  • Testing and targeting
  • Video editing and serving
  • Web development [opens in a new window]
  • Web experience management
  • See all business needs

By industry

  • Broadcast
  • Education
  • Financial services
  • Government
  • Publishing
  • Retail
  • See all industries
Support & Learning

I need help

  • Products
  • Adobe Creative Cloud
  • Adobe Marketing Cloud
  • Forums [opens in a new window]

I want to learn

  • Training and tutorials
  • Certification [opens in a new window]
  • Adobe Developer Connection
  • Adobe Design Center
  • Adobe TV [opens in a new window]
  • Adobe Marketing Center
  • Adobe Labs [opens in a new window]
Download
  • Product trials
  • Adobe Flash Player
  • Adobe Reader
  • Adobe AIR
  • See all downloads
Company
  • Careers at Adobe
  • Investor Relations
  • Newsroom
  • Privacy
  • Corporate Social Responsibility
  • Customer Showcase
  • Contact us
  • More company info
Buy
  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers
  • Adobe Marketing Cloud sales [opens in a new window]
Search
 
Info Sign in
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Welcome,
My Adobe
My orders
My information
My preferences
My products and services
Sign out
My cart
Privacy My Adobe
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out Privacy My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Promotions
Estimated shipping
Tax
Calculated at checkout
Total
Review and Checkout
Adobe Developer Connection / LiveCycle Developer Center /

Externalizing service configuration for BlazeDS and LiveCycle Data Services ES

by Christophe Coenraets

Christophe Coenraets
  • http://coenraets.org/blog/

Modified

27 April 2009

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
BlazeDSconfigurationdata servicesLiveCycle Designer ES4services
Was this helpful?
Yes   No

By clicking Submit, you accept the Adobe Terms of Use.

 
Thanks for your feedback.

Requirements

Prerequisite knowledge

Working knowledge of LiveCycle Data Services ES or BlazeDS.

User level

Beginning

Required products

  • BlazeDS (Download trial)

Additional Requirements

LiveCycle Data Services ES

  • Try
  • Buy

When developers start working with the RemoteObject class or other BlazeDS and LiveCycle Data Services ES classes, a common point of confusion is where the services are configured and most importantly when the configuration is read.

The question often arises after an application stops working when you move it to another server, and it is one of the most frequently asked questions related to BlazeDS and LiveCycle Data Services ES. The goal of this article is to answer it while showing you how to externalize your services configuration from your code.

Services configuration at compile time

When you create a new BlazeDS or LiveCycle Data Services ES project in Flex Builder, you will typically select J2EE as the Application Server Type and then check Use Remote Object Access Service in the New Flex Project Wizard. This adds a compiler argument that specifies the location of your services-config.xml file. If you check the Flex Compiler properties of your Flex Builder project, you'll see something like this:

-services "c:\blazeds\tomcat\webapps\samples\WEB-INF\flex\services-config.xml"

When you then compile your application, the required values from services-config.xml are baked into the SWF. In other words, services-config.xml is read at compile time and not at run time as you may have thought. To abstract things a little bit, you can use tokens such as {server.name}, {server.port}, and {context.root} in services-config.xml. However, {context.root} is still resolved at compile time, while {server.name} and {server.port} are replaced at runtime using the server name and port number of the server that the SWF was loaded from (which is why you can't use these tokens for AIR applications).

Externalizing services configuration

Fortunately, the Flex SDK provides an API that allows you to configure your channels at runtime and entirely externalize your services configuration from your code (you definitely do not want to recompile your application when you move it to another server).

At a high level, it works like this:

var channelSet:ChannelSet = new ChannelSet(); var channel:AMFChannel = new AMFChannel("my-amf", "http://localhost:8400/lcds-samples/messagebroker/amf"); channelSet.addChannel(channel); remoteObject.channelSet = channelSet;

Clearly, this is still not optimal because the endpoint URL is still hardcoded in the application. At least in this case it is obvious that this is happening. So, the last step in externalizing the services configuration is to pass that endpoint URL value at runtime. There are a number of ways you can pass values to a SWF at runtime, including flashVars and URL parameters.

The approach I usually use is to read a configuration file using HTTPService at application startup. That configuration file includes (among other things) the information I need to programmatically create my channel set at runtime. Here is a basic implementation:

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="configSrv.send()"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.messaging.channels.AMFChannel; import mx.messaging.ChannelSet; import mx.rpc.events.ResultEvent; private var channelSet:ChannelSet; private function configResultHandler(event:ResultEvent):void { var xml:XML = event.result as XML; var amfEndpoint:String = "" + xml..channel.(@id=="amf").@endpoint; if (amfEndpoint == "") { Alert.show("amf channel not configured", "Error"); } else { channelSet = new ChannelSet(); var channel:AMFChannel = new AMFChannel("my-amf", amfEndpoint); channelSet.addChannel(channel); ro.channelSet = channelSet; ro.getProducts(); } } ]]> </mx:Script> <mx:HTTPService id="configSrv" url="config.xml" resultFormat="e4x" result="configResultHandler(event)"/> <mx:RemoteObject id="ro" destination="product"/> <mx:DataGrid dataProvider="{ro.getProducts.lastResult}" width="100%" height="100%"/> </mx:Application>

The configuration file (config.xml) looks like this:

<?xml version="1.0" encoding="utf-8"?> <config> <channels> <channel id="amf" endpoint="http://localhost:8400/lcds-samples/messagebroker/amf"/> </channels> </config>

Note: With this type of runtime configuration in place, you can create plain Flex Builder projects (that is, you can select None as the Application Server Type).

Where to go from here

This particular example is not extremely flexible. It assumes I will always work with an AMF channel and therefore the only thing my application needs to know at runtime is the AMF channel endpoint URL. For RemoteObject that's a fairly safe bet, however for messaging-related classes (Producer and Consumer), you may also want to externalize the type of channel you use (so you can choose from among AMF polling, long polling, streaming, RTMP, and so on). Before you start creating that kind of dynamic configuration system, you may want to take a look at existing frameworks that provide built-in capabilities to externalize your services configuration..

More Like This

  • Creating data management applications by manually creating Java server-side classes
  • What's new in LiveCycle ES Update 1
  • Setting up model-driven development with LiveCycle Data Services ES2
  • Configuring and troubleshooting a LiveCycle ES2 server cluster
  • Denying Rights Management ES services for specific applications
  • BlazeDS 30-minute test drive
  • What's new in Adobe LiveCycle Data Services ES2 (3.0)
  • Understanding the data management services in LiveCycle Data Services ES
  • Using the data management services in LiveCycle Data Services ES
  • LiveCycle Data Services ES2 (3.0) videos

Products

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • Digital Publishing Suite
  • Elements family
  • SiteCatalyst
  • For education

Download

  • Product trials
  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR

Support & Learning

  • Product help
  • Forums

Buy

  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2013 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

Ad Choices

Reviewed by TRUSTe: site privacy statement