summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2004-01-28 18:18:28 +0000
committerMarc Laukien <marc@zeroc.com>2004-01-28 18:18:28 +0000
commit3b97f9ae81a3195bdc48c34fc1f83828ad1d7651 (patch)
tree473d3f44c56c171d1091bee2f4fff57aea044e61 /cpp/src
parentMoved FD_SETSIZE to Ice and IceSSL project files (diff)
downloadice-3b97f9ae81a3195bdc48c34fc1f83828ad1d7651.tar.bz2
ice-3b97f9ae81a3195bdc48c34fc1f83828ad1d7651.tar.xz
ice-3b97f9ae81a3195bdc48c34fc1f83828ad1d7651.zip
ami prep
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Proxy.cpp118
-rw-r--r--cpp/src/Ice/Reference.cpp129
-rw-r--r--cpp/src/Ice/Reference.h12
3 files changed, 139 insertions, 120 deletions
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index bbdec516b03..c37bc69ae0e 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -18,7 +18,6 @@
#include <Ice/ProxyFactory.h>
#include <Ice/Object.h>
#include <Ice/ObjectAdapterFactory.h>
-#include <Ice/ObjectAdapterI.h> // For getIncomingConnections().
#include <Ice/Outgoing.h>
#include <Ice/OutgoingAsync.h>
#include <Ice/Direct.h>
@@ -27,13 +26,11 @@
#include <Ice/Instance.h>
#include <Ice/LoggerUtil.h>
#include <Ice/TraceLevels.h>
-#include <Ice/ConnectionFactory.h>
#include <Ice/Connection.h>
#include <Ice/RouterInfo.h>
#include <Ice/LocatorInfo.h>
#include <Ice/BasicStream.h>
#include <Ice/LocalException.h>
-#include <Ice/Functional.h>
using namespace std;
using namespace Ice;
@@ -1043,119 +1040,8 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& ref)
assert(!__connection);
__reference = ref;
-
- if(__reference->reverseAdapter)
- {
- //
- // If we have a reverse object adapter, we use the incoming
- // connections from such object adapter.
- //
- ObjectAdapterIPtr adapter = ObjectAdapterIPtr::dynamicCast(__reference->reverseAdapter);
- assert(adapter);
- list<ConnectionPtr> connections = adapter->getIncomingConnections();
-
- vector<EndpointPtr> endpoints;
- endpoints.reserve(connections.size());
- transform(connections.begin(), connections.end(), back_inserter(endpoints),
- ::Ice::constMemFun(&Connection::endpoint));
- endpoints = __reference->filterEndpoints(endpoints);
-
- if(endpoints.empty())
- {
- NoEndpointException ex(__FILE__, __LINE__);
- ex.proxy = __reference->toString();
- throw ex;
- }
-
- list<ConnectionPtr>::iterator p;
- for(p = connections.begin(); p != connections.end(); ++p)
- {
- if((*p)->endpoint() == endpoints.front())
- {
- break;
- }
- }
- assert(p != connections.end());
- __connection = *p;
- __connection->incProxyCount();
- }
- else
- {
- while(true)
- {
- bool cached;
- vector<EndpointPtr> endpoints;
-
- if(__reference->routerInfo)
- {
- //
- // If we route, we send everything to the router's client
- // proxy endpoints.
- //
- ObjectPrx proxy = ref->routerInfo->getClientProxy();
- endpoints = proxy->__reference()->endpoints;
- }
- else if(!__reference->endpoints.empty())
- {
- endpoints = __reference->endpoints;
- }
- else if(__reference->locatorInfo)
- {
- endpoints = __reference->locatorInfo->getEndpoints(__reference, cached);
- }
-
- vector<EndpointPtr> filteredEndpoints = __reference->filterEndpoints(endpoints);
- if(filteredEndpoints.empty())
- {
- NoEndpointException ex(__FILE__, __LINE__);
- ex.proxy = __reference->toString();
- throw ex;
- }
-
- try
- {
- OutgoingConnectionFactoryPtr factory = __reference->instance->outgoingConnectionFactory();
- __connection = factory->create(filteredEndpoints);
- assert(__connection);
- __connection->incProxyCount();
- }
- catch(const LocalException& ex)
- {
- if(!__reference->routerInfo && __reference->endpoints.empty())
- {
- assert(__reference->locatorInfo);
- __reference->locatorInfo->clearCache(__reference);
-
- if(cached)
- {
- TraceLevelsPtr traceLevels = __reference->instance->traceLevels();
- LoggerPtr logger = __reference->instance->logger();
- if(traceLevels->retry >= 2)
- {
- Trace out(logger, traceLevels->retryCat);
- out << "connection to cached endpoints failed\n"
- << "removing endpoints from cache and trying one more time\n" << ex;
- }
- continue;
- }
- }
-
- throw;
- }
-
- break;
- }
-
- //
- // If we have a router, set the object adapter for this router
- // (if any) to the new connection, so that callbacks from the
- // router can be received over this new connection.
- //
- if(__reference->routerInfo)
- {
- __connection->setAdapter(__reference->routerInfo->getAdapter());
- }
- }
+ __connection = __reference->getConnection();
+ __connection->incProxyCount();
}
bool
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index 8d316b730e7..f76be8ff9a2 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -25,6 +25,11 @@
#include <Ice/Locator.h>
#include <Ice/StringUtil.h>
#include <Ice/Functional.h>
+#include <Ice/ObjectAdapterI.h> // For getIncomingConnections().
+#include <Ice/Connection.h>
+#include <Ice/ConnectionFactory.h>
+#include <Ice/LoggerUtil.h>
+#include <Ice/TraceLevels.h>
using namespace std;
using namespace Ice;
@@ -638,8 +643,130 @@ IceInternal::Reference::changeDefault() const
endpoints, defaultRouterInfo, defaultLocatorInfo, 0, true);
}
+ConnectionPtr
+IceInternal::Reference::getConnection() const
+{
+ ConnectionPtr connection;
+
+ if(reverseAdapter)
+ {
+ //
+ // If we have a reverse object adapter, we use the incoming
+ // connections from such object adapter.
+ //
+ ObjectAdapterIPtr adapter = ObjectAdapterIPtr::dynamicCast(reverseAdapter);
+ assert(adapter);
+ list<ConnectionPtr> connections = adapter->getIncomingConnections();
+
+ vector<EndpointPtr> endpts;
+ endpts.reserve(connections.size());
+ transform(connections.begin(), connections.end(), back_inserter(endpts),
+ ::Ice::constMemFun(&Connection::endpoint));
+ endpts = filterEndpoints(endpts);
+
+ if(endpts.empty())
+ {
+ NoEndpointException ex(__FILE__, __LINE__);
+ ex.proxy = toString();
+ throw ex;
+ }
+
+ list<ConnectionPtr>::iterator p;
+ for(p = connections.begin(); p != connections.end(); ++p)
+ {
+ if((*p)->endpoint() == endpts.front())
+ {
+ break;
+ }
+ }
+ assert(p != connections.end());
+ connection = *p;
+ }
+ else
+ {
+ while(true)
+ {
+ bool cached;
+ vector<EndpointPtr> endpts;
+
+ if(routerInfo)
+ {
+ //
+ // If we route, we send everything to the router's client
+ // proxy endpoints.
+ //
+ ObjectPrx clientProxy = routerInfo->getClientProxy();
+ endpts = clientProxy->__reference()->endpoints;
+ }
+ else if(!endpoints.empty())
+ {
+ endpts = endpoints;
+ }
+ else if(locatorInfo)
+ {
+ ReferencePtr self = const_cast<Reference*>(this);
+ endpts = locatorInfo->getEndpoints(self, cached);
+ }
+
+ vector<EndpointPtr> filteredEndpts = filterEndpoints(endpts);
+ if(filteredEndpts.empty())
+ {
+ NoEndpointException ex(__FILE__, __LINE__);
+ ex.proxy = toString();
+ throw ex;
+ }
+
+ try
+ {
+ OutgoingConnectionFactoryPtr factory = instance->outgoingConnectionFactory();
+ connection = factory->create(filteredEndpts);
+ assert(connection);
+ }
+ catch(const LocalException& ex)
+ {
+ if(!routerInfo && endpoints.empty())
+ {
+ assert(locatorInfo);
+ ReferencePtr self = const_cast<Reference*>(this);
+ locatorInfo->clearCache(self);
+
+ if(cached)
+ {
+ TraceLevelsPtr traceLevels = instance->traceLevels();
+ LoggerPtr logger = instance->logger();
+ if(traceLevels->retry >= 2)
+ {
+ Trace out(logger, traceLevels->retryCat);
+ out << "connection to cached endpoints failed\n"
+ << "removing endpoints from cache and trying one more time\n" << ex;
+ }
+ continue;
+ }
+ }
+
+ throw;
+ }
+
+ break;
+ }
+
+ //
+ // If we have a router, set the object adapter for this router
+ // (if any) to the new connection, so that callbacks from the
+ // router can be received over this new connection.
+ //
+ if(routerInfo)
+ {
+ connection->setAdapter(routerInfo->getAdapter());
+ }
+ }
+
+ assert(connection);
+ return connection;
+}
+
vector<EndpointPtr>
-IceInternal::Reference::filterEndpoints(const vector<EndpointPtr>& allEndpoints)
+IceInternal::Reference::filterEndpoints(const vector<EndpointPtr>& allEndpoints) const
{
vector<EndpointPtr> endpoints = allEndpoints;
diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h
index 9d62c2406a5..77f5bc2b9c0 100644
--- a/cpp/src/Ice/Reference.h
+++ b/cpp/src/Ice/Reference.h
@@ -25,6 +25,7 @@
#include <Ice/RouterInfoF.h>
#include <Ice/LocatorInfoF.h>
#include <Ice/ObjectAdapterF.h>
+#include <Ice/ConnectionF.h>
#include <Ice/Identity.h>
namespace IceInternal
@@ -51,12 +52,12 @@ public:
bool operator<(const Reference&) const;
//
- // Marshal the reference
+ // Marshal the reference.
//
void streamWrite(BasicStream*) const;
//
- // Convert the reference to its string form
+ // Convert the reference to its string form.
//
std::string toString() const;
@@ -96,9 +97,14 @@ public:
ReferencePtr changeDefault() const;
//
+ // Get a suitable connection for this reference.
+ //
+ ConnectionPtr getConnection() const;
+
+ //
// Filter endpoints based on criteria from this reference.
//
- std::vector<EndpointPtr> filterEndpoints(const std::vector<EndpointPtr>&);
+ std::vector<EndpointPtr> filterEndpoints(const std::vector<EndpointPtr>&) const;
private: