Trifork Blog

Posts Tagged ‘Spring Framework’

GOTO Academy – Training & Courses

January 15th, 2014 by
(http://blog.trifork.com/2014/01/15/goto-academy-training-courses/)
The GOTO Academy is organising regular training sessions around professional software development and architecture.
We are currently running a New Year promo: 20% discount on the iOS trainings.
Take advantage of it! Use the voucher code: TRIFORK2014 to book your seat before end of January 2014. Register here, select the training (iOS beginner or advanced) and type the voucher code in the comment section.

Resolve your NodeData automatically using a @NodeData parameter annotation in your Blossom powered Spring MVC controllers

June 19th, 2012 by
(http://blog.trifork.com/2012/06/19/nodedata-blossom-spring-mvc/)

Resolve all content nodeData values in the signature of your controller method

When we were working on a recent Magnolia project here at Orange11, I introduced Magnolia and Blossom to a colleague of mine. Since Blossom enables the use of  Spring MVC, this enables developers to work on Magnolia integration features, without having to know the entire CMS by heart.

One of the first things my colleague did, was addressing content node properties directly in the signature of the controller method.
When you are used to Spring MVC, you are also used to the fact that any relevant parameters in your method signature will automatically be resolved. But unfortunately I had to inform him that we only get the parameter types that come in through the BlossomWebArgumentResolver out-of-the-box.
Here you can read a bit more about Blossom’s argument resolver, as described by Tobias Mattsson, the founder and lead developer of Blossom.

As the words left my mouth, we both realized that this would be a nice add-on for use in Blossom MVC controllers.

So this is why we introduced the method parameter annotation: @NodeData.
The annotation is quite useful in combination with Blossom. The argument resolver will try and resolve all annotated parameters from the current content node out of the aggregationState.

An example of the use of this annotation:

    @RequestMapping("/myParagraph")
    public String getStuffForMyBlossomParagraph(
        ModelMap modelMap,
        @NodeData String eventCode,
        @NodeData(name="startDate") Date date,
        @NodeData(defaultValue="true") boolean active) {
        ....

The method signature above would lead in the resolving of the following parameter values out of the current content node:

  • String nodeData with name eventCode
  • Date nodeData with name startDate
  • boolean nodeData with name active, that defaults to true when no value is found

This is a very standard thing to do with Spring, but the results can be really powerful and makes the controller in combination with your content very easy to use. Also the mocking of your controller will become that much easier, because you won’t need to extract any data from a Content node anymore, but just pass the value directly as a method parameter.

A full tutorial and zip with sourcecode after the jump.
Read the rest of this entry »

Spring context configuration in Magnolia

May 31st, 2012 by
(http://blog.trifork.com/2012/05/31/spring-context-configuration-in-magnolia/)

Here at Trifork we have quite a Magnolia portfolio. We do not only install, configure and host the actual CMS itself alone, we also design and implement pixel-perfect designs, and last but certainly not least: integrate new or existing business processes from external resources.

When we create any piece of software for such an integration, that software is 90% of the time a Spring configured application. For example, when  we need to load content from an external database into the Data module, or when we want to create a Blossom dialog that renders a select box based on results from an external web service. We create these services in a separate abstraction layer, like most of us would, so that we end up with a nice separate, reusable and testable module. The services we create are usually configured in a number of Spring contexts.

Loading your contexts in the Magnolia admin central.

Are you building your own Magnolia modules instead of Magnolia (1)? Are you letting your modules configure your Magnolia instance (2)?
If the answer to both of these questions is yes, and you do a fair bit of Spring in your modules, you might want to read on!

(1) Grégory Josephs’: Don’t build Magnolia: build your projects.
(2) Grégory Josephs’: Don’t configure Magnolia: let your projects configure it.

Read the rest of this entry »

New in Spring 3.1: Bean definition profiles at a glimpse

July 13th, 2011 by
(http://blog.trifork.com/2011/07/13/new-in-spring-3-bean-definition-profiles-in-a-glimpse/)

The next major release of Spring Framework, 3.1, brings a new feature called bean definition profiles. This is a great add-on which makes the definition of the application context even easier, both in xml and Java-based style. With this new functionality it is possible to group beans into profiles which can be activated at runtime. I will show in this blog post how to leverage bean definition profiles, based on a monitoring use case.

Read the rest of this entry »

Running ActiveMQ using Spring

August 12th, 2010 by
(http://blog.trifork.com/2010/08/12/running-activemq-using-spring/)

Apache ActiveMQ is an open source messaging framework. The ActiveMQ web site is not really clear on how to integrate it with the Spring framework. Therefore, I decided to write this post to explain how to use ActiveMQ in combination with Spring and clarify some points.
The good news is that you can run JMS inside a servlet container (e.g. Apache Tomcat) without the need for a JCA adapter. This means you do not need Jencks or something similar.

Read the rest of this entry »

Implementing RSS Feeds with new features of Spring 3

May 5th, 2010 by
(http://blog.trifork.com/2010/05/05/implementing-rss-feeds-with-new-features-of-spring-3/)

In this post I explain how we implemented the way we created the RSS feeds in a project and the challenges that we had during the set-up.

My colleague Jettro Coenradie explained in a previous post how you can create a feed using Rome and Spring 3, but didn’t elaborated on the Spring 3 part. I will explain how we used Spring 3 to create the feeds.

Read the rest of this entry »

Free Java hosting with the Google App Engine

February 4th, 2010 by
(http://blog.trifork.com/2010/02/04/free-java-hosting-with-the-google-app-engine/)

Lately I have been looking into and playing around with the Google App Engine. In this post I want to give a little introduction to the Google App Engine, why it can be interesting and how to work with it.
Read the rest of this entry »

Migrating content with Spring Integration – A real life example

January 13th, 2010 by
(http://blog.trifork.com/2010/01/13/migrating-content-with-spring-integration-a-real-life-example/)

In one of the projects we need to migrate content from multiple websites into Hippo CMS. One of the interesting parts of this migration is that one of the websites will constantly provide us with updates of the content. Therefore it makes the migration a continuous process.

In this post I will explain how we use Spring Integration to migrate content, handle errors, measure performance and deal with the fact that content could contain references to other content that is not imported yet.

Read the rest of this entry »

Serving a heavy load rss feed with Spring 3 and EHCache

December 17th, 2009 by
(http://blog.trifork.com/2009/12/17/serving-a-heavy-load-rss-feed-with-spring-3-and-ehcache/)

For a project I am doing there was a feature request to come up with an rss component for their new website. This seems pretty easy but the amount of possible feeds (100.000) and the potential for very high load made us think about a custom made solution based on ehcache, spring 3 and rome.

Some of the requirements for the solution have already been mentioned. The following list gives an overview of the things to consider.

    ?

  • Over 100.000 of possible feeds.
  • Every search on the page can be used as a feed
  • Certain feeds will be under very high load
  • Content can easily be cached

Within this post I will discuss the different technical requirements for caching in these kind of solutions. I will also step through the creating of a feed using spring 3 and finally I present the demo application that can actually be used as a web application that exposes news content using a feed as well as a website.

Read the rest of this entry »

Bean Validation: Integrating JSR-303 with Spring

August 4th, 2009 by
(http://blog.trifork.com/2009/08/04/bean-validation-integrating-jsr-303-with-spring/)

I recently had a chance to actually use the new Bean Validation spec. in one of my projects. As the developer of the Bean Validation Framework for Spring (part of the springmodules project) it of course feels a bit weird to ditch all the work I’ve done, but at the same time, it also feels good to use a standard spec that very soon will be finalized. As a member of the JSR-303 expert group (although quite a quiet member) I can assure you that the guys (special kudo’s to Emmanuel Bernard) worked really hard to come up with a specification that will fit in many of the different programming models and technologies we all use (e.g. JPA, JSF, Swing, etc..). In this writing, I’d like to show you a how you can integrate Bean Validation in your Spring based application, especially  if you’re using Spring MVC. Please note, that Spring 3.0 promises to bring such support out of the box, but the last time I checked, it wasn’t implemented yet, and besides, if you’re using Spring 2.x you may find this useful as well.

Read the rest of this entry »