Spring MVC Error handling flow
There are broadly three ways of handling an exception flow using Spring MVC, the objective being to intercept any application exception and present a friendly and informative view back to the user.1....
View ArticleSpring MVC - Migrating to Jackson 2
This does not really require a blog entry - migrating from Jackson 1.9.x to Jackson 2.x is extremely simple with Spring MVC 3.1+ based applications. The only thing that needs to be done is to replace...
View ArticleAbstractAnnotationConfigDispatcherServletInitializer - Long and short of it
AbstractAnnotationConfigDispatcherServletInitializer is a newly(3.2+ versions of Spring) introduced Template Method based base class that makes Spring pure java based web application...
View ArticleSpring @Bean and PropertyPlaceHolderConfigurer
I was recently stumped by what I thought was going to be a fairly straightforward implementation - Consider the following Spring Java based bean definition file (@Configuration):package...
View ArticleSpring - Autowiring multiple beans of the same type and @Primary annotation
Consider a simple Spring annotation based context, with two beans with @Service annotation, but of the same type:@Service public class CustomerServiceImpl1 implements CustomerService{ @Override public...
View ArticleSpring based applications and logging dependencies
There is not much to say on the topic of Spring based applications and adding logging dependencies apart from pointing to the excellent blog entry at the Spring site itself -...
View ArticleReasons to consider spring-boot for your next Spring based application!
Spring-boot provides a quick way to create a Spring based application. There are very good reasons to consider spring-boot:Reason 1 : Simpler Dependency management using spring-boot starter...
View ArticleSpring data "Page" based bootstrap pager
Spring data "Page" provides a good abstraction for a Page of records, and has fields to access the current page that is being displayed, the count of all the records and the page size.A good pager...
View ArticleSpring 4 Conditional
Spring 4 is introducing a new feature called Conditional - an annotation targeted towards Spring components which generate beans and vetos the generation of these beans, in essence it provides a way to...
View ArticleComparator as a Functional interface in Java 8
Comparator seemingly has two abstract methods but still has been tagged as a FunctionalInterface in Java 8. Consider the following:@FunctionalInterfacepublic interface Comparator<T> { int...
View ArticleJava 8 parameter name at runtime
Java 8 will be introducing an easier way to discover the parameter names of methods and constructors. Prior to Java 8, the way to find the parameter names is by turning the debug symbols on at the...
View Articlejava.util.Random in Java 8
One of the neat features of java.util.Random class in Java 8 is that it has been retrofitted to now return a random Stream of numbers.For eg, to generate an infinite stream of random doubles between...
View ArticleObjenesis for class instantiation
Objenesis is a neat little library for instantiating classes . Consider the following class:public class Person { private final String firstName; private final String lastName; public Person(String...
View ArticleSpring Integration Publisher
Consider a hypothetical requirement - You have a service class in your application and you want to capture some information around the calls to this service:@Servicepublic class SampleBean { private...
View ArticleConsuming Spring-hateoas Rest service using Spring RestTemplate and Super...
Spring-hateoas provides an excellent way for applications to create REST based services which follow the HATEOAS principle. My objective here is not to show how to create the service itself, but to...
View ArticleSpring Integration Standalone application with Spring Boot
I had earlier blogged about a way to write a standalone Spring Integration application. Spring Boot makes creating this standalone application much simpler. The simple flow was to poll the USGS service...
View ArticleCall by name using Java 8 Supplier
A call by name example in the Functional programming course offered through Coursera is the following:def loop: Boolean = loop def and(x: =>Boolean, y: =>Boolean) = if (x) y else falseand(false,...
View ArticleWebsockets with Spring 4
I am throwing the entire kitchen sink into a small web application that I am developing as part of this post - Spring Boot, Spring Integration, RabbitMQ and finally the topic of the post, the Websocket...
View ArticleJava 8 functional interfaces - random musings implementing a Scala type
In one of the assignments of the Functional programming with Scala course a type called Terrain is introduced - Terrain represents a region parts of which are accessible and parts which are not. So in...
View ArticleServlet 3.0 ServletContainerInitializer and Spring WebApplicationInitializer
Spring WebApplicationInitializer provides a programatic way to configure the Spring DispatcherServlet and ContextLoaderListener in Servlet 3.0+ compliant servlet containers , rather than adding this...
View Article