Session state using guice

I have a session state. The first idea of ​​this was session servlets. So I bind my servlet this way

bind(Foo.class).in(ServletScopes.SESSION);

But I get an exception

javax.servlet.ServletException: Servlets must be connected as single. The key [type = Foo, annotation = [none]] was not bound in the Singleton scope.

So servlets can't have scope with ServletScopes? What is the correct way to work with session state (yes, of course, it is better to write state less than servlets / classes / applications)?

+3
source share
2 answers

, , , Foo Servlet, Singleton.

, ( Bar) Foo a Provider<Bar> ( Guice), Foo.

+3

Guice, . : .

, : Guice .

(.. )

+2

Source: https://habr.com/ru/post/1794134/


All Articles