Gotcha: Migrating from Spring Security 3.2.x to Spring Security 4.x

Here is a simple gotcha to keep in mind while migrating to newer Spring Security version 4.x from Spring Security 3.2.x What’s the problem? The Spring security configuration expressions hasRole(‘role_name’) and hasAuthority(‘role_name’) are no longer the same. The catch is: hasAuthority checks for any role name passed to the expression without prepending ‘ROLE_’ (which is … Read more

Deep dive into Optional class API in Java 8

We all as Java programmers been through the situation where in we invoke a method to get some value and then instead of directly invoking some methods on the return value, we first have to check that the return value is not null and then invoke the methods on the return value. This has been … Read more

Book review: Core Java, Volume II–Advanc​ed Features (9th Edition) I always liked the approach Cay S. Horstmann takes in the examples in his Core Java books. He tries to follow good practices in all his examples which includes better naming convention, documentation and comments, identifying right classes. This book, Core Java Volume-2, is no different. You find examples which are in themselves mini … Read more

Whats in store for Project Lambda in Java 8?

There are lot of things happening in the Project Lambda branch of JDK 8 and these are quite significant for Java programmers. I know lot of Anti-Java people would criticize these changes claiming them to be too late. But for loads of the Java developers out there its a welcome change. At this point of … Read more

Developing a sample Todo desktop application using JavaFX and MongoDB

I wanted to explore learning to use MongoDB with Java and the best way to do this was to develop a toy application. And to add to this, I thought of using JavaFX and building a desktop application instead. I am building the application as I am writing this. I will upload the code onto … Read more

Using JDeodorant to refactor java code

I got to know about JDeodorant– a tool for identifying bad smells in code and helping it to refactor. I got curious and downloaded its Eclipse plugin, I then picked the first bad smell code which Martin Fowler explains in his book: “Refactoring: Improving the design of existing code”. I tried my hand at refactoring a long method by Extract Method refactor move. Here’s the long method:

Read more

Play Framework Cookbook review

In a previous post I had mentioned that I would be soon reviewing the Play Framework Cookbook. So here it is-

Chapter-1 Basics of Play Framework

  • Concise coverage of basic features of the Play Framework. Though you must be using the Play Framework documentation for a more detailed information. The last few sections which explain- Extensions, Suspendable requests need a bit more explanation.
  • Good to have, as one can refresh the basic concepts.

Play Framework Cookbook- Using Play! in a better way- A preview

I had written a brief introductory post about Play! Framework and since then I havent written much about it. Not before I got an opportunity to review the Play Framework Cookbook. Before coming back to Play! I used Gaelyk for a long time and found it really useful to get started quickly on any project. … Read more

Java 7 Project Coin: try-with-resources explained with examples

Prior to “try-with-resources” (before Java 7) while dealing with SQL Statement or ResultSet or Connection objects or other IO objects one had to explicitly close the resource. So one would write something like-

  //Create a resource- R
}catch(SomeException e){
  //Hanlde the exception
  //if resource R is not null then
    //close the resource
  catch(SomeOtherException ex){

Read more

Sample application using JavaFX 2.0 beta and the after thoughts

This sample uses- TabPane, GridView and Bindings in javafx 2.0.

I had quite sometime back played around with JavaFX and had good and bad experiences using the language. With the JavaFX 2.0 beta being released I thought of giving it a try. Here I developed a simple Geocoding application which will take the address and provide the latitude-longitude values for that location- using Google Geocoding API.

Read more