Friday, August 28, 2015

JRebel plugin for Magnolia Blossom

Blossom user Arne Diekmann has created a JRebel plugin for development with Blossom and Magnolia. The source along with usage instructions is available on their project page at Bitbucket.

It is a port of the plugin for Spring Loaded I released back in May.

I'm still not sure how to use the Spring Loaded plugin with Eclipse, although I am convinced that it's possible, so for those of you using Eclipse this plugin should come in handy.

Friday, May 29, 2015

Develop faster with the Blossom plugin for Spring Loaded

Spring Loaded is an open source JVM agent that improves on the JVMs hot-code replace functionality. It does for instance make it possible to add, remove and rename methods and add annotations or change their values. Using it while developing means you can avoid restarting the application and save a lot of time.

Since Blossom makes heavy use of annotations Spring Loaded can be a real time saver.

Spring Loaded has basic support for Spring built-in but it's not enough to cover what we need for Blossom. To find templates, dialogs, etc, Blossom scans the beans available and introspects their classes to find the information it needs in their annotations. This needs to be done again every time Spring Loaded reloads a class. For this we need a custom plugin.

The Spring Loaded plugin for Blossom version 1.0 was released today and is available in the Magnolia CMS maven repository.

When added to your project it will automatically find all BlossomDispatcherServlets and refresh their ApplicationContexts. Refreshing an ApplicationContext makes it dispose of all beans its currently managing and creating new ones. It's a pretty costly operation but it's what's needed to make Blossom see the changes. Most applications have their main infrastructure beans that takes time to start in the root web application context and only simpler beans in DispatcherServlets so this should be fine.

It will by default only refresh if it sees a class reloaded that has a Blossom annotation or the @Controller annotation. This can be changed so it refreshes on any change by setting the BlossomSpringLoadedPlugin.refreshOnAnyChange system property to true.


If you have standard DispatcherServlets in your projects it can be useful to have those refreshed as well. If you set the BlossomSpringLoadedPlugin.refreshAllDispatcherServlets system property to true the plugin will refresh those too.


To use the plugin start by downloading the Spring Loaded JAR. Then add it to the JVM using these JVM arguments:

-javaagent:<path to the JAR> -noverify

Then add the plugin dependency to your project.


After this you can start the application in debug mode and reload changes using hot-swap. But since Magnolia projects are multi module maven projects its unfortunately not this easy. Spring Loaded 1.2.3 doesn't reload classes from JAR files. It's been said this is coming in the next release, 1.2.4.

Until 1.2.4 is out you need to reconfigure your development environment to place classes inside WEB-INF/classes instead of inside JAR files in WEB-INF/lib.

I don't know how to do it in Eclipse but I suspect its possible to configure in project properties in the Build Path and Deployment Assembly views. Please leave a comment if you know how to do this.

In IntelliJ you open Project Structure, select Artifacts, click on your artifact (the one that ends in war exploded), then on the Output Layout tab you expand WEB-INF/lib and remove your module. Then scroll back up and add it to WEB-INF/classes.

If you later do reimport of your maven projects in IDEA you'll need to do this again because IDEA will restore the settings.

Hopefully, this should save you a bunch of time!

A huge credit to Thomas Kratz who shared his work on using Magnolia with Blossom and Spring Loaded on his blog and for his ideas on how to improve it!

Thomas also wrote a module for using Thymeleaf with Blossom, great work!

Tuesday, May 5, 2015

Blossom at Spring I/O 2015

Last week the Spring I/O conference was held in Barcelona, Spain. There were sessions covering most of the Spring landscape ranging from WebSocket and Server Sent Events support in MVC to Spring Cloud and Spring XD.

The conference opened with Juergen Hoeller's keynote where he took us back to the inception of Spring Framework and then shared anecdotes and stories through the years up to where we are now and with the Spring team at Pivotal.

I had the pleasure to give a talk on Blossom about how Blossom brings Spring into Magnolia CMS.

