Trifork Blog

Category ‘Groovy’

Writing less code

November 23rd, 2016 by
(http://blog.trifork.com/2016/11/23/writing-less-code/)

Have you had that feeling that you have to write too much code to build simple functionality? Some things just feel repetitive, they feel you should be not have to write them yourself, instead a framework should make your life easier.

Recently I’ve been building a project in Java/Spring, and after some time I┬ástarted wondering about alternatives and how to build the same functionality with less code.

There is lots of alternative frameworks and multiple ways of building rest endpoints in Java/Spring.

  • Building the controller/service/dao layers manually in Spring ; https://spring.io/guides/tutorials/bookmarks/
  • Using spring-data-rest to export your spring-data repositories ; https://spring.io/guides/gs/accessing-data-rest/
  • Groovy/grails RestfulController ; https://examples.javacodegeeks.com/jvm-languages/groovy/grails/grails-rest-example/
  • Python/django django-rest-framework ; http://www.django-rest-framework.org/tutorial/6-viewsets-and-routers/
  • etc

Examples

Below some abbreviated examples of how a simple rest endpoint looks for each approach. To actually run the examples, you’ll need check out the tutorials mentioned earlier. My goal here is a quick comparison of how you do things in each framework.

Read the rest of this entry »

The Spock Framework

July 31st, 2014 by
(http://blog.trifork.com/2014/07/31/the-spock-framework/)

Groovy Logo

In one of my current projects, I started to play around with Groovy and was fascinated how groovy this language is. I got more curious about the way to perform testing and started googling around a little bit. My google research showed me several frameworks to test groovy applications. One of these frameworks is the Spock framework. Spock is created for testing Java and Groovy applications. It has a very clear syntax that is easy to read and it comes with a JUnit runner that ensures you can use it with any of your existing tooling. Furthermore, Spock combines the best features of proven tools like JUnit, jMock, and RSpec, and innovates on top of them. In the first part of the blog I am going to explain how you get started with the Spock framework and how a test method looks like. After that I am going to show how you can use Spock with the Geb framework and what the difference is between testing with Spock alone and Spock combined with Geb. In the end a conclusion is given.

Read the rest of this entry »

Trifork implements Overstapservice Onderwijs (OSO)

December 4th, 2012 by
(http://blog.trifork.com/2012/12/04/trifor-implements-overstapservice-onderwijs/)

Trifork is currently busy implementing the Overstapservice Onderwijs (OSO) Traffic Center, a system that mediates the transfer of student files between schools. The Traffic Center standardizes the exchange of student files between primary- and secondary schools. The OSO project is a continuation of the Electronisch Leerling Dossier (ELD) project. It enables the digital transfer of student related documents between the individual student administration systems (LAS) of schools, regional initiatives and other stakeholders. A major challenge for the Traffic Center is that by law it is not allowed to store the student files, but it is purely facilitating the exchange.

In this blog entry I provide some insights into how the exchange is eventually facilitated and some of the challenges we had with it.

Read the rest of this entry »

Gather content for Lucene from WordPress using Groovy

August 16th, 2011 by
(http://blog.trifork.com/2011/08/16/gather-content-for-lucene-from-wordpress-using-groovy/)

I am learning about the capabilities of Lucene. Here at JTeam we have a few people that are specialized in Search using technology like Lucene and Solr. Therefore I want to have a higher level of knowledge of Lucene than I have now. So I started reading the Lucene in Action book. As I read a book I want to create some samples. When learning about Lucene you need to have content. I decided to gather content from my own website and use it for my Lucene learning.

First challenge, how to get the content from my website and give the content meaning? That is what this blog post is about. I take you on my journey from one end of the groovy spectrum (using the XMLSlurper) to the other end using the XMLRPCServerProxy. During this journey I will also explain some of the basics of the XMLRPC api of wordpress.

Read the rest of this entry »

Cleaning up your maven repository

August 1st, 2011 by
(http://blog.trifork.com/2011/08/01/cleaning-up-your-maven-repository/)

A few days a go I was looking at a warning that my disk was getting to full. I just upgraded to apple osx lion. There were a few things that were related to the upgrade, but another large directory was the maven repository directory. The easy way out is to just remove everything, but I do not want to do that every week. Than I started to think about a solution to delete only part of the repository. As I like playing around with groovy, it must be a groovy script.

So what libraries or artifacts to remove? I want to remove all old snapshots and I want to remove old artifacts of which newer ones have been installed. In this blog post I explain the script, what it can and how it works.

Read the rest of this entry »

Monitoring Hippo Connection pool using JMX and Groovy

August 19th, 2010 by
(http://blog.trifork.com/2010/08/19/monitoring-hippo-connection-pool-using-jmx-and-groovy/)

For a project we are using Hippo to manage our content. We have a few components that interact with the repository using the connection pool as provided by hippo. I have modified the connection pool to increase the amount of logs and I have added statistics to the pool which can be exposed using JMX. Our custom components use this altered connection pool, but I the site did not. Our site makes use of the Hippo Site Toolkit, and I want to have this monitoring available as well.

In this blogpost I will explain the changes I made to the connection pool. After that I’ll show what to do to make this changed connection pool available to a site created with the HST and I’ll show a groovy script that reads the data from the remote servers using the JMX connection.

Read the rest of this entry »

Shebang! Birth of a Groovy script

May 12th, 2009 by
(http://blog.trifork.com/2009/05/12/shebang-birth-of-a-groovy-script/)

For a few days I have been browsing through Groovy in Action and wanted to give Groovy a try. So what should I code? I was busy with other stuff and while I was setting up a wicket project at home I wondered….what was the mvn wicket-quickstart syntax again?! I could have just pasted the command from the wicket site, but I decided to let Groovy handle this one. My first Groovy script was born. Read the rest of this entry »