Spring Integration

Is there something ready for Spring? Any article?

or a better question can be: how can I get the session context?


No support for spring is included, but there is nothing that prevents you to use IT Mill Toolkit with Spring.

Did you mean Spring ApplicationContext? If so, then you can treat toolkit apps as servlets. So it would be something like:

ServletContext servletContext = ((WebApplicationContext) yourApplication.getContext()).getHttpSession().getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.

Did not test the above, please tell me if it works :)

Hi Joonas,

I did not tested your solution yet, but I’ve come with another one that is working:

import java.util.Map;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.util.StringUtils;
import org.springframework.web.context.ConfigurableWebApplicationContext;

import br.com.insula.agilejira.itmill.ui.window.MainWindow;

public class Application extends com.itmill.toolkit.Application {

	private MainWindow mainWindow; // this is a simple extended window
	private static final String CONFIG_LOCATION = "classpath*:META-INF/*-context-itmill.xml";
	public void init() {
		String[] configLocations = StringUtils.tokenizeToStringArray(CONFIG_LOCATION,

		ClassPathXmlApplicationContext instanceContext =
			new ClassPathXmlApplicationContext(configLocations);
		Map beans = instanceContext.getBeansOfType(MainWindow.class, false, false);

		if (beans.size() <= 0) {
			throw new NullPointerException("Error capturing MainWindow from Spring context.");
		mainWindow = (MainWindow)beans.get("mainWindow");


Unfortunately it’s not getting the ServerContext yet… just the SpringContext.

Yes it worked Joonas, thanks. :mrgreen:

Great! If you could post a working Spring example code here, it will save the day for the others trying out to use Spring with IT Mill Toolkit.

After reading that post, I wrote that some months ago - more as a personal HowTo than something designed to be read by other, but if it can help anyone…



Sorry Joonas, I haven’t read your request, but I think the example of our friend Quentin is the same I have made.

No worries and thanks to Quentin!