It's been eight years since I went to a Spring conference in Europe, the last one was SpringOne 2007 in Antwerp. Europe has been lacking a good Spring conference for years and in my opinion we now have a great one in Spring I/O. Go there in 2016!

Below are the slides from my talk:

Wednesday, October 9, 2013

Blossom 3.0 released

I'm happy to announce that Blossom 3.0 final has been released!

This release is a major update for Magnolia 5, compatible with Magnolia 5.1 and later. In version 5 Magnolia has a brand new user interface and with it comes a new API for dialogs. This version of Blossom is an update for this API and also contains a few other improvements and new features.

Blossom 3 uses a new builder style API for dialogs with a fluent programming style. A new set of classes replaces the previous API. These classes include a new TabBuilder and DialogBuilder and provides builders for each of the built-in fields, making it easier to configure properties on fields.

A new feature in this release is meta-annotations for component availability. It allows for creating custom annotations that can then be used on components to categorise them. They can then be used for specifying which components can go into an area with the @AvailableComponentClasses annotation. All components having a specified annotation will be available.

public @interface Banner {}

public class BannersArea {}

@Template(id = "myModule:components/largePromoBanner", title="Large promo")
public class LargePromoBannerComponent {}

Starting with this release the groupId changes to info.magnolia.blossom, use this snippet for your maven poms.


Using Springs freemarker macros for forms is now straight forward. When rendering freemarker views Blossom will expose a RequestContext object which these macros require, it will also expose everything in the model as request attributes. This feature is enabled by default but can be switched off on the FreemarkerTemplateViewRenderer..

The multipart support that bridges Springs multipart handling to the multipart support in Magnolia has been updated for API changes in Spring 3.1.

New is also AbstractAutowiredRenderingModel which allows for autowiring of RenderingModel classes used outside of Blossom. Very handy.

The sample has also been updated and as always, this is the best place to start.

Get the source and start it up with these commands:

git clone
cd samples
git checkout magnolia-blossom-samples-3.0
mvn install
cd magnolia-blossom-sample-webapp
mvn jetty:run-war

The complete change log can be found in the updated Blossom documentation.

Tuesday, October 8, 2013

Webinar: Blossom Q & A recording online

The recording of my Q & A webinar on Blossom is online. A whole bunch of questions were submitted and I think I managed to answer them all. It starts with an introduction to the module and what's coming up in the next version.

Grab some popcorn, lean back and enjoy!

Friday, September 20, 2013

Blossom 3.0 release candidate 1 released

This week at the Magnolia conference we released Magnolia 5.1 RC1 and with it I released Blossom 3.0 RC1. The feature set is stable since alpha1 but on a deeper level there were many changes to the inner workings of presenting dialogs.

See my earlier blog post on alpha1 for in-depth details on Blossom 3.0 features.

Note that the RC1 of Blossom requires at least Magnolia 5.1 RC1.

UPDATE: The groupId changes to info.magnolia.blossom starting with this release, use this snippet for your maven poms.


Blossom at SpringOne 2GX 2013

I had the pleasure of presenting Blossom and Magnolia CMS at this year's SpringOne conference in Santa Clara California. The conference took place over the course of three intense days with tons of interesting talks. At the keynote Pivotal announced the Spring IO platform and Chris Beams even launched the new site right there on stage.

Our talk was on the first day right after lunch, me and my co-presenter Daniel Lipp showed what Magnolia can do for Spring developers and I shared my experience of integrating it with Spring Web MVC. I wrote the Blossom module so I wouldn't have to write my own CMS for my Spring projects. It surprised me hearing from so many attendees coming to our table in the exhibit hall that that's exactly what many people do.

SpringOne 2GX is also the biggest Grails event of the year. Many attendees I talked to who where there primarily for the Grails talks were thrilled to here about Maglev, the Grails plugin that bundles Magnolia CMS with Blossom and brings it to the Grails platform. Using the same annotation based API but on Grails classes instead.

The slides from the talk is up on slideshare, it was recorded and will be available on youtube soon.