exposed method RegisterAutoProxyCreatorIfNecessary()

This commit is contained in:
eeichinger
2009-12-14 13:39:54 +00:00
parent 11ae851769
commit 29410497a7

View File

@@ -30,7 +30,6 @@ using Spring.Util;
#endregion
namespace Spring.Aop.Config
{
/// <summary>
@@ -46,39 +45,41 @@ namespace Spring.Aop.Config
/// <summary>
/// The object name of the internally managed auto-proxy creator.
/// </summary>
public static readonly string AUTO_PROXY_CREATOR_OBJECT_NAME = "Spring.Aop.Config.InternalAutoProxyCreator";
public static readonly string AUTO_PROXY_CREATOR_OBJECT_NAME = "Spring.Aop.Config.InternalAutoProxyCreator";
/// <summary>
/// The type of the APC that handles advisors with object role <see cref="ObjectRole.ROLE_INFRASTRUCTURE"/>.
/// </summary>
private static readonly Type InfrastructureAutoProxyCreatorType = typeof(InfrastructureAdvisorAutoProxyCreator);
/// <summary>
/// Registers the auto proxy creator if necessary.
/// Registers the internal auto proxy creator if necessary.
/// </summary>
/// <param name="parserContext">The parser context.</param>
/// <param name="sourceElement">The source element.</param>
public static void RegisterAutoProxyCreatorIfNecessary(ParserContext parserContext, XmlElement sourceElement)
{
RegisterApcAsRequired(typeof(InfrastructureAdvisorAutoProxyCreator), parserContext);
}
/// <summary>
/// Registries the or escalate apc as required.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="parserContext">The parser context.</param>
private static void RegisterApcAsRequired(Type type, ParserContext parserContext)
{
AssertUtils.ArgumentNotNull(parserContext, "parserContext");
IObjectDefinitionRegistry registry = parserContext.Registry;
if (!registry.ContainsObjectDefinition(AUTO_PROXY_CREATOR_OBJECT_NAME))
{
RootObjectDefinition objectDefinition = new RootObjectDefinition(type);
objectDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE;
objectDefinition.PropertyValues.Add("order", int.MaxValue);
registry.RegisterObjectDefinition(AUTO_PROXY_CREATOR_OBJECT_NAME, objectDefinition);
}
}
{
AssertUtils.ArgumentNotNull(parserContext, "parserContext");
IObjectDefinitionRegistry registry = parserContext.Registry;
RegisterAutoProxyCreatorIfNecessary(registry);
}
/// <summary>
/// Registers the internal auto proxy creator if necessary.
/// </summary>
public static void RegisterAutoProxyCreatorIfNecessary(IObjectDefinitionRegistry registry)
{
AssertUtils.ArgumentNotNull(registry, "registry");
if (!registry.ContainsObjectDefinition(AUTO_PROXY_CREATOR_OBJECT_NAME))
{
RootObjectDefinition objectDefinition = new RootObjectDefinition(InfrastructureAutoProxyCreatorType);
objectDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE;
objectDefinition.PropertyValues.Add("order", int.MaxValue);
registry.RegisterObjectDefinition(AUTO_PROXY_CREATOR_OBJECT_NAME, objectDefinition);
}
}
/// <summary>
/// Forces the auto proxy creator to use decorator proxy.
/// </summary>