CRest (Client Representational State Transfer or Client REST) is a lightweight JAX-RS compatible framework aiming to simplify the integration of external REST services into java applications.
CRest allows the developer to focus on the essential aspects of the integration of a REST service, such as the definition of:
The rest is achieved by annotating the java interface with the relevant information such as the service end-point, the desired timeouts, parameters etc...
Here is a quick example of what a CRest annotated interface would look like:
@EndPoint("http://api.twitter.com")
@Path("/1/statuses")
@Consumes("application/json")
public interface StatusService {
@POST
@Path("update.json")
Status updateStatus(
@FormParam("status") String status,
@QueryParam("lat") float lat,
@QueryParam("long") float longitude);
@Path("{id}/retweeted_by.json")
User[] getRetweetedBy(
@PathParam("id") long id,
@QueryParam("count") long count,
@QueryParam("page") long page);
@Path("followers.json")
User[] getFollowers(@QueryParam("user_id") long userId);
}And here how you would get an instance of it:
// Get a CRest instance CRest crest = CRest.getInstance(); // Get a StatusService instance StatusService statusService = crest.build(StatusService.class);