diff --git a/src/Spring/Spring.Aop/Aop/Config/AopNamespaceUtils.cs b/src/Spring/Spring.Aop/Aop/Config/AopNamespaceUtils.cs index ac2e3b53..5354b372 100644 --- a/src/Spring/Spring.Aop/Aop/Config/AopNamespaceUtils.cs +++ b/src/Spring/Spring.Aop/Aop/Config/AopNamespaceUtils.cs @@ -30,7 +30,6 @@ using Spring.Util; #endregion - namespace Spring.Aop.Config { /// @@ -46,39 +45,41 @@ namespace Spring.Aop.Config /// /// The object name of the internally managed auto-proxy creator. /// - 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"; + + /// + /// The type of the APC that handles advisors with object role . + /// + private static readonly Type InfrastructureAutoProxyCreatorType = typeof(InfrastructureAdvisorAutoProxyCreator); + /// - /// Registers the auto proxy creator if necessary. + /// Registers the internal auto proxy creator if necessary. /// /// The parser context. /// The source element. public static void RegisterAutoProxyCreatorIfNecessary(ParserContext parserContext, XmlElement sourceElement) - { - RegisterApcAsRequired(typeof(InfrastructureAdvisorAutoProxyCreator), parserContext); - } - - /// - /// Registries the or escalate apc as required. - /// - /// The type. - /// The parser context. - 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); + } + + /// + /// Registers the internal auto proxy creator if necessary. + /// + 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); + } + } + /// /// Forces the auto proxy creator to use decorator proxy. ///