summaryrefslogtreecommitdiff
path: root/csharp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2017-04-27 13:05:25 +0200
committerBenoit Foucher <benoit@zeroc.com>2017-04-27 13:05:25 +0200
commitc5ee6fd5310199110dae6b2d01decbd20174d8db (patch)
treedaf558482821eb3a1ffd496b06ba8bcc2edce841 /csharp
parentExtra whitespace (diff)
downloadice-c5ee6fd5310199110dae6b2d01decbd20174d8db.tar.bz2
ice-c5ee6fd5310199110dae6b2d01decbd20174d8db.tar.xz
ice-c5ee6fd5310199110dae6b2d01decbd20174d8db.zip
Fixed ICE-6680 - WS transports are now provided by a separate IceWS plugin
Diffstat (limited to 'csharp')
-rw-r--r--csharp/src/Ice/EndpointFactory.cs77
-rw-r--r--csharp/src/Ice/EndpointFactoryManager.cs25
-rw-r--r--csharp/src/Ice/Instance.cs23
-rw-r--r--csharp/src/Ice/ProtocolInstance.cs5
-rw-r--r--csharp/src/Ice/TcpEndpointI.cs6
-rw-r--r--csharp/src/Ice/UdpEndpointI.cs6
-rw-r--r--csharp/src/Ice/WSEndpoint.cs37
-rw-r--r--csharp/src/IceSSL/EndpointI.cs39
-rw-r--r--csharp/src/IceSSL/PluginI.cs8
-rw-r--r--csharp/test/Ice/background/EndpointFactory.cs6
10 files changed, 145 insertions, 87 deletions
diff --git a/csharp/src/Ice/EndpointFactory.cs b/csharp/src/Ice/EndpointFactory.cs
index 3bc4e979ea4..225cf374a15 100644
--- a/csharp/src/Ice/EndpointFactory.cs
+++ b/csharp/src/Ice/EndpointFactory.cs
@@ -13,13 +13,88 @@ namespace IceInternal
public interface EndpointFactory
{
+ void initialize();
short type();
string protocol();
EndpointI create(List<string> args, bool oaEndpoint);
EndpointI read(Ice.InputStream s);
void destroy();
- EndpointFactory clone(ProtocolInstance instance, EndpointFactory del);
+ EndpointFactory clone(ProtocolInstance instance);
}
+ abstract public class EndpointFactoryWithUnderlying : EndpointFactory
+ {
+ public EndpointFactoryWithUnderlying(ProtocolInstance instance, short type)
+ {
+ instance_ = instance;
+ _type = type;
+ }
+
+ public void initialize()
+ {
+ //
+ // Get the endpoint factory for the underlying type and clone it with
+ // our protocol instance.
+ //
+ EndpointFactory factory = instance_.getEndpointFactory(_type);
+ if(factory != null)
+ {
+ _underlying = factory.clone(instance_);
+ _underlying.initialize();
+ }
+ }
+
+ public short type()
+ {
+ return instance_.type();
+ }
+
+ public string protocol()
+ {
+ return instance_.protocol();
+ }
+
+ public EndpointI create(List<string> args, bool oaEndpoint)
+ {
+ if(_underlying == null)
+ {
+ return null; // Can't create an endpoint without underlying factory.
+ }
+ return createWithUnderlying(_underlying.create(args, oaEndpoint), args, oaEndpoint);
+ }
+
+ public EndpointI read(Ice.InputStream s)
+ {
+ if(_underlying == null)
+ {
+ return null; // Can't create an endpoint without underlying factory.
+ }
+ return readWithUnderlying(_underlying.read(s), s);
+ }
+
+ public void destroy()
+ {
+ if(_underlying != null)
+ {
+ _underlying.destroy();
+ }
+ instance_ = null;
+ }
+
+ public EndpointFactory clone(ProtocolInstance instance)
+ {
+ return cloneWithUnderlying(instance, _type);
+ }
+
+ abstract public EndpointFactory cloneWithUnderlying(ProtocolInstance instance, short type);
+
+ abstract protected EndpointI createWithUnderlying(EndpointI underlying, List<string> args, bool oaEndpoint);
+ abstract protected EndpointI readWithUnderlying(EndpointI underlying, Ice.InputStream s);
+
+ protected ProtocolInstance instance_;
+
+ private readonly short _type;
+ private EndpointFactory _underlying;
+ }
}
diff --git a/csharp/src/Ice/EndpointFactoryManager.cs b/csharp/src/Ice/EndpointFactoryManager.cs
index 7dc55c990b5..73c31e557aa 100644
--- a/csharp/src/Ice/EndpointFactoryManager.cs
+++ b/csharp/src/Ice/EndpointFactoryManager.cs
@@ -20,13 +20,20 @@ namespace IceInternal
_factories = new List<EndpointFactory>();
}
+ public void initialize()
+ {
+ foreach(EndpointFactory f in _factories)
+ {
+ f.initialize();
+ }
+ }
+
public void add(EndpointFactory factory)
{
lock(this)
{
- for(int i = 0; i < _factories.Count; i++)
+ foreach(EndpointFactory f in _factories)
{
- EndpointFactory f = _factories[i];
if(f.type() == factory.type())
{
Debug.Assert(false);
@@ -40,9 +47,8 @@ namespace IceInternal
{
lock(this)
{
- for(int i = 0; i < _factories.Count; i++)
+ foreach(EndpointFactory f in _factories)
{
- EndpointFactory f = _factories[i];
if(f.type() == type)
{
return f;
@@ -173,7 +179,13 @@ namespace IceInternal
{
e = factory.read(s);
}
- else
+ //
+ // If the factory failed to read the endpoint, return an opaque endpoint. This can
+ // occur if for example the factory delegates to another factory and this factory
+ // isn't available. In this case, the factory needs to make sure the stream position
+ // is preserved for reading the opaque endpoint.
+ //
+ if(e == null)
{
e = new OpaqueEndpointI(type, s);
}
@@ -186,9 +198,8 @@ namespace IceInternal
internal void destroy()
{
- for(int i = 0; i < _factories.Count; i++)
+ foreach(EndpointFactory f in _factories)
{
- EndpointFactory f = (EndpointFactory)_factories[i];
f.destroy();
}
_factories.Clear();
diff --git a/csharp/src/Ice/Instance.cs b/csharp/src/Ice/Instance.cs
index 423b24b96d2..63d3b232a70 100644
--- a/csharp/src/Ice/Instance.cs
+++ b/csharp/src/Ice/Instance.cs
@@ -937,6 +937,13 @@ namespace IceInternal
ProtocolInstance udpInstance = new ProtocolInstance(this, Ice.UDPEndpointType.value, "udp", false);
_endpointFactoryManager.add(new UdpEndpointFactory(udpInstance));
+
+ ProtocolInstance wsInstance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false);
+ _endpointFactoryManager.add(new WSEndpointFactory(wsInstance, Ice.TCPEndpointType.value));
+
+ ProtocolInstance wssInstance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true);
+ _endpointFactoryManager.add(new WSEndpointFactory(wssInstance, Ice.SSLEndpointType.value));
+
_pluginManager = new Ice.PluginManagerI(communicator);
if(_initData.valueFactoryManager == null)
@@ -983,20 +990,10 @@ namespace IceInternal
pluginManagerImpl.loadPlugins(ref args);
//
- // Add WS and WSS endpoint factories if TCP/SSL factories are installed.
+ // Initialize the endpoint factories once all the plugins are loaded. This gives
+ // the opportunity for the endpoint factories to find underyling factories.
//
- EndpointFactory tcpFactory = _endpointFactoryManager.get(Ice.TCPEndpointType.value);
- if(tcpFactory != null)
- {
- ProtocolInstance instance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false);
- _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance, null)));
- }
- EndpointFactory sslFactory = _endpointFactoryManager.get(Ice.SSLEndpointType.value);
- if(sslFactory != null)
- {
- ProtocolInstance instance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true);
- _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance, null)));
- }
+ _endpointFactoryManager.initialize();
//
// Create Admin facets, if enabled.
diff --git a/csharp/src/Ice/ProtocolInstance.cs b/csharp/src/Ice/ProtocolInstance.cs
index 6cd500e44f1..83b843eefbc 100644
--- a/csharp/src/Ice/ProtocolInstance.cs
+++ b/csharp/src/Ice/ProtocolInstance.cs
@@ -52,6 +52,11 @@ namespace IceInternal
return logger_;
}
+ public EndpointFactory getEndpointFactory(short type)
+ {
+ return instance_.endpointFactoryManager().get(type);
+ }
+
public string protocol()
{
return protocol_;
diff --git a/csharp/src/Ice/TcpEndpointI.cs b/csharp/src/Ice/TcpEndpointI.cs
index 0f0e7d628ac..9d6f7c6b6af 100644
--- a/csharp/src/Ice/TcpEndpointI.cs
+++ b/csharp/src/Ice/TcpEndpointI.cs
@@ -299,6 +299,10 @@ namespace IceInternal
_instance = instance;
}
+ public void initialize()
+ {
+ }
+
public short type()
{
return _instance.type();
@@ -326,7 +330,7 @@ namespace IceInternal
_instance = null;
}
- public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del)
+ public EndpointFactory clone(ProtocolInstance instance)
{
return new TcpEndpointFactory(instance);
}
diff --git a/csharp/src/Ice/UdpEndpointI.cs b/csharp/src/Ice/UdpEndpointI.cs
index 45a9adcf6e6..45dd6199f14 100644
--- a/csharp/src/Ice/UdpEndpointI.cs
+++ b/csharp/src/Ice/UdpEndpointI.cs
@@ -436,6 +436,10 @@ namespace IceInternal
_instance = instance;
}
+ public void initialize()
+ {
+ }
+
public short type()
{
return _instance.type();
@@ -463,7 +467,7 @@ namespace IceInternal
_instance = null;
}
- public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del)
+ public EndpointFactory clone(ProtocolInstance instance)
{
return new UdpEndpointFactory(instance);
}
diff --git a/csharp/src/Ice/WSEndpoint.cs b/csharp/src/Ice/WSEndpoint.cs
index 2749388f585..ef6df9486e8 100644
--- a/csharp/src/Ice/WSEndpoint.cs
+++ b/csharp/src/Ice/WSEndpoint.cs
@@ -342,46 +342,25 @@ namespace IceInternal
private string _resource;
}
- public class WSEndpointFactory : EndpointFactory
+ public class WSEndpointFactory : EndpointFactoryWithUnderlying
{
- public WSEndpointFactory(ProtocolInstance instance, EndpointFactory del)
+ public WSEndpointFactory(ProtocolInstance instance, short type) : base(instance, type)
{
- _instance = instance;
- _delegate = del;
}
- public short type()
+ override public EndpointFactory cloneWithUnderlying(ProtocolInstance instance, short underlying)
{
- return _instance.type();
+ return new WSEndpointFactory(instance, underlying);
}
- public string protocol()
+ override protected EndpointI createWithUnderlying(EndpointI underlying, List<string> args, bool oaEndpoint)
{
- return _instance.protocol();
+ return new WSEndpoint(instance_, underlying, args);
}
- public EndpointI create(List<string> args, bool oaEndpoint)
+ override protected EndpointI readWithUnderlying(EndpointI underlying, Ice.InputStream s)
{
- return new WSEndpoint(_instance, _delegate.create(args, oaEndpoint), args);
+ return new WSEndpoint(instance_, underlying, s);
}
-
- public EndpointI read(Ice.InputStream s)
- {
- return new WSEndpoint(_instance, _delegate.read(s), s);
- }
-
- public void destroy()
- {
- _delegate.destroy();
- _instance = null;
- }
-
- public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del)
- {
- return new WSEndpointFactory(instance, del);
- }
-
- private ProtocolInstance _instance;
- private EndpointFactory _delegate;
}
}
diff --git a/csharp/src/IceSSL/EndpointI.cs b/csharp/src/IceSSL/EndpointI.cs
index 13028f96428..3ed47be71e0 100644
--- a/csharp/src/IceSSL/EndpointI.cs
+++ b/csharp/src/IceSSL/EndpointI.cs
@@ -267,48 +267,31 @@ namespace IceSSL
private IceInternal.EndpointI _delegate;
}
- internal sealed class EndpointFactoryI : IceInternal.EndpointFactory
+ internal sealed class EndpointFactoryI : IceInternal.EndpointFactoryWithUnderlying
{
- internal EndpointFactoryI(Instance instance, IceInternal.EndpointFactory del)
+ public EndpointFactoryI(Instance instance, short type) : base(instance, type)
{
_instance = instance;
- _delegate = del;
- }
-
- public short type()
- {
- return _delegate.type();
- }
-
- public string protocol()
- {
- return _delegate.protocol();
- }
-
- public IceInternal.EndpointI create(List<string> args, bool oaEndpoint)
- {
- return new EndpointI(_instance, _delegate.create(args, oaEndpoint));
}
- public IceInternal.EndpointI read(Ice.InputStream s)
+ override public IceInternal.EndpointFactory
+ cloneWithUnderlying(IceInternal.ProtocolInstance inst, short underlying)
{
- return new EndpointI(_instance, _delegate.read(s));
+ return new EndpointFactoryI(new Instance(_instance.engine(), inst.type(), inst.protocol()), underlying);
}
- public void destroy()
+ override protected IceInternal.EndpointI
+ createWithUnderlying(IceInternal.EndpointI underlying, List<string> args, bool oaEndpoint)
{
- _delegate.destroy();
- _instance = null;
+ return new EndpointI(_instance, underlying);
}
- public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance inst,
- IceInternal.EndpointFactory del)
+ override protected IceInternal.EndpointI
+ readWithUnderlying(IceInternal.EndpointI underlying, Ice.InputStream s)
{
- Instance instance = new Instance(_instance.engine(), inst.type(), inst.protocol());
- return new EndpointFactoryI(instance, del != null ? del : _delegate.clone(instance, null));
+ return new EndpointI(_instance, underlying);
}
private Instance _instance;
- private IceInternal.EndpointFactory _delegate;
}
}
diff --git a/csharp/src/IceSSL/PluginI.cs b/csharp/src/IceSSL/PluginI.cs
index f4d205e4c83..fba2919ae38 100644
--- a/csharp/src/IceSSL/PluginI.cs
+++ b/csharp/src/IceSSL/PluginI.cs
@@ -43,12 +43,8 @@ namespace IceSSL
//
// SSL based on TCP
//
- IceInternal.EndpointFactory tcp = facade.getEndpointFactory(Ice.TCPEndpointType.value);
- if(tcp != null)
- {
- Instance instance = new Instance(_engine, Ice.SSLEndpointType.value, "ssl");
- facade.addEndpointFactory(new EndpointFactoryI(instance, tcp.clone(instance, null)));
- }
+ Instance instance = new Instance(_engine, Ice.SSLEndpointType.value, "ssl");
+ facade.addEndpointFactory(new EndpointFactoryI(instance, Ice.TCPEndpointType.value));
}
public override void initialize()
diff --git a/csharp/test/Ice/background/EndpointFactory.cs b/csharp/test/Ice/background/EndpointFactory.cs
index 9cbcd9def84..dd85387e7d0 100644
--- a/csharp/test/Ice/background/EndpointFactory.cs
+++ b/csharp/test/Ice/background/EndpointFactory.cs
@@ -17,6 +17,10 @@ internal class EndpointFactory : IceInternal.EndpointFactory
_factory = factory;
}
+ public void initialize()
+ {
+ }
+
public short type()
{
return (short)(EndpointI.TYPE_BASE + _factory.type());
@@ -47,7 +51,7 @@ internal class EndpointFactory : IceInternal.EndpointFactory
{
}
- public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance, IceInternal.EndpointFactory del)
+ public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance)
{
return this;
}