heart-beat

Quick way to check if the REST API is alive – GET details from Manifest file

There might be cases when you want to quickly verify if your REST API, that is deployed either on dev, test or prod environments, is reachable altogether. A common way to do this is by building a generic resource that delivers for example the version of the deployed API. You can trigger a request to this resource manually or, even better, have a Jenkings/Hudson job, which runs a checkup job after deployment. In this post, I will present how to implement such a service that reads the implementation details from the application’s manifest file. The API verified, is the one developed in the Tutorial – REST API design and implementation in Java with Jersey and Spring Continue reading

jersey-spring-logo

How to integrate Jersey in a Spring MVC application

I have recently started to build a public REST API with Java for Podcastpedia.org and for the JAX-RS implementation I have chosen Jersey, as I find it “natural” and powerful – you can find out more about it by following the Tutorial – REST API design and implementation in Java with Jersey and Spring.  Because Podcastpedia.org is a web application powered by Spring MVC, I wanted to integrate both frameworks in podcastpedia-web, to take advantage of the backend service functionality already present in the project. Anyway this short post will present the steps I had to take to make the integration between the two frameworks work. Continue reading

Jetty ApacheCXF Spring

Embedded Jetty and Apache CXF: secure REST services with Spring Security

Recently I run into very interesting problem which I thought would take me just a couple of minutes to solve: protecting Apache CXF (current release 3.0.1)/ JAX-RS REST services with Spring Security (current stable version 3.2.5) in the application running inside embedded Jetty container (current release 9.2). At the end, it turns out to be very easy, once you understand how things work together and known subtle intrinsic details. This blog post will try to reveal that. Continue reading

JS-logo

Understanding JavaScript Callbacks

Unlocking the Asynchronous Powers of JavaScript

When I got started working with Node.js and Express, one of the first things I had to really wrap my head around was JavaScript callbacks. This is a powerful functionality built into the language that allows you to defer action until a desired event occurs, while proceeding on with other activities.

The truth is, I’ve been using callbacks for a long time, I just didn’t really realize it. I work with jQuery constantly, and it’s designed with callbacks in mind, passing anonymous functions via its built-in methods to be triggered when certain events occur, for example. Still, I wanted to move beyond “I know this works” to “I know how this works” both with jQuery and JavaScript, so I dug out my copy of JavaScript: The Good Parts, did some reading, hit the web, did some more reading, and then wrote a few simple experiments.

I thought I’d write up a little tutorial to help folks who are new to the concept get started. Hope it’s useful! Continue reading

JS-logo

Lessons learned from building ChessHub.io

I spent most of my (little) career until now building web applications using the MVC pattern with action-based (Spring MVC, Struts2, Servelt/JSP) and component-based (Tapestry, JSF) Java technologies. It has always been a classical model where the client requests a server that responds with a HTML page. Of course, I have built ajax powered web apps but I never got the chance to develop a real time single page application with a modern Javascript framework like Angular, Backbone or Ember.

So I decided to give it a try by building ChessHub.io with a completely new technology stack and way of thinking:

  • Moving form Java to Javascript
  • Moving from SQL to NoSQL
  • Moving from multi-threaded Java servers to the single threaded NodeJS
  • Moving from classic MVC + Ajax to real time with ExpressJS and Socket IO
  • Moving from synchronous processing to an asynchronous model

Continue reading

curl

How to test a REST api from command line with curl

If you want to quickly test your REST api from the command line, you can use curl. In this post I will present how to execute GET, POST, PUT, HEAD, DELETE HTTP Requests against a REST API. For the purpose of this blog post I will be using the REST api developed in my post Tutorial – REST API design and implementation in Java with Jersey and Spring Continue reading

Java Logo

A beginner’s guide to java time zone handling

Basic time notions

Most web applications have to support different time-zones and properly handling time-zones is no way easy. To make matters worse, you have to make sure that timestamps are consistent across various programming languages (e.g. JavaScript on the front-end, Java in the middleware and MongoDB as the data repository). This post aims to explain the basic notions of absolute and relative time. Continue reading

Gzip Jersey

How to compress responses in Java REST API with GZip and Jersey

There may be cases when your REST api provides responses that are very long, and we all know how important transfer speed and bandwidth still are on mobile devices/networks. I think this is the first performance optimization point one needs to address, when developing REST apis that support mobile apps. Guess what? Because responses are text, we can compress them. And with today’s power of smartphones and tablets uncompressing them on the client side should not be a big deal… So in this post I will present how you can SELECTIVELY compress your REST API responses, if you’ve built it in Java with Jersey, which is  the JAX-RS Reference Implementation (and more)…  Continue reading