Documenting Jersey REST API

Documentation is error-prone. So the best documentation should be the code itself… or automatically generated from the code. I haven’t found any open source project that can do this so I created one. As I’m currently learning Scala, I decided to write the code with Scala. You can find the code in Bitbucket: https://bitbucket.org/enefem/restdoc It’s …

Deployment parameter for REST resource

When you are creating resource in a REST application, it will only be automatically created if you have an empty parameter. The problem is, sometime we need a resource that is configurable, so it can be reused by other applications. We can solve this problem by defining init parameter in our web.xml like this: Or …

Java Tips: Process Object Based On Its Type Without if-then-else Solution

I want to share my answer for this question on StackOverflow. Say you want to process several objects with different types. Each type must be processed differently but some concerns are: You don’t want if-then-else solution which is obviously not great for long-term Configuration is also bad for the same reason So how is the …

Guava: Using CheckedFuture

In this post, I want to discuss another class from Google Guava. Today, it will be CheckedFuture. Let’s first see the JavaDoc of the class: A CheckedFuture is an extension of Future that includes versions of the get methods that can throw a checked exception and allows listeners to be attached to the future. This …

Guava: Using ListenableFuture

Google Guava has many interesting classes which we can use on our application. The ones from collection package have been already used by many developers and this blog has tutorial on how to use the computing map. I want to move to the other package. This one is com.google.common.util.concurrent, specifically I want to introduce ListenableFuture. …

Java Tips: Initializing Collection

Especially in unit test, it is common case that we have to initialize an array or a collection. Well, for array, it’s OK… A simple code that we know can solve the problem: But how about Collection? Normal way to initialize collection is something like this (which pretty ugly): I hardly find an elegant solution …

Hello World… Using Spring Roo 1.1.0M1 under STS 2.3.3M1

The first day’s Google I/O keynote shows how much work has been done to integrate Spring Roo with GWT. Despite the fact that the demo is not smoothly done, it is kind of interesting combination. Before we have to do all the work to integrate Spring + Hibernate + GWT manually, now the work has …