diff options
Diffstat (limited to 'cppe/src/IceE/ObjectAdapter.cpp')
-rw-r--r-- | cppe/src/IceE/ObjectAdapter.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/cppe/src/IceE/ObjectAdapter.cpp b/cppe/src/IceE/ObjectAdapter.cpp index 724a7f2737e..878e9934f09 100644 --- a/cppe/src/IceE/ObjectAdapter.cpp +++ b/cppe/src/IceE/ObjectAdapter.cpp @@ -450,6 +450,8 @@ Ice::ObjectAdapter::addRouter(const RouterPrx& router) RouterInfoPtr routerInfo = _instance->routerManager()->get(router); if(routerInfo) { + _routerInfos.push_back(routerInfo); + // // Add the router's server proxy endpoints to this object // adapter. @@ -472,7 +474,52 @@ Ice::ObjectAdapter::addRouter(const RouterPrx& router) // router's client proxy to use this object adapter for // callbacks. // - _instance->outgoingConnectionFactory()->setRouter(routerInfo->getRouter()); + _instance->outgoingConnectionFactory()->setRouterInfo(routerInfo); + } +} + +void +Ice::ObjectAdapter::removeRouter(const RouterPrx& router) +{ + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + + checkForDeactivation(); + + RouterInfoPtr routerInfo = _instance->routerManager()->erase(router); + if(routerInfo) + { + // + // Rebuild the router endpoints from our set of router infos. + // + _routerEndpoints.clear(); + vector<RouterInfoPtr>::iterator p = _routerInfos.begin(); + while(p != _routerInfos.end()) + { + if(*p == routerInfo) + { + p = _routerInfos.erase(p); + continue; + } + ObjectPrx proxy = (*p)->getServerProxy(); + vector<EndpointPtr> endpoints = proxy->__reference()->getEndpoints(); + copy(endpoints.begin(), endpoints.end(), back_inserter(_routerEndpoints)); + ++p; + } + + sort(_routerEndpoints.begin(), _routerEndpoints.end()); // Must be sorted. + _routerEndpoints.erase(unique(_routerEndpoints.begin(), _routerEndpoints.end()), _routerEndpoints.end()); + + // + // Clear this object adapter with the router. + // + routerInfo->setAdapter(0); + + // + // Also modify all existing outgoing connections to the + // router's client proxy to use this object adapter for + // callbacks. + // + _instance->outgoingConnectionFactory()->setRouterInfo(routerInfo); } } #endif |