From: <fab...@us...> - 2009-03-04 04:39:59
|
Revision: 4108 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4108&view=rev Author: fabiomaulo Date: 2009-03-04 04:39:58 +0000 (Wed, 04 Mar 2009) Log Message: ----------- ByteCode provider of Spring.NET: 7 test to full support Modified Paths: -------------- trunk/nhibernate/src/NHibernate.ByteCode.Spring/LazyInitializer.cs trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs Modified: trunk/nhibernate/src/NHibernate.ByteCode.Spring/LazyInitializer.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ByteCode.Spring/LazyInitializer.cs 2009-03-03 20:02:23 UTC (rev 4107) +++ trunk/nhibernate/src/NHibernate.ByteCode.Spring/LazyInitializer.cs 2009-03-04 04:39:58 UTC (rev 4108) @@ -12,8 +12,6 @@ [Serializable] public class LazyInitializer : BasicLazyInitializer, IMethodInterceptor, ITargetSource { - private static readonly object NULL = new object(); - private static readonly MethodInfo exceptionInternalPreserveStackTrace = typeof (Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | BindingFlags.NonPublic); @@ -51,7 +49,8 @@ object returnValue; try { - returnValue = base.Invoke(info.Method, info.Arguments, info.Target); + var methodInfo = info.Method; + returnValue = base.Invoke(methodInfo, info.Arguments, info.Proxy); if (returnValue != InvokeImplementation) { @@ -59,7 +58,7 @@ } if (InterceptCalls) { - var method = new SafeMethod(info.Method); + var method = new SafeMethod(methodInfo); return method.Invoke(GetImplementation(), info.Arguments); } } @@ -78,11 +77,7 @@ object ITargetSource.GetTarget() { - if (!IsUninitialized) - { - return Target; - } - return NULL; + return Target ?? this; } void ITargetSource.ReleaseTarget(object target) Modified: trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs 2009-03-03 20:02:23 UTC (rev 4107) +++ trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs 2009-03-04 04:39:58 UTC (rev 4108) @@ -31,10 +31,8 @@ var initializer = new LazyInitializer(EntityName, PersistentClass, id, GetIdentifierMethod, SetIdentifierMethod, ComponentIdType, session); - var proxyFactory = new SerializableProxyFactory(); - proxyFactory.Interfaces = Interfaces; - proxyFactory.TargetSource = initializer; - proxyFactory.ProxyTargetType = IsClassProxy; + var proxyFactory = new SerializableProxyFactory + {Interfaces = Interfaces, TargetSource = initializer, ProxyTargetType = IsClassProxy}; proxyFactory.AddAdvice(initializer); object proxyInstance = proxyFactory.GetProxy(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-03-05 12:54:31
|
Revision: 4115 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4115&view=rev Author: fabiomaulo Date: 2009-03-05 12:54:29 +0000 (Thu, 05 Mar 2009) Log Message: ----------- Minor Modified Paths: -------------- trunk/nhibernate/src/NHibernate.ByteCode.Spring/AbstractProxyFactory.cs trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs Modified: trunk/nhibernate/src/NHibernate.ByteCode.Spring/AbstractProxyFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ByteCode.Spring/AbstractProxyFactory.cs 2009-03-05 07:41:21 UTC (rev 4114) +++ trunk/nhibernate/src/NHibernate.ByteCode.Spring/AbstractProxyFactory.cs 2009-03-05 12:54:29 UTC (rev 4115) @@ -1,5 +1,4 @@ using System.Reflection; -using Common.Logging; using Iesi.Collections.Generic; using NHibernate.Engine; using NHibernate.Proxy; @@ -14,8 +13,6 @@ /// <author>Erich Eichinger (Spring.NET Team)</author> public abstract class AbstractProxyFactory : IProxyFactory { - protected readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected string EntityName { get; private set; } protected System.Type PersistentClass { get; private set; } protected System.Type[] Interfaces { get; private set; } Modified: trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs 2009-03-05 07:41:21 UTC (rev 4114) +++ trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs 2009-03-05 12:54:29 UTC (rev 4115) @@ -1,4 +1,5 @@ using System; +using Common.Logging; using NHibernate.Engine; using NHibernate.Proxy; @@ -12,6 +13,8 @@ /// <author>Erich Eichinger (Spring.NET Team)</author> public class ProxyFactory : AbstractProxyFactory { + private static readonly ILog log = LogManager.GetLogger(typeof(ProxyFactory)); + [Serializable] private class SerializableProxyFactory : global::Spring.Aop.Framework.ProxyFactory { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-03-14 03:09:42
|
Revision: 4125 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4125&view=rev Author: fabiomaulo Date: 2009-03-14 03:09:32 +0000 (Sat, 14 Mar 2009) Log Message: ----------- Improvement by Erich Eichinger Modified Paths: -------------- trunk/nhibernate/src/NHibernate.ByteCode.Spring/LazyInitializer.cs trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs Modified: trunk/nhibernate/src/NHibernate.ByteCode.Spring/LazyInitializer.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ByteCode.Spring/LazyInitializer.cs 2009-03-11 21:26:06 UTC (rev 4124) +++ trunk/nhibernate/src/NHibernate.ByteCode.Spring/LazyInitializer.cs 2009-03-14 03:09:32 UTC (rev 4125) @@ -15,60 +15,35 @@ private static readonly MethodInfo exceptionInternalPreserveStackTrace = typeof (Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | BindingFlags.NonPublic); - private static MethodInfo MapInterfaceMethodToImplementationIfNecessary(MethodInfo methodInfo, - System.Type implementingType) - { - MethodInfo concreteMethodInfo = methodInfo; - - if (methodInfo!= null && methodInfo.DeclaringType.IsInterface) - { - InterfaceMapping interfaceMapping = implementingType.GetInterfaceMap(methodInfo.DeclaringType); - int methodIndex = Array.IndexOf(interfaceMapping.InterfaceMethods, methodInfo); - concreteMethodInfo = interfaceMapping.TargetMethods[methodIndex]; - } - - return concreteMethodInfo; - } - public LazyInitializer(string entityName, System.Type persistentClass, object id, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType, ISessionImplementor session) : base( - entityName, persistentClass, id, MapInterfaceMethodToImplementationIfNecessary(getIdentifierMethod, persistentClass), - MapInterfaceMethodToImplementationIfNecessary(setIdentifierMethod, persistentClass), componentIdType, session) - { - InterceptCalls = true; - } + entityName, persistentClass.IsInterface ? typeof (object) : persistentClass, id, getIdentifierMethod, + setIdentifierMethod, componentIdType, session) {} - public bool InterceptCalls { get; set; } - #region Implementation of IInterceptor public object Invoke(IMethodInvocation info) { - object returnValue; try { - var methodInfo = info.Method; - returnValue = base.Invoke(methodInfo, info.Arguments, info.Proxy); + MethodInfo methodInfo = info.Method; + object returnValue = base.Invoke(methodInfo, info.Arguments, info.Proxy); if (returnValue != InvokeImplementation) { return returnValue; } - if (InterceptCalls) - { - var method = new SafeMethod(methodInfo); - return method.Invoke(GetImplementation(), info.Arguments); - } + + var method = new SafeMethod(methodInfo); + return method.Invoke(GetImplementation(), info.Arguments); } catch (TargetInvocationException ex) { - exceptionInternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] { }); + exceptionInternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] {}); throw ex.InnerException; } - - return returnValue; } #endregion @@ -77,17 +52,14 @@ object ITargetSource.GetTarget() { - return Target ?? this; + return Target; } - void ITargetSource.ReleaseTarget(object target) - { - //throw new System.NotImplementedException(); - } + void ITargetSource.ReleaseTarget(object target) {} System.Type ITargetSource.TargetType { - get { return base.PersistentClass; } + get { return PersistentClass; } } bool ITargetSource.IsStatic Modified: trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs 2009-03-11 21:26:06 UTC (rev 4124) +++ trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactory.cs 2009-03-14 03:09:32 UTC (rev 4125) @@ -13,7 +13,7 @@ /// <author>Erich Eichinger (Spring.NET Team)</author> public class ProxyFactory : AbstractProxyFactory { - private static readonly ILog log = LogManager.GetLogger(typeof(ProxyFactory)); + private static readonly ILog log = LogManager.GetLogger(typeof (ProxyFactory)); [Serializable] private class SerializableProxyFactory : global::Spring.Aop.Framework.ProxyFactory @@ -31,17 +31,14 @@ { try { - var initializer = new LazyInitializer(EntityName, PersistentClass, id, GetIdentifierMethod, SetIdentifierMethod, - ComponentIdType, session); + var initializer = new LazyInitializer(EntityName, PersistentClass.IsInterface ? typeof (object) : PersistentClass, + id, GetIdentifierMethod, SetIdentifierMethod, ComponentIdType, session); var proxyFactory = new SerializableProxyFactory {Interfaces = Interfaces, TargetSource = initializer, ProxyTargetType = IsClassProxy}; proxyFactory.AddAdvice(initializer); object proxyInstance = proxyFactory.GetProxy(); - - initializer.InterceptCalls = true; - return (INHibernateProxy) proxyInstance; } catch (Exception ex) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |