not sure if this helps, but this is what I did to force the module to
initialize at application startup rather than when the first action is
hit, which is the default behaviour, bit of a hack but it works

extend the struts2 filterdispatcher and use it in the web.xml instead

public class ExtendedFilterDispatcher extends FilterDispatcher {
        @Override
        public void init(FilterConfig filterConfig) throws ServletException {
                super.init(filterConfig);

                try {
                        Container cont = super.dispatcher.getContainer();
                        ObjectFactory.setObjectFactory(cont.getInstance
(ObjectFactory.class));
                        //any valid object will do to trigger GuiceModule 
initialisation
                        //the rest of startups can happen there
                        
ObjectFactory.getObjectFactory().buildBean(QuartzService.class,
null);
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
}

Ron

On Jan 23, 12: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.  I'd ideally
> like to instantiate guice myself, in a ServletContextListener or
> something similar, upstream to all the frameworks that will consume
> it.
>
> This seems like something that isn't that hard to do with both warp-
> persist, and jsecurity, but the problems arise when we get to
> struts2.  Because struts2 expects it's ObjectFactory implementation to
> "discover" all the relavent classes during struts2 initialization I
> have a bit of a chicken and egg problem.  I can't setup the bindings
> to all the struts2 classes (actions, interceptors, results, etc) in my
> Module because they're not known yet.
>
> Is there a proper way to handle adding bindings to an existing guice
> configuration outside a module?  I'm sure I can expose the Binder
> somehow and get it done, but I'd like to know if there is a more
> framework supported or encouraged way to handle this.
>
> Brian Yarger
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to