Home » Author Archives: Biju Kunjummen (page 6)

Author Archives: Biju Kunjummen

Spring Bean names

spring-interview-questions-answers

Spring bean names are straightforward, except for cases where names are not explicitly specified. To start with, Spring bean names for an xml based bean definition is specified this way:                 <bean name='sampleService1' class='mvcsample.beanname.SampleService'> <constructor-arg> <bean class='mvcsample.beanname.SampleDao'></bean> </constructor-arg> </bean> For a Java @Configuration based bean definition, the method name of the @Bean annotated ...

Read More »

Spring Data JPA and pagination

spring-interview-questions-answers

Let us start with the classic JPA way to support pagination. Consider a simple domain class – A ‘Member’ with attributes first name, last name. To support pagination on a list of members, the JPA way is to support a finder which takes in the offset of the first result(firstResult) and the size of the result(maxResults) to retrieve, this way: ...

Read More »

Mixin in Java with Aspects – for a Scala traits sample

java-interview-questions-answers

Scala traits allow new behaviors to be mixed into a class. Consider two traits to add auditing and version related fields to JPA entities:                   package mvcsample.domain import javax.persistence.Version import scala.reflect.BeanProperty import java.util.Date trait Versionable { @Version @BeanProperty var version: Int = _ } trait Auditable { @BeanProperty var createdAt: Date = ...

Read More »

Spring Property Placeholder Configurer – A few not so obvious options

spring-interview-questions-answers

Spring’s PropertySourcesPlaceholderConfigurer is used for externalizing properties from the Spring bean definitions defined in XML or using Java Config. There are a few options that PlaceholderConfigurer supports that are not obvious from the documentation but are interesting and could be useful. To start with, an example from Spring’s documentation, consider a properties file with information to configure a datasource:   ...

Read More »

Spring MVC – Customizing RequestMappingHandlerMapping

spring-interview-questions-answers

When Spring MVC is configured using <mvc:annotation-driven/> in an xml bean definition file, internally a component called RequestMappingHandlerMapping gets registered with Spring MVC. This component or in general a HandlerMapping component is responsible for routing request URI’s to handlers which are the controller methods annotated with @RequestMapping annotation.               There are two specific configurations ...

Read More »

JUnit test method ordering

junit-logo

Junit until version 4.10 uses the order of test methods in a test class as returned by the reflection API as the order of test method execution – Class.getMethods(). To quote the Javadoc of getMethods() api: The elements in the array returned are not sorted and are not in any particular order. thus the order of test method execution in ...

Read More »

Json deserialization with Jackson and Super type tokens

json-logo

Datatables is a jquery plugin to present tabular information – it can enhance a simple table or can use a AJAX based data and present the information in a tabular form. Datatables requires the data from the server to follow a specific JSON format for it to be displayed on screen. Consider the case where a list of Member entities ...

Read More »

Composing Java annotations

java-logo

The allowed attribute types of a Java annotations are deliberately very restrictive, however some clean composite annotation types are possible with the allowed types.                     Consider a sample annotation from the tutorial site: package annotation; @interface ClassPreamble { String author(); String[] reviewers(); } Here the author and reviewers are of String ...

Read More »

Polling an http end point using Spring Integration

spring-interview-questions-answers

It is a little non-intuitive if you want to write a flow with Spring Integration which polls an http end point and gathers some content from the http end point for further processing. Spring Integration provides a couple of ways for integrating with a HTTP endpoint – Http Outbound adapter – to send the messages to an http endpoint Http Outbound ...

Read More »

Method Parameter Names and Spring

spring-interview-questions-answers

Continuing on the previous blog entry about Constructor and method parameters and Java not retaining the parameter names at runtime – the previous entry was about constructor not retaining the parameter names and the implication of this for Contructor injections in Spring, here I will cover a few more scenarios where parameter names not being retained has implications with Spring: 1. ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close