Sometimes we need to access details of current logged in user but that will be an additional database query. To save that query we can use principal object of Spring security which provides details of logged in user . But by default principal object have few fields like id, username and password. If we need to access user's name /...
In Grails, We can define custom beans in resources.groovy. A simple bean definition looks like [java] myClass(MyClass) [/java] Read more about them here. Recently, I wanted to define a bean, where the bean's constructor required me to call a method on another bean to be instantiated. To make it more clear, Let us consider a...
Restricting concurrent sessions for a single user is a very common requirement for any software tool which requires licensing based on number of users. You can read about how we can manage (or allow) concurrent sessions with Grails 2 using Spring security plugin in this awesome concise blog here. let us see how we can allow or...
The final day of SpirngOne 2GX went just like a Mega Finale where they kept best for the last. There were only 3 sessions today, but each one was like one of the best. Here the few highlights of the sessions # Micro Service Architecture with Spring Boot and Groovy : Marco Vermeulen Beautifully explained the concept of micro...
The much awaited conference of the Java ecosystem "SpringOne 2GX" started in Dallas at the Omni Dallas Hotel with a jam packed hall full of eager registrants. The hall was fully packed pretty soon with 1000+ attendees and we talked to around 250+ people about IntelliGrape, Grails and the amazing work we do at IntelliGrape. We were amazed...
Hi all, I have published a new blog post Using Spring Events in Grails. Spring Events are basically used to perform events asynchronously. In my use case I need to save hundreds of records in the database. So I use Spring Events to save records asynchronously. There is a plugin available in Grails for using Spring Events which...
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...
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...
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...
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...
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...
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...