Over a million developers have joined DZone.

Calling Flex Data Services from Pivot

DZone's Guide to

Calling Flex Data Services from Pivot

· Java Zone
Free Resource

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

Pivot comes with built-in support for calling JSON-based REST services. However, if you prefer a more RPC-oriented approach to interacting with server-side data, Adobe's BlazeDS is now a great alternative. BlazeDS is an open-source implementation of the Flex RPC protocol, called AMF (short for Action Message Format). Adobe has begun including Java client libraries in recent builds of BlazeDS, making this protocol available to Pivot applications, which are written in Java.

Documentation on the Java AMF client API is scarce, but I was able to get a prototype up and running relatively quickly. The relevant source code is shown below; the full source is available here:

AMFConnection amfConnection = new AMFConnection();
String url = "http://localhost:8080/samples/messagebroker/amf";

Object result = null;
try {
result = amfConnection.call("product.getProducts");
java.util.ArrayList<object> products = (java.util.ArrayList<object>)result;
productTableView.setTableData(new ListAdapter<object>(products));
} catch(Exception exception) {
} finally {

The application creates an instance of AMFConnection and calls the getProducts() method of the "product" service. This method returns an array list of Product instances that will be displayed in the table. See the samples included with the BlazeDS distribution for more information on how the service is defined.

The returned array list is wrapped in a Pivot ListAdapter and set as the table data. The result looks like this:

For comparison, here is a screen shot of the original Flex example:

So, in addition to REST, Pivot now also has a simple and lightweight means of invoking RPC-oriented web services via BlazeDS, which opens up a number of additional possibilities for Pivot developers.

From http://pivot-toolkit.org/demos/pivot_amf.html

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}