Friday Nov 14, 2008

Zembly, Sang Shin, and Swing

I took the first half of Sang Shin's Zembly Basics course today. It was the first time that I'd ever used Zembly. I didn't even really know what it was, before taking Sang's course.

It seems pretty cool. Zembly is an on-line platform for creating 'things', which are 'services', 'widgets', and 'applications'. First you create services (such as a weather service) and then you create widgets that provide a presentation layer on top of the services (such as a widget where the user needs to type in a zip code for the area of interest for the weather service). Then you make the widgets available to others, by embedding them in your website, or something similar. (You can also create applications, but that's the second part of the course, which I haven't done yet.) You can very easily reuse other people's services and widgets too. Hard to visualize all this without doing it yourself, though.

So then I created a service following Sang's instructions and then thought: "Why would I create an on-line widget when I could just as easily create a widget in Swing?" So I created a small NetBeans module that calls my service from a menu item:

public final class GreetMeAction implements ActionListener {

    public void actionPerformed(ActionEvent e) {
        int ageValue = 34;
        String nameValue = "Tom";
        try {
            URL zemblyServiceURL = new URL(";exec?name=" + nameValue + "&age=" + ageValue);
        } catch (IOException ex) {

Then the browser opens, displaying this result:

Hi Tom! Your age is 34

So, the menu item is the widget for my Zembly service. It would be even better to be able to receive the results within Swing, rather than needing to open the browser to see them. Not sure how that would be done, though. But, imagine creating a weather service in Zembly. Then you'd (under the hood of your module) call that service and then do something with the results, within the module itself. But how could one get access to the results?


Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« November 2008 »