diff options
author | Marc Laukien <marc@zeroc.com> | 2001-10-01 02:28:14 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-10-01 02:28:14 +0000 |
commit | af6ee090545af2480f22c91d84bb4f8aba43d052 (patch) | |
tree | c9f8af9f44a14df699f9999b4933cd556f8bc951 /cpp | |
parent | some doc fixes (diff) | |
download | ice-af6ee090545af2480f22c91d84bb4f8aba43d052.tar.bz2 ice-af6ee090545af2480f22c91d84bb4f8aba43d052.tar.xz ice-af6ee090545af2480f22c91d84bb4f8aba43d052.zip |
servant factory/locator management changes
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/Freeze/phonebook/Collocated.cpp | 4 | ||||
-rw-r--r-- | cpp/demo/Freeze/phonebook/PhoneBookI.cpp | 5 | ||||
-rw-r--r-- | cpp/demo/Freeze/phonebook/Server.cpp | 4 | ||||
-rw-r--r-- | cpp/demo/Ice/pickle/Reader.cpp | 2 | ||||
-rw-r--r-- | cpp/demo/Ice/value/Client.cpp | 4 | ||||
-rw-r--r-- | cpp/doc/manual.sgml | 6 | ||||
-rw-r--r-- | cpp/include/Ice/Functional.h | 66 | ||||
-rw-r--r-- | cpp/slice/Ice/Communicator.ice | 47 | ||||
-rw-r--r-- | cpp/slice/Ice/ObjectAdapter.ice | 51 | ||||
-rw-r--r-- | cpp/src/Ice/.depend | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Collector.cpp | 9 | ||||
-rw-r--r-- | cpp/src/Ice/CommunicatorI.cpp | 26 | ||||
-rw-r--r-- | cpp/src/Ice/CommunicatorI.h | 4 | ||||
-rw-r--r-- | cpp/src/Ice/Direct.cpp | 11 | ||||
-rw-r--r-- | cpp/src/Ice/Incoming.cpp | 11 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 86 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.h | 8 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 10 | ||||
-rw-r--r-- | cpp/src/Ice/ServantFactoryManager.cpp | 42 | ||||
-rw-r--r-- | cpp/src/Ice/ServantFactoryManager.h | 8 | ||||
-rw-r--r-- | cpp/src/Ice/Stream.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IcePack/Server.cpp | 2 |
22 files changed, 293 insertions, 117 deletions
diff --git a/cpp/demo/Freeze/phonebook/Collocated.cpp b/cpp/demo/Freeze/phonebook/Collocated.cpp index b02aa8960d7..3e5becb0693 100644 --- a/cpp/demo/Freeze/phonebook/Collocated.cpp +++ b/cpp/demo/Freeze/phonebook/Collocated.cpp @@ -70,7 +70,7 @@ PhoneBookCollocated::run(int argc, char* argv[]) // Create an Object Adapter, use the Evictor as Servant Locator. // ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PhoneBookAdapter"); - adapter->setServantLocator(evictor); + adapter->addServantLocator(evictor, "contact"); // // Create the phonebook, and add it to the Object Adapter. @@ -83,7 +83,7 @@ PhoneBookCollocated::run(int argc, char* argv[]) // ServantFactoryPtr contactFactory = new ContactFactory(phoneBook, evictor); ServantInitializerPtr contactInitializer = ServantInitializerPtr::dynamicCast(contactFactory); - communicator()->installServantFactory(contactFactory, "::Contact"); + communicator()->addServantFactory(contactFactory, "::Contact"); evictor->installServantInitializer(contactInitializer); // diff --git a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp index 69d02daab1b..3a1c70895a4 100644 --- a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp +++ b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp @@ -269,8 +269,5 @@ PhoneBookI::getNewIdentity() ids.push_back(s); _nameIdentitiesDict->put("ID", ids); - return string("phonebook.contact#") + s; + return string("contact#") + s; } - - - diff --git a/cpp/demo/Freeze/phonebook/Server.cpp b/cpp/demo/Freeze/phonebook/Server.cpp index 48732884f89..ea4c8376d2a 100644 --- a/cpp/demo/Freeze/phonebook/Server.cpp +++ b/cpp/demo/Freeze/phonebook/Server.cpp @@ -71,7 +71,7 @@ PhoneBookServer::run(int argc, char* argv[]) // Create an Object Adapter, use the Evictor as Servant Locator. // ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PhoneBookAdapter"); - adapter->setServantLocator(evictor); + adapter->addServantLocator(evictor, "contact"); // // Create the phonebook, and add it to the Object Adapter. @@ -84,7 +84,7 @@ PhoneBookServer::run(int argc, char* argv[]) // ServantFactoryPtr contactFactory = new ContactFactory(phoneBook, evictor); ServantInitializerPtr contactInitializer = ServantInitializerPtr::dynamicCast(contactFactory); - communicator()->installServantFactory(contactFactory, "::Contact"); + communicator()->addServantFactory(contactFactory, "::Contact"); evictor->installServantInitializer(contactInitializer); // diff --git a/cpp/demo/Ice/pickle/Reader.cpp b/cpp/demo/Ice/pickle/Reader.cpp index 238c53bb998..26e5e562bc9 100644 --- a/cpp/demo/Ice/pickle/Reader.cpp +++ b/cpp/demo/Ice/pickle/Reader.cpp @@ -19,7 +19,7 @@ int run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { Ice::ServantFactoryPtr factory = new ServantFactory; - communicator->installServantFactory(factory, "::Persistent"); + communicator->addServantFactory(factory, "::Persistent"); ifstream in("persistent"); if (!in) diff --git a/cpp/demo/Ice/value/Client.cpp b/cpp/demo/Ice/value/Client.cpp index 246fcceb8bf..40946464496 100644 --- a/cpp/demo/Ice/value/Client.cpp +++ b/cpp/demo/Ice/value/Client.cpp @@ -70,7 +70,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cin.getline(&c, 1); Ice::ServantFactoryPtr factory = new ServantFactory; - communicator->installServantFactory(factory, "::Printer"); + communicator->addServantFactory(factory, "::Printer"); initial->printer(printer, printerProxy); cout << "==> " << printer->_message << endl; @@ -119,7 +119,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) << "[press enter]\n"; cin.getline(&c, 1); - communicator->installServantFactory(factory, "::DerivedPrinter"); + communicator->addServantFactory(factory, "::DerivedPrinter"); derivedAsBase = initial->derivedPrinter(); DerivedPrinterPtr derived = DerivedPrinterPtr::dynamicCast(derivedAsBase); diff --git a/cpp/doc/manual.sgml b/cpp/doc/manual.sgml index 7d7071de9a9..79e3825dd06 100644 --- a/cpp/doc/manual.sgml +++ b/cpp/doc/manual.sgml @@ -1,8 +1,8 @@ <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [ -<!ENTITY Ice "<phrase>Ice</phrase>"> -<!ENTITY IcePack "<phrase>IcePack</phrase>"> -<!ENTITY Freeze "<phrase>Freeze</phrase>"> +<!ENTITY Ice "<abbrev>Ice</abbrev>"> +<!ENTITY IcePack "<abbrev>IcePack</abbrev>"> +<!ENTITY Freeze "<abbrev>Freeze</abbrev>"> <!ENTITY SliceDoc SYSTEM "SliceDoc.sgml"> <!ENTITY Properties SYSTEM "Properties.sgml"> diff --git a/cpp/include/Ice/Functional.h b/cpp/include/Ice/Functional.h index 3d972725efc..4565bc1cb9e 100644 --- a/cpp/include/Ice/Functional.h +++ b/cpp/include/Ice/Functional.h @@ -19,119 +19,119 @@ // IceInternal::Handle // ---------------------------------------------------------------------- -namespace IceInternal +namespace Ice { template<class R, class T> -inline ::IceUtilInternal::MemFun<R, T, Handle<T> > +inline ::IceUtilInternal::MemFun<R, T, ::IceInternal::Handle<T> > memFun(R (T::*p)(void)) { - return ::IceUtilInternal::MemFun<R, T, Handle<T> >(p); + return ::IceUtilInternal::MemFun<R, T, ::IceInternal::Handle<T> >(p); } template<class R, class T, class A> -inline ::IceUtilInternal::MemFun1<R, T, Handle<T>, A> +inline ::IceUtilInternal::MemFun1<R, T, ::IceInternal::Handle<T>, A> memFun1(R (T::*p)(A)) { - return ::IceUtilInternal::MemFun1<R, T, Handle<T>, A>(p); + return ::IceUtilInternal::MemFun1<R, T, ::IceInternal::Handle<T>, A>(p); } template<class T> -inline ::IceUtilInternal::VoidMemFun<T, Handle<T> > +inline ::IceUtilInternal::VoidMemFun<T, ::IceInternal::Handle<T> > voidMemFun(void (T::*p)(void)) { - return ::IceUtilInternal::VoidMemFun<T, Handle<T> >(p); + return ::IceUtilInternal::VoidMemFun<T, ::IceInternal::Handle<T> >(p); } template<class T, class A> -inline ::IceUtilInternal::VoidMemFun1<T, Handle<T>, A> +inline ::IceUtilInternal::VoidMemFun1<T, ::IceInternal::Handle<T>, A> voidMemFun1(void (T::*p)(A)) { - return ::IceUtilInternal::VoidMemFun1<T, Handle<T>, A>(p); + return ::IceUtilInternal::VoidMemFun1<T, ::IceInternal::Handle<T>, A>(p); } template<class R, class K, class T> -inline ::IceUtilInternal::SecondMemFun<R, K, T, Handle<T> > +inline ::IceUtilInternal::SecondMemFun<R, K, T, ::IceInternal::Handle<T> > secondMemFun(R (T::*p)(void)) { - return ::IceUtilInternal::SecondMemFun<R, K, T, Handle<T> >(p); + return ::IceUtilInternal::SecondMemFun<R, K, T, ::IceInternal::Handle<T> >(p); } template<class R, class K, class T, class A> -inline ::IceUtilInternal::SecondMemFun1<R, K, T, Handle<T>, A> +inline ::IceUtilInternal::SecondMemFun1<R, K, T, ::IceInternal::Handle<T>, A> secondMemFun1(R (T::*p)(A)) { - return ::IceUtilInternal::SecondMemFun1<R, K, T, Handle<T>, A>(p); + return ::IceUtilInternal::SecondMemFun1<R, K, T, ::IceInternal::Handle<T>, A>(p); } template<class K, class T> -inline ::IceUtilInternal::SecondVoidMemFun<K, T, Handle<T> > +inline ::IceUtilInternal::SecondVoidMemFun<K, T, ::IceInternal::Handle<T> > secondVoidMemFun(void (T::*p)(void)) { - return ::IceUtilInternal::SecondVoidMemFun<K, T, Handle<T> >(p); + return ::IceUtilInternal::SecondVoidMemFun<K, T, ::IceInternal::Handle<T> >(p); } template<class K, class T, class A> -inline ::IceUtilInternal::SecondVoidMemFun1<K, T, Handle<T>, A> +inline ::IceUtilInternal::SecondVoidMemFun1<K, T, ::IceInternal::Handle<T>, A> secondVoidMemFun1(void (T::*p)(A)) { - return ::IceUtilInternal::SecondVoidMemFun1<K, T, Handle<T>, A>(p); + return ::IceUtilInternal::SecondVoidMemFun1<K, T, ::IceInternal::Handle<T>, A>(p); } template<class R, class T> -inline ::IceUtilInternal::ConstMemFun<R, T, Handle<T> > +inline ::IceUtilInternal::ConstMemFun<R, T, ::IceInternal::Handle<T> > constMemFun(R (T::*p)(void) const) { - return ::IceUtilInternal::ConstMemFun<R, T, Handle<T> >(p); + return ::IceUtilInternal::ConstMemFun<R, T, ::IceInternal::Handle<T> >(p); } template<class R, class T, class A> -inline ::IceUtilInternal::ConstMemFun1<R, T, Handle<T>, A> +inline ::IceUtilInternal::ConstMemFun1<R, T, ::IceInternal::Handle<T>, A> constMemFun1(R (T::*p)(A)) { - return ::IceUtilInternal::ConstMemFun1<R, T, Handle<T>, A>(p); + return ::IceUtilInternal::ConstMemFun1<R, T, ::IceInternal::Handle<T>, A>(p); } template<class T> -inline ::IceUtilInternal::ConstVoidMemFun<T, Handle<T> > +inline ::IceUtilInternal::ConstVoidMemFun<T, ::IceInternal::Handle<T> > constVoidMemFun(void (T::*p)(void) const) { - return ::IceUtilInternal::ConstVoidMemFun<T, Handle<T> >(p); + return ::IceUtilInternal::ConstVoidMemFun<T, ::IceInternal::Handle<T> >(p); } template<class T, class A> -inline ::IceUtilInternal::ConstVoidMemFun1<T, Handle<T>, A> +inline ::IceUtilInternal::ConstVoidMemFun1<T, ::IceInternal::Handle<T>, A> constVoidMemFun1(void (T::*p)(A)) { - return ::IceUtilInternal::ConstVoidMemFun1<T, Handle<T>, A>(p); + return ::IceUtilInternal::ConstVoidMemFun1<T, ::IceInternal::Handle<T>, A>(p); } template<class R, class K, class T> -inline ::IceUtilInternal::SecondConstMemFun<R, K, T, Handle<T> > +inline ::IceUtilInternal::SecondConstMemFun<R, K, T, ::IceInternal::Handle<T> > secondConstMemFun(R (T::*p)(void) const) { - return ::IceUtilInternal::SecondConstMemFun<R, K, T, Handle<T> >(p); + return ::IceUtilInternal::SecondConstMemFun<R, K, T, ::IceInternal::Handle<T> >(p); } template<class R, class K, class T, class A> -inline ::IceUtilInternal::SecondConstMemFun1<R, K, T, Handle<T>, A> +inline ::IceUtilInternal::SecondConstMemFun1<R, K, T, ::IceInternal::Handle<T>, A> secondConstMemFun1(R (T::*p)(A)) { - return ::IceUtilInternal::SecondConstMemFun1<R, K, T, Handle<T>, A>(p); + return ::IceUtilInternal::SecondConstMemFun1<R, K, T, ::IceInternal::Handle<T>, A>(p); } template<class K, class T> -inline ::IceUtilInternal::SecondConstVoidMemFun<K, T, Handle<T> > +inline ::IceUtilInternal::SecondConstVoidMemFun<K, T, ::IceInternal::Handle<T> > secondConstVoidMemFun(void (T::*p)(void) const) { - return ::IceUtilInternal::SecondConstVoidMemFun<K, T, Handle<T> >(p); + return ::IceUtilInternal::SecondConstVoidMemFun<K, T, ::IceInternal::Handle<T> >(p); } template<class K, class T, class A> -inline ::IceUtilInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A> +inline ::IceUtilInternal::SecondConstVoidMemFun1<K, T, ::IceInternal::Handle<T>, A> secondConstVoidMemFun1(void (T::*p)(A)) { - return ::IceUtilInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A>(p); + return ::IceUtilInternal::SecondConstVoidMemFun1<K, T, ::IceInternal::Handle<T>, A>(p); } } diff --git a/cpp/slice/Ice/Communicator.ice b/cpp/slice/Ice/Communicator.ice index 5ab59c36fd3..89a6dfb64b9 100644 --- a/cpp/slice/Ice/Communicator.ice +++ b/cpp/slice/Ice/Communicator.ice @@ -162,14 +162,53 @@ local interface Communicator /** * - * Install a new Servant Factory. + * Add a Servant factory to this Communicator. If a factory has + * already been installed for the given id, the current factory + * for this id is replaced by the new one. * - * @param factory The factory to install. + * @param factory The factory to add. * - * @param id The type id for which the factory can create instances. + * @param id The type id for which the factory can create + * instances. + * + * @see removeServantFactory + * @see findServantFactory + * @see ServantFactory + * + **/ + void addServantFactory(ServantFactory factory, string id); + + /** + * + * Remove a Servant factory from this Communicator. This operation + * does nothing if no factory for the given id has been installed. + * + * @param id The type id for which the factory can create + * instances. + * + * @see addServantFactory + * @see findServantFactory + * @see ServantFactory + * + **/ + void removeServantFactory(string id); + + /** + * + * Find a Servant factory installed with this Communicator. + * + * @param id The type id for which the factory can create + * instances. + * + * @return The Servant factory, or null if no Servant factory was + * found for the given id. + * + * @see addServantFactory + * @see removeServantFactory + * @see ServantFactory * **/ - void installServantFactory(ServantFactory factory, string id); + ServantFactory findServantFactory(string id); /** * diff --git a/cpp/slice/Ice/ObjectAdapter.ice b/cpp/slice/Ice/ObjectAdapter.ice index 077d444b77d..499b97921d0 100644 --- a/cpp/slice/Ice/ObjectAdapter.ice +++ b/cpp/slice/Ice/ObjectAdapter.ice @@ -152,28 +152,61 @@ local interface ObjectAdapter /** * - * Set a Servant Locator for this Object Adapter. + * Add a Servant Locator to this Object Adapter. If a locator has + * already been installed for the given prefix, the current + * locator for this prefix is replaced by the new one. If a + * non-empty prefix is specified, the locator will only be called + * for Ice Objects with an identity that starts with + * "<replaceable>prefix</replaceable><literal>#</literal>". If an + * empty prefix is given, the Ice Object identity can be + * completely free-form, except that it cannot contain a + * "<literal>#</literal>". Only one locator for an empty prefix + * can be installed with one single Object Adapter. + * + * @param locator The locator to add. + * + * @param prefix The Ice Object identity prefix for which the + * Servant Locator can locate Servants. + * + * @see removeServantLocator + * @see findServantLocator + * @see ServantLocator * - * @param locator The Servant Locator to set. + **/ + void addServantLocator(ServantLocator locator, string prefix); + + /** * + * Remove a Servant locator from this Object Adapter. This + * operation does nothing if no locator for the given prefix has + * been installed. + * + * @param prefix The Ice Object identity prefix for which the + * Servant Locator can locate Servants. + * + * @see addServantLocator + * @see findServantLocator * @see ServantLocator - * @see getServantLocator * **/ - void setServantLocator(ServantLocator locator); + void removeServantLocator(string prefix); /** * - * Get the Object Locator for this Object Adapter. + * Find a Servant Locator installed with this Object Adapter. + * + * @param prefix The Ice Object identity prefix for which the + * Servant Locator can locate Servants. * - * @return The Servant Locator for this Object Adapter. If no - * Servant Locator is set, null is returned. + * @return The Servant Locator, or null if no Servant Locator was + * found for the given prefix. * + * @see addServantLocator + * @see removeServantLocator * @see ServantLocator - * @see setServantLocator * **/ - ServantLocator getServantLocator(); + ServantLocator findServantLocator(string prefix); /** * diff --git a/cpp/src/Ice/.depend b/cpp/src/Ice/.depend index 2b3ddd9a4a8..ca0f0396472 100644 --- a/cpp/src/Ice/.depend +++ b/cpp/src/Ice/.depend @@ -17,7 +17,7 @@ ObjectAdapter.o: ObjectAdapter.cpp ../../include/Ice/ObjectAdapter.h ../../inclu ObjectAdapterI.o: ObjectAdapterI.cpp ../Ice/ObjectAdapterI.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/CommunicatorF.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/CollectorF.h ../../include/Ice/LocalException.h ../Ice/Instance.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../Ice/TraceLevelsF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/EmitterF.h ../Ice/ServantFactoryManagerF.h ../../include/Ice/PicklerF.h ../../include/Ice/Proxy.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../Ice/ProxyFactory.h ../Ice/Reference.h ../Ice/EndpointF.h ../Ice/Endpoint.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/AcceptorF.h ../Ice/Collector.h ../Ice/EventHandler.h ../Ice/EventHandlerF.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../../include/Ice/Properties.h ../../include/Ice/Functional.h ../../include/IceUtil/Functional.h ObjectAdapterFactory.o: ObjectAdapterFactory.cpp ../Ice/ObjectAdapterFactory.h ../Ice/ObjectAdapterI.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/CommunicatorF.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/CollectorF.h ../../include/Ice/LocalException.h ../../include/Ice/Functional.h ../../include/IceUtil/Functional.h ../Ice/Instance.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../Ice/TraceLevelsF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/EmitterF.h ../Ice/ServantFactoryManagerF.h ../../include/Ice/PicklerF.h ServantFactory.o: ServantFactory.cpp ../../include/Ice/ServantFactory.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h -ServantFactoryManager.o: ServantFactoryManager.cpp ../Ice/ServantFactoryManager.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../Ice/ServantFactoryManagerF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/Config.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/ServantFactory.h +ServantFactoryManager.o: ServantFactoryManager.cpp ../Ice/ServantFactoryManager.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../Ice/ServantFactoryManagerF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/Config.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/ServantFactory.h ../../include/Ice/Functional.h ../../include/IceUtil/Functional.h Endpoint.o: Endpoint.cpp ../Ice/Endpoint.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../Ice/EndpointF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/AcceptorF.h ../Ice/Network.h ../Ice/TcpAcceptor.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../Ice/Acceptor.h ../Ice/TcpConnector.h ../Ice/Connector.h ../Ice/TcpTransceiver.h ../Ice/Transceiver.h ../Ice/SslAcceptor.h ../Ice/SslConnector.h ../Ice/SslTransceiver.h ../Ice/UdpTransceiver.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../../include/Ice/LocalException.h Reference.o: Reference.cpp ../Ice/Reference.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/ReferenceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/Config.h ../Ice/EndpointF.h ../../include/Ice/InstanceF.h ../Ice/Endpoint.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/AcceptorF.h ../../include/Ice/Stream.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../../include/Ice/LocalException.h LocalObject.o: LocalObject.cpp ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h diff --git a/cpp/src/Ice/Collector.cpp b/cpp/src/Ice/Collector.cpp index a6128e2ef36..0726ca0ed9b 100644 --- a/cpp/src/Ice/Collector.cpp +++ b/cpp/src/Ice/Collector.cpp @@ -515,8 +515,7 @@ IceInternal::CollectorFactory::message(Stream&) // // Can't use _collectors.remove_if(constMemFun(...)), because VC++ // doesn't support member templates :-( - _collectors.erase(remove_if(_collectors.begin(), _collectors.end(), - ::IceInternal::constMemFun(&Collector::destroyed)), + _collectors.erase(remove_if(_collectors.begin(), _collectors.end(), ::Ice::constMemFun(&Collector::destroyed)), _collectors.end()); // @@ -623,7 +622,7 @@ IceInternal::CollectorFactory::setState(State state) _threadPool->_register(_acceptor->fd(), this); } - for_each(_collectors.begin(), _collectors.end(), ::IceInternal::voidMemFun(&Collector::activate)); + for_each(_collectors.begin(), _collectors.end(), ::Ice::voidMemFun(&Collector::activate)); break; } @@ -639,7 +638,7 @@ IceInternal::CollectorFactory::setState(State state) _threadPool->unregister(_acceptor->fd()); } - for_each(_collectors.begin(), _collectors.end(), ::IceInternal::voidMemFun(&Collector::hold)); + for_each(_collectors.begin(), _collectors.end(), ::Ice::voidMemFun(&Collector::hold)); break; } @@ -662,7 +661,7 @@ IceInternal::CollectorFactory::setState(State state) _threadPool->unregister(_acceptor->fd()); } } - for_each(_collectors.begin(), _collectors.end(), ::IceInternal::voidMemFun(&Collector::destroy)); + for_each(_collectors.begin(), _collectors.end(), ::Ice::voidMemFun(&Collector::destroy)); _collectors.clear(); break; } diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp index eea0778af89..9ba6b1f2702 100644 --- a/cpp/src/Ice/CommunicatorI.cpp +++ b/cpp/src/Ice/CommunicatorI.cpp @@ -102,14 +102,36 @@ Ice::CommunicatorI::createObjectAdapterWithEndpoints(const string& name, const s } void -Ice::CommunicatorI::installServantFactory(const ServantFactoryPtr& factory, const string& id) +Ice::CommunicatorI::addServantFactory(const ServantFactoryPtr& factory, const string& id) { JTCSyncT<JTCRecursiveMutex> sync(*this); if (!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } - _instance->servantFactoryManager()->install(factory, id); + _instance->servantFactoryManager()->add(factory, id); +} + +void +Ice::CommunicatorI::removeServantFactory(const string& id) +{ + JTCSyncT<JTCRecursiveMutex> sync(*this); + if (!_instance) + { + throw CommunicatorDestroyedException(__FILE__, __LINE__); + } + _instance->servantFactoryManager()->remove(id); +} + +ServantFactoryPtr +Ice::CommunicatorI::findServantFactory(const string& id) +{ + JTCSyncT<JTCRecursiveMutex> sync(*this); + if (!_instance) + { + throw CommunicatorDestroyedException(__FILE__, __LINE__); + } + return _instance->servantFactoryManager()->find(id); } PropertiesPtr diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h index eaf797102f7..e60eb8fdef0 100644 --- a/cpp/src/Ice/CommunicatorI.h +++ b/cpp/src/Ice/CommunicatorI.h @@ -32,7 +32,9 @@ public: virtual ObjectAdapterPtr createObjectAdapter(const std::string&); virtual ObjectAdapterPtr createObjectAdapterWithEndpoints(const std::string&, const std::string&); - virtual void installServantFactory(const ServantFactoryPtr&, const std::string&); + virtual void addServantFactory(const ServantFactoryPtr&, const std::string&); + virtual void removeServantFactory(const std::string&); + virtual ServantFactoryPtr findServantFactory(const std::string&); virtual PropertiesPtr getProperties(); diff --git a/cpp/src/Ice/Direct.cpp b/cpp/src/Ice/Direct.cpp index 59a57e1a4d0..c8a40bf63eb 100644 --- a/cpp/src/Ice/Direct.cpp +++ b/cpp/src/Ice/Direct.cpp @@ -29,7 +29,16 @@ IceInternal::Direct::Direct(const ObjectAdapterPtr& adapter, const ReferencePtr& { if (!_servant) { - _locator = _adapter->getServantLocator(); + string::size_type pos = _reference->identity.find('#'); + if (pos != string::npos) + { + _locator = _adapter->findServantLocator(_reference->identity.substr(0, pos)); + } + else + { + _locator = _adapter->findServantLocator(""); + } + if (_locator) { _servant = _locator->locate(_adapter, _reference->identity, _operation, _cookie); diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index f54520a35fb..f9a74512494 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -47,7 +47,16 @@ IceInternal::Incoming::invoke(Stream& is) { if (!servant) { - locator = _adapter->getServantLocator(); + string::size_type pos = identity.find('#'); + if (pos != string::npos) + { + locator = _adapter->findServantLocator(identity.substr(0, pos)); + } + else + { + locator = _adapter->findServantLocator(""); + } + if (locator) { servant = locator->locate(_adapter, identity, operation, cookie); diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index 0790e49de34..56aa2301eb8 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -52,8 +52,7 @@ Ice::ObjectAdapterI::activate() throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } - for_each(_collectorFactories.begin(), _collectorFactories.end(), - ::IceInternal::voidMemFun(&CollectorFactory::activate)); + for_each(_collectorFactories.begin(), _collectorFactories.end(), Ice::voidMemFun(&CollectorFactory::activate)); } void @@ -66,8 +65,7 @@ Ice::ObjectAdapterI::hold() throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } - for_each(_collectorFactories.begin(), _collectorFactories.end(), - ::IceInternal::voidMemFun(&CollectorFactory::hold)); + for_each(_collectorFactories.begin(), _collectorFactories.end(), Ice::voidMemFun(&CollectorFactory::hold)); } void @@ -84,16 +82,16 @@ Ice::ObjectAdapterI::deactivate() return; } - for_each(_collectorFactories.begin(), _collectorFactories.end(), - ::IceInternal::voidMemFun(&CollectorFactory::destroy)); + for_each(_collectorFactories.begin(), _collectorFactories.end(), Ice::voidMemFun(&CollectorFactory::destroy)); _collectorFactories.clear(); + _activeServantMap.clear(); - _activeServantMapHint = _activeServantMap.begin(); - if (_locator) - { - _locator->deactivate(); - _locator = 0; - } + _activeServantMapHint = _activeServantMap.end(); + + for_each(_locatorMap.begin(), _locatorMap.end(), + secondVoidMemFun<string, ServantLocator>(&ServantLocator::deactivate)); + _locatorMap.clear(); + _locatorMapHint = _locatorMap.end(); } ObjectPrx @@ -149,21 +147,59 @@ Ice::ObjectAdapterI::remove(const string& ident) } _activeServantMap.erase(ident); - _activeServantMapHint = _activeServantMap.begin(); + _activeServantMapHint = _activeServantMap.end(); } void -Ice::ObjectAdapterI::setServantLocator(const ServantLocatorPtr& locator) +Ice::ObjectAdapterI::addServantLocator(const ServantLocatorPtr& locator, const string& prefix) { JTCSyncT<JTCMutex> sync(*this); - _locator = locator; + + if (_collectorFactories.empty()) + { + throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); + } + + _locatorMapHint = _locatorMap.insert(_locatorMapHint, make_pair(prefix, locator)); +} + +void +Ice::ObjectAdapterI::removeServantLocator(const string& prefix) +{ + JTCSyncT<JTCMutex> sync(*this); + + if (_collectorFactories.empty()) + { + throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); + } + + _locatorMap.erase(prefix); + _locatorMapHint = _locatorMap.end(); } ServantLocatorPtr -Ice::ObjectAdapterI::getServantLocator() +Ice::ObjectAdapterI::findServantLocator(const string& prefix) { JTCSyncT<JTCMutex> sync(*this); - return _locator; + + if (_locatorMapHint != _locatorMap.end()) + { + if (_locatorMapHint->first == prefix) + { + return _locatorMapHint->second; + } + } + + map<string, ::Ice::ServantLocatorPtr>::iterator p = _locatorMap.find(prefix); + if (p != _locatorMap.end()) + { + _locatorMapHint = p; + return p->second; + } + else + { + return 0; + } } ObjectPtr @@ -171,9 +207,18 @@ Ice::ObjectAdapterI::identityToServant(const string& ident) { JTCSyncT<JTCMutex> sync(*this); - map<string, ObjectPtr>::const_iterator p = _activeServantMap.find(ident); + if (_activeServantMapHint != _activeServantMap.end()) + { + if (_activeServantMapHint->first == ident) + { + return _activeServantMapHint->second; + } + } + + map<string, ObjectPtr>::iterator p = _activeServantMap.find(ident); if (p != _activeServantMap.end()) { + _activeServantMapHint = p; return p->second; } else @@ -205,7 +250,8 @@ Ice::ObjectAdapterI::createProxy(const string& ident) Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const string& name, const string& endpts) : _instance(instance), _name(name), - _activeServantMapHint(_activeServantMap.begin()) + _activeServantMapHint(_activeServantMap.end()), + _locatorMapHint(_locatorMap.end()) { string s(endpts); transform(s.begin(), s.end(), s.begin(), tolower); @@ -283,7 +329,7 @@ Ice::ObjectAdapterI::newProxy(const string& ident) { vector<EndpointPtr> endpoints; transform(_collectorFactories.begin(), _collectorFactories.end(), back_inserter(endpoints), - ::IceInternal::constMemFun(&CollectorFactory::endpoint)); + Ice::constMemFun(&CollectorFactory::endpoint)); ReferencePtr reference = new Reference(_instance, ident, Reference::ModeTwoway, false, endpoints, endpoints); return _instance->proxyFactory()->referenceToProxy(reference); diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h index 122f0a375f5..81233e4ed59 100644 --- a/cpp/src/Ice/ObjectAdapterI.h +++ b/cpp/src/Ice/ObjectAdapterI.h @@ -42,8 +42,9 @@ public: virtual ObjectPrx addTemporary(const ObjectPtr&); virtual void remove(const std::string&); - virtual void setServantLocator(const ServantLocatorPtr&); - virtual ServantLocatorPtr getServantLocator(); + virtual void addServantLocator(const ServantLocatorPtr&, const std::string&); + virtual void removeServantLocator(const std::string&); + virtual ServantLocatorPtr findServantLocator(const std::string&); virtual ObjectPtr identityToServant(const ::std::string&); virtual ObjectPtr proxyToServant(const ObjectPrx&); @@ -64,7 +65,8 @@ private: std::vector< IceInternal::CollectorFactoryPtr> _collectorFactories; std::map<std::string, ObjectPtr> _activeServantMap; std::map<std::string, ObjectPtr>::iterator _activeServantMapHint; - ServantLocatorPtr _locator; + std::map<std::string, ServantLocatorPtr> _locatorMap; + std::map<std::string, ServantLocatorPtr>::iterator _locatorMapHint; }; } diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 2ef08373d0f..d0b87ebcfc9 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -517,7 +517,7 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& ref) case Reference::ModeBatchOneway: { remove_copy_if(__reference->endpoints.begin(), __reference->endpoints.end(), back_inserter(endpoints), - ::IceInternal::constMemFun(&Endpoint::datagram)); + ::Ice::constMemFun(&Endpoint::datagram)); break; } @@ -525,21 +525,19 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& ref) case Reference::ModeBatchDatagram: { remove_copy_if(__reference->endpoints.begin(), __reference->endpoints.end(), back_inserter(endpoints), - not1(::IceInternal::constMemFun(&Endpoint::datagram))); + not1(::Ice::constMemFun(&Endpoint::datagram))); break; } } if (__reference->secure) { - endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), - not1(::IceInternal::constMemFun(&Endpoint::secure))), + endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), not1(::Ice::constMemFun(&Endpoint::secure))), endpoints.end()); } else { - endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), - ::IceInternal::constMemFun(&Endpoint::secure)), + endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), ::Ice::constMemFun(&Endpoint::secure)), endpoints.end()); } diff --git a/cpp/src/Ice/ServantFactoryManager.cpp b/cpp/src/Ice/ServantFactoryManager.cpp index 91c01f4f0c2..d1f0372f5a6 100644 --- a/cpp/src/Ice/ServantFactoryManager.cpp +++ b/cpp/src/Ice/ServantFactoryManager.cpp @@ -10,6 +10,7 @@ #include <Ice/ServantFactoryManager.h> #include <Ice/ServantFactory.h> +#include <Ice/Functional.h> using namespace std; using namespace Ice; @@ -19,20 +20,37 @@ void IceInternal::incRef(ServantFactoryManager* p) { p->__incRef(); } void IceInternal::decRef(ServantFactoryManager* p) { p->__decRef(); } void -IceInternal::ServantFactoryManager::install(const ServantFactoryPtr& factory, const string& id) +IceInternal::ServantFactoryManager::add(const ServantFactoryPtr& factory, const string& id) { JTCSyncT<JTCMutex> sync(*this); - _factories.insert(make_pair(id, factory)); + _factoryMapHint = _factoryMap.insert(_factoryMapHint, make_pair(id, factory)); +} + +void +IceInternal::ServantFactoryManager::remove(const string& id) +{ + JTCSyncT<JTCMutex> sync(*this); + _factoryMap.erase(id); + _factoryMapHint = _factoryMap.end(); } ServantFactoryPtr -IceInternal::ServantFactoryManager::lookup(const string& id) +IceInternal::ServantFactoryManager::find(const string& id) { JTCSyncT<JTCMutex> sync(*this); - map<string, ::Ice::ServantFactoryPtr>::const_iterator p; - p = _factories.find(id); - if (p != _factories.end()) + + if (_factoryMapHint != _factoryMap.end()) { + if (_factoryMapHint->first == id) + { + return _factoryMapHint->second; + } + } + + map<string, ::Ice::ServantFactoryPtr>::iterator p = _factoryMap.find(id); + if (p != _factoryMap.end()) + { + _factoryMapHint = p; return p->second; } else @@ -41,7 +59,8 @@ IceInternal::ServantFactoryManager::lookup(const string& id) } } -IceInternal::ServantFactoryManager::ServantFactoryManager() +IceInternal::ServantFactoryManager::ServantFactoryManager() : + _factoryMapHint(_factoryMap.end()) { } @@ -49,9 +68,8 @@ void IceInternal::ServantFactoryManager::destroy() { JTCSyncT<JTCMutex> sync(*this); - for (map<string, ::Ice::ServantFactoryPtr>::iterator p = _factories.begin(); p != _factories.end(); ++p) - { - p->second->destroy(); - } - _factories.clear(); + for_each(_factoryMap.begin(), _factoryMap.end(), + secondVoidMemFun<string, ServantFactory>(&ServantFactory::destroy)); + _factoryMap.clear(); + _factoryMapHint = _factoryMap.end(); } diff --git a/cpp/src/Ice/ServantFactoryManager.h b/cpp/src/Ice/ServantFactoryManager.h index b738878405f..de1a3716129 100644 --- a/cpp/src/Ice/ServantFactoryManager.h +++ b/cpp/src/Ice/ServantFactoryManager.h @@ -22,8 +22,9 @@ class ServantFactoryManager : public ::IceUtil::Shared, public JTCMutex { public: - void install(const ::Ice::ServantFactoryPtr&, const std::string&); - ::Ice::ServantFactoryPtr lookup(const std::string&); + void add(const ::Ice::ServantFactoryPtr&, const std::string&); + void remove(const std::string&); + ::Ice::ServantFactoryPtr find(const std::string&); private: @@ -31,7 +32,8 @@ private: void destroy(); friend class Instance; - std::map<std::string, ::Ice::ServantFactoryPtr> _factories; + std::map<std::string, ::Ice::ServantFactoryPtr> _factoryMap; + std::map<std::string, ::Ice::ServantFactoryPtr>::iterator _factoryMapHint; }; } diff --git a/cpp/src/Ice/Stream.cpp b/cpp/src/Ice/Stream.cpp index cf3b50a53ef..112c561bc5c 100644 --- a/cpp/src/Ice/Stream.cpp +++ b/cpp/src/Ice/Stream.cpp @@ -820,7 +820,7 @@ IceInternal::Stream::read(ObjectPtr& v, const string& type) vector<string>::const_iterator p; for (p = classIds.begin(); p != classIds.end(); ++p) { - ServantFactoryPtr factory = _instance->servantFactoryManager()->lookup(*p); + ServantFactoryPtr factory = _instance->servantFactoryManager()->find(*p); if (factory) { diff --git a/cpp/src/IcePack/Server.cpp b/cpp/src/IcePack/Server.cpp index 0af2b57fec3..18c350d0b54 100644 --- a/cpp/src/IcePack/Server.cpp +++ b/cpp/src/IcePack/Server.cpp @@ -85,7 +85,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) } ObjectAdapterPtr forwardAdapter = communicator->createObjectAdapter("Forward"); - forwardAdapter->setServantLocator(forward); + forwardAdapter->addServantLocator(forward, ""); forwardAdapter->activate(); communicator->waitForShutdown(); |