Hi everybody,
first of all I want to say that ItMill is just awesome. In my opinion, it deserves much more attention in the Java web community than it currently has.
I started to work with Google Guice (http://code.google.com/p/google-guice/) long time ago and it strikingly increases productivity. For those who dont know Guice, its a dependency injection framework in pure java. The upcoming 2.0 even comes along with a neat servlet package that allows the configuration of filters, mappings, and parameters, and also contains some very useful scopes (RequestScope, SessionScope). See: http://code.google.com/p/google-guice/wiki/Servlets
Unfortunately, you only have to change the ApplicationServlet slightly to allow an easy subclassing of it to integrate Guice (currenlty im building my own jar for each release). In fact, only the construction of the Application instance has to be overridden (Guice will use a Provider to construct new Application instances instead of “newInstance”). See the following patch:
--------- PATCH BEGIN -------------
Index: src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
— src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java (revision 6985)
+++ src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java (working copy)
@@ -1498,8 +1498,7 @@
// Creates new application and start it
try {
-
final Application application = (Application) applicationClass
-
.newInstance();
-
final Application application = getNewApplicationInstance(context, request, response); context.addApplication(application); // Sets initial locale from the request
@@ -1516,6 +1515,25 @@
throw e;
}
}
+
-
/**
-
- Constructs a new application instance.
-
-
- @param context
-
-
the context
-
-
- @param request
-
-
the request
-
-
- @param response
-
-
the response
-
-
- @return an instance of the current application
-
- @throws InstantiationException
-
- @throws IllegalAccessException
-
*/
-
protected Application getNewApplicationInstance(WebApplicationContext context, HttpServletRequest request,
-
HttpServletResponse response) throws InstantiationException, IllegalAccessException {
-
final Application application = (Application) applicationClass.newInstance();
-
return application;
-
}
/**
- Ends the application.
--------- PATCH END -------------
Is it possible to change that in some next release?
bye
Martin