Ok, got it. In this case, your action bean is responsible for validation, web site flow management, some business logic (create a user profile when a new user is registered) and with a @Transactional annotation also for transaction declaration. Doing this breaks the single responsibility principle and mixes the abstraction layers of your application. Additionally the action bean is complex, hard to understand and hard to test. A proper name for this method would be something like registerUserCreateDefaultProfileAndForwardToUsersPageOnSuccess. If a method name gets this long its a good idicator that the method needs refactoring. The name also indicates that the web and business tier is contained in one method and abstraction layers are mixed. I really recommend you to extract the part "registerUserAndCreateDefaultProfile" into a seperate layer. The guice aop part will then work for you.
Did you include the cglib jar? I did not and code runs like expected.(didn't look at perforance). Maybe you give it try and remove the cglib jar. But thats really only a guess and I'm not sure if it'll solve the problem of lost generic supertypes. On Mon, May 25, 2009 at 7:43 PM, Michael Day <[email protected]> wrote: > I don't have anything simple enough to paste here, so I'll make up a > contrived example for user registration: > > public Resolution execute() { > User user = registrationService.registerUser(username, password, > email); > > // let's create an empty user profile for the newly created user > to store their settings > UserProfile profile = userProfileService.createProfile(user); > } > > Now if the createProfile() method throws a RuntimeException for > whatever reason, the user will see an error page. The user will > reasonably think that registration failed, when it in fact succeeded. > I would prefer that the registration gets rolled back. > > On May 25, 2009, at 12:59 PM, Richard Hauswald wrote: > >> would you send me a sample of a method doing some database action? >> >> On Mon, May 25, 2009 at 6:18 PM, Michael Day <[email protected] >> > wrote: >>> Yes, you are correct. But I am hoping to not have to do that. I >>> want >>> the transaction around the entire event handling process so that >>> every >>> database update will be rolled back any time a user sees an error >>> page. >>> >>> On May 25, 2009, at 2:33 AM, Richard Hauswald wrote: >>> >>>> It's not impossible... If you extract the code that needs >>>> interception >>>> into a separate class the ActionBean would not not need to be >>>> enhanced >>>> by cglib. But I'm not sure if I really understood your problem so >>>> excuse me if I'm wrong. >>>> >>>> On Mon, May 25, 2009 at 2:56 AM, Michael Day <[email protected] >>>>> wrote: >>>>> Upon further investigation, I have found that the indexed >>>>> properties >>>>> binding problem occurs because the cglib proxies lose generic types >>>>> from the superclass. I don't know anything about cglib, so maybe >>>>> someone else can provide some insight. >>>>> >>>>> As it stands, using guice to manage ActionBeans with method >>>>> interception appears to be impossible. >>>>> >>>>> On May 24, 2009, at 1:42 PM, Michael Day wrote: >>>>> >>>>>> Richard, >>>>>> >>>>>> Thanks for the suggestion. I looked through the code, and it >>>>>> appears >>>>>> that it would suffer from the same problems I identified. I >>>>>> neglected >>>>>> to mention before that the problems are only occurring with >>>>>> ActionBeans that have been enhanced by cglib. I'm guessing that >>>>>> stripes-guice is working for you because your ActionBeans are not. >>>>>> >>>>>> On May 24, 2009, at 4:08 AM, Richard Hauswald wrote: >>>>>> >>>>>>> Hello Michael, >>>>>>> try to use stripes-guice(http://www.silvermindsoftware.com/stripesguice/ >>>>>>> ) >>>>>>> and bind the interceptors in the guice module(s) using >>>>>>> bindInterceptor. I'm using guice based injection and interceptors >>>>>>> without any problems. Documentation is also great, so give it try >>>>>>> and >>>>>>> don't mix it with stripes-guicer ;-) >>>>>>> Regards, >>>>>>> Richard >>>>>>> >>>>>>> On Sun, May 24, 2009 at 9:00 AM, Michael Day <[email protected] >>>>>>>> wrote: >>>>>>>> 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 >>>>>>>> >>>>>>> >>>>>>> ------------------------------------------------------------------------------ >>>>>>> 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 >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> 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 >>>>>> >>>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> 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 >>>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> 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 >>>> >>>> >>> >>> >>> ------------------------------------------------------------------------------ >>> 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 >>> >> >> ------------------------------------------------------------------------------ >> 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 >> >> > > > ------------------------------------------------------------------------------ > 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 > ------------------------------------------------------------------------------ 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
