Spring Integration

Is there something ready for Spring? Any article?

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

tks.

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.
getRequiredWebApplicationContext(servletContext);

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

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";
	
	
	@Override
	public void init() {
		String[] configLocations = StringUtils.tokenizeToStringArray(CONFIG_LOCATION,
				ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS);

		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");
		this.setMainWindow(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…

http://qastegiano.blogspot.com/2008/01/itmill-toolkit-5-spring.html

Quentin.

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!