Showing posts from 2012

60 days at expedia India

I am about to complete 60 days in expedia and till now the ride has been fun.

I joined expedia hoping challenging work, participating in building a good team and workplace full of geniuses. To be frank everything is as close to reality as i thought.

The experience is amazing, people are awesome, the new office is great, parties are crazy, but the most important think is freedom to express yourself and asking questions. And people around you listen and have enough patience to make you feel comfortable ;) .

Work wise finishing user stories (part of on-boarding process), building a team by interviewing brightest mind in the industry and ideating about new ideas to make it a better workplace. And to emphasis working on one of the biggest ecommerce platform is not easy. Its a great earning opportunity and even bigger to contributing in one of the fastest growing industry.

I hope this answers whether you should join here or not.

Looking forward to see on board ;).

Java references in nutshell

Java developers struggle to use java references and i don't blame them. The topic seldom covered by text books and even code reviews rarely give emphasis on usage of references. Why the topic is important at all? and if everybody (atleast people i have come across) is coding without it why the hell you need it?

Since you are reading this, either you are already aware of them or for the interview. Anyways, knowing references helps you manage memory better because you are able to define the behavior of the object when GC (garbage collector) is run.
Type of references:
1. Strong Reference: The normal reference in the java code is strong reference and the object referenced by strong reference is eligible for GC as soon as scope ends or reference started pointing to null in the code. E.g. Person p = new Person();                p = null;// will make object initialized above eligible for GC 2. Weak Reference: As name suggest these reference are weaker than the strong references.  Their a…

CXF-RS adding custom response code

Following snippet show how to return the custom Response code as http response code while returning the response:


public class Test  {

public  Test () {

public Response test() {
Response response = Response.status(4xx).entity("Testing").build();
return response;

CXF-RS Hiding JAXRS Service Endpoints Listing

You may come across a scenario where you want to stop listing of the exposed service from given endpoint. This can be achieved by setting the property "org.apache.cxf.endpoint.private"to true as shown in following snippet:


Eclipse Tips

Escape string while pasting in the editor
Go to Window > Preferences, type escape in the search field. Go to Java > Editor > Typing preference page. In last group label "String literals" select the "Escape text when pasting into a string literal".

CXF JSON Generation remove @ prefix

Working with CXF-RS if you want to generate the json response along with xml than it becomes pain in cases where your xml is a mixture of attributes and elements. Problem comes because of default jettison json provider which is configured in cxf-rs. The jettison appends the '@' prefix  with the attributes. However, I needed json free from any prefixes. To achieve this i had configure jackson as json provider like this:

CXF-RS: Java Code Generation from xml/xsd

Cleaner approach is to use xjc like this:

Continue to dirty approach below if u need to:

When working with CXF-RS services often we start with XML message that will be served. After that we go through endless iteration of generating the right Java POJO's for the XML. The library like apache XMLBeans generate the Java code but the code generated is not what a developer would write and generally tedious to modify and understand.

I have come across a work around for generating Java classes from XSD (xml) which is very close to what a developer with decent experience will write. 
Follow the steps given below to explore the solution: 1. Generate the wsdl from from xsd as given in at this link ( 2. The Java classes can be generated from wsdl from maven plugin entry below find complete details here