spring

07 Feb: High performance RSS/Atom parsing

Parsing RSS feeds is very easy in Java. Several libs exist to get the job done: feed4j, rssowl, Apache Abdera and many others. But the most commly used is ROME. ROME is a set of RSS and Atom Utilities for Java. It makes it easy to work in Java with most syndication formats: RSS 0.9x, 1.0, 2.0 and Atom 0.3, 1.0. Reading RSS from a source is dead-simple, you need these dependencies: <!– Rome Atom+RSS –> <dependency>…

21 Oct: A best Spring AsyncRestTemplate!

I wrote an article on the famous Spring’s RestTemplate some months ago (https://layer4.fr/2013/02/24/a-best-spring-resttemplate/). Since the last version of Spring 4, currently 4.0.0.M3, or the BUILD-SNAPSHOT for the most courageous, you can use a custom RestTemplate in an async way: the AsyncRestTemplate API. Why should I use that? The purpose of this API is to allow Java applications to easily execute HTTP requests and asynchronously process the HTTP responses. In non async mode, the code will block until…

17 Oct: Myrrix, the REST-ified Mahout for real-time recommandations

Myrrix is a complete, real-time, scalable clustering and recommender system, evolved from Apache Mahout. The full Myrrix system uses two components: a Computation Layer and one or many Serving Layers. While the Computation Layer computes the large machine learning models needed by the Serving Layer, the Serving Layer is a Java HTTP server application. This server serves user requests in real-time, making recommendations and receiving new input via a REST API. Many instances of the Serving Layer…

22 Aug: Implementing a role hierarchy in Spring Security (Java config style)

From http://static.springsource.org/spring-security/site/docs/3.1.x/reference/authz-arch.html: It is a common requirement that a particular role in an application should automatically “include” other roles. For example, in an application which has the concept of an “admin” and a “user” role, you may want an admin to be able to do everything a normal user can. To achieve this, you can either make sure that all admin users are also assigned the “user” role. Alternatively, you can modify every access constraint which requires…

14 Mar: Deploy an application on AppFog using Cloudfoundry vmc tool or Maven plugin

AppFog is a simple Cloud Platform for web applications. It’s built on Cloud Foundry, the Open Platform as a Service Project. Like the Cloud Foundry command-line interface (known as ‘vmc’), AppFog offers a CLI tool, ‘af’ based on CloudFoundry’s ‘vmc’ but includes features specific to AppFog and has the default target set to AppFog’s service. But if you want to use ‘vmc’ with the AppFog Service or the Cloudfoundry Maven plugin, you will be rejected when creating…

24 Feb: A best Spring RestTemplate!

The RestTemplate is the central class for client-side HTTP access. It simplifies communication with HTTP servers, and enforces RESTful principles. It handles HTTP connections, leaving application code to provide URLs (with possible template variables) and extract results. The template uses a ClientHttpRequestFactory for creating HTTP connections. The default ClientHttpRequestFactory is a SimpleClientHttpRequestFactory that uses standard J2SE classes like java.net.HttpURLConnection. And this is not really production ready… (why?) So, the solution is to use the org.springframework.http.client.HttpComponentsClientHttpRequestFactory, which is…

24 Feb: Use Cloudfoundry in Spring without the dedicated XML namespace

Spring allows you to configure a dead simple connection on a provisioned service, like mysql, redis, rabbitmq and many others. It’s really simple, since you don’t even need to configure explicit credentials and connection strings. Instead, you can retrieve a reference to this service from the cloud itself using the CloudFoundry “cloud” namespace. Problem is, you have to create an XML file, and we have more and more projects without XML anymore. So, how to use the…

24 Mar: Automatic retry on failure

What the need? To make processing more robust and less prone to failure, sometimes it helps to automatically retry a failed operation in case it might succeed on a subsequent attempt. For example a call to a web service that fails because of a network glitch or a DeadLockLoserException in a database update may resolve themselves after a short wait. So, how to…? To automate the retry of such operations the Spring team developped a retry module…