Grails

Using PostConstruct annotation with Grails Services

We can use PostConstruct with Grails Services and injected Spring Beans. This PostConstruct annotation can be used to annotate a method which needs to be executed after dependency injection to perform any initialization. [code] import javax.annotation.PostConstruct class PostConstructDemoService { @PostConstruct private...

by Ankur Tripathi
Tag: grails services
27-Aug-2012

Grails

Discovering grails goodness: Scoped Services

Recently, I got to learn about the scoped services in grails and I found it worth sharing. For instance: A Service marked as 'session' scoped would be instantiated once for a session and remains there throughout the lifetime of the session. This can be used to store user specific data in this service bean class. [java] class...

by Mohd Farid
Tag: grails services
29-Dec-2011

Grails

Using bindData in services

In one of my projects, I was working on rest calls, and one of the requirement was such that I had to pass the XML to service and then parse it and bind the relevant details to an instance of a domain object. In essence I had to call bindData in service after creating a Map from the XML. I soon realised we could not call bindData in...

by Sachin
Tag: grails services
11-Aug-2010

Grails

Overriding default Transactional Behaviour in Grails Services using Annotations

In a project, we needed to have fine tune the transaction behaviour on our Service classes. One service method was calling the a method in another service. The calling service method A was to happen in one transaction and the called service method B in its own transaction. This was required because we needed to persist the error log from...

by Vivek Krishna
Tag: grails services
28-Apr-2010