I'm trying to instantiate my ActionBeans through guice so that I can  
put @Transactional annotations on my event handler methods.  So far it  
seems to be my holy grail for transaction management in a web  
environment, but it is proving difficult to attain.  Has anyone  
successfully done this?

I've identified two problems so far beyond those already identified by  
others on the mailing list (which were apparently solved by using an  
ActionResolver similar to the one I have included below).

1.) @Before/@After annotations are ignored, presumably because the  
BeforeAfterMethodInterceptor is not examining annotations on the  
proxied ActionBean's superclass(es).

2.) Numeric indexed properties (item[0], item[1], etc) are not being  
set on form submission.

Other annotations may not be working either.  I have tested  
@UrlBinding and @ValidationMethod, so I can confirm that they appear  
to be working.

Thanks,
Michael Day

-------------

public class GuiceActionResolver extends NameBasedActionResolver {
     private Injector injector;
     private Set<Class<?>> addedProxies = new HashSet<Class<?>>();

     public void init(Configuration configuration) throws Exception {
         injector = GuiceInjectorHolder.getInjector();
         super.init(configuration);
     }

     @Override
     protected ActionBean makeNewActionBean(Class<? extends  
ActionBean> type, ActionBeanContext context)
             throws Exception {

         ActionBean proxiedActionBean = injector.getInstance(type);

         if (!addedProxies.contains(proxiedActionBean.getClass())) {
             super.addActionBean(proxiedActionBean.getClass());
             addedProxies.add(proxiedActionBean.getClass());
         }

         return proxiedActionBean;
        }
}


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to