diff --git a/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs b/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs
index 00260543..53e24e78 100644
--- a/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs
+++ b/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs
@@ -377,8 +377,8 @@ namespace Spring.ServiceModel
protected virtual void GenerateProxy()
{
IProxyTypeBuilder builder = new ConfigurableServiceProxyTypeBuilder(
- TargetName, objectFactory.GetType(TargetName), this.objectName, _useServiceProxyTypeCache,
- Name, Namespace, ConfigurationName, CallbackContract, ProtectionLevel, SessionMode, this.objectFactory);
+ TargetName, this.objectName, this.objectFactory, _useServiceProxyTypeCache,
+ Name, Namespace, ConfigurationName, CallbackContract, ProtectionLevel, SessionMode);
if (ContractInterface != null)
{
@@ -409,8 +409,8 @@ namespace Spring.ServiceModel
private CustomAttributeBuilder serviceContractAttribute;
private DefaultListableObjectFactory objectFactory;
- public ConfigurableServiceProxyTypeBuilder(string targetName, Type targetType, string objectName, bool useServiceProxyTypeCache, string name, string ns, string configurationName, Type callbackContract, ProtectionLevel protectionLevel, SessionMode sessionMode, DefaultListableObjectFactory objectFactory)
- : base(targetName, targetType, objectName, useServiceProxyTypeCache)
+ public ConfigurableServiceProxyTypeBuilder(string targetName, string objectName, DefaultListableObjectFactory objectFactory, bool useServiceProxyTypeCache, string name, string ns, string configurationName, Type callbackContract, ProtectionLevel protectionLevel, SessionMode sessionMode)
+ : base(targetName, objectName, objectFactory, useServiceProxyTypeCache)
{
this.objectFactory = objectFactory;
if (!StringUtils.HasText(configurationName))
diff --git a/src/Spring/Spring.Services/ServiceModel/SpringServiceHost.cs b/src/Spring/Spring.Services/ServiceModel/SpringServiceHost.cs
index afafd918..69b95a27 100644
--- a/src/Spring/Spring.Services/ServiceModel/SpringServiceHost.cs
+++ b/src/Spring/Spring.Services/ServiceModel/SpringServiceHost.cs
@@ -108,8 +108,8 @@ namespace Spring.ServiceModel
return objectFactory.GetObject(serviceName) as Type;
}
- return new ServiceProxyTypeBuilder(serviceName, objectFactory.GetType(serviceName), useServiceProxyTypeCache)
- .BuildProxyType(objectFactory);
+ return new ServiceProxyTypeBuilder(serviceName, objectFactory, useServiceProxyTypeCache)
+ .BuildProxyType();
}
#endregion
diff --git a/src/Spring/Spring.Services/ServiceModel/Support/ServiceProxyTypeBuilder.cs b/src/Spring/Spring.Services/ServiceModel/Support/ServiceProxyTypeBuilder.cs
index 5ec4fab5..5f56f052 100644
--- a/src/Spring/Spring.Services/ServiceModel/Support/ServiceProxyTypeBuilder.cs
+++ b/src/Spring/Spring.Services/ServiceModel/Support/ServiceProxyTypeBuilder.cs
@@ -44,6 +44,7 @@ namespace Spring.ServiceModel.Support
private static readonly MethodInfo GetObject =
typeof(IObjectFactory).GetMethod("GetObject", new Type[] { typeof(string) });
+ private IObjectFactory objectFactory;
private static Hashtable s_serviceTypeCache = new Hashtable();
private string targetName;
@@ -63,10 +64,10 @@ namespace Spring.ServiceModel.Support
/// class.
///
/// The name of the service within Spring's IoC container.
- /// The type of the service.
+ /// The to use.
/// Whether to cache the generated service proxy type.
- public ServiceProxyTypeBuilder(string targetName, Type targetType, bool useServiceProxyTypeCache)
- : this(targetName, targetType, targetName, useServiceProxyTypeCache)
+ public ServiceProxyTypeBuilder(string targetName, IObjectFactory objectFactory, bool useServiceProxyTypeCache)
+ : this(targetName, targetName, objectFactory, useServiceProxyTypeCache)
{
}
@@ -76,16 +77,17 @@ namespace Spring.ServiceModel.Support
/// class.
///
/// The name of the service within Spring's IoC container.
- /// The type of the service.
/// The name of the generated WCF service .
+ /// The to use.
/// Whether to cache the generated service proxy type.
- public ServiceProxyTypeBuilder(string targetName, Type targetType, string serviceTypeName, bool useServiceProxyTypeCache)
+ public ServiceProxyTypeBuilder(string targetName, string serviceTypeName, IObjectFactory objectFactory, bool useServiceProxyTypeCache)
{
this.targetName = targetName;
+ this.objectFactory = objectFactory;
this.useServiceProxyTypeCache = useServiceProxyTypeCache;
this.Name = serviceTypeName;
- this.TargetType = targetType;
+ this.TargetType = objectFactory.GetType(targetName);
}
#endregion
@@ -93,17 +95,15 @@ namespace Spring.ServiceModel.Support
#region Protected Methods
///
- /// Creates a proxy that delegates calls to an instance of the target object
- /// and caches the instance.
+ /// Creates a proxy that delegates calls to an instance of the target object.
+ /// This overriden implementation caches the generated proxy type
+ /// and sets the '__objectFactory' field.
///
- ///
- /// The to use to get the target object.
- ///
///
/// If the
/// does not implement any interfaces.
///
- public virtual Type BuildProxyType(IObjectFactory objectFactory)
+ public override Type BuildProxyType()
{
Type proxyType = null;
if (useServiceProxyTypeCache)
@@ -113,18 +113,18 @@ namespace Spring.ServiceModel.Support
proxyType = (Type)s_serviceTypeCache[this.Name];
if (proxyType == null)
{
- proxyType = BuildProxyType();
+ proxyType = base.BuildProxyType();
s_serviceTypeCache[this.Name] = proxyType;
}
}
}
else
{
- proxyType = BuildProxyType();
+ proxyType = base.BuildProxyType();
}
FieldInfo field = proxyType.GetField("__objectFactory", BindingFlags.NonPublic | BindingFlags.Static);
- field.SetValue(proxyType, objectFactory);
+ field.SetValue(proxyType, this.objectFactory);
return proxyType;
}