I think it's perfectly reasonable to use Guice this way. You may want to make sure that you're being careful about not leaking memory (i.e. it looks like your event bus is shared across calls, so you'll want to make sure things like that aren't holding on to the object graph). Also, if you use Guice outside of each request, you may consider using a childInjector to easily get global scope into wherever the request goes. I've personally wanted to try something like this to see if it can better prevent some terrible spaghetti code in a fairly large multi-tenant code base. You should write back in a couple of months how much you liked or disliked your design; I'd love to hear it.
Nate On Wed, May 28, 2014 at 9:56 AM, Luca Miorelli <miorelli.l...@gmail.com>wrote: > Hi, I work with legacy web app that have a ojbect in session scope. > I create a new front end with Vaadin and mvp lite that work togheter with > old Struts front end. > > Now in my vaadin application class at every request, i create a new > injector with an object because i retrieve a UserContextInfo object from > Session that have some infos of user and db name to use. > > private Module createModule(final CreateViewService s) { > Module modules = new AbstractModule() { > > @Override > protected void configure() { > bind(EventBus.class).toInstance(eventBus); > // usercontext info get from request > > bind(UserContextInfoDecorator.class).toInstance(userContextInfo); > > bind(View.class).annotatedWith(ParentViewAnnotation.class).toInstance(s.getParent()); > bind(Parameter.class).toInstance(s.getParameters()); > bind(SecureValidator.class).toInstance(validator); > } > }; > > return modules; > } > > At every request i create a new injector whit this method and catch the > exact instance of UserContextInfo. > > private View createViewInstance(Class<? extends View> clazz, Module > modules) throws GuiException, ProvisionException { > > Injector localInjector = Guice.createInjector(modules); > View instance = localInjector.getInstance(clazz); > > instance.inizialize(validator); > return instance; > } > > It right use of guice? or it's better to exclude instance parameter from > injections? Any suggestion? > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to google-guice+unsubscr...@googlegroups.com. > To post to this group, send email to google-guice@googlegroups.com. > Visit this group at http://groups.google.com/group/google-guice. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice+unsubscr...@googlegroups.com. To post to this group, send email to google-guice@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice. For more options, visit https://groups.google.com/d/optout.