|
From: <fab...@us...> - 2009-05-25 22:27:07
|
Revision: 4388
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4388&view=rev
Author: fabiomaulo
Date: 2009-05-25 22:26:28 +0000 (Mon, 25 May 2009)
Log Message:
-----------
Refactoring (common AbstractProxyFactory)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.ByteCode.Castle/ProxyFactory.cs
trunk/nhibernate/src/NHibernate.ByteCode.LinFu/ProxyFactory.cs
trunk/nhibernate/src/NHibernate.ByteCode.Spring/NHibernate.ByteCode.Spring.csproj
trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactoryFactory.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Proxy/AbstractProxyFactory.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.ByteCode.Spring/AbstractProxyFactory.cs
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-25 21:31:19 UTC (rev 4387)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-25 22:26:28 UTC (rev 4388)
@@ -598,6 +598,7 @@
<Compile Include="Hql\Ast\ANTLR\Util\LiteralProcessor.cs" />
<Compile Include="Hql\Ast\ANTLR\Util\NodeTraverser.cs" />
<Compile Include="Param\VersionTypeSeedParameterSpecification.cs" />
+ <Compile Include="Proxy\AbstractProxyFactory.cs" />
<Compile Include="SqlCommand\InsertSelect.cs" />
<Compile Include="Transaction\AdoNetWithDistrubtedTransactionFactory.cs" />
<Compile Include="Transform\ToListResultTransformer.cs" />
Added: trunk/nhibernate/src/NHibernate/Proxy/AbstractProxyFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Proxy/AbstractProxyFactory.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Proxy/AbstractProxyFactory.cs 2009-05-25 22:26:28 UTC (rev 4388)
@@ -0,0 +1,46 @@
+using System.Reflection;
+using Iesi.Collections.Generic;
+using NHibernate.Engine;
+using NHibernate.Type;
+
+namespace NHibernate.Proxy
+{
+ /// <summary>
+ /// Convenient common implementation for ProxyFactory
+ /// </summary>
+ public abstract class AbstractProxyFactory: IProxyFactory
+ {
+ protected virtual string EntityName { get; private set; }
+ protected virtual System.Type PersistentClass { get; private set; }
+ protected virtual System.Type[] Interfaces { get; private set; }
+ protected virtual MethodInfo GetIdentifierMethod { get; private set; }
+ protected virtual MethodInfo SetIdentifierMethod { get; private set; }
+ protected virtual IAbstractComponentType ComponentIdType { get; private set; }
+
+ protected bool IsClassProxy
+ {
+ get { return Interfaces.Length == 1; }
+ }
+
+ public virtual void PostInstantiate(string entityName, System.Type persistentClass, ISet<System.Type> interfaces,
+ MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod,
+ IAbstractComponentType componentIdType)
+ {
+ EntityName = entityName;
+ PersistentClass = persistentClass;
+ Interfaces = new System.Type[interfaces.Count];
+
+ if (interfaces.Count > 0)
+ {
+ interfaces.CopyTo(Interfaces, 0);
+ }
+
+ GetIdentifierMethod = getIdentifierMethod;
+ SetIdentifierMethod = setIdentifierMethod;
+ ComponentIdType = componentIdType;
+ }
+
+
+ public abstract INHibernateProxy GetProxy(object id, ISessionImplementor session);
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.ByteCode.Castle/ProxyFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.ByteCode.Castle/ProxyFactory.cs 2009-05-25 21:31:19 UTC (rev 4387)
+++ trunk/nhibernate/src/NHibernate.ByteCode.Castle/ProxyFactory.cs 2009-05-25 22:26:28 UTC (rev 4388)
@@ -1,95 +1,37 @@
using System;
-using System.Reflection;
using Castle.DynamicProxy;
-using Iesi.Collections.Generic;
using log4net;
using NHibernate.Engine;
using NHibernate.Proxy;
-using NHibernate.Type;
namespace NHibernate.ByteCode.Castle
{
- public class ProxyFactory : IProxyFactory
+ public class ProxyFactory : AbstractProxyFactory
{
protected static readonly ILog log = LogManager.GetLogger(typeof (ProxyFactory));
- private static readonly ProxyGenerator _proxyGenerator = new ProxyGenerator();
+ private static readonly ProxyGenerator ProxyGenerator = new ProxyGenerator();
- private System.Type _persistentClass;
- private System.Type[] _interfaces;
- private MethodInfo _getIdentifierMethod;
- private MethodInfo _setIdentifierMethod;
- private string _entityName;
- private IAbstractComponentType _componentIdType;
-
- public virtual void PostInstantiate(string entityName, System.Type persistentClass, ISet<System.Type> interfaces,
- MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod,
- IAbstractComponentType componentIdType)
- {
- _entityName = entityName;
- _persistentClass = persistentClass;
- _interfaces = new System.Type[interfaces.Count];
- interfaces.CopyTo(_interfaces, 0);
- _getIdentifierMethod = getIdentifierMethod;
- _setIdentifierMethod = setIdentifierMethod;
- _componentIdType = componentIdType;
- }
-
protected static ProxyGenerator DefaultProxyGenerator
{
- get { return _proxyGenerator; }
+ get { return ProxyGenerator; }
}
- protected System.Type PersistentClass
- {
- get { return _persistentClass; }
- }
-
- protected System.Type[] Interfaces
- {
- get { return _interfaces; }
- }
-
- protected MethodInfo GetIdentifierMethod
- {
- get { return _getIdentifierMethod; }
- }
-
- protected MethodInfo SetIdentifierMethod
- {
- get { return _setIdentifierMethod; }
- }
-
- protected bool IsClassProxy
- {
- get { return _interfaces.Length == 1; }
- }
-
- public string EntityName
- {
- get { return _entityName; }
- }
-
- public IAbstractComponentType ComponentIdType
- {
- get { return _componentIdType; }
- }
-
/// <summary>
/// Build a proxy using the Castle.DynamicProxy library.
/// </summary>
/// <param name="id">The value for the Id.</param>
/// <param name="session">The Session the proxy is in.</param>
/// <returns>A fully built <c>INHibernateProxy</c>.</returns>
- public virtual INHibernateProxy GetProxy(object id, ISessionImplementor session)
+ public override INHibernateProxy GetProxy(object id, ISessionImplementor session)
{
try
{
- var initializer = new LazyInitializer(EntityName, _persistentClass, id, _getIdentifierMethod,
- _setIdentifierMethod, ComponentIdType, session);
+ var initializer = new LazyInitializer(EntityName, PersistentClass, id, GetIdentifierMethod,
+ SetIdentifierMethod, ComponentIdType, session);
object generatedProxy = IsClassProxy
- ? _proxyGenerator.CreateClassProxy(_persistentClass, _interfaces, initializer)
- : _proxyGenerator.CreateInterfaceProxyWithoutTarget(_interfaces[0], _interfaces,
+ ? ProxyGenerator.CreateClassProxy(PersistentClass, Interfaces, initializer)
+ : ProxyGenerator.CreateInterfaceProxyWithoutTarget(Interfaces[0], Interfaces,
initializer);
initializer._constructed = true;
Modified: trunk/nhibernate/src/NHibernate.ByteCode.LinFu/ProxyFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.ByteCode.LinFu/ProxyFactory.cs 2009-05-25 21:31:19 UTC (rev 4387)
+++ trunk/nhibernate/src/NHibernate.ByteCode.LinFu/ProxyFactory.cs 2009-05-25 22:26:28 UTC (rev 4388)
@@ -1,57 +1,19 @@
using System;
-using System.Reflection;
-using Iesi.Collections.Generic;
using log4net;
using NHibernate.Engine;
using NHibernate.Proxy;
-using NHibernate.Type;
namespace NHibernate.ByteCode.LinFu
{
- public class ProxyFactory : IProxyFactory
+ public class ProxyFactory : AbstractProxyFactory
{
private static readonly global::LinFu.DynamicProxy.ProxyFactory factory = new global::LinFu.DynamicProxy.ProxyFactory();
protected static readonly ILog log = LogManager.GetLogger(typeof (ProxyFactory));
- protected System.Type PersistentClass { get; private set; }
-
- protected System.Type[] Interfaces { get; private set; }
-
- protected MethodInfo GetIdentifierMethod { get; private set; }
-
- public MethodInfo SetIdentifierMethod { get; private set; }
-
- protected IAbstractComponentType ComponentIdType { get; private set; }
-
- protected string EntityName { get; private set; }
-
- protected bool IsClassProxy
- {
- get { return Interfaces.Length == 1; }
- }
-
#region IProxyFactory Members
- public void PostInstantiate(string entityName, System.Type persistentClass, ISet<System.Type> interfaces,
- MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod,
- IAbstractComponentType componentIdType)
+ public override INHibernateProxy GetProxy(object id, ISessionImplementor session)
{
- EntityName = entityName;
- PersistentClass = persistentClass;
- Interfaces = new System.Type[interfaces.Count];
-
- if (interfaces.Count > 0)
- {
- interfaces.CopyTo(Interfaces, 0);
- }
-
- GetIdentifierMethod = getIdentifierMethod;
- SetIdentifierMethod = setIdentifierMethod;
- ComponentIdType = componentIdType;
- }
-
- public INHibernateProxy GetProxy(object id, ISessionImplementor session)
- {
try
{
var initializer = new LazyInitializer(EntityName, PersistentClass, id, GetIdentifierMethod, SetIdentifierMethod,
Deleted: trunk/nhibernate/src/NHibernate.ByteCode.Spring/AbstractProxyFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.ByteCode.Spring/AbstractProxyFactory.cs 2009-05-25 21:31:19 UTC (rev 4387)
+++ trunk/nhibernate/src/NHibernate.ByteCode.Spring/AbstractProxyFactory.cs 2009-05-25 22:26:28 UTC (rev 4388)
@@ -1,48 +0,0 @@
-using System.Reflection;
-using Iesi.Collections.Generic;
-using NHibernate.Engine;
-using NHibernate.Proxy;
-using NHibernate.Type;
-
-namespace NHibernate.ByteCode.Spring
-{
- /// <summary>
- /// Convenience base class for <see cref="IProxyFactory"/> implementations,
- /// providing common functionality.
- /// </summary>
- /// <author>Erich Eichinger (Spring.NET Team)</author>
- public abstract class AbstractProxyFactory : IProxyFactory
- {
- protected string EntityName { get; private set; }
- protected System.Type PersistentClass { get; private set; }
- protected System.Type[] Interfaces { get; private set; }
- protected MethodInfo GetIdentifierMethod { get; private set; }
- protected MethodInfo SetIdentifierMethod { get; private set; }
- protected IAbstractComponentType ComponentIdType { get; private set; }
-
- protected bool IsClassProxy
- {
- get { return Interfaces.Length == 1; }
- }
-
- public virtual void PostInstantiate(string entityName, System.Type persistentClass, ISet<System.Type> interfaces,
- MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod,
- IAbstractComponentType componentIdType)
- {
- EntityName = entityName;
- PersistentClass = persistentClass;
- Interfaces = new System.Type[interfaces.Count];
-
- if (interfaces.Count > 0)
- {
- interfaces.CopyTo(Interfaces, 0);
- }
-
- GetIdentifierMethod = getIdentifierMethod;
- SetIdentifierMethod = setIdentifierMethod;
- ComponentIdType = componentIdType;
- }
-
- public abstract INHibernateProxy GetProxy(object id, ISessionImplementor session);
- }
-}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.ByteCode.Spring/NHibernate.ByteCode.Spring.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.ByteCode.Spring/NHibernate.ByteCode.Spring.csproj 2009-05-25 21:31:19 UTC (rev 4387)
+++ trunk/nhibernate/src/NHibernate.ByteCode.Spring/NHibernate.ByteCode.Spring.csproj 2009-05-25 22:26:28 UTC (rev 4388)
@@ -63,7 +63,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
- <Compile Include="AbstractProxyFactory.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="LazyInitializer.cs" />
<Compile Include="ProxyFactory.cs" />
Modified: trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactoryFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactoryFactory.cs 2009-05-25 21:31:19 UTC (rev 4387)
+++ trunk/nhibernate/src/NHibernate.ByteCode.Spring/ProxyFactoryFactory.cs 2009-05-25 22:26:28 UTC (rev 4388)
@@ -6,9 +6,6 @@
/// <summary>
/// Creates a Spring for .NET backed <see cref="IProxyFactory"/> instance.
/// </summary>
- /// <remarks>
- /// TODO: mention how to configure
- /// </remarks>
/// <author>Erich Eichinger</author>
public class ProxyFactoryFactory : IProxyFactoryFactory
{
@@ -21,7 +18,6 @@
public IProxyValidator ProxyValidator
{
- // TODO : check what this validator does?
get { return new DynProxyTypeValidator(); }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|