Wednesday, March 21, 2007

Jazoon scriptlet challenge for european students

The company I work for sponsors a scriptlet programming challenge to mark the 2007 Jazoon conference (JavaOne of Europe) in Zurich.

The goal is not to spend a lot of time coding, but to realize an interesting idea. Particularly encouraged are scriptlets using new features of Java 6, Groovy 1.0 and Mashups.
The number of raw lines of code is limited to 100 lines.

You can win 3 free student entries for Jazoon and Amazon book vouchers.

More details

2 comments:

linuxswords said...

Hallo, Ich war am 20.03.06 bei der ELCA presents Jazoon dabei, als einer der 4 Studenten. Ich war derjenige, der um 18:00 Uhr gehen musste und so keine Fragen stellen konnte.

Kann ich dies auf diesem Wege tun oder darf Ich Ihnen ein Email schreiben (die Adresse habe ich nicht)?

Eine Frage stelle ich schon jetzt, Sie ist nämlich auf das Post bezogen.

Kann man beim Scripting Wettbewerb bekannte/verbreitete Librarys wie JDom verwenden? Wäre ja einfacher damit XML zu parsen da zum Beispiel flickr-API die Antworten als XML schickt.

Zu den 100 Zeilen Code, zaehlt da das GUI dazu, oder sind da die 'wirklichen' Funktionen gemeint?

Beste Grüsse

Martin Knoller Stocker
http://www.linuxswords.com

Phil said...

Hello Martin

I choose to answer in English as I use this as the default language for my blog. My direct email address can be found on my website (http://www.oser.org/~poser/philipp.html).

To answer your questions: we wanted to restrict the libraries to those in the default environment (we feared that otherwise the scriptlets could become too complex/ big).
In case you want to parse XML, Groovy has some very nice library support.

Here's for example a part of my code in groovy to make a REST request to the amazon webservice:

def urlAsString = " http://webservices.amazon.${country}/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=XXX&Operation=ItemLookup&ItemId=${isbn}&ResponseGroup=OfferSummary";

// REST request to amazon
result = new URL(urlAsString).getText();

def doc = DOMBuilder.parse(new StringReader(result))
def ItemLookupResponse = doc.documentElement

// direct access to elements in XML file:
use(DOMCategory) {
lowestNewPrice = ItemLookupResponse.Items.Item.OfferSummary.LowestNewPrice;
amount= lowestNewPrice.Amount[0].text();
currency=lowestNewPrice.CurrencyCode[0].text();
}

The parts in the line "ItemLookupResponse.Items.Item.OfferSummary.LowestNewPrice" all denote XML tags.
It looks a bit surprising at first, but you can actually work on XML tags as if they were objects.

As for the GUI: we wanted to really keep it simple, too. My Web-GUI (for my comparison of Amazon prices) takes about 25 lines.
In the groovy in action book (http://www.manning.com/koenig/), there are some
sample Groovlet Web-UIs (you can download the source, see e.g. the NumberGuesser.groovy).

Alternatively you could just make a basic command line UI.


BTW: I was also not able to find your email address on your website?

Cheers,
Philipp