diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 76 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.h | 5 | ||||
-rw-r--r-- | cpp/test/Ice/info/AllTests.cpp | 6 |
3 files changed, 67 insertions, 20 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index e7c6e529095..d7998cf49a1 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -63,6 +63,12 @@ inline void checkServant(const ObjectPtr& servant) throw IllegalServantException(__FILE__, __LINE__, "cannot add null servant to Object Adapter"); } } + +inline EndpointIPtr toEndpointI(const EndpointPtr& endp) +{ + return ICE_DYNAMIC_CAST(EndpointI, endp); +} + } string @@ -641,6 +647,24 @@ Ice::ObjectAdapterI::getLocator() const } } +EndpointSeq +Ice::ObjectAdapterI::getEndpoints() const +{ + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + + EndpointSeq endpoints; + transform(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(), + back_inserter(endpoints), +#ifdef ICE_CPP11_MAPPING + [](const IncomingConnectionFactoryPtr& factory) + { + return factory->endpoint(); + }); +#else + Ice::constMemFun(&IncomingConnectionFactory::endpoint)); +#endif + return endpoints; +} void Ice::ObjectAdapterI::refreshPublishedEndpoints() @@ -650,7 +674,6 @@ Ice::ObjectAdapterI::refreshPublishedEndpoints() { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - checkForDeactivation(); oldPublishedEndpoints = _publishedEndpoints; @@ -678,32 +701,49 @@ Ice::ObjectAdapterI::refreshPublishedEndpoints() } EndpointSeq -Ice::ObjectAdapterI::getEndpoints() const +Ice::ObjectAdapterI::getPublishedEndpoints() const { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); EndpointSeq endpoints; - transform(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(), - back_inserter(endpoints), -#ifdef ICE_CPP11_MAPPING - [](const IncomingConnectionFactoryPtr& factory) - { - return factory->endpoint(); - }); -#else - Ice::constMemFun(&IncomingConnectionFactory::endpoint)); -#endif + copy(_publishedEndpoints.begin(), _publishedEndpoints.end(), back_inserter(endpoints)); return endpoints; } -EndpointSeq -Ice::ObjectAdapterI::getPublishedEndpoints() const +void +Ice::ObjectAdapterI::setPublishedEndpoints(const EndpointSeq& newEndpoints) { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + vector<EndpointIPtr> newPublishedEndpoints; + transform(newEndpoints.begin(), newEndpoints.end(), back_inserter(newPublishedEndpoints), toEndpointI); - EndpointSeq endpoints; - copy(_publishedEndpoints.begin(), _publishedEndpoints.end(), back_inserter(endpoints)); - return endpoints; + LocatorInfoPtr locatorInfo; + vector<EndpointIPtr> oldPublishedEndpoints; + { + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + checkForDeactivation(); + + oldPublishedEndpoints = _publishedEndpoints; + _publishedEndpoints = newPublishedEndpoints; + + locatorInfo = _locatorInfo; + } + + try + { + Ice::Identity dummy; + dummy.name = "dummy"; + updateLocatorRegistry(locatorInfo, createDirectProxy(dummy)); + } + catch(const Ice::LocalException&) + { + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + + // + // Restore the old published endpoints. + // + _publishedEndpoints = oldPublishedEndpoints; + throw; + } } bool diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h index d86ce43235c..c1a731946f0 100644 --- a/cpp/src/Ice/ObjectAdapterI.h +++ b/cpp/src/Ice/ObjectAdapterI.h @@ -85,10 +85,11 @@ public: virtual void setLocator(const LocatorPrxPtr&); virtual Ice::LocatorPrxPtr getLocator() const; - virtual void refreshPublishedEndpoints(); - virtual EndpointSeq getEndpoints() const; + + virtual void refreshPublishedEndpoints(); virtual EndpointSeq getPublishedEndpoints() const; + virtual void setPublishedEndpoints(const EndpointSeq&); bool isLocal(const ObjectPrxPtr&) const; diff --git a/cpp/test/Ice/info/AllTests.cpp b/cpp/test/Ice/info/AllTests.cpp index 124b5069aad..9a21a3a01b6 100644 --- a/cpp/test/Ice/info/AllTests.cpp +++ b/cpp/test/Ice/info/AllTests.cpp @@ -139,6 +139,12 @@ allTests(const Ice::CommunicatorPtr& communicator) test(udpEndpoint->datagram()); test(udpEndpoint->port > 0); + endpoints.pop_back(); + test(endpoints.size() == 1); + adapter->setPublishedEndpoints(endpoints); + publishedEndpoints = adapter->getPublishedEndpoints(); + test(endpoints == publishedEndpoints); + adapter->destroy(); int port = getTestPort(communicator->getProperties(), 1); |