Front End Development, MEAN

Why and how finally{…} block is NOT meaningless

A definition first (from the internet): try-catch-finally is used to handle runtime errors and prevent them from halting the execution of a program. The finally block triggers regardless of: what is implemented inside the try-catch block any errors encountered inside try-catch block any return statement written...

by shivang.chaturvedi
Tag: grails services
25-Jan-2023

MEAN, Node.js

Top level await() without async() function in NodeJs

Here’s how async-await function typically works: function myDummyBackendCall() { return new Promise((resolve) => { setTimeout(() => { resolve({ name: "Shivang", id: "asmdhajkdhajdsh8qweuqoweuiqepoi-0q-0eueiuaisjdaKcjaisku", }); }); }); } // Used an async wrapper function to make an await call (async () => { ...

by shivang.chaturvedi
Tag: grails services
24-Jan-2023

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