Skip to content

Commit f30a7fa

Browse files
committed
- Port of some base classes to prepare the port of some features from H3.2.5
- Refactoring SVN: trunk@3089
1 parent 694ac2e commit f30a7fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2125
-339
lines changed

src/NHibernate.Test/NHSpecificTest/VersionTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class VersionTest
1010
[Test]
1111
public void UnsavedNegativeIntOrShort()
1212
{
13-
Cascades.VersionValue negative = Cascades.VersionValue.VersionNegative;
13+
VersionValue negative = VersionValue.VersionNegative;
1414

1515
Assert.AreEqual(true, negative.IsUnsaved((short) -1));
1616
Assert.AreEqual(true, negative.IsUnsaved(-1));

src/NHibernate/Bytecode/CodeDom/BytecodeProviderImpl.cs

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ public class BytecodeProviderImpl : IBytecodeProvider
1515
{
1616
private static readonly ILog log = LogManager.GetLogger(typeof(BytecodeProviderImpl));
1717

18+
#region IBytecodeProvider Members
19+
20+
public IProxyFactoryFactory ProxyFactoryFactory
21+
{
22+
get { return new DefaultProxyFactoryFactory(); }
23+
set { throw new NotSupportedException(); }
24+
}
25+
26+
#endregion
27+
1828
public IReflectionOptimizer GetReflectionOptimizer(System.Type clazz, IGetter[] getters, ISetter[] setters)
1929
{
2030
if (clazz.IsValueType)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using NHibernate.Proxy;
3+
4+
namespace NHibernate.Bytecode
5+
{
6+
public class DefaultProxyFactoryFactory : IProxyFactoryFactory
7+
{
8+
private readonly System.Type proxyFactoryClass;
9+
10+
public DefaultProxyFactoryFactory() {}
11+
12+
public DefaultProxyFactoryFactory(System.Type proxyFactoryClass)
13+
{
14+
this.proxyFactoryClass = proxyFactoryClass;
15+
}
16+
17+
#region IProxyFactoryFactory Members
18+
19+
public IProxyFactory BuildProxyFactory()
20+
{
21+
if (proxyFactoryClass == null || proxyFactoryClass == typeof(CastleProxyFactory))
22+
return new CastleProxyFactory();
23+
try
24+
{
25+
return (IProxyFactory)Activator.CreateInstance(proxyFactoryClass);
26+
}
27+
catch (Exception e)
28+
{
29+
throw new HibernateException("Failed to create an instance of '" + proxyFactoryClass.FullName + "'!", e);
30+
}
31+
}
32+
33+
#endregion
34+
}
35+
}
+20-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
using System;
21
using NHibernate.Property;
32

43
namespace NHibernate.Bytecode
54
{
65
public interface IBytecodeProvider
76
{
8-
// Not ported: getProxyFactoryFactory() - there aren't any alternative proxy factory
9-
// implementations yet
7+
/// <summary>
8+
/// The specific factory for this provider capable of
9+
/// generating run-time proxies for lazy-loading purposes.
10+
/// </summary>
11+
IProxyFactoryFactory ProxyFactoryFactory { get; set;}
12+
// NH specific: we add the set method because NH-975; the responsability of
13+
// ProxyFactory is of BytecodeProvider like H3.2
1014

1115
/// <summary>
1216
/// Retrieve the <see cref="IReflectionOptimizer" /> delegate for this provider
@@ -17,5 +21,18 @@ public interface IBytecodeProvider
1721
/// <param name="setters">All property setters to be accessed via reflection.</param>
1822
/// <returns>The reflection optimization delegate.</returns>
1923
IReflectionOptimizer GetReflectionOptimizer(System.Type clazz, IGetter[] getters, ISetter[] setters);
24+
25+
/// <summary> Generate a ClassTransformer capable of performing bytecode manipulation. </summary>
26+
/// <param name="classFilter">
27+
/// filter used to limit which classes are to be instrumented via this ClassTransformer.
28+
/// </param>
29+
/// <param name="fieldFilter">
30+
/// filter used to limit which fields are to be instrumented
31+
/// via this ClassTransformer.
32+
/// </param>
33+
/// <returns> The appropriate ClassTransformer. </returns>
34+
// Not ported
35+
//ClassTransformer getTransformer(ClassFilter classFilter, FieldFilter fieldFilter);
36+
2037
}
2138
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using NHibernate.Proxy;
2+
3+
namespace NHibernate.Bytecode
4+
{
5+
/// <summary>
6+
/// An interface for factories of <see cref="IProxyFactory">proxy factory</see> instances.
7+
/// </summary>
8+
/// <remarks>
9+
/// Currently used to abstract from the tupizer even if...
10+
/// </remarks>
11+
public interface IProxyFactoryFactory
12+
{
13+
/// <summary>
14+
/// Build a proxy factory specifically for handling runtime
15+
/// lazy loading.
16+
/// </summary>
17+
/// <returns> The lazy-load proxy factory. </returns>
18+
IProxyFactory BuildProxyFactory();
19+
20+
/// <summary> Build a proxy factory for basic proxy concerns. The return
21+
/// should be capable of properly handling newInstance() calls.
22+
/// <p/>
23+
/// Should build basic proxies essentially equivalent to JDK proxies in
24+
/// terms of capabilities, but should be able to deal with abstract super
25+
/// classes in addition to proxy interfaces.
26+
/// <p/>
27+
/// Must pass in either superClass or interfaces (or both).
28+
///
29+
/// </summary>
30+
/// <param name="superClass">The abstract super class (or null if none).
31+
/// </param>
32+
/// <param name="interfaces">Interfaces to be proxied (or null if none).
33+
/// </param>
34+
/// <returns> The proxy class
35+
/// </returns>
36+
// TODO: H3.2
37+
//BasicProxyFactory buildBasicProxyFactory(System.Type superClass, System.Type[] interfaces);
38+
}
39+
}

src/NHibernate/Bytecode/Lightweight/BytecodeProviderImpl.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using log4net;
32
using NHibernate.Persister.Entity;
43
using NHibernate.Property;
54

@@ -15,7 +14,15 @@ namespace NHibernate.Bytecode.Lightweight
1514
/// </remarks>
1615
public class BytecodeProviderImpl : IBytecodeProvider
1716
{
18-
private static readonly ILog log = LogManager.GetLogger(typeof(BytecodeProviderImpl));
17+
#region IBytecodeProvider Members
18+
19+
public virtual IProxyFactoryFactory ProxyFactoryFactory
20+
{
21+
get { return new DefaultProxyFactoryFactory(); }
22+
set { throw new NotSupportedException(); }
23+
}
24+
25+
#endregion
1926

2027
/// <summary>
2128
/// Generate the IReflectionOptimizer object

src/NHibernate/Bytecode/NullBytecodeProvider.cs

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ namespace NHibernate.Bytecode
99
/// </summary>
1010
public class NullBytecodeProvider : IBytecodeProvider
1111
{
12+
#region IBytecodeProvider Members
13+
14+
public IProxyFactoryFactory ProxyFactoryFactory
15+
{
16+
get { return new DefaultProxyFactoryFactory(); }
17+
set { throw new NotSupportedException(); }
18+
}
19+
20+
#endregion
21+
1222
public IReflectionOptimizer GetReflectionOptimizer(System.Type clazz, IGetter[] getters, ISetter[] setters)
1323
{
1424
return null;

src/NHibernate/Cfg/Environment.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Reflection;
55
using log4net;
66
using NHibernate.Bytecode;
7-
using NHibernate.Bytecode.CodeDom;
87
using NHibernate.Util;
98
using NHibernate.Cfg.ConfigurationSchema;
109

@@ -294,7 +293,7 @@ private static IBytecodeProvider BuildBytecodeProvider(string providerName)
294293
switch (providerName)
295294
{
296295
case "codedom":
297-
return new BytecodeProviderImpl();
296+
return new Bytecode.CodeDom.BytecodeProviderImpl();
298297
case "lcg":
299298
return new Bytecode.Lightweight.BytecodeProviderImpl();
300299
case "null":

src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ protected void BindComponent(XmlNode node, Component model, System.Type reflecte
550550
FetchMode[] joinedFetch = new FetchMode[span];
551551

552552
int i = 0;
553-
foreach (Mapping.Property prop in model.PropertyCollection)
553+
foreach (Mapping.Property prop in model.PropertyIterator)
554554
{
555555
names[i] = prop.Name;
556556
types[i] = prop.Type;
@@ -569,7 +569,7 @@ protected void BindComponent(XmlNode node, Component model, System.Type reflecte
569569
ISetter[] setters = new ISetter[span];
570570
bool foundCustomAccessor = false;
571571
i = 0;
572-
foreach (Mapping.Property prop in model.PropertyCollection)
572+
foreach (Mapping.Property prop in model.PropertyIterator)
573573
{
574574
setters[i] = prop.GetSetter(model.ComponentClass);
575575
getters[i] = prop.GetGetter(model.ComponentClass);

src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private void BindComponent(Component compositeId, System.Type reflectedClass, st
125125
FetchMode[] joinedFetch = new FetchMode[span];
126126

127127
int i = 0;
128-
foreach (Mapping.Property prop in compositeId.PropertyCollection)
128+
foreach (Mapping.Property prop in compositeId.PropertyIterator)
129129
{
130130
names[i] = prop.Name;
131131
types[i] = prop.Type;
@@ -145,7 +145,7 @@ private void BindComponent(Component compositeId, System.Type reflectedClass, st
145145
ISetter[] setters = new ISetter[span];
146146
bool foundCustomAccessor = false;
147147
i = 0;
148-
foreach (Mapping.Property prop in compositeId.PropertyCollection)
148+
foreach (Mapping.Property prop in compositeId.PropertyIterator)
149149
{
150150
setters[i] = prop.GetSetter(compositeId.ComponentClass);
151151
getters[i] = prop.GetGetter(compositeId.ComponentClass);

src/NHibernate/Cfg/XmlHbmBinding/ResultSetMappingBinder.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private IDictionary BindPropertyResults(string alias, HbmReturnDiscriminator dis
184184
if (value is Component)
185185
{
186186
Component comp = (Component) value;
187-
parentPropIter = comp.PropertyCollection;
187+
parentPropIter = comp.PropertyIterator;
188188
}
189189
else if (value is ToOne)
190190
{
@@ -194,7 +194,7 @@ private IDictionary BindPropertyResults(string alias, HbmReturnDiscriminator dis
194194
try
195195
{
196196
parentPropIter =
197-
((Component) referencedPc.GetRecursiveProperty(toOne.ReferencedPropertyName).Value).PropertyCollection;
197+
((Component) referencedPc.GetRecursiveProperty(toOne.ReferencedPropertyName).Value).PropertyIterator;
198198
}
199199
catch (InvalidCastException e)
200200
{
@@ -203,7 +203,7 @@ private IDictionary BindPropertyResults(string alias, HbmReturnDiscriminator dis
203203
else
204204
try
205205
{
206-
parentPropIter = ((Component) referencedPc.IdentifierProperty.Value).PropertyCollection;
206+
parentPropIter = ((Component) referencedPc.IdentifierProperty.Value).PropertyIterator;
207207
}
208208
catch (InvalidCastException e)
209209
{

0 commit comments

Comments
 (0)