diff --git a/src/Spring/Spring.Aop/Aop/Config/AopNamespaceUtils.cs b/src/Spring/Spring.Aop/Aop/Config/AopNamespaceUtils.cs index 6e332855..25f3b9f3 100644 --- a/src/Spring/Spring.Aop/Aop/Config/AopNamespaceUtils.cs +++ b/src/Spring/Spring.Aop/Aop/Config/AopNamespaceUtils.cs @@ -55,7 +55,7 @@ namespace Spring.Aop.Config /// The source element. public static void RegisterAutoProxyCreatorIfNecessary(ParserContext parserContext, XmlElement sourceElement) { - RegisterApcAsRequired(typeof(DefaultAdvisorAutoProxyCreator), parserContext); + RegisterApcAsRequired(typeof(InfrastructureAdvisorAutoProxyCreator), parserContext); } /// diff --git a/src/Spring/Spring.Aop/Aop/Config/ConfigObjectDefinitionParser.cs b/src/Spring/Spring.Aop/Aop/Config/ConfigObjectDefinitionParser.cs index 9a69bf31..c1fe0d3c 100644 --- a/src/Spring/Spring.Aop/Aop/Config/ConfigObjectDefinitionParser.cs +++ b/src/Spring/Spring.Aop/Aop/Config/ConfigObjectDefinitionParser.cs @@ -128,6 +128,7 @@ namespace Spring.Aop.Config { ObjectDefinitionBuilder advisorDefinitionBuilder = parserContext.ParserHelper.CreateRootObjectDefinitionBuilder(typeof(DefaultObjectFactoryPointcutAdvisor)); + advisorDefinitionBuilder.RawObjectDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE; if (advisorElement.HasAttribute(ORDER_PROPERTY)) { diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs index 1c5a115d..fb9969dd 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs @@ -57,7 +57,7 @@ namespace Spring.Aop.Framework.AutoProxy public abstract class AbstractAdvisorAutoProxyCreator : AbstractAutoProxyCreator { private readonly ILog Log; - private ObjectFactoryAdvisorRetrievalHelper _advisorRetrievalHelper; + private IAdvisorRetrievalHelper _advisorRetrievalHelper; /// /// Initialize @@ -76,12 +76,12 @@ namespace Spring.Aop.Framework.AutoProxy { set { - base.ObjectFactory = value; if (!(value is IConfigurableListableObjectFactory)) { throw new InvalidOperationException("Can not use AdvisorAutoProxyCreator without a ConfigurableListableObjectFactory"); } - InitObjectFactory((IConfigurableListableObjectFactory) value); + base.ObjectFactory = value; + InitObjectFactory((IConfigurableListableObjectFactory)value); } } @@ -92,7 +92,21 @@ namespace Spring.Aop.Framework.AutoProxy /// protected virtual void InitObjectFactory(IConfigurableListableObjectFactory objectFactory) { - _advisorRetrievalHelper = new ObjectFactoryAdvisorRetrievalHelperAdapter(this, objectFactory); + _advisorRetrievalHelper = CreateAdvisorRetrievalHelper(objectFactory); + } + + /// + /// Create the for retrieving the list of + /// applicable advisor objects. The default implementation calls back into + /// thus it usually is sufficient to just + /// override . Override + /// only if you know what you are doing! + /// + /// + /// + protected virtual IAdvisorRetrievalHelper CreateAdvisorRetrievalHelper(IConfigurableListableObjectFactory objectFactory) + { + return new ObjectFactoryAdvisorRetrievalHelperAdapter(this, objectFactory); } /// @@ -264,7 +278,8 @@ namespace Spring.Aop.Framework.AutoProxy protected override bool IsEligibleObject(string advisorName, Type objectType, string objectName) { - return _owner.IsEligibleAdvisorObject(advisorName, objectType, objectName); + return base.IsEligibleObject(advisorName, objectType, objectName) + && _owner.IsEligibleAdvisorObject(advisorName, objectType, objectName); } } } diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs index a4f8d814..3fe16902 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2005 the original author or authors. + * Copyright © 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,6 @@ #endregion -#region Imports - using System; using System.Collections; using System.Reflection; @@ -35,8 +33,6 @@ using Spring.Objects.Factory; using Spring.Objects.Factory.Config; using Spring.Util; -#endregion - namespace Spring.Aop.Framework.AutoProxy { /// @@ -78,7 +74,7 @@ namespace Spring.Aop.Framework.AutoProxy /// /// The logger for this class hierarchy. /// - protected readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected readonly ILog logger; /// /// Convenience constant for subclasses: Return value for "do not proxy". @@ -105,10 +101,13 @@ namespace Spring.Aop.Framework.AutoProxy /// private IAdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.Instance; - /// - /// + /// Indicates whether to mark the create proxy as immutable. /// + /// + /// Setting this to true effectively disables modifying the generated + /// proxy's advisor configuration + /// private bool freezeProxy = false; /// @@ -218,6 +217,18 @@ namespace Spring.Aop.Framework.AutoProxy #endregion + #region Constructor + + /// + /// Create a new instance of this AutoProxyCreator + /// + protected AbstractAutoProxyCreator() + { + logger = LogManager.GetLogger(this.GetType()); + } + + #endregion + #region IObjectPostProcessor Members /// diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs index 2ebf8fb8..3846e6b0 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs @@ -124,7 +124,8 @@ namespace Spring.Aop.Framework.AutoProxy /// the target object's name protected override bool IsEligibleAdvisorObject(string advisorName, Type targetType, string targetName) { - return (!usePrefix || advisorName.StartsWith(advisorObjectNamePrefix)); + return (!usePrefix || advisorName.StartsWith(advisorObjectNamePrefix)) + && base.IsEligibleAdvisorObject(advisorName, targetType, targetName); } /// diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/IAdvisorRetrievalHelper.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/IAdvisorRetrievalHelper.cs new file mode 100644 index 00000000..681b82a7 --- /dev/null +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/IAdvisorRetrievalHelper.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections; + +namespace Spring.Aop.Framework.AutoProxy +{ + /// + /// Interface encapsulating the advisor retrieval strategy used by + /// an to retrieve the + /// applicable list of advisor objects. + /// + public interface IAdvisorRetrievalHelper + { + /// + /// Get the list of advisor objects to apply on the target. + /// + IList FindAdvisorObjects(Type targetType, string targetName); + } +} \ No newline at end of file diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InfrastructureAdvisorAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InfrastructureAdvisorAutoProxyCreator.cs index 4cd266fc..c0ae1973 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InfrastructureAdvisorAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InfrastructureAdvisorAutoProxyCreator.cs @@ -24,22 +24,38 @@ using Spring.Objects.Factory.Config; namespace Spring.Aop.Framework.AutoProxy { /// + /// A special version of an APC that explicitely cares for infrastructure (=internal) + /// advisors only /// /// Erich Eichinger - internal class InfrastructureAdvisorAutoProxyCreator : AbstractAdvisorAutoProxyCreator + public class InfrastructureAdvisorAutoProxyCreator : AbstractAdvisorAutoProxyCreator { - private IConfigurableListableObjectFactory _objectFactory; - - protected override void InitObjectFactory(IConfigurableListableObjectFactory objectFactory) + /// + /// Overridden to create a special version of an + /// that accepts only infrastructure advisor definitions + /// + /// + /// + protected override IAdvisorRetrievalHelper CreateAdvisorRetrievalHelper(IConfigurableListableObjectFactory objectFactory) { - base.InitObjectFactory(objectFactory); - _objectFactory = objectFactory; + return new InfrastructurAdvisorRetrievalHelper(this, objectFactory); } - - protected override bool IsEligibleAdvisorObject(string advisorName, Type targetType, string targetName) + + private class InfrastructurAdvisorRetrievalHelper : ObjectFactoryAdvisorRetrievalHelper { - return _objectFactory.ContainsObjectDefinition(advisorName) - && _objectFactory.GetObjectDefinition(advisorName).Role == ObjectRole.ROLE_INFRASTRUCTURE; + private readonly InfrastructureAdvisorAutoProxyCreator _owner; + + public InfrastructurAdvisorRetrievalHelper(InfrastructureAdvisorAutoProxyCreator owner, IConfigurableListableObjectFactory objectFactory) + : base(objectFactory) + { + _owner = owner; + } + + protected override bool IsEligibleObject(string advisorName, Type objectType, string objectName) + { + return this.ObjectFactory.ContainsObjectDefinition(advisorName) + && this.ObjectFactory.GetObjectDefinition(advisorName).Role == ObjectRole.ROLE_INFRASTRUCTURE; + } } } } \ No newline at end of file diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs index ea81b381..4597be73 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs @@ -32,20 +32,28 @@ namespace Spring.Aop.Framework.AutoProxy /// use with auto-proxying. /// /// Erich Eichinger - public class ObjectFactoryAdvisorRetrievalHelper + public class ObjectFactoryAdvisorRetrievalHelper : IAdvisorRetrievalHelper { private readonly ILog _log; - private readonly IConfigurableListableObjectFactory _owningFactory; + private readonly IConfigurableListableObjectFactory _objectFactory; private string[] _cachedObjectNames; /// - /// Create a new helper for the specified . + /// The object factory to lookup advisors from /// - public ObjectFactoryAdvisorRetrievalHelper(IConfigurableListableObjectFactory owningFactory ) + public IConfigurableListableObjectFactory ObjectFactory { - AssertUtils.ArgumentNotNull(owningFactory, "owningFactory"); + get { return _objectFactory; } + } + + /// + /// Create a new helper for the specified . + /// + public ObjectFactoryAdvisorRetrievalHelper(IConfigurableListableObjectFactory objectFactory ) + { + AssertUtils.ArgumentNotNull(objectFactory, "objectFactory"); _log = LogManager.GetLogger(this.GetType()); - _owningFactory = owningFactory; + _objectFactory = objectFactory; } /// @@ -68,7 +76,7 @@ namespace Spring.Aop.Framework.AutoProxy for (int i = 0; i < advisorNames.Length; i++) { string name = advisorNames[i]; - if (IsEligibleObject(name, targetType, targetName) && !_owningFactory.IsCurrentlyInCreation(name)) + if (IsEligibleObject(name, targetType, targetName) && !_objectFactory.IsCurrentlyInCreation(name)) { try { @@ -80,7 +88,7 @@ namespace Spring.Aop.Framework.AutoProxy if (rootEx is ObjectCurrentlyInCreationException) { ObjectCurrentlyInCreationException oce = (ObjectCurrentlyInCreationException)rootEx; - if (_owningFactory.IsCurrentlyInCreation(oce.ObjectName)) + if (_objectFactory.IsCurrentlyInCreation(oce.ObjectName)) { if (_log.IsDebugEnabled) { @@ -105,7 +113,7 @@ namespace Spring.Aop.Framework.AutoProxy /// the object name of the advisor to add private void AddAdvisorCandidate(ArrayList advisors, string advisorName) { - object advisorCandidate = _owningFactory.GetObject(advisorName); + object advisorCandidate = _objectFactory.GetObject(advisorName); if (advisorCandidate is IAdvisor) { advisors.Add(advisorCandidate); @@ -136,9 +144,9 @@ namespace Spring.Aop.Framework.AutoProxy if (_cachedObjectNames == null) { ArrayList candidateNameList = new ArrayList(); - string[] advisorCandidateNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors( _owningFactory, typeof(IAdvisor), true, false); + string[] advisorCandidateNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors( _objectFactory, typeof(IAdvisor), true, false); candidateNameList.AddRange(advisorCandidateNames); - string[] advisorsCandidateNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(_owningFactory, typeof(IAdvisors), true, false); + string[] advisorsCandidateNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(_objectFactory, typeof(IAdvisors), true, false); candidateNameList.AddRange(advisorsCandidateNames); _cachedObjectNames = (string[]) candidateNameList.ToArray(typeof(string)); } @@ -149,14 +157,16 @@ namespace Spring.Aop.Framework.AutoProxy /// /// Determine, whether the specified aspect object is eligible. - /// The default implementation always returns true. + /// The default implementation accepts all except for advisors that are + /// part of the internal infrastructure. /// /// the name of the candidate advisor /// the type of the object to be advised /// the name of the object to be advised protected virtual bool IsEligibleObject(string advisorName, Type objectType, string objectName ) { - return true; - } + return this.ObjectFactory.ContainsObjectDefinition(advisorName) + && this.ObjectFactory.GetObjectDefinition(advisorName).Role != ObjectRole.ROLE_INFRASTRUCTURE; + } } } \ No newline at end of file diff --git a/src/Spring/Spring.Aop/Spring.Aop.2008.csproj b/src/Spring/Spring.Aop/Spring.Aop.2008.csproj index 76bda49d..008be677 100644 --- a/src/Spring/Spring.Aop/Spring.Aop.2008.csproj +++ b/src/Spring/Spring.Aop/Spring.Aop.2008.csproj @@ -138,6 +138,7 @@ + diff --git a/src/Spring/Spring.Data/Transaction/Config/AttributeDrivenObjectDefinitionParser.cs b/src/Spring/Spring.Data/Transaction/Config/AttributeDrivenObjectDefinitionParser.cs index cfc38e58..f2051028 100644 --- a/src/Spring/Spring.Data/Transaction/Config/AttributeDrivenObjectDefinitionParser.cs +++ b/src/Spring/Spring.Data/Transaction/Config/AttributeDrivenObjectDefinitionParser.cs @@ -71,6 +71,7 @@ namespace Spring.Transaction.Config //Create the TransactionInterceptor definition. RootObjectDefinition interceptorDefinition = new RootObjectDefinition(typeof(TransactionInterceptor)); + interceptorDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE; interceptorDefinition.PropertyValues.Add(TxNamespaceUtils.TRANSACTION_MANAGER_PROPERTY, new RuntimeObjectReference(transactionManagerName)); interceptorDefinition.PropertyValues.Add(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE, @@ -78,6 +79,7 @@ namespace Spring.Transaction.Config //Create the TransactionAttributeSourceAdvisor definition. RootObjectDefinition advisorDefinition = new RootObjectDefinition(typeof(TransactionAttributeSourceAdvisor)); + advisorDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE; advisorDefinition.PropertyValues.Add(TRANSACTION_INTERCEPTOR, interceptorDefinition); if (element.HasAttribute(ORDER)) { diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreatorTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreatorTests.cs new file mode 100644 index 00000000..8b25109f --- /dev/null +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreatorTests.cs @@ -0,0 +1,91 @@ +#region License + +/* + * Copyright 2002-2009 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using System; +using AopAlliance.Aop; +using NUnit.Framework; +using Spring.Objects.Factory.Config; +using Spring.Objects.Factory.Support; + +namespace Spring.Aop.Framework.AutoProxy +{ + /// + /// + /// Erich Eichinger + [TestFixture] + public class AbstractAdvisorAutoProxyCreatorTests + { + public class TestAdvisorAutoProxyCreator : AbstractAdvisorAutoProxyCreator + { + public object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName) + { + return base.GetAdvicesAndAdvisorsForObject(targetType, targetName, null); + } + + protected override bool IsEligibleAdvisorObject(string advisorName, Type targetType, string targetName) + { + return true; + } + } + + public class TestAdvisor : IAdvisor + { + public string Name; + + #region Implementation of IAdvisor + + public bool IsPerInstance + { + get { throw new NotImplementedException(); } + } + + public IAdvice Advice + { + get { throw new NotImplementedException(); } + } + + #endregion + } + + [Test] + public void DoesNotAcceptInfrastructureAdvisorsDuringScanning() + { + DefaultListableObjectFactory of = new DefaultListableObjectFactory(); + + GenericObjectDefinition infrastructureAdvisorDefinition = new GenericObjectDefinition(); + infrastructureAdvisorDefinition.ObjectType = typeof (TestAdvisor); + infrastructureAdvisorDefinition.PropertyValues.Add("Name", "InfrastructureAdvisor"); + infrastructureAdvisorDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE; + of.RegisterObjectDefinition("infrastructure", infrastructureAdvisorDefinition); + + GenericObjectDefinition regularAdvisorDefinition = new GenericObjectDefinition(); + regularAdvisorDefinition.ObjectType = typeof (TestAdvisor); + regularAdvisorDefinition.PropertyValues.Add("Name", "RegularAdvisor"); +// regularAdvisorDefinition.Role = ObjectRole.ROLE_APPLICATION; + of.RegisterObjectDefinition("regular", regularAdvisorDefinition); + + TestAdvisorAutoProxyCreator apc = new TestAdvisorAutoProxyCreator(); + apc.ObjectFactory = of; + object[] advisors = apc.GetAdvicesAndAdvisorsForObject(typeof (object), "dummyTarget"); + Assert.AreEqual(1, advisors.Length); + Assert.AreEqual( "RegularAdvisor", ((TestAdvisor)advisors[0]).Name ); + } + } +} \ No newline at end of file diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAutoProxyCreatorTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAutoProxyCreatorTests.cs index 00f7824d..3b0c787d 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAutoProxyCreatorTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAutoProxyCreatorTests.cs @@ -22,7 +22,6 @@ using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Messaging; using System.Runtime.Remoting.Proxies; -using AopAlliance.Aop; using NUnit.Framework; using Spring.Aop.Interceptor; using Spring.Objects.Factory; diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/InfrastructureAdvisorAutoProxyCreator.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/InfrastructureAdvisorAutoProxyCreator.cs new file mode 100644 index 00000000..8fdbc38c --- /dev/null +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/InfrastructureAdvisorAutoProxyCreator.cs @@ -0,0 +1,86 @@ +#region License + +/* + * Copyright 2002-2009 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using System; +using AopAlliance.Aop; +using NUnit.Framework; +using Spring.Objects.Factory.Config; +using Spring.Objects.Factory.Support; + +namespace Spring.Aop.Framework.AutoProxy +{ + /// + /// + /// Erich Eichinger + [TestFixture] + public class InfrastructureAdvisorAutoProxyCreatorTests + { + public class TestAdvisorAutoProxyCreator : InfrastructureAdvisorAutoProxyCreator + { + public object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName) + { + return base.GetAdvicesAndAdvisorsForObject(targetType, targetName, null); + } + } + + public class TestAdvisor : IAdvisor + { + public string Name; + + #region Implementation of IAdvisor + + public bool IsPerInstance + { + get { throw new NotImplementedException(); } + } + + public IAdvice Advice + { + get { throw new NotImplementedException(); } + } + + #endregion + } + + [Test] + public void DoesAcceptInfrastructureAdvisorsOnlyDuringScanning() + { + DefaultListableObjectFactory of = new DefaultListableObjectFactory(); + + GenericObjectDefinition infrastructureAdvisorDefinition = new GenericObjectDefinition(); + infrastructureAdvisorDefinition.ObjectType = typeof(TestAdvisor); + infrastructureAdvisorDefinition.PropertyValues.Add("Name", "InfrastructureAdvisor"); + infrastructureAdvisorDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE; + of.RegisterObjectDefinition("infrastructure", infrastructureAdvisorDefinition); + + GenericObjectDefinition regularAdvisorDefinition = new GenericObjectDefinition(); + regularAdvisorDefinition.ObjectType = typeof(TestAdvisor); + regularAdvisorDefinition.PropertyValues.Add("Name", "RegularAdvisor"); + // regularAdvisorDefinition.Role = ObjectRole.ROLE_APPLICATION; + of.RegisterObjectDefinition("regular", regularAdvisorDefinition); + + TestAdvisorAutoProxyCreator apc = new TestAdvisorAutoProxyCreator(); + apc.ObjectFactory = of; + object[] advisors = apc.GetAdvicesAndAdvisorsForObject(typeof(object), "dummyTarget"); + Assert.AreEqual(1, advisors.Length); + Assert.AreEqual("InfrastructureAdvisor", ((TestAdvisor)advisors[0]).Name); + } + } +} \ No newline at end of file diff --git a/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.2008.csproj b/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.2008.csproj index 63bc9817..9b9bb748 100644 --- a/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.2008.csproj +++ b/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.2008.csproj @@ -1,7 +1,7 @@  Local - 9.0.21022 + 9.0.30729 2.0 {2111596A-0327-4C9D-8919-294FBD988A23} Debug @@ -125,10 +125,12 @@ Code + +