<br /> <b>Warning</b>: Missing argument 2 for issart_title(), called in /var/www/blog.issart.ru/wp-includes/class-wp-hook.php on line 288 and defined in <b>/var/www/blog.issart.ru/wp-content/themes/seashell/functions.php</b> on line <b>289</b><br /> <br /> <b>Warning</b>: Missing argument 3 for issart_title(), called in /var/www/blog.issart.ru/wp-includes/class-wp-hook.php on line 288 and defined in <b>/var/www/blog.issart.ru/wp-content/themes/seashell/functions.php</b> on line <b>289</b><br /> 06.10.2015 - Custom Web Development Blog

Archive - 06.10.2015

Request-scoped resources with Guice and Servlet

Our team was looking for a very simple Java Web framework for one of our projects, and we found the next combination of tools very fascinating:

  • Eclipse Jetty Web server for HTTP request interception
  • Google Guice for dependency injection
  • Java Servlet for request handling

They work together pretty well, and there is a plenty of articles on the Internet covering this topic, so it is easy to get things started. But none of these articles explains how to scope your code in a single HTTP request. By design, servlet is always a singleton. Guice refuses to register servlets as request-scoped objects, so, the whole point of request-scoped object instantiation is being lost. Due to this issue, we’ve almost decided to abandon an idea of using low-level servlets and switch to Jersey framework, which wasn’t very attractive for us as well, for different reasons. But a deeper look to Guice API has saved my day.

Read More