From e591999d8782430e68c5917552ae50aa9bcf1e9d Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Fri, 6 Feb 2015 11:43:41 +0100 Subject: Added C++ plugins for endpoint factories, cleaned up registration of WS factories --- cpp/src/Ice/Instance.cpp | 69 ++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 41 deletions(-) (limited to 'cpp/src/Ice/Instance.cpp') diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 47de1ec9a20..1a0ac26f360 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -8,6 +8,7 @@ // ********************************************************************** #include + #include #include #include @@ -26,25 +27,28 @@ #include #include #include -#include #include #include +#include // For EndpointHostResolver +#include #include #include #include #include #include #include -#include #include #include #include #include #include +#include +#include + +#include #include #include #include -#include #include #include @@ -62,17 +66,6 @@ # include // for initgroups #endif -#include - -#ifndef ICE_OS_WINRT -# include -#else -# include // For IceSSL::EndpointType -# include -#endif - -#include - using namespace std; using namespace Ice; using namespace IceInternal; @@ -168,6 +161,11 @@ public: Init init; +// +// Static initializer to register plugins. +// +IceInternal::RegisterPluginsInit initPlugins; + } namespace IceInternal // Required because ObserverUpdaterI is a friend of Instance @@ -1343,33 +1341,6 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi _networkProxy = IceInternal::createNetworkProxy(_initData.properties, _protocolSupport); _endpointFactoryManager = new EndpointFactoryManager(this); -#ifndef ICE_OS_WINRT - ProtocolInstancePtr tcpProtocolInstance = new ProtocolInstance(this, TCPEndpointType, "tcp", false); - EndpointFactoryPtr tcpEndpointFactory = new TcpEndpointFactory(tcpProtocolInstance); - _endpointFactoryManager->add(tcpEndpointFactory); -#else - ProtocolInstancePtr tcpProtocolInstance = new ProtocolInstance(this, TCPEndpointType, "tcp", false); - EndpointFactoryPtr tcpEndpointFactory = new StreamEndpointFactory(tcpProtocolInstance); - _endpointFactoryManager->add(tcpEndpointFactory); - - ProtocolInstancePtr sslProtocolInstance = new ProtocolInstance(this, IceSSL::EndpointType, "ssl", true); - EndpointFactoryPtr sslEndpointFactory = new StreamEndpointFactory(sslProtocolInstance); - _endpointFactoryManager->add(sslEndpointFactory); - - ProtocolInstancePtr wssProtocolInstance = new ProtocolInstance(this, WSSEndpointType, "wss", true); - EndpointFactoryPtr wssEndpointFactory = new WSEndpointFactory(wssProtocolInstance, - sslEndpointFactory->clone(wssProtocolInstance)); - _endpointFactoryManager->add(wssEndpointFactory); -#endif - ProtocolInstancePtr udpProtocolInstance = new ProtocolInstance(this, UDPEndpointType, "udp", false); - EndpointFactoryPtr udpEndpointFactory = new UdpEndpointFactory(udpProtocolInstance); - _endpointFactoryManager->add(udpEndpointFactory); - - ProtocolInstancePtr wsProtocolInstance = new ProtocolInstance(this, WSEndpointType, "ws", false); - EndpointFactoryPtr wsEndpointFactory = new WSEndpointFactory(wsProtocolInstance, - tcpEndpointFactory->clone(wsProtocolInstance)); - - _endpointFactoryManager->add(wsEndpointFactory); _dynamicLibraryList = new DynamicLibraryList; @@ -1459,6 +1430,22 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[], const Ice::Communica assert(pluginManagerImpl); pluginManagerImpl->loadPlugins(argc, argv); + // + // Add WS and WSS endpoint factories if TCP/SSL factories are installed. + // + EndpointFactoryPtr tcpFactory = _endpointFactoryManager->get(TCPEndpointType); + if(tcpFactory) + { + ProtocolInstancePtr instance = new ProtocolInstance(communicator, WSEndpointType, "ws", false); + _endpointFactoryManager->add(new WSEndpointFactory(instance, tcpFactory->clone(instance))); + } + EndpointFactoryPtr sslFactory = _endpointFactoryManager->get(SSLEndpointType); + if(sslFactory) + { + ProtocolInstancePtr instance = new ProtocolInstance(communicator, WSSEndpointType, "wss", true); + _endpointFactoryManager->add(new WSEndpointFactory(instance, sslFactory->clone(instance))); + } + // // Reset _stringConverter and _wstringConverter, in case a plugin changed them // -- cgit v1.2.3