diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-04-27 13:05:25 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-04-27 13:05:25 +0200 |
commit | c5ee6fd5310199110dae6b2d01decbd20174d8db (patch) | |
tree | daf558482821eb3a1ffd496b06ba8bcc2edce841 /cpp/src | |
parent | Extra whitespace (diff) | |
download | ice-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 'cpp/src')
27 files changed, 426 insertions, 181 deletions
diff --git a/cpp/src/Ice/EndpointFactory.cpp b/cpp/src/Ice/EndpointFactory.cpp index 1ccd152bac5..e7a79313404 100644 --- a/cpp/src/Ice/EndpointFactory.cpp +++ b/cpp/src/Ice/EndpointFactory.cpp @@ -10,6 +10,7 @@ #include <Ice/EndpointFactory.h> #include <Ice/Instance.h> #include <Ice/EndpointFactoryManager.h> +#include <Ice/ProtocolInstance.h> using namespace std; using namespace Ice; @@ -25,6 +26,12 @@ IceInternal::EndpointFactory::~EndpointFactory() { } +void +IceInternal::EndpointFactory::initialize() +{ + // Nothing to do, can be overriden by specialization to finish initialization. +} + IceInternal::EndpointFactoryPlugin::EndpointFactoryPlugin(const CommunicatorPtr& communicator, const EndpointFactoryPtr& factory) { @@ -41,3 +48,147 @@ void IceInternal::EndpointFactoryPlugin::destroy() { } + +IceInternal::EndpointFactoryWithUnderlying::EndpointFactoryWithUnderlying(const ProtocolInstancePtr& instance, + Short type) : + _instance(instance), _type(type) +{ +} + +void +IceInternal::EndpointFactoryWithUnderlying::initialize() +{ + // + // Get the endpoint factory for the underlying type and clone it with + // our protocol instance. + // + EndpointFactoryPtr factory = _instance->getEndpointFactory(_type); + if(factory) + { + _underlying = factory->clone(_instance); + _underlying->initialize(); + } +} + +Short +IceInternal::EndpointFactoryWithUnderlying::type() const +{ + return _instance->type(); +} + +string +IceInternal::EndpointFactoryWithUnderlying::protocol() const +{ + return _instance->protocol(); +} + +EndpointIPtr +IceInternal::EndpointFactoryWithUnderlying::create(vector<string>& args, bool oaEndpoint) const +{ + if(!_underlying) + { + return 0; // Can't create an endpoint without underlying factory. + } + return createWithUnderlying(_underlying->create(args, oaEndpoint), args, oaEndpoint); +} + +EndpointIPtr +IceInternal::EndpointFactoryWithUnderlying::read(InputStream* s) const +{ + if(!_underlying) + { + return 0; // Can't create an endpoint without underlying factory. + } + return readWithUnderlying(_underlying->read(s), s); +} + +void +IceInternal::EndpointFactoryWithUnderlying::destroy() +{ + if(_underlying) + { + _underlying->destroy(); + } + _instance = 0; +} + +EndpointFactoryPtr +IceInternal::EndpointFactoryWithUnderlying::clone(const ProtocolInstancePtr& instance) const +{ + return cloneWithUnderlying(instance, _type); +} + +IceInternal::UnderlyingEndpointFactory::UnderlyingEndpointFactory(const ProtocolInstancePtr& instance, + Short type, + Short underlying) : + _instance(instance), _type(type), _underlying(underlying) +{ +} + +void +IceInternal::UnderlyingEndpointFactory::initialize() +{ + // + // Get the endpoint factory of the given endpoint type. If it's a factory that + // delegates to an underlying endpoint, clone it and instruct it to delegate to + // our underlying factory. + // + EndpointFactoryPtr factory = _instance->getEndpointFactory(_type); + if(factory) + { + EndpointFactoryWithUnderlying* f = dynamic_cast<EndpointFactoryWithUnderlying*>(factory.get()); + if(f) + { + _factory = f->cloneWithUnderlying(_instance, _underlying); + _factory->initialize(); + } + } +} + +Short +IceInternal::UnderlyingEndpointFactory::type() const +{ + return _instance->type(); +} + +string +IceInternal::UnderlyingEndpointFactory::protocol() const +{ + return _instance->protocol(); +} + +EndpointIPtr +IceInternal::UnderlyingEndpointFactory::create(vector<string>& args, bool oaEndpoint) const +{ + if(!_factory) + { + return 0; + } + return _factory->create(args, oaEndpoint); +} + +EndpointIPtr +IceInternal::UnderlyingEndpointFactory::read(InputStream* s) const +{ + if(!_factory) + { + return 0; + } + return _factory->read(s); +} + +void +IceInternal::UnderlyingEndpointFactory::destroy() +{ + if(_factory) + { + _factory->destroy(); + } + _instance = 0; +} + +EndpointFactoryPtr +IceInternal::UnderlyingEndpointFactory::clone(const ProtocolInstancePtr& instance) const +{ + return new UnderlyingEndpointFactory(instance, _type, _underlying); +} diff --git a/cpp/src/Ice/EndpointFactory.h b/cpp/src/Ice/EndpointFactory.h index 1a206b52d6b..b775cd1c91a 100644 --- a/cpp/src/Ice/EndpointFactory.h +++ b/cpp/src/Ice/EndpointFactory.h @@ -33,19 +33,80 @@ public: virtual ~EndpointFactory(); - virtual ::Ice::Short type() const = 0; - virtual ::std::string protocol() const = 0; + virtual void initialize(); + virtual Ice::Short type() const = 0; + virtual std::string protocol() const = 0; virtual EndpointIPtr create(std::vector<std::string>&, bool) const = 0; virtual EndpointIPtr read(Ice::InputStream*) const = 0; virtual void destroy() = 0; - virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&, const EndpointFactoryPtr&) const = 0; + virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const = 0; protected: EndpointFactory(); }; +// +// The endpoint factory with underlying create endpoints that delegate to an underlying +// endpoint (e.g.: the SSL/WS endpoints are endpoints with underlying endpoints). +// +class ICE_API EndpointFactoryWithUnderlying : public EndpointFactory +{ +public: + + EndpointFactoryWithUnderlying(const ProtocolInstancePtr&, Ice::Short); + + virtual void initialize(); + virtual Ice::Short type() const; + virtual std::string protocol() const; + virtual EndpointIPtr create(std::vector<std::string>&, bool) const; + virtual EndpointIPtr read(Ice::InputStream*) const; + virtual void destroy(); + + virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const; + + virtual EndpointFactoryPtr cloneWithUnderlying(const ProtocolInstancePtr&, Ice::Short) const = 0; + +protected: + + virtual EndpointIPtr createWithUnderlying(const EndpointIPtr&, std::vector<std::string>&, bool) const = 0; + virtual EndpointIPtr readWithUnderlying(const EndpointIPtr&, Ice::InputStream*) const = 0; + + ProtocolInstancePtr _instance; + const Ice::Short _type; + EndpointFactoryPtr _underlying; +}; + +// +// The underlying endpoint factory creates endpoints with a factory of the given +// type. If this factory is of the EndpointFactoryWithUnderlying type, it will +// delegate to the given underlying factory (this is used by IceIAP/IceBT plugins +// for the BTS/iAPS endpoint factories). +// +class ICE_API UnderlyingEndpointFactory : public EndpointFactory +{ +public: + + UnderlyingEndpointFactory(const ProtocolInstancePtr&, Ice::Short, Ice::Short); + + virtual void initialize(); + virtual Ice::Short type() const; + virtual std::string protocol() const; + virtual EndpointIPtr create(std::vector<std::string>&, bool) const; + virtual EndpointIPtr read(Ice::InputStream*) const; + virtual void destroy(); + + virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const; + +private: + + ProtocolInstancePtr _instance; + const Ice::Short _type; + const Ice::Short _underlying; + EndpointFactoryPtr _factory; +}; + class ICE_API EndpointFactoryPlugin : public Ice::Plugin { public: diff --git a/cpp/src/Ice/EndpointFactoryManager.cpp b/cpp/src/Ice/EndpointFactoryManager.cpp index 8fa1e614769..a2105da4274 100644 --- a/cpp/src/Ice/EndpointFactoryManager.cpp +++ b/cpp/src/Ice/EndpointFactoryManager.cpp @@ -30,6 +30,15 @@ IceInternal::EndpointFactoryManager::EndpointFactoryManager(const InstancePtr& i } void +IceInternal::EndpointFactoryManager::initialize() const +{ + for(vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++) + { + _factories[i]->initialize(); + } +} + +void IceInternal::EndpointFactoryManager::add(const EndpointFactoryPtr& factory) { IceUtil::Mutex::Lock sync(*this); // TODO: Necessary? @@ -188,7 +197,13 @@ IceInternal::EndpointFactoryManager::read(InputStream* s) const { 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) { e = ICE_MAKE_SHARED(OpaqueEndpointI, type, s); } diff --git a/cpp/src/Ice/EndpointFactoryManager.h b/cpp/src/Ice/EndpointFactoryManager.h index afa99c77232..bdeb9a4e45e 100644 --- a/cpp/src/Ice/EndpointFactoryManager.h +++ b/cpp/src/Ice/EndpointFactoryManager.h @@ -31,6 +31,7 @@ class EndpointFactoryManager : public ::IceUtil::Shared, public ::IceUtil::Mutex { public: + void initialize() const; void add(const EndpointFactoryPtr&); EndpointFactoryPtr get(::Ice::Short) const; EndpointIPtr create(const std::string&, bool) const; diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index e94781b3cf1..490327881d2 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -1351,20 +1351,10 @@ IceInternal::Instance::finishSetup(int& argc, const char* argv[], const Ice::Com pluginManagerImpl->loadPlugins(argc, argv); // - // 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. // - EndpointFactoryPtr tcpFactory = _endpointFactoryManager->get(TCPEndpointType); - if(tcpFactory) - { - ProtocolInstancePtr instance = new ProtocolInstance(communicator, WSEndpointType, "ws", false); - _endpointFactoryManager->add(new WSEndpointFactory(instance, tcpFactory->clone(instance, 0))); - } - EndpointFactoryPtr sslFactory = _endpointFactoryManager->get(SSLEndpointType); - if(sslFactory) - { - ProtocolInstancePtr instance = new ProtocolInstance(communicator, WSSEndpointType, "wss", true); - _endpointFactoryManager->add(new WSEndpointFactory(instance, sslFactory->clone(instance, 0))); - } + _endpointFactoryManager->initialize(); // // Reset _stringConverter and _wstringConverter, in case a plugin changed them diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index a78556b151d..c761d65dfe0 100755 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -855,7 +855,7 @@ IceInternal::NativeInfo::queueAction(SocketOperation op, IAsyncAction^ action, b [=] (IAsyncAction^ info, Windows::Foundation::AsyncStatus status) { // - // COMPILERFIX with VC141 using operator!= and operator== inside + // COMPILERFIX with VC141 using operator!= and operator== inside // a lambda callback triggers a compiler bug, we move the code to // a seperate private method to workaround the issue. // @@ -896,11 +896,11 @@ IceInternal::NativeInfo::queueOperation(SocketOperation op, IAsyncOperation<unsi [=] (IAsyncOperation<unsigned int>^ operation, Windows::Foundation::AsyncStatus status) { // - // COMPILERFIX with VC141 using operator!= and operator== inside + // COMPILERFIX with VC141 using operator!= and operator== inside // a lambda callback triggers a compiler bug, we move the code to // a seperate private method to workaround the issue. // - this->queueOperationCompleted(op, info, operation, status); + this->queueOperationCompleted(op, info, operation, status); }); } operation->Completed = info->completedHandler; diff --git a/cpp/src/Ice/ProtocolInstance.cpp b/cpp/src/Ice/ProtocolInstance.cpp index c9950f65a64..43ed6b27bcc 100644 --- a/cpp/src/Ice/ProtocolInstance.cpp +++ b/cpp/src/Ice/ProtocolInstance.cpp @@ -13,6 +13,7 @@ #include <Ice/IPEndpointI.h> #include <Ice/DefaultsAndOverrides.h> #include <Ice/TraceLevels.h> +#include <Ice/EndpointFactoryManager.h> using namespace std; using namespace Ice; @@ -55,6 +56,12 @@ IceInternal::ProtocolInstance::logger() const return _instance->initializationData().logger; } +EndpointFactoryPtr +IceInternal::ProtocolInstance::getEndpointFactory(Ice::Short type) const +{ + return _instance->endpointFactoryManager()->get(type); +} + BufSizeWarnInfo IceInternal::ProtocolInstance::getBufSizeWarn(Short type) { diff --git a/cpp/src/Ice/ProtocolInstance.h b/cpp/src/Ice/ProtocolInstance.h index 3f3805eb917..ba791c1928d 100644 --- a/cpp/src/Ice/ProtocolInstance.h +++ b/cpp/src/Ice/ProtocolInstance.h @@ -15,6 +15,7 @@ #include <Ice/PropertiesF.h> #include <Ice/LoggerF.h> #include <Ice/EndpointIF.h> +#include <Ice/EndpointFactory.h> #include <Ice/ConnectorF.h> #include <Ice/IPEndpointIF.h> #include <Ice/NetworkF.h> @@ -63,6 +64,7 @@ public: return _secure; } + IceInternal::EndpointFactoryPtr getEndpointFactory(Ice::Short) const; BufSizeWarnInfo getBufSizeWarn(Ice::Short type); void setSndBufSizeWarn(Ice::Short type, int size); void setRcvBufSizeWarn(Ice::Short type, int size); diff --git a/cpp/src/Ice/RegisterPluginsInit.cpp b/cpp/src/Ice/RegisterPluginsInit.cpp index f0fac12f972..47c7a00c81c 100644 --- a/cpp/src/Ice/RegisterPluginsInit.cpp +++ b/cpp/src/Ice/RegisterPluginsInit.cpp @@ -16,11 +16,19 @@ extern "C" Ice::Plugin* createIceUDP(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&); Ice::Plugin* createIceTCP(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&); +Ice::Plugin* createIceWS(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&); }; IceInternal::RegisterPluginsInit::RegisterPluginsInit() { - Ice::registerPluginFactory("IceUDP", createIceUDP, true); Ice::registerPluginFactory("IceTCP", createIceTCP, true); + + // + // Only include the UDP and WS transport plugins with non-static builds or Gem/PyPI builds. + // +#if !defined(ICE_STATIC_LIBS) || defined(ICE_GEM) || defined(ICE_PYPI) + Ice::registerPluginFactory("IceUDP", createIceUDP, true); + Ice::registerPluginFactory("IceWS", createIceWS, true); +#endif } diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index c1b87d1b931..57a44ac4b20 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -382,7 +382,7 @@ IceInternal::TcpEndpointFactory::destroy() } EndpointFactoryPtr -IceInternal::TcpEndpointFactory::clone(const ProtocolInstancePtr& instance, const EndpointFactoryPtr&) const +IceInternal::TcpEndpointFactory::clone(const ProtocolInstancePtr& instance) const { return new TcpEndpointFactory(instance); } diff --git a/cpp/src/Ice/TcpEndpointI.h b/cpp/src/Ice/TcpEndpointI.h index 6c027e27392..93bc40e25e0 100644 --- a/cpp/src/Ice/TcpEndpointI.h +++ b/cpp/src/Ice/TcpEndpointI.h @@ -83,7 +83,7 @@ public: virtual EndpointIPtr read(Ice::InputStream*) const; virtual void destroy(); - virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&, const EndpointFactoryPtr&) const; + virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const; private: diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp index 9016a2ae2f7..11f7d565008 100644 --- a/cpp/src/Ice/UdpEndpointI.cpp +++ b/cpp/src/Ice/UdpEndpointI.cpp @@ -38,6 +38,26 @@ createIceUDP(const CommunicatorPtr& c, const string&, const StringSeq&) } +namespace Ice +{ + +ICE_API void +registerIceUDP(bool loadOnInitialize) +{ + Ice::registerPluginFactory("IceUDP", createIceUDP, loadOnInitialize); +} + +} + +// +// Objective-C function to allow Objective-C programs to register plugin. +// +extern "C" ICE_API void +ICEregisterIceUDP(bool loadOnInitialize) +{ + Ice::registerIceUDP(loadOnInitialize); +} + IceInternal::UdpEndpointI::UdpEndpointI(const ProtocolInstancePtr& instance, const string& host, Int port, const Address& sourceAddr, const string& mcastInterface, Int mttl, bool conn, const string& conId, bool co) : @@ -492,7 +512,7 @@ IceInternal::UdpEndpointFactory::destroy() } EndpointFactoryPtr -IceInternal::UdpEndpointFactory::clone(const ProtocolInstancePtr& instance, const EndpointFactoryPtr&) const +IceInternal::UdpEndpointFactory::clone(const ProtocolInstancePtr& instance) const { return new UdpEndpointFactory(instance); } diff --git a/cpp/src/Ice/UdpEndpointI.h b/cpp/src/Ice/UdpEndpointI.h index 19400fb031a..f95af7ef8b3 100644 --- a/cpp/src/Ice/UdpEndpointI.h +++ b/cpp/src/Ice/UdpEndpointI.h @@ -88,7 +88,7 @@ public: virtual EndpointIPtr read(Ice::InputStream*) const; virtual void destroy(); - virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&, const EndpointFactoryPtr&) const; + virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const; private: diff --git a/cpp/src/Ice/WSEndpoint.cpp b/cpp/src/Ice/WSEndpoint.cpp index 6296400a16d..386125545d4 100644 --- a/cpp/src/Ice/WSEndpoint.cpp +++ b/cpp/src/Ice/WSEndpoint.cpp @@ -25,12 +25,21 @@ using namespace IceInternal; namespace { -Ice::IPEndpointInfoPtr -getIPEndpointInfo(const Ice::EndpointInfoPtr& info) +class WSEndpointFactoryPlugin : public Plugin { - for(Ice::EndpointInfoPtr p = info; p; p = p->underlying) +public: + + WSEndpointFactoryPlugin(const CommunicatorPtr&); + virtual void initialize(); + virtual void destroy(); +}; + +IPEndpointInfoPtr +getIPEndpointInfo(const EndpointInfoPtr& info) +{ + for(EndpointInfoPtr p = info; p; p = p->underlying) { - Ice::IPEndpointInfoPtr ipInfo = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, p); + IPEndpointInfoPtr ipInfo = ICE_DYNAMIC_CAST(IPEndpointInfo, p); if(ipInfo) { return ipInfo; @@ -41,10 +50,60 @@ getIPEndpointInfo(const Ice::EndpointInfoPtr& info) } +extern "C" +{ + +Plugin* +createIceWS(const CommunicatorPtr& c, const string&, const StringSeq&) +{ + return new WSEndpointFactoryPlugin(c); +} + +} + +namespace Ice +{ + +ICE_API void +registerIceWS(bool loadOnInitialize) +{ + registerPluginFactory("IceWS", createIceWS, loadOnInitialize); +} + +} + +// +// Objective-C function to allow Objective-C programs to register plugin. +// +extern "C" ICE_API void +ICEregisterIceWS(bool loadOnInitialize) +{ + Ice::registerIceWS(loadOnInitialize); +} + #ifndef ICE_CPP11_MAPPING IceUtil::Shared* IceInternal::upCast(WSEndpoint* p) { return p; } #endif +WSEndpointFactoryPlugin::WSEndpointFactoryPlugin(const CommunicatorPtr& communicator) +{ + assert(communicator); + + const EndpointFactoryManagerPtr efm = getInstance(communicator)->endpointFactoryManager(); + efm->add(new WSEndpointFactory(new ProtocolInstance(communicator, WSEndpointType, "ws", false), TCPEndpointType)); + efm->add(new WSEndpointFactory(new ProtocolInstance(communicator, WSSEndpointType, "wss", true), SSLEndpointType)); +} + +void +WSEndpointFactoryPlugin::initialize() +{ +} + +void +WSEndpointFactoryPlugin::destroy() +{ +} + IceInternal::WSEndpoint::WSEndpoint(const ProtocolInstancePtr& instance, const EndpointIPtr& del, const string& res) : _instance(instance), _delegate(del), _resource(res) { @@ -67,10 +126,10 @@ IceInternal::WSEndpoint::WSEndpoint(const ProtocolInstancePtr& instance, const E s->read(const_cast<string&>(_resource), false); } -Ice::EndpointInfoPtr +EndpointInfoPtr IceInternal::WSEndpoint::getInfo() const { - WSEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::WSEndpointInfo>, ICE_SHARED_FROM_CONST_THIS(WSEndpoint)); + WSEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<WSEndpointInfo>, ICE_SHARED_FROM_CONST_THIS(WSEndpoint)); info->underlying = _delegate->getInfo(); info->compress = info->underlying->compress; info->timeout = info->underlying->timeout; @@ -78,7 +137,7 @@ IceInternal::WSEndpoint::getInfo() const return info; } -Ice::Short +Short IceInternal::WSEndpoint::type() const { return _delegate->type(); @@ -173,7 +232,7 @@ IceInternal::WSEndpoint::transceiver() const } void -IceInternal::WSEndpoint::connectors_async(Ice::EndpointSelectionType selType, +IceInternal::WSEndpoint::connectors_async(EndpointSelectionType selType, const EndpointI_connectorsPtr& callback) const { class CallbackI : public EndpointI_connectors @@ -196,7 +255,7 @@ IceInternal::WSEndpoint::connectors_async(Ice::EndpointSelectionType selType, _callback->connectors(connectors); } - virtual void exception(const Ice::LocalException& ex) + virtual void exception(const LocalException& ex) { _callback->exception(ex); } @@ -293,7 +352,7 @@ IceInternal::WSEndpoint::equivalent(const EndpointIPtr& endpoint) const return _delegate->equivalent(wsEndpointI->_delegate); } -Ice::Int +Int IceInternal::WSEndpoint::hash() const { int h = _delegate->hash(); @@ -336,7 +395,7 @@ bool #ifdef ICE_CPP11_MAPPING IceInternal::WSEndpoint::operator==(const Endpoint& r) const #else -IceInternal::WSEndpoint::operator==(const Ice::LocalObject& r) const +IceInternal::WSEndpoint::operator==(const LocalObject& r) const #endif { const WSEndpoint* p = dynamic_cast<const WSEndpoint*>(&r); @@ -350,7 +409,7 @@ IceInternal::WSEndpoint::operator==(const Ice::LocalObject& r) const return true; } - if(!Ice::targetEqualTo(_delegate, p->_delegate)) + if(!targetEqualTo(_delegate, p->_delegate)) { return false; } @@ -367,7 +426,7 @@ bool #ifdef ICE_CPP11_MAPPING IceInternal::WSEndpoint::operator<(const Endpoint& r) const #else -IceInternal::WSEndpoint::operator<(const Ice::LocalObject& r) const +IceInternal::WSEndpoint::operator<(const LocalObject& r) const #endif { const WSEndpoint* p = dynamic_cast<const WSEndpoint*>(&r); @@ -386,11 +445,11 @@ IceInternal::WSEndpoint::operator<(const Ice::LocalObject& r) const return false; } - if(Ice::targetLess(_delegate, p->_delegate)) + if(targetLess(_delegate, p->_delegate)) { return true; } - else if (Ice::targetLess(p->_delegate, _delegate)) + else if (targetLess(p->_delegate, _delegate)) { return false; } @@ -431,48 +490,25 @@ IceInternal::WSEndpoint::checkOption(const string& option, const string& argumen } } -IceInternal::WSEndpointFactory::WSEndpointFactory(const ProtocolInstancePtr& instance, const EndpointFactoryPtr& del) : - _instance(instance), _delegate(del) +IceInternal::WSEndpointFactory::WSEndpointFactory(const ProtocolInstancePtr& instance, Short type) : + EndpointFactoryWithUnderlying(instance, type) { } -IceInternal::WSEndpointFactory::~WSEndpointFactory() -{ -} - -Short -IceInternal::WSEndpointFactory::type() const -{ - return _instance->type(); -} - -string -IceInternal::WSEndpointFactory::protocol() const +EndpointFactoryPtr +IceInternal::WSEndpointFactory::cloneWithUnderlying(const ProtocolInstancePtr& instance, Short underlying) const { - return _instance->protocol(); + return new WSEndpointFactory(instance, underlying); } EndpointIPtr -IceInternal::WSEndpointFactory::create(vector<string>& args, bool oaEndpoint) const +IceInternal::WSEndpointFactory::createWithUnderlying(const EndpointIPtr& underlying, vector<string>& args, bool) const { - return ICE_MAKE_SHARED(WSEndpoint, _instance, _delegate->create(args, oaEndpoint), args); + return ICE_MAKE_SHARED(WSEndpoint, _instance, underlying, args); } EndpointIPtr -IceInternal::WSEndpointFactory::read(InputStream* s) const -{ - return ICE_MAKE_SHARED(WSEndpoint, _instance, _delegate->read(s), s); -} - -void -IceInternal::WSEndpointFactory::destroy() -{ - _delegate->destroy(); - _instance = 0; -} - -EndpointFactoryPtr -IceInternal::WSEndpointFactory::clone(const ProtocolInstancePtr& instance, const EndpointFactoryPtr& delegate) const +IceInternal::WSEndpointFactory::readWithUnderlying(const EndpointIPtr& underlying, InputStream* s) const { - return new WSEndpointFactory(instance, delegate); + return ICE_MAKE_SHARED(WSEndpoint, _instance, underlying, s); } diff --git a/cpp/src/Ice/WSEndpoint.h b/cpp/src/Ice/WSEndpoint.h index fe38fe331cf..8cb1b39b235 100644 --- a/cpp/src/Ice/WSEndpoint.h +++ b/cpp/src/Ice/WSEndpoint.h @@ -79,25 +79,18 @@ private: const std::string _resource; }; -class ICE_API WSEndpointFactory : public EndpointFactory +class ICE_API WSEndpointFactory : public EndpointFactoryWithUnderlying { public: - WSEndpointFactory(const ProtocolInstancePtr&, const EndpointFactoryPtr&); - virtual ~WSEndpointFactory(); + WSEndpointFactory(const ProtocolInstancePtr&, Ice::Short); - virtual Ice::Short type() const; - virtual std::string protocol() const; - virtual EndpointIPtr create(std::vector<std::string>&, bool) const; - virtual EndpointIPtr read(Ice::InputStream*) const; - virtual void destroy(); - - virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&, const EndpointFactoryPtr&) const; + virtual EndpointFactoryPtr cloneWithUnderlying(const ProtocolInstancePtr&, Ice::Short) const; -private: +protected: - ProtocolInstancePtr _instance; - const EndpointFactoryPtr _delegate; + virtual EndpointIPtr createWithUnderlying(const EndpointIPtr&, std::vector<std::string>&, bool) const; + virtual EndpointIPtr readWithUnderlying(const EndpointIPtr&, Ice::InputStream*) const; }; } diff --git a/cpp/src/Ice/ios/StreamEndpointI.cpp b/cpp/src/Ice/ios/StreamEndpointI.cpp index d2290c88dfc..7c2ad1a4738 100644 --- a/cpp/src/Ice/ios/StreamEndpointI.cpp +++ b/cpp/src/Ice/ios/StreamEndpointI.cpp @@ -480,7 +480,7 @@ IceObjC::StreamEndpointFactory::destroy() } EndpointFactoryPtr -IceObjC::StreamEndpointFactory::clone(const ProtocolInstancePtr& instance, const EndpointFactoryPtr&) const +IceObjC::StreamEndpointFactory::clone(const ProtocolInstancePtr& instance) const { return new StreamEndpointFactory(_instance->clone(instance)); } diff --git a/cpp/src/Ice/ios/StreamEndpointI.h b/cpp/src/Ice/ios/StreamEndpointI.h index 0a05061d5ea..cd117edb06e 100644 --- a/cpp/src/Ice/ios/StreamEndpointI.h +++ b/cpp/src/Ice/ios/StreamEndpointI.h @@ -144,8 +144,7 @@ public: virtual IceInternal::EndpointIPtr read(Ice::InputStream*) const; virtual void destroy(); - virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&, - const IceInternal::EndpointFactoryPtr&) const; + virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&) const; private: diff --git a/cpp/src/IceBT/EndpointI.cpp b/cpp/src/IceBT/EndpointI.cpp index a081b36747f..40726c63b82 100644 --- a/cpp/src/IceBT/EndpointI.cpp +++ b/cpp/src/IceBT/EndpointI.cpp @@ -684,8 +684,7 @@ IceBT::EndpointFactoryI::destroy() } IceInternal::EndpointFactoryPtr -IceBT::EndpointFactoryI::clone(const IceInternal::ProtocolInstancePtr& instance, - const IceInternal::EndpointFactoryPtr&) const +IceBT::EndpointFactoryI::clone(const IceInternal::ProtocolInstancePtr& instance) const { return new EndpointFactoryI(new Instance(_instance->engine(), instance->type(), instance->protocol())); } diff --git a/cpp/src/IceBT/EndpointI.h b/cpp/src/IceBT/EndpointI.h index 8e322574a1f..3d3e58db9cf 100644 --- a/cpp/src/IceBT/EndpointI.h +++ b/cpp/src/IceBT/EndpointI.h @@ -113,8 +113,7 @@ public: virtual IceInternal::EndpointIPtr read(Ice::InputStream*) const; virtual void destroy(); - virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&, - const IceInternal::EndpointFactoryPtr&) const; + virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&) const; private: diff --git a/cpp/src/IceBT/PluginI.cpp b/cpp/src/IceBT/PluginI.cpp index 1703c7732b5..55728c448fc 100644 --- a/cpp/src/IceBT/PluginI.cpp +++ b/cpp/src/IceBT/PluginI.cpp @@ -59,21 +59,18 @@ registerIceBT(bool loadOnInitialize) IceBT::PluginI::PluginI(const Ice::CommunicatorPtr& com) : _engine(new Engine(com)) { - IceInternal::ProtocolPluginFacadePtr pluginFacade = IceInternal::getProtocolPluginFacade(com); + IceInternal::ProtocolPluginFacadePtr f = IceInternal::getProtocolPluginFacade(com); // // Register the endpoint factory. We have to do this now, rather // than in initialize, because the communicator may need to // interpret proxies before the plug-in is fully initialized. // - pluginFacade->addEndpointFactory(new EndpointFactoryI(new Instance(_engine, BTEndpointType, "bt"))); - - IceInternal::EndpointFactoryPtr sslFactory = pluginFacade->getEndpointFactory(SSLEndpointType); - if(sslFactory) - { - InstancePtr instance = new Instance(_engine, BTSEndpointType, "bts"); - pluginFacade->addEndpointFactory(sslFactory->clone(instance, new EndpointFactoryI(instance))); - } + InstancePtr bt = new Instance(_engine, BTEndpointType, "bt"); + f->addEndpointFactory(new EndpointFactoryI(bt)); + + InstancePtr bts = new Instance(_engine, BTSEndpointType, "bts"); + f->addEndpointFactory(new IceInternal::UnderlyingEndpointFactory(bts, SSLEndpointType, BTEndpointType)); } void diff --git a/cpp/src/IceDiscovery/PluginI.cpp b/cpp/src/IceDiscovery/PluginI.cpp index 1a76f34ff06..1489f725184 100644 --- a/cpp/src/IceDiscovery/PluginI.cpp +++ b/cpp/src/IceDiscovery/PluginI.cpp @@ -42,6 +42,13 @@ ICE_DISCOVERY_API void registerIceDiscovery(bool loadOnInitialize) { Ice::registerPluginFactory("IceDiscovery", createIceDiscovery, loadOnInitialize); + +#ifdef ICE_STATIC_LIBS + // + // Also register the UDP plugin with static builds to ensure the UDP transport is loaded. + // + registerIceUDP(true); +#endif } } diff --git a/cpp/src/IceIAP/EndpointI.h b/cpp/src/IceIAP/EndpointI.h index 8e71869eb70..ce1157c7e7a 100644 --- a/cpp/src/IceIAP/EndpointI.h +++ b/cpp/src/IceIAP/EndpointI.h @@ -100,8 +100,7 @@ public: virtual IceInternal::EndpointIPtr read(Ice::InputStream*) const; virtual void destroy(); - virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&, - const IceInternal::EndpointFactoryPtr&) const; + virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&) const; private: diff --git a/cpp/src/IceIAP/EndpointI.mm b/cpp/src/IceIAP/EndpointI.mm index 1914e3e79ba..9d160964d87 100644 --- a/cpp/src/IceIAP/EndpointI.mm +++ b/cpp/src/IceIAP/EndpointI.mm @@ -42,19 +42,15 @@ public: iAPEndpointFactoryPlugin(const Ice::CommunicatorPtr& com) { - ProtocolPluginFacadePtr pluginFacade = getProtocolPluginFacade(com); + ProtocolPluginFacadePtr f = getProtocolPluginFacade(com); // iAP transport - ProtocolInstancePtr instance = new ProtocolInstance(com, iAPEndpointType, "iap", false); - pluginFacade->addEndpointFactory(new IceObjC::iAPEndpointFactory(instance)); + ProtocolInstancePtr iap = new ProtocolInstance(com, iAPEndpointType, "iap", false); + f->addEndpointFactory(new IceObjC::iAPEndpointFactory(iap)); // SSL based on iAP transport - EndpointFactoryPtr ssl = pluginFacade->getEndpointFactory(SSLEndpointType); - if(ssl) - { - ProtocolInstancePtr sslinstance = new ProtocolInstance(com, iAPSEndpointType, "iaps", true); - pluginFacade->addEndpointFactory(ssl->clone(sslinstance, new IceObjC::iAPEndpointFactory(sslinstance))); - } + ProtocolInstancePtr iaps = new ProtocolInstance(com, iAPSEndpointType, "iaps", true); + f->addEndpointFactory(new UnderlyingEndpointFactory(iaps, SSLEndpointType, iAPEndpointType)); } virtual void initialize() {} @@ -708,7 +704,7 @@ IceObjC::iAPEndpointFactory::destroy() } EndpointFactoryPtr -IceObjC::iAPEndpointFactory::clone(const ProtocolInstancePtr& instance, const IceInternal::EndpointFactoryPtr&) const +IceObjC::iAPEndpointFactory::clone(const ProtocolInstancePtr& instance) const { return new iAPEndpointFactory(instance); } diff --git a/cpp/src/IceLocatorDiscovery/PluginI.cpp b/cpp/src/IceLocatorDiscovery/PluginI.cpp index 7a32c20a844..ee01719fd72 100644 --- a/cpp/src/IceLocatorDiscovery/PluginI.cpp +++ b/cpp/src/IceLocatorDiscovery/PluginI.cpp @@ -247,6 +247,13 @@ ICE_LOCATOR_DISCOVERY_API void registerIceLocatorDiscovery(bool loadOnInitialize) { Ice::registerPluginFactory("IceLocatorDiscovery", createIceLocatorDiscovery, loadOnInitialize); + +#ifdef ICE_STATIC_LIBS + // + // Also register the UDP plugin with static builds to ensure the UDP transport is loaded. + // + registerIceUDP(true); +#endif } } diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp index 69705dcbcd8..099818f8fbc 100644 --- a/cpp/src/IceSSL/EndpointI.cpp +++ b/cpp/src/IceSSL/EndpointI.cpp @@ -347,51 +347,32 @@ IceSSL::EndpointI::checkOption(const string& option, const string& argument, con return false; } -IceSSL::EndpointFactoryI::EndpointFactoryI(const InstancePtr& instance, - const IceInternal::EndpointFactoryPtr& delegate) : - _instance(instance), _delegate(delegate) +IceSSL::EndpointFactoryI::EndpointFactoryI(const InstancePtr& instance, Short type) : + IceInternal::EndpointFactoryWithUnderlying(instance, type), _instance(instance.get()) { } -IceSSL::EndpointFactoryI::~EndpointFactoryI() -{ -} - -Short -IceSSL::EndpointFactoryI::type() const +void +IceSSL::EndpointFactoryI::destroy() { - return _instance->type(); + _instance = 0; } -string -IceSSL::EndpointFactoryI::protocol() const +IceInternal::EndpointFactoryPtr +IceSSL::EndpointFactoryI::cloneWithUnderlying(const IceInternal::ProtocolInstancePtr& instance, Short underlying) const { - return _instance->protocol(); + return new EndpointFactoryI(new Instance(_instance->engine(), instance->type(), instance->protocol()), underlying); } IceInternal::EndpointIPtr -IceSSL::EndpointFactoryI::create(vector<string>& args, bool oaEndpoint) const +IceSSL::EndpointFactoryI::createWithUnderlying(const IceInternal::EndpointIPtr& underlying, vector<string>&, bool) const { - return ICE_MAKE_SHARED(EndpointI, _instance, _delegate->create(args, oaEndpoint)); + return ICE_MAKE_SHARED(EndpointI, _instance, underlying); } IceInternal::EndpointIPtr -IceSSL::EndpointFactoryI::read(Ice::InputStream* s) const +IceSSL::EndpointFactoryI::readWithUnderlying(const IceInternal::EndpointIPtr& underlying, Ice::InputStream* s) const { - return ICE_MAKE_SHARED(EndpointI, _instance, _delegate->read(s)); + return ICE_MAKE_SHARED(EndpointI, _instance, underlying); } -void -IceSSL::EndpointFactoryI::destroy() -{ - _delegate->destroy(); - _instance = 0; -} - -IceInternal::EndpointFactoryPtr -IceSSL::EndpointFactoryI::clone(const IceInternal::ProtocolInstancePtr& inst, - const IceInternal::EndpointFactoryPtr& delegate) const -{ - InstancePtr instance = new Instance(_instance->engine(), inst->type(), inst->protocol()); - return new EndpointFactoryI(instance, delegate ? delegate : _delegate->clone(instance, 0)); -} diff --git a/cpp/src/IceSSL/EndpointI.h b/cpp/src/IceSSL/EndpointI.h index d27a7182a4a..584ec149848 100644 --- a/cpp/src/IceSSL/EndpointI.h +++ b/cpp/src/IceSSL/EndpointI.h @@ -15,6 +15,7 @@ #include <Ice/EndpointFactory.h> #include <IceSSL/InstanceF.h> #include <IceSSL/EndpointInfo.h> +#include <IceSSL/SSLEngineF.h> #include <Ice/Network.h> namespace IceSSL @@ -76,28 +77,27 @@ private: const IceInternal::EndpointIPtr _delegate; }; -class EndpointFactoryI : public IceInternal::EndpointFactory +class EndpointFactoryI : public IceInternal::EndpointFactoryWithUnderlying { public: - virtual ~EndpointFactoryI(); + EndpointFactoryI(const InstancePtr&, Ice::Short); - virtual Ice::Short type() const; - virtual std::string protocol() const; - virtual IceInternal::EndpointIPtr create(std::vector<std::string>&, bool) const; - virtual IceInternal::EndpointIPtr read(Ice::InputStream*) const; virtual void destroy(); - virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&, - const IceInternal::EndpointFactoryPtr&) const; + virtual IceInternal::EndpointFactoryPtr + cloneWithUnderlying(const IceInternal::ProtocolInstancePtr&, Ice::Short) const; -private: +protected: - EndpointFactoryI(const InstancePtr&, const IceInternal::EndpointFactoryPtr&); - friend class PluginI; + virtual IceInternal::EndpointIPtr + createWithUnderlying(const IceInternal::EndpointIPtr&, std::vector<std::string>&, bool) const; + virtual IceInternal::EndpointIPtr + readWithUnderlying(const IceInternal::EndpointIPtr&, Ice::InputStream*) const; + +private: InstancePtr _instance; - const IceInternal::EndpointFactoryPtr _delegate; }; } diff --git a/cpp/src/IceSSL/PluginI.cpp b/cpp/src/IceSSL/PluginI.cpp index cb0f20f5f6f..c12b3f9098e 100755 --- a/cpp/src/IceSSL/PluginI.cpp +++ b/cpp/src/IceSSL/PluginI.cpp @@ -49,31 +49,8 @@ PluginI::PluginI(const Ice::CommunicatorPtr& com, const SSLEnginePtr& engine) : // than in initialize, because the communicator may need to // interpret proxies before the plug-in is fully initialized. // - IceInternal::ProtocolPluginFacadePtr pluginFacade = IceInternal::getProtocolPluginFacade(com); - - // SSL based on TCP - IceInternal::EndpointFactoryPtr tcp = pluginFacade->getEndpointFactory(TCPEndpointType); - if(tcp) - { - InstancePtr instance = new Instance(_engine, SSLEndpointType, "ssl"); - pluginFacade->addEndpointFactory(new EndpointFactoryI(instance, tcp->clone(instance, 0))); - } - - // SSL based on Bluetooth - IceInternal::EndpointFactoryPtr bluetooth = pluginFacade->getEndpointFactory(BTEndpointType); - if(bluetooth) - { - InstancePtr instance = new Instance(_engine, BTSEndpointType, "bts"); - pluginFacade->addEndpointFactory(new EndpointFactoryI(instance, bluetooth->clone(instance, 0))); - } - - // SSL based on iAP - IceInternal::EndpointFactoryPtr iap = pluginFacade->getEndpointFactory(iAPEndpointType); - if(iap) - { - InstancePtr instance = new Instance(_engine, iAPSEndpointType, "iaps"); - pluginFacade->addEndpointFactory(new EndpointFactoryI(instance, iap->clone(instance, 0))); - } + InstancePtr instance = new Instance(_engine, SSLEndpointType, "ssl"); // SSL based on TCP + IceInternal::getProtocolPluginFacade(com)->addEndpointFactory(new EndpointFactoryI(instance, TCPEndpointType)); } void |