fixed sprnet-967
cleaned up dead code in AbstractAutowireCapableObjectFactory -> code now lives in ObjectDefinitionValueResolver
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<objects
|
||||
xmlns="http://www.springframework.net"
|
||||
xmlns:r="http://www.springframework.net/remoting">
|
||||
|
||||
<!-- server -->
|
||||
<!--
|
||||
<object id="singletonCounter" type="Spring.Remoting.SimpleCounter, Spring.Services.Tests">
|
||||
<constructor-arg index="0" value="1" />
|
||||
</object>
|
||||
|
||||
<r:saoExporter targetName="singletonCounter" serviceName="RemotedSaoSingletonCounter"/>
|
||||
-->
|
||||
<!--
|
||||
Old fashion way without remoting config parser...
|
||||
<object type="Spring.Remoting.SaoExporter, Spring.Services">
|
||||
<property name="TargetName" value="singletonCounter" />
|
||||
<property name="ServiceName" value="RemotedSaoSingletonCounter" />
|
||||
</object>
|
||||
-->
|
||||
|
||||
|
||||
<!-- client -->
|
||||
|
||||
<r:saoFactory id="remoteSaoSingletonCounter"
|
||||
serviceInterface="Spring.Remoting.ISimpleCounter, Spring.Services.Tests"
|
||||
serviceUrl="tcp://localhost:8005/RemotedSaoSingletonCounter"/>
|
||||
|
||||
<object id="counterClient" type="Spring.Remoting.SaoFactoryObjectTests+SPRNET967_SimpleCounterClient, Spring.Services.Tests" autowire="byType" />
|
||||
|
||||
<!--
|
||||
Old fashion way without remoting config parser...
|
||||
<object id="remoteSaoSingletonCounter" type="Spring.Remoting.SaoFactoryObject, Spring.Services">
|
||||
<property name="ServiceInterface" value="Spring.Remoting.ISimpleCounter, Spring.Services.Tests" />
|
||||
<property name="ServiceUrl" value="tcp://localhost:8005/RemotedSaoSingletonCounter" />
|
||||
</object>
|
||||
-->
|
||||
|
||||
</objects>
|
||||
@@ -21,6 +21,7 @@
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Remoting;
|
||||
using System.Runtime.Remoting.Lifetime;
|
||||
using NUnit.Framework;
|
||||
@@ -28,6 +29,7 @@ using Spring.Aop.Framework;
|
||||
using Spring.Context;
|
||||
using Spring.Context.Support;
|
||||
using Spring.Objects;
|
||||
using Spring.Objects.Factory.Config;
|
||||
using Spring.Objects.Factory.Xml;
|
||||
|
||||
#endregion
|
||||
@@ -92,6 +94,84 @@ namespace Spring.Remoting
|
||||
sc.Count();
|
||||
Assert.AreEqual(2, sc.Counter, "Remote object doesn't work in a 'Singleton' mode.");
|
||||
}
|
||||
|
||||
public class SPRNET967_SimpleCounterWrapper : MarshalByRefObject, ISimpleCounter
|
||||
{
|
||||
private ISimpleCounter service;
|
||||
|
||||
public SPRNET967_SimpleCounterWrapper()
|
||||
{}
|
||||
|
||||
public SPRNET967_SimpleCounterWrapper(ISimpleCounter service)
|
||||
{
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public ISimpleCounter Service
|
||||
{
|
||||
get { return service; }
|
||||
set { service = value; }
|
||||
}
|
||||
|
||||
public int Counter
|
||||
{
|
||||
get { return service.Counter; }
|
||||
set { service.Counter = value; }
|
||||
}
|
||||
|
||||
public void Count()
|
||||
{
|
||||
service.Count();
|
||||
}
|
||||
}
|
||||
|
||||
public class SPRNET967_SimpleCounterClient
|
||||
{
|
||||
private ISimpleCounter service;
|
||||
|
||||
public SPRNET967_SimpleCounterClient()
|
||||
{}
|
||||
|
||||
public SPRNET967_SimpleCounterClient(ISimpleCounter service)
|
||||
{
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public ISimpleCounter Service
|
||||
{
|
||||
get { return service; }
|
||||
set { service = value; }
|
||||
}
|
||||
|
||||
public int Counter
|
||||
{
|
||||
get { return service.Counter; }
|
||||
set { service.Counter = value; }
|
||||
}
|
||||
|
||||
public void Count()
|
||||
{
|
||||
service.Count();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSaoWithSingletonModeAutowired_SPRNET967()
|
||||
{
|
||||
// register server by hand to avoid duplicate interfaces
|
||||
SPRNET967_SimpleCounterWrapper svr = new SPRNET967_SimpleCounterWrapper( new SimpleCounter(1) );
|
||||
RemotingServices.Marshal(svr, "RemotedSaoSingletonCounter");
|
||||
|
||||
// object svc = Activator.GetObject(typeof(ISimpleCounter), "tcp://localhost:8005/RemotedSaoSingletonCounter");
|
||||
// Assert.IsTrue( svc is IObjectDefinition );
|
||||
// Assert.IsTrue( svc is ISimpleCounter );
|
||||
|
||||
IApplicationContext ctx = new XmlApplicationContext("assembly://Spring.Services.Tests/Spring.Data.Spring.Remoting/saoSingleton-autowired.xml");
|
||||
ContextRegistry.RegisterContext(ctx);
|
||||
SPRNET967_SimpleCounterClient client = (SPRNET967_SimpleCounterClient) ctx.GetObject("counterClient");
|
||||
client.Count();
|
||||
Assert.AreEqual(2, client.Counter);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSaoWithSingletonModeAndAop()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{4374F018-9738-46BF-A399-4594CEE75B21}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -181,6 +181,12 @@
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Data\Spring\Web\Services\configurableFactory.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Data\Spring\Remoting\saoSingleton-aop.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Data\Spring\Remoting\saoSingleton-autowired.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="ServiceModel\" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user