Home » Tag Archives: RESTful Web Services

Tag Archives: RESTful Web Services

Getting started with Spark: it is possible to create lightweight RESTful application also in Java

apache-spark-logo

Recently I have been writing a RESTful service using Spark, a web framework for Java (which is not related to Apache Spark). When we planned to write this I was ready to the unavoidable Javaesque avalanche of interfaces, boilerplate code and deep hierarchies. I was very surprised to find out that an alternative world exists also for the developers confined to Java. In this ...

Read More »

RESTful considered harmful

software-development-2-logo

I don’t like RESTful principles and APIs. In recent years it is seen as universal protocol for inter-process communication, especially in distributed systems. However I see many deficiencies of REST and there are alternatives that work well for certain use cases. Obviously there is no one size fits all, I just want to emphasize that REST architecture is flawed in ...

Read More »

How To Stream/Serialize JPA Result As JAX-RS Response For Large Data

java-interview-questions-answers

There are times that retrieving a large data set through JPA is necessary (e.g. more than 1,000,000 records) and having them stuffed into a single instance of java.util.List is just risky (memory barrier). So, here’s a quick solution of how a JAX-RS REST resource end-point could still give us a timely Response without breaking the memory constrain through streaming or ...

Read More »

Java REST JAX-RS 2.0 – How To Handle Date, Time and Timestamp Data Types

java-interview-questions-answers

Be it X-Form-Urlencoded or JSON HTTP post to a REST resource end-point, there is no specific “data type” for date or time related data. Most developers will have these data posted as “String” or just simply convert them to Unix timestamp value (e.g. 1435061152). But, as developers implement more and more end-point methods, codes to parse of date, time and ...

Read More »

How to Keep REST API Credentials Secure

software-development-2-logo

If you are building mobile apps then you are connecting to some REST API. For example, if you want to resolve an address to a latitude/longitude information to display on a map, you might use the Google Geocoding API: https://maps.googleapis.com/maps/api/geocode/json?address=San Francisco,CA&key=AIzaSyDvFMYGjeR02RH If you are invoking the API from the client, then the API key also has to be present on ...

Read More »

RESTful Error Handling with Spring

spring-interview-questions-answers

This post will illustrate a way in which exception handling can be implemented for RESTful web services in Spring in such a manner that the exception handling concerns are separated from the application logic. Taking advantage of the @ControllerAdvice annotation we are able to create a global helper class for all controllers. By adding methods that we annotate with both ...

Read More »

Jersey WebResource – Header don’t get appended

Jersey-logo

Yesterday I ran into a strange problem when using the Jersey WebResource class for doing HTTP calls: it seemed as if the headers I set, simply got ignored when executing the HTTP call. Read ahead. What I tried to achieve was to call a REST Api to get some data from on of our applications. For doing so, I used ...

Read More »

Automated testing of REST-services

junit-logo

Despite I’m a Java and Scala developer I still passioned a lot in testing of software. If to be more precisely – web applications. It’s really interesting to develop web app and be confident that the apps have a good quality. When I’ve started a career the most popular web architecture was MVC (Model View Control) and there was pretty ...

Read More »

Building a rest api with spray

akka-logo

Building a rest api with akka and spray is easy. This is how I did it: SprayApiApp:                   import akka.actor.{ActorSystem, Props} import akka.io.IO import akka.pattern.ask import akka.util.Timeout import spray.can.Http import scala.concurrent.duration._ object SprayApiApp extends App { //we need an ActorSystem to host our application in implicit val system = ActorSystem("SprayApiApp") //create apiActor ...

Read More »

Improving performance: non-blocking processing of streams

spring-interview-questions-answers

1. Introduction Imagine we have an application that needs to access an external web service in order to gather information about clients and then process it. More specifically, we can’t get all this information in a single invocation. If we want to look up different clients, we will need several invocations. As shown in the graphic below, the example application ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.