I would call it AroundInterceptor, except there is already one... The problem with the AroundInterceptor is that the after method doesn't get called if there is an exception thrown in the action, or a chained interceptor. Therefore I created a new interceptor to faciliate this.
I suggest that the existing AroundInterceptor is changed to use the code in my ContainerInterceptor > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Mike Cannon-Brookes > Sent: Thursday, 17 July 2003 1:13 PM > To: [EMAIL PROTECTED] > Subject: Re: [OS-webwork] BeforeAfterInterceptor > > > Using AOP like language - isn't this really an 'AroundInterceptor'? > > M > > On 17/7/03 12:32 PM, "Cameron Braid" ([EMAIL PROTECTED]) > penned the > words: > > > I would think that only 1 abstract interceptor is required, > though the > > one that is provided doesn't allow the after method to respond if > > there is an exception. > > > > Its your call. > > > >> -----Original Message----- > >> From: [EMAIL PROTECTED] > >> [mailto:[EMAIL PROTECTED] > On Behalf > >> Of Pat Lightbody > >> Sent: Thursday, 17 July 2003 1:19 AM > >> To: [EMAIL PROTECTED] > >> Subject: Re: [OS-webwork] BeforeAfterInterceptor > >> > >> > >> This looks fine, but why is it called ContainerInterceptor? > >> > >> This might be yet another example of why interceptor > configurations > >> are a good thing... couldn't this just be a paramter in xwork.xml? > >> Also, couldn't subclasses also just define the behavior > they want by > >> toggling a switch. I'd rather have one base/abstract > interceptor in > >> XWork. > >> > >> -Pat > >> > >> ----- Original Message ----- > >> From: "Cameron Braid" <[EMAIL PROTECTED]> > >> To: <[EMAIL PROTECTED]> > >> Sent: Tuesday, July 15, 2003 10:23 PM > >> Subject: RE: [OS-webwork] BeforeAfterInterceptor > >> > >> > >> I have implemented a ContainerInterceptor that always executed the > >> after method, though it still allows the after processing to be > >> conditional on an exception being thrown. > >> > >> Shall I add it to xwork ? > >> > >> 01 /* > >> 02 * Created on 15/07/2003 > >> 03 * > >> 04 */ > >> 05 package interceptor; > >> 06 > >> 07 import com.opensymphony.xwork.ActionInvocation; > >> 08 import com.opensymphony.xwork.interceptor.Interceptor; > >> 09 > >> 10 /** > >> 11 * > >> 12 * An interceptor that executes an operation before and > after the > >> invocation, irrespective of whether or not 13 * an exception is > >> thrown. 14 * 15 * @author CameronBraid 16 * 17 */ 18 public > >> abstract class ContainerInterceptor implements Interceptor 19 { 20 > >> 21 /** > >> 22 * > >> 23 */ > >> 24 public ContainerInterceptor() > >> 25 { > >> 26 super(); > >> 27 } > >> 28 > >> 29 /* (non-Javadoc) > >> 30 * @see > com.opensymphony.xwork.interceptor.Interceptor#destroy() > >> 31 */ > >> 32 public abstract void destroy(); > >> 33 > >> 34 /* (non-Javadoc) > >> 35 * @see com.opensymphony.xwork.interceptor.Interceptor#init() > >> 36 */ > >> 37 public abstract void init(); > >> 38 > >> 39 public abstract void before(ActionInvocation > invocation) throws > >> Exception; > >> 40 public abstract void after(ActionInvocation invocation, > >> String result, > >> Exception exception) throws Exception; > >> 41 > >> 42 /* (non-Javadoc) > >> 43 * @see > >> com.opensymphony.xwork.interceptor.Interceptor#intercept(com.o > >> pensymphony.xw > >> ork.ActionInvocation) > >> 44 */ > >> 45 public String intercept(ActionInvocation invocation) > >> throws Exception > >> 46 { > >> 47 before(invocation); > >> 48 > >> 49 Exception exception = null; > >> 50 String result = null; > >> 51 > >> 52 try > >> 53 { > >> 54 result = invocation.invoke(); > >> 55 } > >> 56 catch (Exception e) > >> 57 { > >> 58 exception = e; > >> 59 } > >> 60 > >> 61 after(invocation, result, exception); > >> 62 > >> 63 if (exception == null) > >> 64 { > >> 65 return result; > >> 66 } > >> 67 else > >> 68 { > >> 69 throw exception; > >> 70 } > >> 71 > >> 72 } > >> 73 > >> 74 } > >> > >> -----Original Message----- > >> From: [EMAIL PROTECTED] > >> [mailto:[EMAIL PROTECTED] > On Behalf > >> Of Jason Carreira > >> Sent: Tuesday, 15 July 2003 10:48 PM > >> To: [EMAIL PROTECTED] > >> Subject: RE: [OS-webwork] BeforeAfterInterceptor > >> > >> > >> I don't think this is good to do as a general rule. Most times you > >> want to stop processing when an exception occurs. You > could implement > >> this behavior with a couple of carefully placed interceptors. > >> > >> -----Original Message----- > >> From: Cameron Braid [mailto:[EMAIL PROTECTED] > >> Sent: Tuesday, July 15, 2003 5:08 AM > >> To: [EMAIL PROTECTED] > >> Subject: [OS-webwork] BeforeAfterInterceptor > >> > >> > >> When extending the BeforeAfterInterceptor, if the > invocation throws > >> an exception, the after method isn't called. > >> > >> Should the BeforeAfterInterceptor catch the exception, run the > >> after() and then re-throw the exception ? > >> > >> Any thoughts anyone ? > >> > >> > >> > >> > >> ------------------------------------------------------- > >> This SF.net email is sponsored by: VM Ware > >> With VMware you can run multiple operating systems on a single > >> machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual > >> machines at the same time. Free trial click > >> here: http://www.vmware.com/wl/offer/345/0 > >> _______________________________________________ > >> Opensymphony-webwork mailing list > >> [EMAIL PROTECTED] > >> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > >> > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: VM Ware > > With VMware you can run multiple operating systems on a single > > machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual > > machines at the same time. Free trial click here: > > http://www.vmware.com/wl/offer/345/0 > > _______________________________________________ > > Opensymphony-webwork mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems on a > single machine. WITHOUT REBOOTING! Mix Linux / Windows / > Novell virtual machines at the same time. Free trial click > here: http://www.vmware.com/wl/offer/345/0 > _______________________________________________ > Opensymphony-webwork mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > ------------------------------------------------------- This SF.net email is sponsored by: VM Ware With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork