Hello,

I wasn't satisfied with stripes-guicer module. I took a different tack, and it 
seems simpler to me. I'm using the Guice filter as the front end. In the 
stripes-guicer module the stripes filter was the front end. In the end it only 
took one extra class to delegate to Guice to create the action beans.


public class ActionBeanGuicer
        extends NameBasedActionResolver
{
        Injector injector;
        
    @Override
        public void init(Configuration configuration) throws Exception
        {
        injector = 
(Injector)configuration.getServletContext().getAttribute(Injector.class.getName(
));
                super.init(configuration);
        }


        protected ActionBean makeNewActionBean(Class<? extends ActionBean> type,
            ActionBeanContext context) throws Exception 
    {
        return injector.getInstance(type);
    }
}


Then I use Guice's ServletModule to tie everything together.

public class ServletModule 
        extends com.google.inject.servlet.ServletModule
{
        @Override
        protected void configureServlets()
        {
                Map<String, String> params;
                
                params = new HashMap<String, String>();
                params.put("ActionResolver.Packages", "com.sample");
                params.put("ActionResolver.Class", 
"com.sample.stripes.ActionBeanGuicer");
                
                bind(StripesFilter.class).in(Singleton.class);
                bind(DispatcherServlet.class).in(Singleton.class);
                
                filter("/*").through(StripesFilter.class, params);
                serve("*.action").with(DispatcherServlet.class);
        }
        
        
}



------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to