diff options
43 files changed, 717 insertions, 632 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index a70bb4ed1c3..c82f3f2f47f 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -1,6 +1,17 @@ Changes since version 3.2.X (binary incompabible) ------------------------------------------------- +- Added a new method to the ObjectAdapter interface named + refreshPublishedEndpoints(). This method is meant to be used to + update the published endpoints after change in the available local + interfaces or after the PublishedEndpoints object adapter property + has been changed by the user. + +- Ice now listens on INADDR_ANY for object adapter endpoints that do + not contain a host name (or are set to use "-h *" or "-h 0.0.0.0"). + Previously, Ice would only listen on the local interfaces that were + present when the adapter was created. + - Freeze evictor update: - the existing evictor was renamed BackgroundSaveEvictor - added new TransactionalEvictor diff --git a/cpp/include/Ice/EndpointFactory.h b/cpp/include/Ice/EndpointFactory.h index 96648e0aad0..c4201322c1a 100644 --- a/cpp/include/Ice/EndpointFactory.h +++ b/cpp/include/Ice/EndpointFactory.h @@ -27,7 +27,7 @@ public: virtual ::Ice::Short type() const = 0; virtual ::std::string protocol() const = 0; - virtual EndpointIPtr create(const std::string&) const = 0; + virtual EndpointIPtr create(const std::string&, bool) const = 0; virtual EndpointIPtr read(BasicStream*) const = 0; virtual void destroy() = 0; diff --git a/cpp/slice/Ice/ObjectAdapter.ice b/cpp/slice/Ice/ObjectAdapter.ice index 64894fe46c0..51650c25de7 100644 --- a/cpp/slice/Ice/ObjectAdapter.ice +++ b/cpp/slice/Ice/ObjectAdapter.ice @@ -554,6 +554,16 @@ local interface ObjectAdapter * **/ void setLocator(Locator* loc); + + /** + * Refresh the set of published endpoints. The PublishedEndpoints + * property will be reread if it is set. Also the list of local + * interfaces will be rechecked for any endpoints configured to listen + * on INADDR_ANY and published endpoints will be updated with new + * address list. + * + **/ + void refreshPublishedEndpoints(); }; }; diff --git a/cpp/src/Ice/EndpointFactoryManager.cpp b/cpp/src/Ice/EndpointFactoryManager.cpp index 9b97258d958..a2a7900c26d 100644 --- a/cpp/src/Ice/EndpointFactoryManager.cpp +++ b/cpp/src/Ice/EndpointFactoryManager.cpp @@ -64,7 +64,7 @@ IceInternal::EndpointFactoryManager::get(Short type) const } EndpointIPtr -IceInternal::EndpointFactoryManager::create(const string& str) const +IceInternal::EndpointFactoryManager::create(const string& str, bool oaEndpoint) const { IceUtil::Mutex::Lock sync(*this); // TODO: Necessary? @@ -99,11 +99,11 @@ IceInternal::EndpointFactoryManager::create(const string& str) const if(_factories[i]->protocol() == protocol) { #if 1 - return _factories[i]->create(str.substr(end)); + return _factories[i]->create(str.substr(end), oaEndpoint); #else // Code below left in place for debugging. - EndpointIPtr e = _factories[i]->create(str.substr(end)); + EndpointIPtr e = _factories[i]->create(str.substr(end), oaEndpoint); BasicStream bs(_instance.get()); e->streamWrite(&bs); bs.i = bs.b.begin(); diff --git a/cpp/src/Ice/EndpointFactoryManager.h b/cpp/src/Ice/EndpointFactoryManager.h index acac063e870..c2e5671020a 100644 --- a/cpp/src/Ice/EndpointFactoryManager.h +++ b/cpp/src/Ice/EndpointFactoryManager.h @@ -28,7 +28,7 @@ public: void add(const EndpointFactoryPtr&); EndpointFactoryPtr get(::Ice::Short) const; - EndpointIPtr create(const std::string&) const; + EndpointIPtr create(const std::string&, bool) const; EndpointIPtr read(BasicStream*) const; private: diff --git a/cpp/src/Ice/EndpointI.h b/cpp/src/Ice/EndpointI.h index d6f86782d0b..516438205a3 100644 --- a/cpp/src/Ice/EndpointI.h +++ b/cpp/src/Ice/EndpointI.h @@ -115,15 +115,9 @@ public: // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. + // host if listening on INADDR_ANY. // - virtual std::vector<EndpointIPtr> expand(bool) const = 0; - - // - // Return whether the endpoint should be published in proxies - // created by the Object Adapter. - // - virtual bool publish() const = 0; + virtual std::vector<EndpointIPtr> expand() const = 0; // // Check whether the endpoint is equivalent to a specific diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index 8c93ec5cd7a..0b65103f886 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -567,6 +567,47 @@ Ice::ObjectAdapterI::setLocator(const LocatorPrx& locator) _locatorInfo = _instance->locatorManager()->get(locator); } +void +Ice::ObjectAdapterI::refreshPublishedEndpoints() +{ + LocatorInfoPtr locatorInfo; + bool registerProcess = false; + vector<EndpointIPtr> oldPublishedEndpoints; + + { + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + + checkForDeactivation(); + + oldPublishedEndpoints = _publishedEndpoints; + _publishedEndpoints = parsePublishedEndpoints(); + + locatorInfo = _locatorInfo; + if(!_noConfig) + { + registerProcess = + _instance->initializationData().properties->getPropertyAsInt(_name + ".RegisterProcess") > 0; + } + } + + try + { + Ice::Identity dummy; + dummy.name = "dummy"; + updateLocatorRegistry(locatorInfo, createDirectProxy(dummy), registerProcess); + } + catch(const Ice::LocalException& ex) + { + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + + // + // Restore the old published endpoints. + // + _publishedEndpoints = oldPublishedEndpoints; + ex.ice_throw(); + } +} + bool Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const { @@ -899,22 +940,9 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica } // - // Parse published endpoints. If set, these are used in proxies - // instead of the connection factory endpoints. - // - string endpts = properties->getProperty(_name + ".PublishedEndpoints"); - _publishedEndpoints = parseEndpoints(endpts); - if(_publishedEndpoints.empty()) - { - transform(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(), - back_inserter(_publishedEndpoints), Ice::constMemFun(&IncomingConnectionFactory::endpoint)); - } - - // - // Filter out any endpoints that are not meant to be published. + // Parse the published endpoints. // - _publishedEndpoints.erase(remove_if(_publishedEndpoints.begin(), _publishedEndpoints.end(), - not1(Ice::constMemFun(&EndpointI::publish))), _publishedEndpoints.end()); + _publishedEndpoints = parsePublishedEndpoints(); } if(!properties->getProperty(_name + ".Locator").empty()) @@ -1070,15 +1098,14 @@ Ice::ObjectAdapterI::parseEndpoints(const string& endpts) const } string s = endpts.substr(beg, end - beg); - EndpointIPtr endp = _instance->endpointFactoryManager()->create(s); + EndpointIPtr endp = _instance->endpointFactoryManager()->create(s, true); if(endp == 0) { EndpointParseException ex(__FILE__, __LINE__); ex.str = s; throw ex; } - vector<EndpointIPtr> endps = endp->expand(true); - endpoints.insert(endpoints.end(), endps.begin(), endps.end()); + endpoints.push_back(endp); ++end; } @@ -1086,6 +1113,34 @@ Ice::ObjectAdapterI::parseEndpoints(const string& endpts) const return endpoints; } +std::vector<EndpointIPtr> +ObjectAdapterI::parsePublishedEndpoints() +{ + // + // Parse published endpoints. If set, these are used in proxies + // instead of the connection factory endpoints. + // + string endpts = _communicator->getProperties()->getProperty(_name + ".PublishedEndpoints"); + vector<EndpointIPtr> endpoints = parseEndpoints(endpts); + if(endpoints.empty()) + { + transform(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(), + back_inserter(endpoints), Ice::constMemFun(&IncomingConnectionFactory::endpoint)); + } + + // + // Expand any endpoints that may be listening on INADDR_ANY to + // include actual addresses in the published endpoints. + // + vector<EndpointIPtr> expandedEndpoints; + for(unsigned int i = 0; i < endpoints.size(); ++i) + { + vector<EndpointIPtr> endps = endpoints[i]->expand(); + expandedEndpoints.insert(expandedEndpoints.end(), endps.begin(), endps.end()); + } + return expandedEndpoints; +} + void ObjectAdapterI::updateLocatorRegistry(const IceInternal::LocatorInfoPtr& locatorInfo, const Ice::ObjectPrx& proxy, diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h index 89fa481a659..13de0a9cd99 100644 --- a/cpp/src/Ice/ObjectAdapterI.h +++ b/cpp/src/Ice/ObjectAdapterI.h @@ -73,6 +73,7 @@ public: virtual ObjectPrx createReverseProxy(const Identity&) const; virtual void setLocator(const LocatorPrx&); + virtual void refreshPublishedEndpoints(); bool isLocal(const ObjectPrx&) const; @@ -100,6 +101,7 @@ private: void checkForDeactivation() const; static void checkIdentity(const Identity&); std::vector<IceInternal::EndpointIPtr> parseEndpoints(const std::string&) const; + std::vector<IceInternal::EndpointIPtr> parsePublishedEndpoints(); void updateLocatorRegistry(const IceInternal::LocatorInfoPtr&, const Ice::ObjectPrx&, bool); bool filterProperties(Ice::StringSeq&); diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index e296e3e32fc..40272aca13d 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -457,10 +457,10 @@ IceInternal::ReferenceFactory::create(const string& str) } string es = s.substr(beg, end - beg); - EndpointIPtr endp = _instance->endpointFactoryManager()->create(es); + EndpointIPtr endp = _instance->endpointFactoryManager()->create(es, false); if(endp != 0) { - vector<EndpointIPtr> endps = endp->expand(false); + vector<EndpointIPtr> endps = endp->expand(); endpoints.insert(endpoints.end(), endps.begin(), endps.end()); } else diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index 0d0573840fa..b7552308727 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -22,23 +22,23 @@ using namespace Ice; using namespace IceInternal; IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const string& ho, Int po, Int ti, - const string& conId, bool co, bool pub) : + const string& conId, bool co, bool oae) : _instance(instance), _host(ho), _port(po), _timeout(ti), _connectionId(conId), _compress(co), - _publish(pub) + _oaEndpoint(oae) { } -IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const string& str) : +IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const string& str, bool oaEndpoint) : _instance(instance), _port(0), _timeout(-1), _compress(false), - _publish(true) + _oaEndpoint(oaEndpoint) { const string delim = " \t\n\r"; @@ -138,6 +138,26 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin } } } + + if(_host.empty()) + { + const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost; + if(_host.empty()) + { + if(oaEndpoint) + { + const_cast<string&>(_host) = "0.0.0.0"; + } + else + { + const_cast<string&>(_host) = "127.0.0.1"; + } + } + } + else if(_host == "*") + { + const_cast<string&>(_host) = "0.0.0.0"; + } } IceInternal::TcpEndpointI::TcpEndpointI(BasicStream* s) : @@ -145,7 +165,7 @@ IceInternal::TcpEndpointI::TcpEndpointI(BasicStream* s) : _port(0), _timeout(-1), _compress(false), - _publish(true) + _oaEndpoint(false) { s->startReadEncaps(); s->read(const_cast<string&>(_host), false); @@ -211,7 +231,7 @@ IceInternal::TcpEndpointI::timeout(Int timeout) const } else { - return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish); + return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _oaEndpoint); } } @@ -224,7 +244,7 @@ IceInternal::TcpEndpointI::connectionId(const string& connectionId) const } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish); + return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _oaEndpoint); } } @@ -243,7 +263,7 @@ IceInternal::TcpEndpointI::compress(bool compress) const } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish); + return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _oaEndpoint); } } @@ -295,57 +315,35 @@ AcceptorPtr IceInternal::TcpEndpointI::acceptor(EndpointIPtr& endp, const string&) const { TcpAcceptor* p = new TcpAcceptor(_instance, _host, _port); - endp = new TcpEndpointI(_instance, _host, p->effectivePort(), _timeout, _connectionId, _compress, _publish); + endp = new TcpEndpointI(_instance, _host, p->effectivePort(), _timeout, _connectionId, _compress, _oaEndpoint); return p; } + vector<EndpointIPtr> -IceInternal::TcpEndpointI::expand(bool server) const +IceInternal::TcpEndpointI::expand() const { - if(_host.empty()) - { - const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost; - if(_host.empty()) - { - if(server) - { - const_cast<string&>(_host) = "0.0.0.0"; - } - else - { - const_cast<string&>(_host) = "127.0.0.1"; - } - } - } - else if(_host == "*") - { - const_cast<string&>(_host) = "0.0.0.0"; - } - vector<EndpointIPtr> endps; if(_host == "0.0.0.0") { vector<string> hosts = getLocalHosts(); for(unsigned int i = 0; i < hosts.size(); ++i) { - endps.push_back(new TcpEndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress, - hosts.size() == 1 || hosts[i] != "127.0.0.1")); + if(!_oaEndpoint || hosts.size() == 1 || hosts[i] != "127.0.0.1") + { + endps.push_back(new TcpEndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress, + _oaEndpoint)); + } } } else { endps.push_back(const_cast<TcpEndpointI*>(this)); - } + } return endps; } bool -IceInternal::TcpEndpointI::publish() const -{ - return _publish; -} - -bool IceInternal::TcpEndpointI::equivalent(const TransceiverPtr&) const { return false; @@ -533,9 +531,9 @@ IceInternal::TcpEndpointFactory::protocol() const } EndpointIPtr -IceInternal::TcpEndpointFactory::create(const std::string& str) const +IceInternal::TcpEndpointFactory::create(const std::string& str, bool oaEndpoint) const { - return new TcpEndpointI(_instance, str); + return new TcpEndpointI(_instance, str, oaEndpoint); } EndpointIPtr diff --git a/cpp/src/Ice/TcpEndpointI.h b/cpp/src/Ice/TcpEndpointI.h index 0e003a179ef..cd482946ba6 100644 --- a/cpp/src/Ice/TcpEndpointI.h +++ b/cpp/src/Ice/TcpEndpointI.h @@ -23,7 +23,7 @@ class TcpEndpointI : public EndpointI public: TcpEndpointI(const InstancePtr&, const std::string&, Ice::Int, Ice::Int, const std::string&, bool, bool); - TcpEndpointI(const InstancePtr&, const std::string&); + TcpEndpointI(const InstancePtr&, const std::string&, bool); TcpEndpointI(BasicStream*); virtual void streamWrite(BasicStream*) const; @@ -41,8 +41,7 @@ public: virtual TransceiverPtr serverTransceiver(EndpointIPtr&) const; virtual std::vector<ConnectorPtr> connectors() const; virtual AcceptorPtr acceptor(EndpointIPtr&, const std::string&) const; - virtual std::vector<EndpointIPtr> expand(bool) const; - virtual bool publish() const; + virtual std::vector<EndpointIPtr> expand() const; virtual bool equivalent(const TransceiverPtr&) const; virtual bool equivalent(const AcceptorPtr&) const; @@ -71,7 +70,7 @@ private: const Ice::Int _timeout; const std::string _connectionId; const bool _compress; - const bool _publish; + const bool _oaEndpoint; }; class TcpEndpointFactory : public EndpointFactory @@ -82,7 +81,7 @@ public: virtual Ice::Short type() const; virtual std::string protocol() const; - virtual EndpointIPtr create(const std::string&) const; + virtual EndpointIPtr create(const std::string&, bool) const; virtual EndpointIPtr read(BasicStream*) const; virtual void destroy(); diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp index 030c44f6f0b..b365971d608 100644 --- a/cpp/src/Ice/UdpEndpointI.cpp +++ b/cpp/src/Ice/UdpEndpointI.cpp @@ -21,7 +21,7 @@ using namespace Ice; using namespace IceInternal; IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const string& ho, Int po, const string& mif, - Int mttl, bool conn, const string& conId, bool co, bool pub) : + Int mttl, bool conn, const string& conId, bool co, bool oae) : _instance(instance), _host(ho), _port(po), @@ -34,11 +34,11 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin _connect(conn), _connectionId(conId), _compress(co), - _publish(pub) + _oaEndpoint(oae) { } -IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const string& str) : +IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const string& str, bool oaEndpoint) : _instance(instance), _port(0), _mcastTtl(-1), @@ -48,7 +48,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin _encodingMinor(encodingMinor), _connect(false), _compress(false), - _publish(true) + _oaEndpoint(oaEndpoint) { const string delim = " \t\n\r"; @@ -263,6 +263,26 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin ex.str = "udp " + str; } } + + if(_host.empty()) + { + const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost; + if(_host.empty()) + { + if(_oaEndpoint) + { + const_cast<string&>(_host) = "0.0.0.0"; + } + else + { + const_cast<string&>(_host) = "127.0.0.1"; + } + } + } + else if(_host == "*") + { + const_cast<string&>(_host) = "0.0.0.0"; + } } IceInternal::UdpEndpointI::UdpEndpointI(BasicStream* s) : @@ -275,7 +295,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(BasicStream* s) : _encodingMinor(encodingMinor), _connect(false), _compress(false), - _publish(true) + _oaEndpoint(false) { s->startReadEncaps(); s->read(const_cast<string&>(_host), false); @@ -406,7 +426,7 @@ IceInternal::UdpEndpointI::connectionId(const string& connectionId) const else { return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _connect, connectionId, - _compress, _publish); + _compress, _oaEndpoint); } } @@ -426,7 +446,7 @@ IceInternal::UdpEndpointI::compress(bool compress) const else { return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _connect, _connectionId, - compress, _publish); + compress, _oaEndpoint); } } @@ -465,7 +485,7 @@ IceInternal::UdpEndpointI::serverTransceiver(EndpointIPtr& endp) const { UdpTransceiver* p = new UdpTransceiver(_instance, _host, _port, _mcastInterface, _connect); endp = new UdpEndpointI(_instance, _host, p->effectivePort(), _mcastInterface, _mcastTtl, _connect, _connectionId, - _compress, _publish); + _compress, _oaEndpoint); return p; } @@ -484,36 +504,19 @@ IceInternal::UdpEndpointI::acceptor(EndpointIPtr& endp, const string&) const } vector<EndpointIPtr> -IceInternal::UdpEndpointI::expand(bool server) const +IceInternal::UdpEndpointI::expand() const { - if(_host.empty()) - { - const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost; - if(_host.empty()) - { - if(server) - { - const_cast<string&>(_host) = "0.0.0.0"; - } - else - { - const_cast<string&>(_host) = "127.0.0.1"; - } - } - } - else if(_host == "*") - { - const_cast<string&>(_host) = "0.0.0.0"; - } - vector<EndpointIPtr> endps; if(_host == "0.0.0.0") { vector<string> hosts = getLocalHosts(); for(unsigned int i = 0; i < hosts.size(); ++i) { - endps.push_back(new UdpEndpointI(_instance, hosts[i], _port, _mcastInterface, _mcastTtl, _connect, - _connectionId, _compress, hosts.size() == 1 || hosts[i] != "127.0.0.1")); + if(!_oaEndpoint || hosts.size() == 1 || hosts[i] != "127.0.0.1") + { + endps.push_back(new UdpEndpointI(_instance, hosts[i], _port, _mcastInterface, _mcastTtl, _connect, + _connectionId, _compress, _oaEndpoint)); + } } } else @@ -524,12 +527,6 @@ IceInternal::UdpEndpointI::expand(bool server) const } bool -IceInternal::UdpEndpointI::publish() const -{ - return _publish; -} - -bool IceInternal::UdpEndpointI::equivalent(const TransceiverPtr& transceiver) const { const UdpTransceiver* udpTransceiver = dynamic_cast<const UdpTransceiver*>(transceiver.get()); @@ -801,9 +798,9 @@ IceInternal::UdpEndpointFactory::protocol() const } EndpointIPtr -IceInternal::UdpEndpointFactory::create(const std::string& str) const +IceInternal::UdpEndpointFactory::create(const std::string& str, bool oaEndpoint) const { - return new UdpEndpointI(_instance, str); + return new UdpEndpointI(_instance, str, oaEndpoint); } EndpointIPtr diff --git a/cpp/src/Ice/UdpEndpointI.h b/cpp/src/Ice/UdpEndpointI.h index dccb0a78947..bb36be74fc8 100644 --- a/cpp/src/Ice/UdpEndpointI.h +++ b/cpp/src/Ice/UdpEndpointI.h @@ -24,7 +24,7 @@ public: UdpEndpointI(const InstancePtr&, const std::string&, Ice::Int, const std::string&, Ice::Int, bool, const std::string&, bool, bool); - UdpEndpointI(const InstancePtr&, const std::string&); + UdpEndpointI(const InstancePtr&, const std::string&, bool); UdpEndpointI(BasicStream*); virtual void streamWrite(BasicStream*) const; @@ -42,8 +42,7 @@ public: virtual TransceiverPtr serverTransceiver(EndpointIPtr&) const; virtual std::vector<ConnectorPtr> connectors() const; virtual AcceptorPtr acceptor(EndpointIPtr&, const std::string&) const; - virtual std::vector<EndpointIPtr> expand(bool) const; - virtual bool publish() const; + virtual std::vector<EndpointIPtr> expand() const; virtual bool equivalent(const TransceiverPtr&) const; virtual bool equivalent(const AcceptorPtr&) const; @@ -78,7 +77,7 @@ private: const bool _connect; const std::string _connectionId; const bool _compress; - const bool _publish; + const bool _oaEndpoint; }; class UdpEndpointFactory : public EndpointFactory @@ -89,7 +88,7 @@ public: virtual Ice::Short type() const; virtual std::string protocol() const; - virtual EndpointIPtr create(const std::string&) const; + virtual EndpointIPtr create(const std::string&, bool) const; virtual EndpointIPtr read(BasicStream*) const; virtual void destroy(); diff --git a/cpp/src/Ice/UnknownEndpointI.cpp b/cpp/src/Ice/UnknownEndpointI.cpp index a50699e29c7..ed76566f37c 100644 --- a/cpp/src/Ice/UnknownEndpointI.cpp +++ b/cpp/src/Ice/UnknownEndpointI.cpp @@ -228,17 +228,10 @@ IceInternal::UnknownEndpointI::acceptor(EndpointIPtr& endp, const string&) const } vector<EndpointIPtr> -IceInternal::UnknownEndpointI::expand(bool) const +IceInternal::UnknownEndpointI::expand() const { - vector<EndpointIPtr> ret; - ret.push_back(const_cast<UnknownEndpointI*>(this)); - return ret; -} - -bool -IceInternal::UnknownEndpointI::publish() const -{ - return false; + vector<EndpointIPtr> endps; + return endps; } bool diff --git a/cpp/src/Ice/UnknownEndpointI.h b/cpp/src/Ice/UnknownEndpointI.h index 2247c0485a2..cbbb2b8842a 100644 --- a/cpp/src/Ice/UnknownEndpointI.h +++ b/cpp/src/Ice/UnknownEndpointI.h @@ -38,8 +38,7 @@ public: virtual TransceiverPtr serverTransceiver(EndpointIPtr&) const; virtual std::vector<ConnectorPtr> connectors() const; virtual AcceptorPtr acceptor(EndpointIPtr&, const std::string&) const; - virtual std::vector<EndpointIPtr> expand(bool) const; - virtual bool publish() const; + virtual std::vector<EndpointIPtr> expand() const; virtual bool equivalent(const TransceiverPtr&) const; virtual bool equivalent(const AcceptorPtr&) const; diff --git a/cpp/src/IceGrid/ServerAdapterI.cpp b/cpp/src/IceGrid/ServerAdapterI.cpp index 52a63bb3de1..85023b27a3d 100644 --- a/cpp/src/IceGrid/ServerAdapterI.cpp +++ b/cpp/src/IceGrid/ServerAdapterI.cpp @@ -127,13 +127,16 @@ ServerAdapterI::setDirectProxy(const Ice::ObjectPrx& prx, const Ice::Current&) // We don't allow to override an existing proxy by another non // null proxy if the server is not inactive. // - if(prx && _proxy) - { - if(_server->getState() == Active) - { - throw AdapterActiveException(); - } - } + // TODO: This check would fail with the new refreshPublishedEndpoints() call. + // Is some protesction still needed though? + // + //if(prx && _proxy) + //{ + // if(_server->getState() == Active) + // { + // throw AdapterActiveException(); + // } + //} bool updated = _proxy != prx; _proxy = prx; diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp index 9e95dd5aa1e..c057910370c 100644 --- a/cpp/src/IceSSL/EndpointI.cpp +++ b/cpp/src/IceSSL/EndpointI.cpp @@ -22,23 +22,23 @@ using namespace Ice; using namespace IceSSL; IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& ho, Int po, Int ti, const string& conId, - bool co, bool pub) : + bool co, bool oae) : _instance(instance), _host(ho), _port(po), _timeout(ti), _connectionId(conId), _compress(co), - _publish(pub) + _oaEndpoint(oae) { } -IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str) : +IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str, bool oaEndpoint) : _instance(instance), _port(0), _timeout(-1), _compress(false), - _publish(true) + _oaEndpoint(oaEndpoint) { const string delim = " \t\n\r"; @@ -138,6 +138,26 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str) : } } } + + if(_host.empty()) + { + const_cast<string&>(_host) = _instance->defaultHost(); + if(_host.empty()) + { + if(_oaEndpoint) + { + const_cast<string&>(_host) = "0.0.0.0"; + } + else + { + const_cast<string&>(_host) = "127.0.0.1"; + } + } + } + else if(_host == "*") + { + const_cast<string&>(_host) = "0.0.0.0"; + } } IceSSL::EndpointI::EndpointI(const InstancePtr& instance, IceInternal::BasicStream* s) : @@ -145,7 +165,7 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, IceInternal::BasicStre _port(0), _timeout(-1), _compress(false), - _publish(true) + _oaEndpoint(false) { s->startReadEncaps(); s->read(const_cast<string&>(_host), false); @@ -211,7 +231,7 @@ IceSSL::EndpointI::timeout(Int timeout) const } else { - return new EndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish); + return new EndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _oaEndpoint); } } @@ -224,7 +244,7 @@ IceSSL::EndpointI::connectionId(const string& connectionId) const } else { - return new EndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish); + return new EndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _oaEndpoint); } } @@ -243,7 +263,7 @@ IceSSL::EndpointI::compress(bool compress) const } else { - return new EndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish); + return new EndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _oaEndpoint); } } @@ -295,41 +315,24 @@ IceInternal::AcceptorPtr IceSSL::EndpointI::acceptor(IceInternal::EndpointIPtr& endp, const string& adapterName) const { AcceptorI* p = new AcceptorI(_instance, adapterName, _host, _port); - endp = new EndpointI(_instance, _host, p->effectivePort(), _timeout, _connectionId, _compress, _publish); + endp = new EndpointI(_instance, _host, p->effectivePort(), _timeout, _connectionId, _compress, _oaEndpoint); return p; } vector<IceInternal::EndpointIPtr> -IceSSL::EndpointI::expand(bool server) const +IceSSL::EndpointI::expand() const { - if(_host.empty()) - { - const_cast<string&>(_host) = _instance->defaultHost(); - if(_host.empty()) - { - if(server) - { - const_cast<string&>(_host) = "0.0.0.0"; - } - else - { - const_cast<string&>(_host) = "127.0.0.1"; - } - } - } - else if(_host == "*") - { - const_cast<string&>(_host) = "0.0.0.0"; - } - vector<IceInternal::EndpointIPtr> endps; if(_host == "0.0.0.0") { vector<string> hosts = IceInternal::getLocalHosts(); for(unsigned int i = 0; i < hosts.size(); ++i) { - endps.push_back(new EndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress, - hosts.size() == 1 || hosts[i] != "127.0.0.1")); + if(!_oaEndpoint || hosts.size() == 1 || hosts[i] != "127.0.0.1") + { + endps.push_back(new EndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress, + _oaEndpoint)); + } } } else @@ -340,12 +343,6 @@ IceSSL::EndpointI::expand(bool server) const } bool -IceSSL::EndpointI::publish() const -{ - return _publish; -} - -bool IceSSL::EndpointI::equivalent(const IceInternal::TransceiverPtr&) const { return false; @@ -533,9 +530,9 @@ IceSSL::EndpointFactoryI::protocol() const } IceInternal::EndpointIPtr -IceSSL::EndpointFactoryI::create(const string& str) const +IceSSL::EndpointFactoryI::create(const string& str, bool oaEndpoint) const { - return new EndpointI(_instance, str); + return new EndpointI(_instance, str, oaEndpoint); } IceInternal::EndpointIPtr diff --git a/cpp/src/IceSSL/EndpointI.h b/cpp/src/IceSSL/EndpointI.h index 1d842f2e345..80e22f902af 100644 --- a/cpp/src/IceSSL/EndpointI.h +++ b/cpp/src/IceSSL/EndpointI.h @@ -24,7 +24,7 @@ class EndpointI : public IceInternal::EndpointI public: EndpointI(const InstancePtr&, const std::string&, Ice::Int, Ice::Int, const std::string&, bool, bool); - EndpointI(const InstancePtr&, const std::string&); + EndpointI(const InstancePtr&, const std::string&, bool); EndpointI(const InstancePtr&, IceInternal::BasicStream*); virtual void streamWrite(IceInternal::BasicStream*) const; @@ -42,8 +42,7 @@ public: virtual IceInternal::TransceiverPtr serverTransceiver(IceInternal::EndpointIPtr&) const; virtual std::vector<IceInternal::ConnectorPtr> connectors() const; virtual IceInternal::AcceptorPtr acceptor(IceInternal::EndpointIPtr&, const std::string&) const; - virtual std::vector<IceInternal::EndpointIPtr> expand(bool) const; - virtual bool publish() const; + virtual std::vector<IceInternal::EndpointIPtr> expand() const; virtual bool equivalent(const IceInternal::TransceiverPtr&) const; virtual bool equivalent(const IceInternal::AcceptorPtr&) const; @@ -72,7 +71,7 @@ private: const Ice::Int _timeout; const std::string _connectionId; const bool _compress; - const bool _publish; + const bool _oaEndpoint; }; class EndpointFactoryI : public IceInternal::EndpointFactory @@ -83,7 +82,7 @@ public: virtual Ice::Short type() const; virtual std::string protocol() const; - virtual IceInternal::EndpointIPtr create(const std::string&) const; + virtual IceInternal::EndpointIPtr create(const std::string&, bool) const; virtual IceInternal::EndpointIPtr read(IceInternal::BasicStream*) const; virtual void destroy(); diff --git a/cs/CHANGES b/cs/CHANGES index 120389eb8ac..e26ae5630b3 100644 --- a/cs/CHANGES +++ b/cs/CHANGES @@ -1,6 +1,17 @@ Changes since version 3.2.X (binary incompabible) ------------------------------------------------- +- Added a new method to the ObjectAdapter interface named + refreshPublishedEndpoints(). This method is meant to be used to + update the published endpoints after change in the available local + interfaces or after the PublishedEndpoints object adapter property + has been changed by the user. + +- Ice now listens on INADDR_ANY for object adapter endpoints that do + not contain a host name (or are set to use "-h *" or "-h 0.0.0.0"). + Previously, Ice would only listen on the local interfaces that were + present when the adapter was created. + - Added support for udp multicast. See manual for more information. - The Ice.Util.proxyIdentityCompare and proxyIdentityAndFacetCompare diff --git a/cs/src/Ice/EndpointFactory.cs b/cs/src/Ice/EndpointFactory.cs index 5c04622e4d2..e8d9f625a3f 100755 --- a/cs/src/Ice/EndpointFactory.cs +++ b/cs/src/Ice/EndpointFactory.cs @@ -14,7 +14,7 @@ namespace IceInternal { short type(); string protocol(); - EndpointI create(string str); + EndpointI create(string str, bool oaEndpoint); EndpointI read(BasicStream s); void destroy(); } diff --git a/cs/src/Ice/EndpointFactoryManager.cs b/cs/src/Ice/EndpointFactoryManager.cs index 3454d64f90a..4d6e04bec22 100755 --- a/cs/src/Ice/EndpointFactoryManager.cs +++ b/cs/src/Ice/EndpointFactoryManager.cs @@ -54,7 +54,7 @@ namespace IceInternal } } - public EndpointI create(string str) + public EndpointI create(string str, bool oaEndpoint) { lock(this) { @@ -82,12 +82,12 @@ namespace IceInternal EndpointFactory f = (EndpointFactory)_factories[i]; if(f.protocol().Equals(protocol)) { - return f.create(s.Substring(m.Index + m.Length)); + return f.create(s.Substring(m.Index + m.Length), oaEndpoint); // Code below left in place for debugging. /* - EndpointI e = f.create(s.Substring(m.Index + m.Length)); + EndpointI e = f.create(s.Substring(m.Index + m.Length), oaEndpoint); BasicStream bs = new BasicStream(instance_, true); e.streamWrite(bs); IceInternal.ByteBuffer buf = bs.prepareRead(); diff --git a/cs/src/Ice/EndpointI.cs b/cs/src/Ice/EndpointI.cs index 8e85db570a1..b0997203116 100755 --- a/cs/src/Ice/EndpointI.cs +++ b/cs/src/Ice/EndpointI.cs @@ -122,15 +122,9 @@ namespace IceInternal // Expand endpoint out in to separate endpoints for each local // host if endpoint was configured with no host set. // - public abstract ArrayList expand(bool server); + public abstract ArrayList expand(); // - // Return whether the endpoint should be published in proxies - // created by the Object Adapter. - // - public abstract bool publish(); - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor. // diff --git a/cs/src/Ice/ObjectAdapterI.cs b/cs/src/Ice/ObjectAdapterI.cs index 6645f3796e4..99b2d3934c9 100755 --- a/cs/src/Ice/ObjectAdapterI.cs +++ b/cs/src/Ice/ObjectAdapterI.cs @@ -571,6 +571,46 @@ namespace Ice } } + public void refreshPublishedEndpoints() + { + IceInternal.LocatorInfo locatorInfo = null; + bool registerProcess = false; + ArrayList oldPublishedEndpoints; + + lock(this) + { + checkForDeactivation(); + + oldPublishedEndpoints = _publishedEndpoints; + _publishedEndpoints = parsePublishedEndpoints(); + + locatorInfo = _locatorInfo; + if(!_noConfig) + { + registerProcess = + instance_.initializationData().properties.getPropertyAsInt(_name + ".RegisterProcess") > 0; + } + } + + try + { + Ice.Identity dummy = new Ice.Identity(); + dummy.name = "dummy"; + updateLocatorRegistry(locatorInfo, createDirectProxy(dummy), registerProcess); + } + catch(Ice.LocalException ex) + { + lock(this) + { + // + // Restore the old published endpoints. + // + _publishedEndpoints = oldPublishedEndpoints; + throw ex; + } + } + } + public bool isLocal(ObjectPrx proxy) { IceInternal.Reference r = ((ObjectPrxHelperBase)proxy).reference__(); @@ -920,31 +960,9 @@ namespace Ice } // - // Parse published endpoints. If set, these are used in proxies - // instead of the connection factory endpoints. + // Parse published endpoints. // - string endpts = properties.getProperty(_name + ".PublishedEndpoints"); - _publishedEndpoints = parseEndpoints(endpts); - if(_publishedEndpoints.Count == 0) - { - foreach(IceInternal.IncomingConnectionFactory factory in _incomingConnectionFactories) - { - _publishedEndpoints.Add(factory.endpoint()); - } - } - - // - // Filter out any endpoints that are not meant to be published. - // - ArrayList tmp = new ArrayList(); - foreach(IceInternal.EndpointI endpoint in _publishedEndpoints) - { - if(endpoint.publish()) - { - tmp.Add(endpoint); - } - } - _publishedEndpoints = tmp; + _publishedEndpoints = parsePublishedEndpoints(); } if(properties.getProperty(_name + ".Locator").Length > 0) @@ -1124,7 +1142,7 @@ namespace Ice } string s = endpts.Substring(beg, (end) - (beg)); - IceInternal.EndpointI endp = instance_.endpointFactoryManager().create(s); + IceInternal.EndpointI endp = instance_.endpointFactoryManager().create(s, true); if(endp == null) { if(IceInternal.AssemblyUtil.runtime_ == IceInternal.AssemblyUtil.Runtime.Mono && @@ -1139,8 +1157,7 @@ namespace Ice e2.str = s; throw e2; } - ArrayList endps = endp.expand(true); - endpoints.AddRange(endps); + endpoints.Add(endp); ++end; } @@ -1148,6 +1165,36 @@ namespace Ice return endpoints; } + ArrayList parsePublishedEndpoints() + { + + // + // Parse published endpoints. If set, these are used in proxies + // instead of the connection factory endpoints. + // + string endpts = instance_.initializationData().properties.getProperty(_name + ".PublishedEndpoints"); + ArrayList endpoints = parseEndpoints(endpts); + if(endpoints.Count == 0) + { + foreach(IceInternal.IncomingConnectionFactory factory in _incomingConnectionFactories) + { + endpoints.Add(factory.endpoint()); + } + } + + // + // Expand any endpoints that may be listening on INADDR_ANY to + // include actual addresses in the published endpoints. + // + ArrayList expandedEndpoints = new ArrayList(); + foreach(IceInternal.EndpointI endp in endpoints) + { + ArrayList endps = endp.expand(); + expandedEndpoints.AddRange(endps); + } + return expandedEndpoints; + } + private void updateLocatorRegistry(IceInternal.LocatorInfo locatorInfo, ObjectPrx proxy, bool registerProcess) { if(!registerProcess && _id.Length == 0) diff --git a/cs/src/Ice/ReferenceFactory.cs b/cs/src/Ice/ReferenceFactory.cs index 888b3e7890e..fb8abf5b062 100755 --- a/cs/src/Ice/ReferenceFactory.cs +++ b/cs/src/Ice/ReferenceFactory.cs @@ -439,10 +439,10 @@ namespace IceInternal } string es = s.Substring(beg, end - beg); - EndpointI endp = instance_.endpointFactoryManager().create(es); + EndpointI endp = instance_.endpointFactoryManager().create(es, false); if(endp != null) { - ArrayList endps = endp.expand(false); + ArrayList endps = endp.expand(); endpoints.AddRange(endps); } else diff --git a/cs/src/Ice/TcpEndpointI.cs b/cs/src/Ice/TcpEndpointI.cs index 8e4cad40d6e..6aaa992fed1 100755 --- a/cs/src/Ice/TcpEndpointI.cs +++ b/cs/src/Ice/TcpEndpointI.cs @@ -17,7 +17,7 @@ namespace IceInternal { internal const short TYPE = 1; - public TcpEndpointI(Instance instance, string ho, int po, int ti, string conId, bool co, bool pub) + public TcpEndpointI(Instance instance, string ho, int po, int ti, string conId, bool co, bool oae) { instance_ = instance; _host = ho; @@ -25,18 +25,18 @@ namespace IceInternal _timeout = ti; _connectionId = conId; _compress = co; - _publish = pub; + _oaEndpoint = oae; calcHashValue(); } - public TcpEndpointI(Instance instance, string str) + public TcpEndpointI(Instance instance, string str, bool oaEndpoint) { instance_ = instance; _host = null; _port = 0; _timeout = -1; _compress = false; - _publish = true; + _oaEndpoint = oaEndpoint; char[] separators = { ' ', '\t', '\n', '\r' }; string[] arr = str.Split(separators); @@ -153,6 +153,27 @@ namespace IceInternal } } } + + if(_host == null) + { + _host = instance_.defaultsAndOverrides().defaultHost; + if(_host == null) + { + if(_oaEndpoint) + { + _host = "0.0.0.0"; + } + else + { + _host = "127.0.0.1"; + } + } + } + else if(_host.Equals("*")) + { + _host = "0.0.0.0"; + } + calcHashValue(); } public TcpEndpointI(BasicStream s) @@ -164,7 +185,7 @@ namespace IceInternal _timeout = s.readInt(); _compress = s.readBool(); s.endReadEncaps(); - _publish = true; + _oaEndpoint = false; calcHashValue(); } @@ -236,7 +257,7 @@ namespace IceInternal } else { - return new TcpEndpointI(instance_, _host, _port, timeout, _connectionId, _compress, _publish); + return new TcpEndpointI(instance_, _host, _port, timeout, _connectionId, _compress, _oaEndpoint); } } @@ -251,7 +272,7 @@ namespace IceInternal } else { - return new TcpEndpointI(instance_, _host, _port, _timeout, connectionId, _compress, _publish); + return new TcpEndpointI(instance_, _host, _port, _timeout, connectionId, _compress, _oaEndpoint); } } @@ -277,7 +298,7 @@ namespace IceInternal } else { - return new TcpEndpointI(instance_, _host, _port, _timeout, _connectionId, compress, _publish); + return new TcpEndpointI(instance_, _host, _port, _timeout, _connectionId, compress, _oaEndpoint); } } @@ -353,67 +374,38 @@ namespace IceInternal { TcpAcceptor p = new TcpAcceptor(instance_, _host, _port); endpoint = new TcpEndpointI(instance_, _host, p.effectivePort(), _timeout, _connectionId, - _compress, _publish); + _compress, _oaEndpoint); return p; } // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // public override ArrayList - expand(bool server) + expand() { - if(_host == null) - { - _host = instance_.defaultsAndOverrides().defaultHost; - if(_host == null) - { - if(server) - { - _host = "0.0.0.0"; - } - else - { - _host = "127.0.0.1"; - } - } - } - else if(_host.Equals("*")) - { - _host = "0.0.0.0"; - } - ArrayList endps = new ArrayList(); if(_host.Equals("0.0.0.0")) { string[] hosts = Network.getLocalHosts(); for(int i = 0; i < hosts.Length; ++i) { - endps.Add(new TcpEndpointI(instance_, hosts[i], _port, _timeout, _connectionId, _compress, - hosts.Length == 1 || !hosts[i].Equals("127.0.0.1"))); + if(!_oaEndpoint || hosts.Length == 1 || !hosts[i].Equals("127.0.0.1")) + { + endps.Add(new TcpEndpointI(instance_, hosts[i], _port, _timeout, _connectionId, _compress, + _oaEndpoint)); + } } } else { - calcHashValue(); endps.Add(this); } return endps; } // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public override bool - publish() - { - return _publish; - } - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor // @@ -579,7 +571,7 @@ namespace IceInternal private int _timeout; private string _connectionId = ""; private bool _compress; - private bool _publish; + private bool _oaEndpoint; private int _hashCode; } @@ -600,9 +592,9 @@ namespace IceInternal return "tcp"; } - public EndpointI create(string str) + public EndpointI create(string str, bool oaEndpoint) { - return new TcpEndpointI(instance_, str); + return new TcpEndpointI(instance_, str, oaEndpoint); } public EndpointI read(BasicStream s) diff --git a/cs/src/Ice/UdpEndpointI.cs b/cs/src/Ice/UdpEndpointI.cs index 5c12bd7d9ea..5bdee8eafbf 100755 --- a/cs/src/Ice/UdpEndpointI.cs +++ b/cs/src/Ice/UdpEndpointI.cs @@ -18,7 +18,7 @@ namespace IceInternal internal const short TYPE = 3; public UdpEndpointI(Instance instance, string ho, int po, string mif, int mttl, bool conn, string conId, - bool co, bool pub) + bool co, bool oae) { instance_ = instance; _host = ho; @@ -32,11 +32,11 @@ namespace IceInternal _connect = conn; _connectionId = conId; _compress = co; - _publish = pub; + _oaEndpoint = oae; calcHashValue(); } - public UdpEndpointI(Instance instance, string str) + public UdpEndpointI(Instance instance, string str, bool oaEndpoint) { instance_ = instance; _host = null; @@ -47,7 +47,7 @@ namespace IceInternal _encodingMinor = Protocol.encodingMinor; _connect = false; _compress = false; - _publish = true; + _oaEndpoint = true; char[] splitChars = { ' ', '\t', '\n', '\r' }; string[] arr = str.Split(splitChars); @@ -286,6 +286,27 @@ namespace IceInternal throw e; } } + + if(_host == null) + { + _host = instance_.defaultsAndOverrides().defaultHost; + if(_host == null) + { + if(_oaEndpoint) + { + _host = "0.0.0.0"; + } + else + { + _host = "127.0.0.1"; + } + } + } + else if(_host.Equals("*")) + { + _host = "0.0.0.0"; + } + calcHashValue(); } public UdpEndpointI(BasicStream s) @@ -321,7 +342,7 @@ namespace IceInternal _connect = false; _compress = s.readBool(); s.endReadEncaps(); - _publish = true; + _oaEndpoint = false; calcHashValue(); } @@ -435,7 +456,7 @@ namespace IceInternal else { return new UdpEndpointI(instance_, _host, _port, _mcastInterface, _mcastTtl, _connect, _connectionId, - compress, _publish); + compress, _oaEndpoint); } } @@ -451,7 +472,7 @@ namespace IceInternal else { return new UdpEndpointI(instance_, _host, _port, _mcastInterface, _mcastTtl, _connect, connectionId, - _compress, _publish); + _compress, _oaEndpoint); } } @@ -515,7 +536,7 @@ namespace IceInternal { UdpTransceiver p = new UdpTransceiver(instance_, _host, _port, _mcastInterface, _connect); endpoint = new UdpEndpointI(instance_, _host, p.effectivePort(), _mcastInterface, _mcastTtl, _connect, - _connectionId, _compress, _publish); + _connectionId, _compress, _oaEndpoint); return p; } @@ -543,62 +564,32 @@ namespace IceInternal // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // public override ArrayList - expand(bool server) + expand() { - if(_host == null) - { - _host = instance_.defaultsAndOverrides().defaultHost; - if(_host == null) - { - if(server) - { - _host = "0.0.0.0"; - } - else - { - _host = "127.0.0.1"; - } - } - } - else if(_host.Equals("*")) - { - _host = "0.0.0.0"; - } - ArrayList endps = new ArrayList(); if(_host.Equals("0.0.0.0")) { string[] hosts = Network.getLocalHosts(); for(int i = 0; i < hosts.Length; ++i) { - endps.Add(new UdpEndpointI(instance_, hosts[i], _port, _mcastInterface, _mcastTtl, _connect, - _connectionId, _compress, - hosts.Length == 1 || !hosts[i].Equals("127.0.0.1"))); + if(!_oaEndpoint || hosts.Length == 1 || !hosts[i].Equals("127.0.0.1")) + { + endps.Add(new UdpEndpointI(instance_, hosts[i], _port, _mcastInterface, _mcastTtl, _connect, + _connectionId, _compress, _oaEndpoint)); + } } } else { - calcHashValue(); endps.Add(this); } return endps; } // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public override bool - publish() - { - return _publish; - } - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor // @@ -823,7 +814,7 @@ namespace IceInternal private bool _connect; private string _connectionId = ""; private bool _compress; - private bool _publish; + private bool _oaEndpoint; private int _hashCode; } @@ -844,9 +835,9 @@ namespace IceInternal return "udp"; } - public EndpointI create(string str) + public EndpointI create(string str, bool oaEndpoint) { - return new UdpEndpointI(instance_, str); + return new UdpEndpointI(instance_, str, oaEndpoint); } public EndpointI read(BasicStream s) diff --git a/cs/src/Ice/UnknownEndpointI.cs b/cs/src/Ice/UnknownEndpointI.cs index 2b1ca9148e8..9f26642ee9b 100755 --- a/cs/src/Ice/UnknownEndpointI.cs +++ b/cs/src/Ice/UnknownEndpointI.cs @@ -101,6 +101,7 @@ namespace IceInternal { throw new Ice.EndpointParseException("opaque " + str); } + calcHashValue(); } public UnknownEndpointI(short type, BasicStream s) @@ -258,27 +259,15 @@ namespace IceInternal // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // public override ArrayList - expand(bool server) + expand() { ArrayList endps = new ArrayList(); - calcHashValue(); endps.Add(this); return endps; } - - // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public override bool - publish() - { - return false; - } // // Check whether the endpoint is equivalent to a specific diff --git a/cs/src/IceSSL/EndpointI.cs b/cs/src/IceSSL/EndpointI.cs index ea180e3f42a..58bda042867 100755 --- a/cs/src/IceSSL/EndpointI.cs +++ b/cs/src/IceSSL/EndpointI.cs @@ -16,7 +16,7 @@ namespace IceSSL { internal const short TYPE = 2; - internal EndpointI(Instance instance, string ho, int po, int ti, string conId, bool co, bool pub) + internal EndpointI(Instance instance, string ho, int po, int ti, string conId, bool co, bool oae) { instance_ = instance; host_ = ho; @@ -24,18 +24,18 @@ namespace IceSSL timeout_ = ti; connectionId_ = conId; compress_ = co; - publish_ = pub; + oaEndpoint_ = oae; calcHashValue(); } - internal EndpointI(Instance instance, string str) + internal EndpointI(Instance instance, string str, bool oaEndpoint) { instance_ = instance; host_ = null; port_ = 0; timeout_ = -1; compress_ = false; - publish_ = true; + oaEndpoint_ = oaEndpoint; char[] separators = { ' ', '\t', '\n', '\r' }; string[] arr = str.Split(separators); @@ -152,6 +152,27 @@ namespace IceSSL } } } + + if(host_ == null) + { + host_ = instance_.defaultHost(); + if(host_ == null) + { + if(oaEndpoint_) + { + host_ = "0.0.0.0"; + } + else + { + host_ = "127.0.0.1"; + } + } + } + else if(host_.Equals("*")) + { + host_ = "0.0.0.0"; + } + calcHashValue(); } internal EndpointI(Instance instance, IceInternal.BasicStream s) @@ -163,7 +184,7 @@ namespace IceSSL timeout_ = s.readInt(); compress_ = s.readBool(); s.endReadEncaps(); - publish_ = true; + oaEndpoint_ = false; calcHashValue(); } @@ -235,7 +256,7 @@ namespace IceSSL } else { - return new EndpointI(instance_, host_, port_, timeout, connectionId_, compress_, publish_); + return new EndpointI(instance_, host_, port_, timeout, connectionId_, compress_, oaEndpoint_); } } @@ -250,7 +271,7 @@ namespace IceSSL } else { - return new EndpointI(instance_, host_, port_, timeout_, connectionId, compress_, publish_); + return new EndpointI(instance_, host_, port_, timeout_, connectionId, compress_, oaEndpoint_); } } @@ -276,7 +297,7 @@ namespace IceSSL } else { - return new EndpointI(instance_, host_, port_, timeout_, connectionId_, compress, publish_); + return new EndpointI(instance_, host_, port_, timeout_, connectionId_, compress, oaEndpoint_); } } @@ -351,65 +372,38 @@ namespace IceSSL public override IceInternal.Acceptor acceptor(ref IceInternal.EndpointI endpoint, string adapterName) { AcceptorI p = new AcceptorI(instance_, adapterName, host_, port_); - endpoint = new EndpointI(instance_, host_, p.effectivePort(), timeout_, connectionId_, compress_, publish_); + endpoint = + new EndpointI(instance_, host_, p.effectivePort(), timeout_, connectionId_, compress_, oaEndpoint_); return p; } // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // - public override ArrayList expand(bool server) + public override ArrayList expand() { - if(host_ == null) - { - host_ = instance_.defaultHost(); - if(host_ == null) - { - if(server) - { - host_ = "0.0.0.0"; - } - else - { - host_ = "127.0.0.1"; - } - } - } - else if(host_.Equals("*")) - { - host_ = "0.0.0.0"; - } - ArrayList endps = new ArrayList(); if(host_.Equals("0.0.0.0")) { string[] hosts = IceInternal.Network.getLocalHosts(); for(int i = 0; i < hosts.Length; ++i) { - endps.Add(new EndpointI(instance_, hosts[i], port_, timeout_, connectionId_, compress_, - hosts.Length == 1 || !hosts[i].Equals("127.0.0.1"))); + if(!oaEndpoint_ || hosts.Length == 1 || !hosts[i].Equals("127.0.0.1")) + { + endps.Add(new EndpointI(instance_, hosts[i], port_, timeout_, connectionId_, compress_, + oaEndpoint_); + } } } else { - calcHashValue(); endps.Add(this); } return endps; } // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public override bool publish() - { - return publish_; - } - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor // @@ -575,7 +569,7 @@ namespace IceSSL private int timeout_; private string connectionId_ = ""; private bool compress_; - private bool publish_; + private bool oaEndpoint_; private int hashCode_; } @@ -596,9 +590,9 @@ namespace IceSSL return "ssl"; } - public IceInternal.EndpointI create(string str) + public IceInternal.EndpointI create(string str, bool oaEndpoint) { - return new EndpointI(instance_, str); + return new EndpointI(instance_, str, oaEndpoint); } public IceInternal.EndpointI read(IceInternal.BasicStream s) diff --git a/java/CHANGES b/java/CHANGES index 030c332e546..6b3f93ca858 100644 --- a/java/CHANGES +++ b/java/CHANGES @@ -1,6 +1,17 @@ Changes since version 3.2.X (binary incompabible) ------------------------------------------------- +- Added a new method to the ObjectAdapter interface named + refreshPublishedEndpoints(). This method is meant to be used to + update the published endpoints after change in the available local + interfaces or after the PublishedEndpoints object adapter property + has been changed by the user. + +- Ice now listens on INADDR_ANY for object adapter endpoints that do + not contain a host name (or are set to use "-h *" or "-h 0.0.0.0"). + Previously, Ice would only listen on the local interfaces that were + present when the adapter was created. + - Freeze evictor update: - the existing evictor was renamed BackgroundSaveEvictor - added new TransactionalEvictor diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index cfcc8cfcdd6..86fc9f0b6c6 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -565,6 +565,47 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt _locatorInfo = _instance.locatorManager().get(locator); } + public void + refreshPublishedEndpoints() + { + IceInternal.LocatorInfo locatorInfo = null; + boolean registerProcess = false; + java.util.ArrayList oldPublishedEndpoints; + + synchronized(this) + { + checkForDeactivation(); + + oldPublishedEndpoints = _publishedEndpoints; + _publishedEndpoints = parsePublishedEndpoints(); + + locatorInfo = _locatorInfo; + if(!_noConfig) + { + registerProcess = + _instance.initializationData().properties.getPropertyAsInt(_name + ".RegisterProcess") > 0; + } + } + + try + { + Ice.Identity dummy = new Ice.Identity(); + dummy.name = "dummy"; + updateLocatorRegistry(locatorInfo, createDirectProxy(dummy), registerProcess); + } + catch(Ice.LocalException ex) + { + synchronized(this) + { + // + // Restore the old published endpoints. + // + _publishedEndpoints = oldPublishedEndpoints; + throw ex; + } + } + } + public boolean isLocal(ObjectPrx proxy) { @@ -915,33 +956,9 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt } // - // Parse published endpoints. If set, these are used in proxies - // instead of the connection factory Endpoints. - // - String endpts = properties.getProperty(_name + ".PublishedEndpoints"); - _publishedEndpoints = parseEndpoints(endpts); - if(_publishedEndpoints.size() == 0) - { - for(int i = 0; i < _incomingConnectionFactories.size(); ++i) - { - IceInternal.IncomingConnectionFactory factory = - (IceInternal.IncomingConnectionFactory)_incomingConnectionFactories.get(i); - _publishedEndpoints.add(factory.endpoint()); - } - } - - // - // Filter out any endpoints that are not meant to be published. + // Parse the publsihed endpoints. // - java.util.Iterator p = _publishedEndpoints.iterator(); - while(p.hasNext()) - { - IceInternal.EndpointI endpoint = (IceInternal.EndpointI)p.next(); - if(!endpoint.publish()) - { - p.remove(); - } - } + _publishedEndpoints = parsePublishedEndpoints(); } if(properties.getProperty(_name + ".Locator").length() > 0) @@ -1115,15 +1132,14 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt } String s = endpts.substring(beg, end); - IceInternal.EndpointI endp = _instance.endpointFactoryManager().create(s); + IceInternal.EndpointI endp = _instance.endpointFactoryManager().create(s, true); if(endp == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = s; throw e; } - java.util.ArrayList endps = endp.expand(true); - endpoints.addAll(endps); + endpoints.add(endp); ++end; } @@ -1131,6 +1147,40 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt return endpoints; } + private java.util.ArrayList + parsePublishedEndpoints() + { + // + // Parse published endpoints. If set, these are used in proxies + // instead of the connection factory Endpoints. + // + String endpts = _instance.initializationData().properties.getProperty(_name + ".PublishedEndpoints"); + java.util.ArrayList endpoints = parseEndpoints(endpts); + if(endpoints.size() == 0) + { + for(int i = 0; i < _incomingConnectionFactories.size(); ++i) + { + IceInternal.IncomingConnectionFactory factory = + (IceInternal.IncomingConnectionFactory)_incomingConnectionFactories.get(i); + endpoints.add(factory.endpoint()); + } + } + + // + // Expand any endpoints that may be listening on INADDR_ANY to + // include actual addresses in the published endpoints. + // + java.util.ArrayList expandedEndpoints = new java.util.ArrayList(); + java.util.Iterator p = endpoints.iterator(); + while(p.hasNext()) + { + IceInternal.EndpointI endp = (IceInternal.EndpointI)p.next(); + java.util.ArrayList endps = endp.expand(); + expandedEndpoints.addAll(endps); + } + return expandedEndpoints; + } + private void updateLocatorRegistry(IceInternal.LocatorInfo locatorInfo, Ice.ObjectPrx proxy, boolean registerProcess) { diff --git a/java/src/IceInternal/EndpointFactory.java b/java/src/IceInternal/EndpointFactory.java index ed7db6721a1..2a55a48a32a 100644 --- a/java/src/IceInternal/EndpointFactory.java +++ b/java/src/IceInternal/EndpointFactory.java @@ -13,7 +13,7 @@ public interface EndpointFactory { short type(); String protocol(); - EndpointI create(String str); + EndpointI create(String str, boolean oaEndpoint); EndpointI read(BasicStream s); void destroy(); } diff --git a/java/src/IceInternal/EndpointFactoryManager.java b/java/src/IceInternal/EndpointFactoryManager.java index 3ddbbe42b60..52b2e21888e 100644 --- a/java/src/IceInternal/EndpointFactoryManager.java +++ b/java/src/IceInternal/EndpointFactoryManager.java @@ -45,7 +45,7 @@ public final class EndpointFactoryManager } public synchronized EndpointI - create(String str) + create(String str, boolean server) { String s = str.trim(); if(s.length() == 0) @@ -72,12 +72,12 @@ public final class EndpointFactoryManager EndpointFactory f = (EndpointFactory)_factories.get(i); if(f.protocol().equals(protocol)) { - return f.create(s.substring(m.end())); + return f.create(s.substring(m.end()), server); // Code below left in place for debugging. /* - EndpointI e = f.create(s.substring(m.end())); + EndpointI e = f.create(s.substring(m.end()), server); BasicStream bs = new BasicStream(_instance, true); e.streamWrite(bs); java.nio.ByteBuffer buf = bs.prepareRead(); diff --git a/java/src/IceInternal/EndpointI.java b/java/src/IceInternal/EndpointI.java index f20208d8b44..1781db8a5ea 100644 --- a/java/src/IceInternal/EndpointI.java +++ b/java/src/IceInternal/EndpointI.java @@ -120,13 +120,7 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable // Expand endpoint out in to separate endpoints for each local // host if endpoint was configured with no host set. // - public abstract java.util.ArrayList expand(boolean server); - - // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public abstract boolean publish(); + public abstract java.util.ArrayList expand(); // // Check whether the endpoint is equivalent to a specific diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java index 688c2f76be0..06864aa2092 100644 --- a/java/src/IceInternal/ReferenceFactory.java +++ b/java/src/IceInternal/ReferenceFactory.java @@ -425,10 +425,10 @@ public final class ReferenceFactory } String es = s.substring(beg, end); - EndpointI endp = _instance.endpointFactoryManager().create(es); + EndpointI endp = _instance.endpointFactoryManager().create(es, false); if(endp != null) { - java.util.ArrayList endps = endp.expand(false); + java.util.ArrayList endps = endp.expand(); endpoints.addAll(endps); } else diff --git a/java/src/IceInternal/TcpEndpointFactory.java b/java/src/IceInternal/TcpEndpointFactory.java index ace33a69fe3..1bc9e326d66 100644 --- a/java/src/IceInternal/TcpEndpointFactory.java +++ b/java/src/IceInternal/TcpEndpointFactory.java @@ -29,9 +29,9 @@ final class TcpEndpointFactory implements EndpointFactory } public EndpointI - create(String str) + create(String str, boolean oaEndpoint) { - return new TcpEndpointI(_instance, str); + return new TcpEndpointI(_instance, str, oaEndpoint); } public EndpointI diff --git a/java/src/IceInternal/TcpEndpointI.java b/java/src/IceInternal/TcpEndpointI.java index 3acaa224c59..3929ab77681 100644 --- a/java/src/IceInternal/TcpEndpointI.java +++ b/java/src/IceInternal/TcpEndpointI.java @@ -14,7 +14,7 @@ final class TcpEndpointI extends EndpointI final static short TYPE = 1; public - TcpEndpointI(Instance instance, String ho, int po, int ti, String conId, boolean co, boolean pub) + TcpEndpointI(Instance instance, String ho, int po, int ti, String conId, boolean co, boolean oae) { _instance = instance; _host = ho; @@ -22,19 +22,19 @@ final class TcpEndpointI extends EndpointI _timeout = ti; _connectionId = conId; _compress = co; - _publish = pub; + _oaEndpoint = oae; calcHashValue(); } public - TcpEndpointI(Instance instance, String str) + TcpEndpointI(Instance instance, String str, boolean oaEndpoint) { _instance = instance; _host = null; _port = 0; _timeout = -1; _compress = false; - _publish = true; + _oaEndpoint = oaEndpoint; String[] arr = str.split("[ \t\n\r]+"); @@ -132,6 +132,27 @@ final class TcpEndpointI extends EndpointI } } } + + if(_host == null) + { + _host = _instance.defaultsAndOverrides().defaultHost; + if(_host == null) + { + if(_oaEndpoint) + { + _host = "0.0.0.0"; + } + else + { + _host = "127.0.0.1"; + } + } + } + else if(_host.equals("*")) + { + _host = "0.0.0.0"; + } + calcHashValue(); } public @@ -144,7 +165,7 @@ final class TcpEndpointI extends EndpointI _timeout = s.readInt(); _compress = s.readBool(); s.endReadEncaps(); - _publish = true; + _oaEndpoint = false; calcHashValue(); } @@ -221,7 +242,7 @@ final class TcpEndpointI extends EndpointI } else { - return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish); + return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _oaEndpoint); } } @@ -237,7 +258,7 @@ final class TcpEndpointI extends EndpointI } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish); + return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _oaEndpoint); } } @@ -265,7 +286,7 @@ final class TcpEndpointI extends EndpointI } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish); + return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _oaEndpoint); } } @@ -349,38 +370,17 @@ final class TcpEndpointI extends EndpointI { TcpAcceptor p = new TcpAcceptor(_instance, _host, _port); endpoint.value = new TcpEndpointI(_instance, _host, p.effectivePort(), _timeout, _connectionId, - _compress, _publish); + _compress, _oaEndpoint); return p; } // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // public java.util.ArrayList - expand(boolean server) + expand() { - if(_host == null) - { - _host = _instance.defaultsAndOverrides().defaultHost; - if(_host == null) - { - if(server) - { - _host = "0.0.0.0"; - } - else - { - _host = "127.0.0.1"; - } - } - } - else if(_host.equals("*")) - { - _host = "0.0.0.0"; - } - java.util.ArrayList endps = new java.util.ArrayList(); if(_host.equals("0.0.0.0")) { @@ -389,29 +389,21 @@ final class TcpEndpointI extends EndpointI while(iter.hasNext()) { String host = (String)iter.next(); - endps.add(new TcpEndpointI(_instance, host, _port, _timeout, _connectionId, _compress, - hosts.size() == 1 || !host.equals("127.0.0.1"))); + if(!_oaEndpoint || hosts.size() == 1 || !host.equals("127.0.0.1")) + { + endps.add(new TcpEndpointI(_instance, host, _port, _timeout, _connectionId, _compress, + _oaEndpoint)); + } } } else { - calcHashValue(); endps.add(this); } return endps; } // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public boolean - publish() - { - return _publish; - } - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor // @@ -585,6 +577,6 @@ final class TcpEndpointI extends EndpointI private int _timeout; private String _connectionId = ""; private boolean _compress; - private boolean _publish; + private boolean _oaEndpoint; private int _hashCode; } diff --git a/java/src/IceInternal/UdpEndpointFactory.java b/java/src/IceInternal/UdpEndpointFactory.java index 95e886c8bd9..76a98188408 100644 --- a/java/src/IceInternal/UdpEndpointFactory.java +++ b/java/src/IceInternal/UdpEndpointFactory.java @@ -29,9 +29,9 @@ final class UdpEndpointFactory implements EndpointFactory } public EndpointI - create(String str) + create(String str, boolean oaEndpoint) { - return new UdpEndpointI(_instance, str); + return new UdpEndpointI(_instance, str, oaEndpoint); } public EndpointI diff --git a/java/src/IceInternal/UdpEndpointI.java b/java/src/IceInternal/UdpEndpointI.java index 70ad6b17f9c..d31833d8630 100644 --- a/java/src/IceInternal/UdpEndpointI.java +++ b/java/src/IceInternal/UdpEndpointI.java @@ -15,7 +15,7 @@ final class UdpEndpointI extends EndpointI public UdpEndpointI(Instance instance, String ho, int po, String mif, int mttl, boolean conn, String conId, boolean co, - boolean pub) + boolean oae) { _instance = instance; _host = ho; @@ -29,12 +29,12 @@ final class UdpEndpointI extends EndpointI _connect = conn; _connectionId = conId; _compress = co; - _publish = pub; + _oaEndpoint = oae; calcHashValue(); } public - UdpEndpointI(Instance instance, String str) + UdpEndpointI(Instance instance, String str, boolean oaEndpoint) { _instance = instance; _host = null; @@ -45,7 +45,7 @@ final class UdpEndpointI extends EndpointI _encodingMinor = Protocol.encodingMinor; _connect = false; _compress = false; - _publish = true; + _oaEndpoint = oaEndpoint; String[] arr = str.split("[ \t\n\r]+"); @@ -245,6 +245,27 @@ final class UdpEndpointI extends EndpointI throw new Ice.EndpointParseException("udp " + str); } } + + if(_host == null) + { + _host = _instance.defaultsAndOverrides().defaultHost; + if(_host == null) + { + if(_oaEndpoint) + { + _host = "0.0.0.0"; + } + else + { + _host = "127.0.0.1"; + } + } + } + else if(_host.equals("*")) + { + _host = "0.0.0.0"; + } + calcHashValue(); } public @@ -281,7 +302,7 @@ final class UdpEndpointI extends EndpointI _connect = false; _compress = s.readBool(); s.endReadEncaps(); - _publish = true; + _oaEndpoint = false; calcHashValue(); } @@ -401,7 +422,7 @@ final class UdpEndpointI extends EndpointI else { return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _connect, _connectionId, - compress, _publish); + compress, _oaEndpoint); } } @@ -418,7 +439,7 @@ final class UdpEndpointI extends EndpointI else { return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _connect, connectionId, - _compress, _publish); + _compress, _oaEndpoint); } } @@ -490,8 +511,7 @@ final class UdpEndpointI extends EndpointI { UdpTransceiver p = new UdpTransceiver(_instance, _host, _port, _mcastInterface, _connect); endpoint.value = new UdpEndpointI(_instance, _host, p.effectivePort(), _mcastInterface, _mcastTtl, _connect, - _connectionId, _compress, - _publish); + _connectionId, _compress, _oaEndpoint); return p; } @@ -521,32 +541,11 @@ final class UdpEndpointI extends EndpointI // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // public java.util.ArrayList - expand(boolean server) + expand() { - if(_host == null) - { - _host = _instance.defaultsAndOverrides().defaultHost; - if(_host == null) - { - if(server) - { - _host = "0.0.0.0"; - } - else - { - _host = "127.0.0.1"; - } - } - } - else if(_host.equals("*")) - { - _host = "0.0.0.0"; - } - java.util.ArrayList endps = new java.util.ArrayList(); if(_host.equals("0.0.0.0")) { @@ -555,29 +554,21 @@ final class UdpEndpointI extends EndpointI while(iter.hasNext()) { String host = (String)iter.next(); - endps.add(new UdpEndpointI(_instance, host, _port, _mcastInterface, _mcastTtl, _connect, - _connectionId, _compress, hosts.size() == 1 || !host.equals("127.0.0.1"))); + if(!_oaEndpoint || hosts.size() == 1 || !host.equals("127.0.0.1")) + { + endps.add(new UdpEndpointI(_instance, host, _port, _mcastInterface, _mcastTtl, _connect, + _connectionId, _compress, _oaEndpoint)); + } } } else { - calcHashValue(); endps.add(this); } return endps; } // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public boolean - publish() - { - return _publish; - } - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor // @@ -810,6 +801,6 @@ final class UdpEndpointI extends EndpointI private boolean _connect; private String _connectionId = ""; private boolean _compress; - private boolean _publish; + private boolean _oaEndpoint; private int _hashCode; } diff --git a/java/src/IceInternal/UnknownEndpointI.java b/java/src/IceInternal/UnknownEndpointI.java index 300da7a056f..8eae6d67a8e 100644 --- a/java/src/IceInternal/UnknownEndpointI.java +++ b/java/src/IceInternal/UnknownEndpointI.java @@ -269,11 +269,10 @@ final class UnknownEndpointI extends EndpointI // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // public java.util.ArrayList - expand(boolean server) + expand() { java.util.ArrayList endps = new java.util.ArrayList(); calcHashValue(); @@ -282,16 +281,6 @@ final class UnknownEndpointI extends EndpointI } // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public boolean - publish() - { - return false; - } - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor // diff --git a/java/ssl/jdk1.4/IceSSL/EndpointFactoryI.java b/java/ssl/jdk1.4/IceSSL/EndpointFactoryI.java index 84bcd8bb21d..9b8cc99309e 100644 --- a/java/ssl/jdk1.4/IceSSL/EndpointFactoryI.java +++ b/java/ssl/jdk1.4/IceSSL/EndpointFactoryI.java @@ -29,9 +29,9 @@ final class EndpointFactoryI implements IceInternal.EndpointFactory } public IceInternal.EndpointI - create(String str) + create(String str, boolean oaEndpoint) { - return new EndpointI(_instance, str); + return new EndpointI(_instance, str, oaEndpoint); } public IceInternal.EndpointI diff --git a/java/ssl/jdk1.4/IceSSL/EndpointI.java b/java/ssl/jdk1.4/IceSSL/EndpointI.java index 1b871399fbb..7f708d94794 100644 --- a/java/ssl/jdk1.4/IceSSL/EndpointI.java +++ b/java/ssl/jdk1.4/IceSSL/EndpointI.java @@ -14,7 +14,7 @@ final class EndpointI extends IceInternal.EndpointI final static short TYPE = 2; public - EndpointI(Instance instance, String ho, int po, int ti, String conId, boolean co, boolean pub) + EndpointI(Instance instance, String ho, int po, int ti, String conId, boolean co, boolean oae) { _instance = instance; _host = ho; @@ -22,19 +22,19 @@ final class EndpointI extends IceInternal.EndpointI _timeout = ti; _connectionId = conId; _compress = co; - _publish = pub; + _oaEndpoint = oae; calcHashValue(); } public - EndpointI(Instance instance, String str) + EndpointI(Instance instance, String str, boolean oaEndpoint) { _instance = instance; _host = null; _port = 0; _timeout = -1; _compress = false; - _publish = true; + _oaEndpoint = oaEndpoint; String[] arr = str.split("[ \t\n\r]+"); @@ -132,6 +132,27 @@ final class EndpointI extends IceInternal.EndpointI } } } + + if(_host == null) + { + _host = _instance.defaultHost(); + if(_host == null) + { + if(_oaEndpoint) + { + _host = "0.0.0.0"; + } + else + { + _host = "127.0.0.1"; + } + } + } + else if(_host.equals("*")) + { + _host = "0.0.0.0"; + } + calcHashValue(); } public @@ -144,7 +165,7 @@ final class EndpointI extends IceInternal.EndpointI _timeout = s.readInt(); _compress = s.readBool(); s.endReadEncaps(); - _publish = true; + _oaEndpoint = false; calcHashValue(); } @@ -221,7 +242,7 @@ final class EndpointI extends IceInternal.EndpointI } else { - return new EndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish); + return new EndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _oaEndpoint); } } @@ -237,7 +258,7 @@ final class EndpointI extends IceInternal.EndpointI } else { - return new EndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish); + return new EndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _oaEndpoint); } } @@ -265,7 +286,7 @@ final class EndpointI extends IceInternal.EndpointI } else { - return new EndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish); + return new EndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _oaEndpoint); } } @@ -349,38 +370,17 @@ final class EndpointI extends IceInternal.EndpointI { AcceptorI p = new AcceptorI(_instance, adapterName, _host, _port); endpoint.value = new EndpointI(_instance, _host, p.effectivePort(), _timeout, _connectionId, _compress, - _publish); + _oaEndpoint); return p; } // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // public java.util.ArrayList - expand(boolean server) + expand() { - if(_host == null) - { - _host = _instance.defaultHost(); - if(_host == null) - { - if(server) - { - _host = "0.0.0.0"; - } - else - { - _host = "127.0.0.1"; - } - } - } - else if(_host.equals("*")) - { - _host = "0.0.0.0"; - } - java.util.ArrayList endps = new java.util.ArrayList(); if(_host.equals("0.0.0.0")) { @@ -389,29 +389,21 @@ final class EndpointI extends IceInternal.EndpointI while(iter.hasNext()) { String host = (String)iter.next(); - endps.add(new EndpointI(_instance, host, _port, _timeout, _connectionId, _compress, - hosts.size() == 1 || !host.equals("127.0.0.1"))); + if(!_oaEndpoint || hosts.size() == 1 || !host.equals("127.0.0.1")) + { + endps.add(new EndpointI(_instance, host, _port, _timeout, _connectionId, _compress, _oaEndpoint)); + + } } } else { - calcHashValue(); endps.add(this); } return endps; } // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public boolean - publish() - { - return _publish; - } - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor // @@ -585,6 +577,6 @@ final class EndpointI extends IceInternal.EndpointI private int _timeout; private String _connectionId = ""; private boolean _compress; - private boolean _publish; + private boolean _oaEndpoint; private int _hashCode; } diff --git a/java/ssl/jdk1.5/IceSSL/EndpointFactoryI.java b/java/ssl/jdk1.5/IceSSL/EndpointFactoryI.java index 84bcd8bb21d..9b8cc99309e 100644 --- a/java/ssl/jdk1.5/IceSSL/EndpointFactoryI.java +++ b/java/ssl/jdk1.5/IceSSL/EndpointFactoryI.java @@ -29,9 +29,9 @@ final class EndpointFactoryI implements IceInternal.EndpointFactory } public IceInternal.EndpointI - create(String str) + create(String str, boolean oaEndpoint) { - return new EndpointI(_instance, str); + return new EndpointI(_instance, str, oaEndpoint); } public IceInternal.EndpointI diff --git a/java/ssl/jdk1.5/IceSSL/EndpointI.java b/java/ssl/jdk1.5/IceSSL/EndpointI.java index fb38ba324e4..0ecd6d78b3a 100644 --- a/java/ssl/jdk1.5/IceSSL/EndpointI.java +++ b/java/ssl/jdk1.5/IceSSL/EndpointI.java @@ -14,7 +14,7 @@ final class EndpointI extends IceInternal.EndpointI final static short TYPE = 2; public - EndpointI(Instance instance, String ho, int po, int ti, String conId, boolean co, boolean pub) + EndpointI(Instance instance, String ho, int po, int ti, String conId, boolean co, boolean oae) { _instance = instance; _host = ho; @@ -22,19 +22,19 @@ final class EndpointI extends IceInternal.EndpointI _timeout = ti; _connectionId = conId; _compress = co; - _publish = pub; + _oaEndpoint = oae; calcHashValue(); } public - EndpointI(Instance instance, String str) + EndpointI(Instance instance, String str, boolean oaEndpoint) { _instance = instance; _host = null; _port = 0; _timeout = -1; _compress = false; - _publish = true; + _oaEndpoint = oaEndpoint; String[] arr = str.split("[ \t\n\r]+"); @@ -132,6 +132,27 @@ final class EndpointI extends IceInternal.EndpointI } } } + + if(_host == null) + { + _host = _instance.defaultHost(); + if(_host == null) + { + if(_oaEndpoint) + { + _host = "0.0.0.0"; + } + else + { + _host = "127.0.0.1"; + } + } + } + else if(_host.equals("*")) + { + _host = "0.0.0.0"; + } + calcHashValue(); } public @@ -144,7 +165,7 @@ final class EndpointI extends IceInternal.EndpointI _timeout = s.readInt(); _compress = s.readBool(); s.endReadEncaps(); - _publish = true; + _oaEndpoint = false; calcHashValue(); } @@ -221,7 +242,7 @@ final class EndpointI extends IceInternal.EndpointI } else { - return new EndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish); + return new EndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _oaEndpoint); } } @@ -237,7 +258,7 @@ final class EndpointI extends IceInternal.EndpointI } else { - return new EndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish); + return new EndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _oaEndpoint); } } @@ -265,7 +286,7 @@ final class EndpointI extends IceInternal.EndpointI } else { - return new EndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish); + return new EndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _oaEndpoint); } } @@ -349,39 +370,18 @@ final class EndpointI extends IceInternal.EndpointI { AcceptorI p = new AcceptorI(_instance, adapterName, _host, _port); endpoint.value = new EndpointI(_instance, _host, p.effectivePort(), _timeout, _connectionId, _compress, - _publish); + _oaEndpoint); return p; } // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // public java.util.ArrayList - expand(boolean server) + expand() { - if(_host == null) - { - _host = _instance.defaultHost(); - if(_host == null) - { - if(server) - { - _host = "0.0.0.0"; - } - else - { - _host = "127.0.0.1"; - } - } - } - else if(_host.equals("*")) - { - _host = "0.0.0.0"; - } - - java.util.ArrayList<EndpointI> endps = new java.util.ArrayList<EndpointI>(); + java.util.ArrayList endps = new java.util.ArrayList(); if(_host.equals("0.0.0.0")) { java.util.ArrayList hosts = IceInternal.Network.getLocalHosts(); @@ -389,29 +389,21 @@ final class EndpointI extends IceInternal.EndpointI while(iter.hasNext()) { String host = (String)iter.next(); - endps.add(new EndpointI(_instance, host, _port, _timeout, _connectionId, _compress, - hosts.size() == 1 || !host.equals("127.0.0.1"))); + if(!_oaEndpoint || hosts.size() == 1 || !host.equals("127.0.0.1")) + { + endps.add(new EndpointI(_instance, host, _port, _timeout, _connectionId, _compress, _oaEndpoint)); + + } } } else { - calcHashValue(); endps.add(this); } return endps; } // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public boolean - publish() - { - return _publish; - } - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor // @@ -585,6 +577,6 @@ final class EndpointI extends IceInternal.EndpointI private int _timeout; private String _connectionId = ""; private boolean _compress; - private boolean _publish; + private boolean _oaEndpoint; private int _hashCode; } |