summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2017-02-10 15:48:21 -0500
committerBernard Normier <bernard@zeroc.com>2017-02-10 15:48:21 -0500
commit4b99177fe0b4a7bd8cf3cc05a8cce0149bf41207 (patch)
tree737adda6375612140c3203086d240a749de1e69d
parentFileTracker cleanup and simplifcations (diff)
downloadice-4b99177fe0b4a7bd8cf3cc05a8cce0149bf41207.tar.bz2
ice-4b99177fe0b4a7bd8cf3cc05a8cce0149bf41207.tar.xz
ice-4b99177fe0b4a7bd8cf3cc05a8cce0149bf41207.zip
C# implementation of setPublishedEndpoints
commit e2ec6cd17350f81af4062df53bfd4f828f52540b Author: Bernard Normier <bernard@zeroc.com> Date: Fri Feb 10 12:09:45 2017 -0500 New operation setPublishedEndpoints on ObjectAdapter
-rw-r--r--csharp/src/Ice/ObjectAdapterI.cs59
-rw-r--r--csharp/test/Ice/info/AllTests.cs6
2 files changed, 56 insertions, 9 deletions
diff --git a/csharp/src/Ice/ObjectAdapterI.cs b/csharp/src/Ice/ObjectAdapterI.cs
index 01892c30401..98c1c7bbafc 100644
--- a/csharp/src/Ice/ObjectAdapterI.cs
+++ b/csharp/src/Ice/ObjectAdapterI.cs
@@ -554,6 +554,19 @@ namespace Ice
}
}
+ public Endpoint[] getEndpoints()
+ {
+ lock(this)
+ {
+ List<Endpoint> endpoints = new List<Endpoint>();
+ foreach(IncomingConnectionFactory factory in _incomingConnectionFactories)
+ {
+ endpoints.Add(factory.endpoint());
+ }
+ return endpoints.ToArray();
+ }
+ }
+
public void refreshPublishedEndpoints()
{
LocatorInfo locatorInfo = null;
@@ -588,24 +601,52 @@ namespace Ice
}
}
- public Endpoint[] getEndpoints()
+ public Endpoint[] getPublishedEndpoints()
{
lock(this)
{
- List<Endpoint> endpoints = new List<Endpoint>();
- foreach(IncomingConnectionFactory factory in _incomingConnectionFactories)
- {
- endpoints.Add(factory.endpoint());
- }
- return endpoints.ToArray();
+ return _publishedEndpoints.ToArray();
}
}
- public Endpoint[] getPublishedEndpoints()
+ public void setPublishedEndpoints(Endpoint[] newEndpoints)
{
+ List<EndpointI> newPublishedEndpoints = new List<EndpointI>(newEndpoints.Length);
+
+ foreach(Endpoint e in newEndpoints)
+ {
+ newPublishedEndpoints.Add((EndpointI)e);
+ }
+
+ LocatorInfo locatorInfo = null;
+ List<EndpointI> oldPublishedEndpoints;
+
lock(this)
{
- return _publishedEndpoints.ToArray();
+ checkForDeactivation();
+
+ oldPublishedEndpoints = _publishedEndpoints;
+ _publishedEndpoints = newPublishedEndpoints;
+
+ locatorInfo = _locatorInfo;
+ }
+
+ try
+ {
+ Identity dummy = new Identity();
+ dummy.name = "dummy";
+ updateLocatorRegistry(locatorInfo, createDirectProxy(dummy));
+ }
+ catch(LocalException)
+ {
+ lock(this)
+ {
+ //
+ // Restore the old published endpoints.
+ //
+ _publishedEndpoints = oldPublishedEndpoints;
+ throw;
+ }
}
}
diff --git a/csharp/test/Ice/info/AllTests.cs b/csharp/test/Ice/info/AllTests.cs
index cb62a19f513..7aa17b2131c 100644
--- a/csharp/test/Ice/info/AllTests.cs
+++ b/csharp/test/Ice/info/AllTests.cs
@@ -112,6 +112,12 @@ public class AllTests : TestCommon.AllTests
test(udpEndpoint.datagram());
test(udpEndpoint.port > 0);
+ endpoints = new Ice.Endpoint[]{endpoints[0]};
+ test(endpoints.Length == 1);
+ adapter.setPublishedEndpoints(endpoints);
+ publishedEndpoints = adapter.getPublishedEndpoints();
+ test(IceUtilInternal.Arrays.Equals(endpoints, publishedEndpoints));
+
adapter.destroy();
int port = app.getTestPort(1);