PDA

View Full Version : Proceed Method in an Interceptor


spmva
06-03-2005, 08:03 PM
I've been working with the AOP implementation for the past couple of days and have found it to be quite an excellent accomplishment. The design was very intuitive and I was pleased to find that it didn't take long for me to get things running.

Anyway, more in line with the subject of this post, what is the preferred method to disallow processing of a method when implementing an IMethodInterceptor?

In other words, I implement the Invoke method. In that method I decide whether or not to call the Proceed method on the IMethodInvocation and return it's value. Assuming that my course of action within the Invoke method determines that Proceed should NOT be called, what is the best way to notify the client that processing did not take place.

Throwing an exception of some sort sounds logical, but some of my preliminary tests taking that course didn't react as i had suspected they would.

thanks,

steve

Aleks Seovic
06-03-2005, 09:37 PM
Hi Steve,

It really depends on the context. In same cases throwing exception makes sense, in other cases you simply don't call Proceed method on the invocation.

Can you describe in more detail what you are trying to accomplish and what kind of non-logical behavior you experienced when you threw an exception and I'll try to help you out.

Regards,

Aleks

spmva
06-03-2005, 10:04 PM
for discussion sake, let's just talk in terms of a security check. the concept somewhat mirrors what i want to accomplish and is more concrete and universal than my requirements. assume the SecurityInterceptor fails whichever conditions required for the Proceed method to be called.

in that context, not calling the Proceed method (and i assume returning a null from the Invoke method) would seem to leave the client wondering what went wrong on the original call. moreover, a null return could be an acceptable return for that method and the client would never know anything was amiss. for this case, some kind of SecurityCheckException should be thrown, correct?

Aleks Seovic
06-03-2005, 10:44 PM
Yes, you should throw some kind of SecurityException in that case.

Now, what I don't understand is what kind of issue you ran into when you tried to do that.

- Aleks

spmva
06-04-2005, 03:26 AM
my fault...no issue with the exceptions. my logger wasn't configured properly. stupid...