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...
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 () => { ...
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...
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...
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...
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...