fixed SPRNET-1158

This commit is contained in:
eeichinger
2009-02-01 13:04:43 +00:00
parent 2851759002
commit ec6525f510
2 changed files with 34 additions and 0 deletions

View File

@@ -87,6 +87,30 @@ namespace Spring.Aop.Framework
}
}
/// <summary>
/// Indicates if the current call is executed under control of an AOP proxy.
/// </summary>
/// <remarks>
/// <p>
/// Will be <cref lang="null"/> unless the
/// <see cref="Spring.Aop.Framework.ProxyConfig.ExposeProxy"/> property
/// on the controlling proxy has been set to <see langword="true"/>.
/// </p>
/// <p>
/// The default value for the
/// <see cref="Spring.Aop.Framework.ProxyConfig.ExposeProxy"/> property
/// is <see langword="false"/>, for performance reasons.
/// </p>
/// </remarks>
public static bool IsActive
{
get
{
Stack proxyStack = LogicalThreadContext.GetData(CURRENTPROXY_SLOTNAME) as Stack;
return (proxyStack != null && proxyStack.Count > 0);
}
}
/// <summary>
/// Gets the current AOP proxy.
/// </summary>

View File

@@ -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")]