Evaluating Vaadin, application initialization

I’m looking at Vaadin for the development of internal web applications, and I have a few questions that I need to answer for myself before wholly embracing Vaadin. I’ll use separate posts for these questions.

Is there some hook available in Vaadin that lets me do global application initialization on start-up of whatever servlet container/appserver I use to deploy this in? Eg. on start-up of tomcat I’d need to read configuration files, create database connections etc…

Comparing with the Echo framework, they separate things into an Application (instance of WebContainerServlet) which has an init() method, and an ApplicationInstance, which is an object instance specific to a user session…,

Rgds

Vaadin runs as a servlet, so there is nothing special to do. You can create a simple servlet with load-on-starup to initialize things in a servlet container before any requests to Vaadin application.

If the servlet is in the same servlet context with the Vaadin application, you can easily share objects between them using servlet context. Just do getServletContext() in your “load-on-startup” servlet and store your objects to context. You can access them later from your Vaadin application with ((WebApplicationContext)getContext()).getHttpSession().getServletContext();

But there’s no way to override/extend the HTTPServlet.init() method of the main Vaadin ApplicationServlet class? Would seem like a much cleaner solution to me…

Rgds

It is possible to override ApplicationServlet.init(ServletConfig) (from the Servlet interface and the GenericServlet class - not actually in HttpServlet). You could also directly subclass AbstractApplicationServlet and implement getNewApplication() yourself to setup your application instance based on what the servlet knows.

Note that the servlet instance is not application instance specific - there can be multiple applications running on a single servlet instance.

For a nice example of this see
http://vaadin.com/wiki/-/wiki/Main/Hello%20GlassFish%203