Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Open Sourced Gateway to Zembly Web Services

DZone's Guide to

Open Sourced Gateway to Zembly Web Services

· Java Zone
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

Zembly, Sun's Wiki-like application development environment, now exposes a web gateway, in the form of an API. Through the API, applications in JavaFX, Java SE, and Java EE can access Zembly's web services.

The Zembly client library (ZCL)  is open sourced and can be accessed from Kenai:

http://kenai.com/projects/zcl/pages/Home

A Getting Started document can be found there (with a full blown NetBeans tutorial here), as well as a set of samples, for Java applications, as well as for JavaFX applications:

What's interesting is that you use Zembly itself to generate a code snippet that accesses the web service you want to use. Below is part of a page in Zembly that I stepped through to obtain a snippet letting me access the Google translation service:

Then you can do something like this to access the given service from your Java code:

public static String translate(String q, String l, String f) {
try {
String result = Zembly.getInstance().callService(
"google.language.translate",
new String[][]{
{"langpair", l},
{"q", q},
{"format", null}});
System.out.println("result: " + result);
return result;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}

One of the samples made available on the Kenai site takes this a few steps further by providing a GUI that calls the above translation method:

Here's the sample source structure:

The benefit of the API is that services created in Zembly are now very simple to access externally. You could continue accessing them as before (described in my blog), by parsing a URL, but that's a pretty clunky solution. So, the Web Gateway API exposed by Zembly gives you simple and direct access to your web services... outside of Zembly. One might imagine one group of developers creating the services, while another group works on their UIs, particularly in the declarative style provided by JavaFX.

Plus, the fact that ZCL is open source implies that you're welcome to contribute to it. More on the topic of access to Zembly services can be found in the Zembly blog.

 

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}