Aricles related to

Java

Java 8: Composing functions using compose and andThen

In this post we're going to take a look at function composition using two compose functions provided in the Function interface - compose and andThen. What is function composition? It all has to do with creating small reusable functions that you can combine to compose new functions. Now, how can…



Java 8: Replace traditional for loops with IntStreams

I've previously looked at how to work on a higher level by replacing loops with streams. In this post I want to continue this by looking at IntStream and how it could replace the traditional for (int i=0;... loop. IntStream is a stream of primitive int values. It's part…


Inject dependencies into your filters using DelegatingFilterProxy

In this post, we’re going to look at how to inject dependencies into your web application filters. To achieve this, we’re going to use Spring’s DelegatingFilterProxy. Now consider the following. Say we got an AuditHandler that takes care of the audit of incoming requests in our web…


SparkJava: Separating routing and resources

You know how a lot of the tutorials out there always look so clean and neat, but when using it to other things than hello world, it just gets messed up? When playing around with Spark, we didn't want to lose that cleanness, because a clean Spark application sure is…


Java 8: Take your abstractions to the next level

One of the many reasons I enjoy working with functional programming, is the high level of abstraction. You'll end up with more readable and concise code that is closer to the business logic. In this post I'll look at four things that will help you get your abstractions to the…



Execute code on webapp startup and shutdown using ServletContextListener

Sometimes you are in need of invoking some code during startup and shutdown of your web application. There are several ways to achieve this, but in this post I'm going to take a look at the ServletContextListener. How it works ServletContextListener is an interface that gets notified about ServletContext lifecycle…