java - Session state using guice -


i've session scoped state. first idea hold session scoped servlets. bind servlet this

bind(foo.class).in(servletscopes.session); 

but exception

javax.servlet.servletexception: servlets must bound singletons. key[type=foo, annotation=[none]] not bound in singleton scope.

so servlets can't have scope servletscopes? whats right way deal session state (yeah, of course it's better write state less servlets/classes/applications)?

from understanding can bind whatever want session scope, problem in example foo seems subclass of servlet, , servlets must bound in singleton scope.

to resolve this, bind state (called bar) in session scope , give foo constructor provider<bar> argument (which filled in guice) can access session-scoped state singleton-scoped foo servlet.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -