From ec6525f510b6eed8b6354ee1aad3572d2448399f Mon Sep 17 00:00:00 2001 From: eeichinger Date: Sun, 1 Feb 2009 13:04:43 +0000 Subject: [PATCH] fixed SPRNET-1158 --- .../Spring.Aop/Aop/Framework/AopContext.cs | 24 +++++++++++++++++++ .../Aop/Framework/AopContextTests.cs | 10 ++++++++ 2 files changed, 34 insertions(+) diff --git a/src/Spring/Spring.Aop/Aop/Framework/AopContext.cs b/src/Spring/Spring.Aop/Aop/Framework/AopContext.cs index 45260de6..2e8e5629 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AopContext.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AopContext.cs @@ -87,6 +87,30 @@ namespace Spring.Aop.Framework } } + /// + /// Indicates if the current call is executed under control of an AOP proxy. + /// + /// + ///

+ /// Will be unless the + /// property + /// on the controlling proxy has been set to . + ///

+ ///

+ /// The default value for the + /// property + /// is , for performance reasons. + ///

+ ///
+ public static bool IsActive + { + get + { + Stack proxyStack = LogicalThreadContext.GetData(CURRENTPROXY_SLOTNAME) as Stack; + return (proxyStack != null && proxyStack.Count > 0); + } + } + /// /// Gets the current AOP proxy. /// diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/AopContextTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/AopContextTests.cs index fb324bd8..96be81bd 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Framework/AopContextTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AopContextTests.cs @@ -85,6 +85,16 @@ namespace Spring.Aop.Framework AopContext.PopProxy(); } + [Test] + public void IsActiveMatchesStackState() + { + Assert.IsFalse(AopContext.IsActive); + AopContext.PushProxy("Foo"); + Assert.IsTrue(AopContext.IsActive); + AopContext.PopProxy(); + Assert.IsFalse(AopContext.IsActive); + } + #region CurrentProxyIsThreadSafe [Test(Description = "http://opensource.atlassian.com/projects/spring/browse/SPRNET-341")]