Wednesday, May 9, 2012

Grails : Rest Service with JAXB parsing - PART 2

In my last post on Rest Service with JAXB parsing, I showed a very basic example of developing REST Service with Grails Controller and JAXB. In this blog I am going to cover little more advanced features and will mainly be covering following.
  • Collection mapping in JAXB
  • Exception Handling
  • Returning response in XML
  • URLMappings for Grails Controller

Friday, May 4, 2012

Grails : Rest Service with JAXB parsing - PART 1

In this blog I will show how RESTful Web Service can be developed in Grails without the use of any plugins. I will just make use of Grails Controller and JAXB parser to marshal/unmarshal xml.I have divided this into 2 parts blog series. In this blog I will cover very basic usage. In next blog it will be little more advanced with Exception handling.

So let's develop a REST service to create Employee Details. Suppose we have a xml in following format which represents Employee Details.

<?xml version="1.0" encoding="utf-8"?>

Monday, February 20, 2012

Do not use static imports in Groovy/Grails

As per Groovy's documentation, static import is supported and can be used as in java.  However static import usage in Groovy can lead to unpredictable issues. I have been happily using static imports for some time until today when I found very strange issue. Let me demonstrate it with an example of what issue I am talking about.

Groovy/Grails : Hibernate Session Gotchas in multi-threaded code

Click here to view the blog

Saturday, January 14, 2012

With Groovy comes great power of DSL(Domain Specific Language)

Slowly and steadily I have started realizing the power of DSL(Domain Specific Langauge) and I found Groovy a very powerful tool to write DSL. DSL takes programming to next level by allowing  input to a program be given as set of actions than merely a function call.If you want to explore DSL in detail, I would recommend you to read Martin Fowler's book on DSL.

Friday, January 6, 2012

Groovy/Grails : Integration tests for multi-threaded application

Recently I came across a situation in my project, where I had to write integration test for multi-threaded code. Basically I had a business method in service class which executed some portion of it's work in separate thread. Now in order to write integration test for such method, test method should ideally wait for the thread(s) created by service class to complete before asserting result. But there was no way I could figure out if the threads created by service class has completed. So then I thought to refactor my code in a way that I can figure from outside if the threads have got completed or not.