Search This Blog

Tuesday, 29 December 2015

Neo4j - Select with parameters

In the previous post we worked on executing a simple select query - one that selected all the Person records in our database. In this post  I decided to work on parameterized retrieval. I decided to
execute the below query:
MATCH (a:Person{name: "Keanu Reeves"})-[:ACTED_IN]->(m:Movie) RETURN a,m
Only instead of hardcoding 'Keanu Reeves', I would like my method to work for different actors.

Thursday, 24 December 2015

Servlets 3.x - pluggin servlets at runtime

In the previous post we looked at Servlet 3.0 spec's ability to allow Servlets and filters to be defined in jars outside the deployment descriptor. In this post I am going to look at a different feature - declaring Servlets and Filters at runtime.

Sunday, 15 November 2015

Servlet 3.x - time to have a look

Its not brand new - in fact it first appeared in December 2009. Since starting to use servlets (actually servlet 2.5) I never really bothered to look at the specs. What started with application development using MVC and having multiple servlets changed to Spring framework with a single controller and lot of JSPs and then less JSPs and more AJAX. Along the way, my web.xml changed to refer to 3.0 and then 3.1.

Saturday, 7 November 2015

Be careful with Sets and equals behavior

I was recently assigned to fix a bug in the code. For the scope of this post I re-framed the problem as below:
Context: There is a set of objects of each type (lets say fruits). Over a series of operations different type of fruits are added to the set. In certain stages certain fruits may be replaced by others in the family. For example during stage 4, we may need to replace a green apple by a red apple. On the final page we display all the fruits selected.
Problem: While the various fruits show up, the changes are not seen. So if we had updated the apple to be a red one, the final result still displays a green apple.

Wednesday, 4 November 2015

Primitives and Lambdas

II have been playing with the lambda expressions and they have all involved working with objects. There are also some classes in the SDK that have been created for working with primitives.

Wednesday, 28 October 2015

Interfaces and Default Methods

In an earlier post, I covered one of Java 8's new features - default methods in interfaces. While I did the pros there were some corner cases to be considered when implementing this feature.

Tuesday, 20 October 2015

The BiVersions of Java FunctionalInterfaces

In the previous post, we saw a version of the Function class that took two parameters into apply instead of one. Similar to the BiFunction interface, we also have BiPredicate, BinaryOperator, and BiSupplier .

Wednesday, 7 October 2015

Variations in java functions

In the previous post, we saw the Function Interface that takes an object of one type and transforms it into an object of another type. Consider the user case where we need to split a string and retain only the second half.

Thursday, 24 September 2015

The Function Interface

I worked with using lambdas for Comparator interface in my first post on Lambdas. We saw how a Function interface could be used to convert an object of one type into an object of another.

Thursday, 3 September 2015

Predicates to determine the truth !

We have seen some of the functional interfaces like Consumer and Supplier in the earlier posts. The next one I wanted to explore is the Predicate interface. This one is used for testing certain conditions on a passed instance and returns a boolean value.

Thursday, 27 August 2015

Interfaces versus Abstract classes : pre and post Java 8

I have been given a contract to implement in Java. As a developer one of the early design decisions needed is, do I want an interface or an abstract class at the base of my hierarchy. This question is very popular in the Java world and often always pops up when doing low level design.

Tuesday, 25 August 2015

Suppliers in Java Lambda World

In the previous post I had a look at Consumer function objects and how they were used in the forEach method of the Iterable class. An exactly opposite kind of interface to the Consumer is the Supplier interface. (like the name doesn't give it away)

Friday, 21 August 2015

Consumers in Java Lambda World

A I mentioned in the previous post, Lambda expressions have helped simplify Collection use cases. We saw that with sorting a Collection. Let me explore some more simplifications in this post.

Wednesday, 19 August 2015


This is kind of late - very late, but then like always - better late than never. So while java lovers world over have dug deep, praised, criticized and in some cases confused the developer community about Lambda expressions in Java 8, I have finally woken and decided to throw my two cents into the pit.
I was kinda too busy/lazy until I got a code review that used Lambdas. With no escape but to review it, I had to start learning Lambdas.  This post is a collection of thoughts I found online and like always just my ready notes to be available for me to refer back when the next code review comes around. With that time to get started.....

Thursday, 21 May 2015

Introducing database to Spring Batch

Until now we have seen Spring batch without its meta data persistence features. When I say meta-data for Spring batch it includes batch related information - a listing of the steps executed, and their audit information, how many items did the framework read/write, did it skip any items, what was the duration of each step executed etc. This meta data is maintained in a database - persistence.

Monday, 6 April 2015

Multiple Steps in a Job

In the previous post we saw how to execute a job with a single step. A job can be composed of multiple steps. So I decided to extend the previous job to include two steps.
  1. Step 1 is same as before - read csv -> process -> write to List.
  2. Step 2 is read from List -> process -> write to CSV file.

Sunday, 1 March 2015

Hello Spring Batch

Batch processing is something that we keep hearing in the enterprise industry. Most software projects will at some point require that certain tasks happen in the background on certain scheduled times. Such offline tasks constitute batch jobs. Send reminder emails to clients, sending job alerts to prospective candidates, fetching transactions from financial systems and loading them into analytical systems. Batch always creeps into the picture.

Wednesday, 11 February 2015

Indexes and MongoDB

I have never given too  much thought to database indexing. Its a concept that works silently in the background of database tables and views. Most databases provide indexes by default for the primary key and unique keys.