Search This Blog

JAX-RS with GSON and Jersy

Following from the excellent tutorial from Vogella (http://www.vogella.com/articles/REST/article.html ), extending with some extra details.
Using GSON in this as my class had a custom class wrapped in Java collection, GSON makes it very easy to marshall JSON, same also with JAXB using Jersy; But with GSON unmarshalling to Java is also pretty easy. Also multiple parmeter support is shown
So let us start with the interface first. Kindly read Roy Thomas Fielding's 2000 Dissertation, where he described his architecture style for the web
This is a must read for , especially 'architects'. Enough Talk, Let us show some code
Yes read about JAX-RS annotations, otherwise it is a simple Java Class (packaged as a servlet - WAR, see Vogellas article first.
Okay here goes the interface (in rest everything is HTTP,GET,SET, POST etc

Comments

Popular posts from this blog

For easily monitoring the JVM metrics there is no better tool than Java VisualVM or its older counterpart JConsole; These two tools comes with the Java JDK. So it is absolutely necessary that you copy a JDK version to some temp directory in which your server runs. {Make sure that you do not install the JDK / put the java executable in the path.}

Before going in JVM monitoring, it is essential to understand a little about Java's memory model.

Note - This article is written with HotSpot JVM in mind,which is one of the most commonly used one ; implemented by OpenJDK and Oracle - formerly from Sun. This is not the only one , notable being JRockit and others; and some details would change with a different JVM.

When you are running a Java Process in a Server you allocate the Memory for the Java Virtual Machine. This memory is split to process heap { what you give withe the Xmx Xms command}where it is again subdivided on generational basis (Young, Old) and the PermGen - which is grad…

Intermittent failure in Selenium Test cases ?
After clicking the drill down sometimes web-elements are not found causing all summary table test cases to fail.
Common Root Causes
1) Prefer Selection By.ID className then By.cssSelectior and only if all else fails use By.Xpath
Selection by CSS By.CSSSelector should be preferred over XPath as this is more stable as it is natively supported by browser . XPAth is an abstraction provided by Selenium and not as performant. If XPath is used make sure that you have hand written the XPath and it is performant and not generic in that it has to to brute force search through the entire DOM to find your element.
Where ever possible , use By.ID, else By.CSSSelector and in case of no other option use XPath after proper testing.
You can use FireFinder plugin for FireFox (first add FireBug) to test your CSS or Xpath (if there is no way you can select by CSS)
For example this XPath to finding the drill down element //*[@id='scTableTest_Site-PLMN-PL…