INTEGRATING VIA DATA SERVICES
285
The HTTP proxy adapter in BlazeDS uses the Apache HttpClient as the user agent. The configuration
max-total-connections translates to the use of a multithreaded concurrent connections manager for
HttpClient. max-connections-per-host sets the default number of connections if the host supports
hardware clustering. The allow-lax-ssl true value means self-signed certificates will work. If the
connection to the host is made through an external proxy, the external proxy can be specified in the
configuration file as well. Authentication credentials like the password can be passed to the external proxy.
Additional Useful Data Services Tips
Data services are useful and extensible pieces of software. You have seen how they can be extended to
support additional features with the help of custom factories and custom service adapters. What I discuss
next are the interesting features around run-time configuration and application security that data services
offer.
Configuring at Run Time
So far, almost all the configurations I have spoken about have related to compile-time configuration, where
the entries are made in the configuration files. However, it’s also possible to make many of these
configurations and settings at run time. Run-time configuration makes systems more flexible and
amenable to tweaking at the time of use. At run time, you can define channels, create consumers, set up
subscriptions, and affect destination configurations. However, I only show you one of these possibilities
here: channel definitions.
Defining channels at run time At run time, channels can be created on the client with the help of a
ChannelSet object, which may contain one or more Channel objects. Essentially, the process is first to
create a ChannelSet object and then dynamically create channels and add channels to it. After this, the
channel set is associated with the channelSet property of the RemoteObject. This is what a sample
piece of code may look like:
var cs:ChannelSet = new ChannelSet();
var newChannel:Channel = new AMFChannel("my-amf", endpointUrl);
cs.addChannel(newChannel);
remoteObject.channelSet = cs;
The endpoint URL can be defined dynamically at run time. ChannelSet has the ability to search among
the set of configured channels. Each channel can define a failover URL.
Application Security
In many cases, especially in enterprise scenarios, you may need to restrict access to server-side
destinations. It’s possible to define a secure destination without much trouble. Data service configurations
allow definitions for both authentication and authorization. Authentication means confirming one’s identity,
and authorization relates to the server-side resources that an authenticated user can access.
Security is configured using security constraints. These constraints can be defined at multiple levels,
namely the following:
• Global: One set of definitions for all destinations. Usually such configuration would reside in
the common configuration area: within services-config.xml itself.
• Destination specific: Security constraints for a destination. You can define such constraints
inline within the destination configuration tags.
Get AdvancED Flex 4 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.