Thanks to Spring Community: REST-Client for Android

You know what really pissed me off when writing code for Android? There literally is no genuine REST client in that system, even though the original Android API uses REST mechanisms to store and retrieve data in their ContentProvider architecture. Funny enough that the only community project that I know of trying to remedy that issue was a pain in the ass to install (because of Maven dependencies) and in the end nearly unusable in terms of architecture.

Today the Spring Community published a first milestone for Android addons and you guessed it: it comes with a fully fledged REST client (so says the announcement, I haven’t tested yet). The good thing about it: if you’re used to Spring’s ORM template classes (we use iBATIS) you’ll quickly recognize the call architecture for the Android REST client is quite similar. Here’s an example call:

RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(new CommonsClientHttpRequestFactory());
String url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q={query}";
String result = restTemplate.getForObject(url, String.class, "Thanksgiving");

aint that cool stuff? Whilst other authors try to use a common library like Apache HttpClient, Spring allows you have connections created using a RequestFactory. So if you want to use a more reliable another Http layer feel free to implement one. The template mechanism for REST-like URLs also feels comfortable so the last thing to say: incredible but far too late, guys!

Oh, BTW. The only other feature that Spring for Android currently is offering is a streamlined logging client. Also very important but IMHO not made for the catwalk. Pls have look by yourself.

REST API Reference

Spring Android Product Page

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s