Hi,
My group is in the process of evaluating Spring.NET AOP to see if we can leverage it for our existing VB.NET application. To test if it works as expected, I wrote a small sample app (largely rewriting the C# example in the docs for VB.NET, since there aren't really any examples of Spring.NET AOP in a VB.NET app out there.)
In that app, I've got an an aspectized class (ServiceCommand) with two methods: 'Execute' and 'doExecute'. What I am finding is that specifying a regular expression works for the pointcut in most cases, except when that regular expression is 'do'. In this case, the advice (all types including Before, After, and Around) gets applied to both methods, even though the method 'Execute' does not have the substring 'do' anywhere in its name. I'm thinking that this may have something to do with the fact that 'do' is a keyword in .NET.
Here is a code snippet that shows how BeforeAdvice is being applied. When the regular expression is used and I put 'do' into txtRegex, I see that the advice gets applied to both method calls, even though I'd expect it to get applied to 'doExecute' only:
Private Sub cmdBefore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBefore.Click
Dim factory As New Spring.Aop.Framework.ProxyFactory(New ServiceCommand)
If rbRegex.Checked Then
Dim advisor As New Spring.Aop.Support.DefaultPointcutAdvisor(New Spring.Aop.Support.SdkRegularExpressionMethodPoint cut(txtRegex.Text), New BeforeAdvice)
factory.AddAdvisor(advisor)
ElseIf rbAllMethods.Checked Then
factory.AddAdvice(New BeforeAdvice)
End If
Dim command As ICommand = factory.GetProxy()
command.Execute("test advice before invocation")
command.doExecute("test advice before invocation")
End Sub


Reply With Quote
