6.6. The Adapters at Work

You have seen the JMSAdapter and the ActionScriptAdapter in the preceding examples. This section explains both these adapters and lays out the configuration options for them. It also includes a brief discussion on custom adapters.

6.6.1. The ActionScriptAdapter

The ActionScriptAdapter is a lightweight adapter that enables publish/subscribe messaging between Flex clients. The ActionScriptAdapter extends the MessagingAdapter class, which is the base abstract class that supports messaging. Adapters sit at the end of the service call pipe and facilitate interaction with server-side objects or special formats and standards.

The ServiceAdapter interface defines the core contract of an adapter in BlazeDS. The HTTPProxyAdapter that you learned about in Chapter 3 and the JavaAdapter that you learned about in Chapter 4 extend the ServiceAdapter interface. The MessagingAdapter abstract class also extends the ServiceAdapter.

The core features of the ActionScriptAdapter are contained in the invoke method of the adapter. Messages are routed to subscribed Flex clients from inside the invoke method. Following is the code that sends the messages out:

msgService.pushMessageToClients(message, true);
msgService.sendPushMessageFromPeer(message, true);

The pushMessageToClients method of the MessageService class pushes the message to all subscribed local Flex clients. By local, I mean those that reside on the same node within a cluster. If a message needs to be transmitted ...

Get Professional BlazeDS: Creating Rich Internet Applications with Flex® and Java® 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.