Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/AutoProxy
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv30174/AutoProxy
Modified Files:
AbstractAutoProxyCreator.cs ObjectNameAutoProxyCreator.cs
Log Message:
SPRNET-720 - Change ObjectNameAutoProxyCreator default behavior to proxy the product of a IFactoryObject and not the IFactoryObject itself
SPRNET-721 - Intercept all target interfaces when using an introduction with ObjectNameAutoProxyCreator
Index: AbstractAutoProxyCreator.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** AbstractAutoProxyCreator.cs 22 Aug 2007 08:49:08 -0000 1.11
--- AbstractAutoProxyCreator.cs 7 Sep 2007 01:51:49 -0000 1.12
***************
*** 25,32 ****
using System.Reflection;
using AopAlliance.Aop;
- using AopAlliance.Intercept;
using Common.Logging;
using Spring.Aop.Framework.Adapter;
- using Spring.Aop.Support;
using Spring.Aop.Target;
using Spring.Collections;
--- 25,30 ----
***************
*** 107,110 ****
--- 105,114 ----
private IAdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.Instance;
+
+ /// <summary>
+ ///
+ /// </summary>
+ private bool freezeProxy = false;
+
/// <summary>
/// Names of common interceptors.
***************
*** 197,200 ****
--- 201,219 ----
}
+ /// <summary>
+ /// Set whether or not the proxy should be frozen, preventing advice
+ /// from being added to it once it is created.
+ /// </summary>
+ /// <remarks>
+ /// <p>Overridden from the super class to prevent the proxy configuration
+ /// from being frozen before the proxy is created. The default is not frozen.
+ /// </p>
+ /// </remarks>
+ public override bool IsFrozen
+ {
+ get { return freezeProxy; }
+ set { this.freezeProxy = value; }
+ }
+
#endregion
***************
*** 335,347 ****
}
- /*
- protected virtual bool IsInfrastructureType(object obj, String name)
- {
- return ((obj is IAdvisor)
- || (obj is IAdvice)
- || (obj is IAdvisors)
- || (obj is AbstractAutoProxyCreator));
- }*/
-
/// <summary>
/// Determines whether the object is an infrastructure type,
--- 354,357 ----
***************
*** 430,437 ****
--- 440,462 ----
protected virtual object CreateProxy(Type objectType, string objectName, object[] specificInterceptors, ITargetSource targetSource)
{
+
ProxyFactory proxyFactory = new ProxyFactory();
// copy our properties (proxyTargetClass) inherited from ProxyConfig
proxyFactory.CopyFrom(this);
+ object target = targetSource.GetTarget();
+
+
+ if(!ProxyTargetType)
+ {
+ // Must allow for introductions; can't just set interfaces to
+ // the target's interfaces only.
+ Type[] targetInterfaceTypes = AopUtils.GetAllInterfaces(target);
+ foreach (Type interfaceType in targetInterfaceTypes)
+ {
+ proxyFactory.AddInterface(interfaceType);
+ }
+ }
+
IAdvisor[] advisors = BuildAdvisors(objectName, specificInterceptors);
***************
*** 451,454 ****
--- 476,480 ----
CustomizeProxyFactory(proxyFactory);
+ proxyFactory.IsFrozen = freezeProxy;
return proxyFactory.GetProxy();
}
Index: ObjectNameAutoProxyCreator.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectNameAutoProxyCreator.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ObjectNameAutoProxyCreator.cs 22 Aug 2007 08:49:09 -0000 1.6
--- ObjectNameAutoProxyCreator.cs 7 Sep 2007 01:51:49 -0000 1.7
***************
*** 23,26 ****
--- 23,27 ----
using System;
using System.Collections;
+ using Spring.Objects.Factory;
using Spring.Util;
***************
*** 33,38 ****
--- 34,46 ----
/// </summary>
/// <remarks>
+ /// <para>
/// Auto proxy creator that identifies objects to proxy via a list of names.
/// Checks for direct, "xxx*", "*xxx" and "*xxx*" matches.
+ /// </para>
+ /// <para>In case of a IFactoryObject, only the objects created by the
+ /// FactoryBean will get proxied. If you intend to proxy a IFactoryObject instance itself
+ /// specify the object name of the IFactoryObject including
+ /// the factory-object prefix "&" e.g. "&MyFactoryObject".
+ /// </para>
/// </remarks>
/// <seealso cref="Spring.Aop.Framework.AutoProxy.ObjectNameAutoProxyCreator.SetObjectNames"/>
***************
*** 74,84 ****
if (objectNames != null)
{
! if (objectNames.Contains(name))
! {
! return PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS;
! }
!
! foreach (string mappedName in objectNames)
{
if (IsMatch(name, mappedName))
{
--- 82,96 ----
if (objectNames != null)
{
! for (int i = 0; i < objectNames.Count; i++)
{
+ string mappedName = String.Copy((string) objectNames[i]);
+ if (typeof (IFactoryObject).IsAssignableFrom(objType))
+ {
+ if (!name.StartsWith(ObjectFactoryUtils.FactoryObjectPrefix))
+ {
+ continue;
+ }
+ mappedName = mappedName.Substring(ObjectFactoryUtils.FactoryObjectPrefix.Length);
+ }
if (IsMatch(name, mappedName))
{
|