I'd say just write your own ObjectFactory. It's trivially simple (you only need to override one method) and lookup the injector from there. I wrote something like this for warp-servlet: http://code.google.com/p/warp-datagrid/source/browse/trunk/warp-servlet/src/com/wideplay/warp/servlet/StrutsFactory.java
Good luck! Dhanji. On Fri, Jan 23, 2009 at 3:05 PM, Brian Yarger <[email protected]> wrote: > > Thanks for the quick reply Dhanji. Of course, you're right warp- > persist in no way tries to create an injector, I didn't mean to lump > it in with struts in that regard. Something just feels wrong about > letting struts create the injector to me. I think I'm going to > continue down the path of sharing the injector from my ContextListener > and see where that takes me. > > With that approach is there any way other than sharing the binder > instance passed into my module to allow my ObjectFactory to create > it's bindings after the module has been configured? Is this a safe > thing to do (exposing a reference to the binder)? Can you get a > Binder from an Injector somehow? I didn't see any obvious ways to do > that, but I'm only hours into guice at this point. > > Brian > > On Jan 22, 6:04 pm, "Dhanji R. Prasanna" <[email protected]> wrote: > > On Fri, Jan 23, 2009 at 11:22 AM, Brian Yarger <[email protected]> > wrote: > > > > > I'm working on a little experiment trying to ditch spring in a struts2 > > > project. We are using spring primarily for 3 things; DI, annotations > > > based Transaction support with hibernate/JPA, and authentication/ > > > authorization. > > > > > I've identified guice, warp-persist, and jsecurity to replace our > > > usage of spring. Now, comes the hard part. Each of these frameworks > > > seems to want to be the creator of the guice injector. > > > > warp-persist does not create any injector. The problem as you point out, > is > > really in the struts2 plugin. You should be able to use Guice Servlet 2.0 > > (currently trunk) to achieve what you want. > > > > - Put warp-persist's PersistenceFilter in your ServletModule, rather than > > web.xml. > > > > - Then install it in your struts module (you will have to put struts > filter > > in web.xml *below* GuiceFilter). > > > > - The first request, GuiceFilter will not be configured, so it passes > > through to struts, which creates the injector and runs. On subsequent > > requests, GuiceFilter will intercede with warp-persist, security, etc. > > > > This is a bit hacky, but it gets you there if you don't want to write > your > > own trivial ObjectFactory to look up the injector from your > > ServletContextListener. > > > > Dhanji. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-guice?hl=en -~----------~----~----~----~------~----~------~--~---
