Application SecurityGrails

Spring Security & Grails: Cross domain authentication from HTTP to HTTPS

We were trying to implement SSL-based login and registration (i.e. HTTPS) in an e-commerce web application which was otherwise using the non-secure protocol (i.e. HTTP) for the entire website. Instead of moving the entire web application to SSL, which would have increased response times, we thought it would be best if only the authentication part […]

Grails

How to implement AOP Profiling in Grails application

In one of my recent project, i want to profile method execution time. I have used Spring AOP to profile method execution time. It’s very easy to implement AOP profiling in grails 1. Suppose we have below mentioned service class, we want to log execution time of method saveDataStudent,saveDataUpdated methods in service class. We need […]

Mohit Garg
Mohit Garg
Read

Grails

Attributes of Spring Cache

In my previous blog, i have mentioned how to integrate spring cache plugin in grails. In this blog we will see how we can use different attributes of cache. Different attributes of cache :- maxElementsInMemory- How many elements you can store in cache overflowToDisk-The attribute overflowToDisk is true, meaning that whenever the maximum number of […]

Mohit Garg
Mohit Garg
Read

Grails

How to integrate Spring cache plugin with Grails

In one of my recent project, i want to cache  method output. For implementing method level cache, i have used spring cache. For implement Spring cache, we can use grails cache plugin. It’s very easy to integrate cache plugin with grails. 1. Add following plugin dependency in BuildConfig.groovy. [groovy]compile ":springcache:1.3.1" [/groovy] 2.  We need to […]

Mohit Garg
Mohit Garg
Read

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 void init() { println "Initializing" //your initialization code goes here. e.g connect to some […]

Grails

Integrating Spring AOP with Grails Application

AOP means Aspect Oriented Programming Enables encapsulation of functionality that affects multiple classes in separate units. Complements Object Oriented Programming. Cross Cutting Concerns : Functionality whose implementation spans multiple modules. Different From OOPS Sometimes we want to implement common functionality through out some classes, through out some common method. We can achieve that functionality by […]

Mohit Garg
Mohit Garg
Read

Grails

Overriding properties in a Spring Bean with BeanFactoryPostProcessor

I was going through the source code of one of the Grails Plugins where I found the use of Spring’s BeanDefinitionRegistryPostProcessor to override some configurations that are available in DataSource.groovy. That involved a complete over riding of a PropertyValue definition.   It set me thinking about whether there is a way to override bean properties […]

Grails

Change user preferred locale using spring’s SessionLocaleResolver

Here we are going to talk about a scenario where there are some records in database which are specific to locale and they need to be displayed as per user’s current locale at number of places.Also user can change its preferred locale. For this I preferred to set the user’s locale in the session object. […]

Nitesh
Nitesh
Read

Grails

Request Mocking to use groovyPagesTemplateEngine in backend threads

We have a setup where a backend thread, fired by the Spring Events, does some processing, generates a PDF and emails the result to the user. The code we were using to generate the HTML from a GSP to be converted to a PDF using iText was as follows : [java] def webRequest = RequestContextHolder.getRequestAttributes() […]

Vivek Krishna
Vivek Krishna
Read