diff options
author | Marc Laukien <marc@zeroc.com> | 2001-08-24 22:01:20 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-08-24 22:01:20 +0000 |
commit | 96f9a4887edb7d7778332e0eb12657b8ace3b42e (patch) | |
tree | f9476cd6037e8152def769f46ea7a67a7ab21b2b /cpp | |
parent | more activation stuff (diff) | |
download | ice-96f9a4887edb7d7778332e0eb12657b8ace3b42e.tar.bz2 ice-96f9a4887edb7d7778332e0eb12657b8ace3b42e.tar.xz ice-96f9a4887edb7d7778332e0eb12657b8ace3b42e.zip |
fixes
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/slice/Ice/Communicator.ice | 15 | ||||
-rw-r--r-- | cpp/slice/IcePack/Admin.ice | 30 | ||||
-rw-r--r-- | cpp/src/Ice/CommunicatorI.cpp | 11 | ||||
-rw-r--r-- | cpp/src/Ice/CommunicatorI.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 91 | ||||
-rw-r--r-- | cpp/src/Ice/ProxyFactory.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/ProxyFactory.h | 2 | ||||
-rw-r--r-- | cpp/src/IcePack/.depend | 4 | ||||
-rw-r--r-- | cpp/src/IcePack/Activator.cpp | 8 | ||||
-rw-r--r-- | cpp/src/IcePack/Activator.h | 2 | ||||
-rw-r--r-- | cpp/src/IcePack/AdminI.cpp | 12 | ||||
-rw-r--r-- | cpp/src/IcePack/AdminI.h | 9 | ||||
-rw-r--r-- | cpp/src/IcePack/Forward.cpp | 11 | ||||
-rw-r--r-- | cpp/src/IcePack/Forward.h | 10 | ||||
-rw-r--r-- | cpp/src/IcePack/Grammer.y | 21 | ||||
-rw-r--r-- | cpp/src/IcePack/Parser.cpp | 85 | ||||
-rw-r--r-- | cpp/src/IcePack/Parser.h | 1 | ||||
-rw-r--r-- | cpp/src/IcePack/Scanner.l | 128 | ||||
-rw-r--r-- | cpp/src/IcePack/Server.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Slice/Grammer.y | 10 | ||||
-rw-r--r-- | cpp/src/Slice/Scanner.l | 10 | ||||
-rwxr-xr-x | cpp/test/IcePack/simple/run.py | 2 |
22 files changed, 359 insertions, 112 deletions
diff --git a/cpp/slice/Ice/Communicator.ice b/cpp/slice/Ice/Communicator.ice index 4e2a491f42b..97797271a51 100644 --- a/cpp/slice/Ice/Communicator.ice +++ b/cpp/slice/Ice/Communicator.ice @@ -98,11 +98,26 @@ local class Communicator * * @return The Proxy. * + * @see proxyToString + * **/ Object* stringToProxy(string str); /** * + * Convert a Proxy into a string. + * + * @param obj The Proxy to turn into a string. + * + * @return The "stringified" Proxy. + * + * @see stringToProxy + * + **/ + string proxyToString(Object* obj); + + /** + * * Create a new object adapter. The endpoints for the object * adapter are taken from the property * <literal>ice.adapter.<replaceable>name</replaceable>.endpoints</literal>, diff --git a/cpp/slice/IcePack/Admin.ice b/cpp/slice/IcePack/Admin.ice index d2c32a9ec29..466eb8deed4 100644 --- a/cpp/slice/IcePack/Admin.ice +++ b/cpp/slice/IcePack/Admin.ice @@ -37,7 +37,7 @@ class ServerDescription /** * * The server object or object template. Any non-administrative - * IcePack request that matches the identity of + * &IcePack; request that matches the identity of * <literal>object</literal> will be forwarded to * <literal>object</literal>. If <literal>regex</literal> is set * to <literal>true</literal>, <literal>object</literal>'s @@ -93,8 +93,15 @@ class ServerDescription /** * - * The IcePack administrative interface. <warning><para>Allowing - * access to this interface is a security risk! Please see the IcePack + * A vector of server descriptions. + * + **/ +vector<ServerDescription> ServerDescriptions; + +/** + * + * The &IcePack; administrative interface. <warning><para>Allowing + * access to this interface is a security risk! Please see the &IcePack; * documentation for further information.</para></warning> * **/ @@ -102,7 +109,7 @@ class Admin { /** * - * Add a server and objects implemented by that server to IcePack. + * Add a server and objects implemented by that server to &IcePack;. * * @param description The server's description. * @@ -113,7 +120,7 @@ class Admin /** * - * Remove a server and objects implemented by that server from IcePack. + * Remove a server and objects implemented by that server from &IcePack;. * * @param object Must match the field <literal>object</literal> of * the <literal>ServerDescription</literal> data to remove. @@ -125,7 +132,7 @@ class Admin /** * - * Find a server and objects implemented by that server from IcePack. + * Find a server and objects implemented by that server from &IcePack;. * * @param object Must match the field <literal>object</literal> of * the <literal>ServerDescription</literal> data to find. @@ -139,7 +146,16 @@ class Admin /** * - * Shut down IcePack. + * Get all server descriptions in &IcePack;. + * + * @return The descriptions of all servers. + * + **/ + ServerDescriptions getAll(); + + /** + * + * Shut down &IcePack;. * **/ void shutdown(); diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp index e96b41cac50..72104df1b87 100644 --- a/cpp/src/Ice/CommunicatorI.cpp +++ b/cpp/src/Ice/CommunicatorI.cpp @@ -72,6 +72,17 @@ Ice::CommunicatorI::stringToProxy(const string& s) return _instance->proxyFactory()->stringToProxy(s); } +string +Ice::CommunicatorI::proxyToString(const ObjectPrx& proxy) +{ + JTCSyncT<JTCRecursiveMutex> sync(*this); + if (!_instance) + { + throw CommunicatorDestroyedException(__FILE__, __LINE__); + } + return _instance->proxyFactory()->proxyToString(proxy); +} + ObjectAdapterPtr Ice::CommunicatorI::createObjectAdapter(const string& name) { diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h index 044b6a7af86..32f0c0c9fb3 100644 --- a/cpp/src/Ice/CommunicatorI.h +++ b/cpp/src/Ice/CommunicatorI.h @@ -27,6 +27,7 @@ public: virtual void waitForShutdown(); virtual ObjectPrx stringToProxy(const std::string&); + virtual std::string proxyToString(const ObjectPrx&); virtual ObjectAdapterPtr createObjectAdapter(const std::string&); virtual ObjectAdapterPtr createObjectAdapterWithEndpoints(const std::string&, const std::string&); diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index 2a5ecee51ad..772c124962c 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -257,59 +257,66 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const string& n { string s(endpts); transform(s.begin(), s.end(), s.begin(), tolower); - + string::size_type beg = 0; string::size_type end; - while (true) + // + // Set the "no delete" flag to true, meaning that this object will + // not be deleted, even if the reference count drops to zero. This + // is needed because if the constructor of the CollectorFactory + // throws an exception, or if the CollectorFactories are destroyed + // with "deactivate" from within this constructor, all + // ObjectAdapterPtrs for this object will be destroyed, and thus + // this object would be deleted if the "no delete" flag is not + // set. + // + __setNoDelete(true); + + try { - end = s.find(':', beg); - if (end == string::npos) - { - end = s.length(); - } - - if (end == beg) - { - throw EndpointParseException(__FILE__, __LINE__); - } - - string es = s.substr(beg, end - beg); - - // Don't store the endpoint in the adapter. The Collector - // might change it, for example, to fill in the real port - // number if a zero port number is given. - EndpointPtr endp = Endpoint::endpointFromString(es); - try + while (true) { - // Set the "no delete" flag to true, meaning that this - // object will not be deleted, even if the reference count - // drops to zero. This is needed because if the - // constructor of the CollectorFactory throws an - // exception, the only CollectorFactoryPtr reference for - // this object will be the one that is temporarily - // constructed for passing the "this" parameter below. And - // then this temporary reference is destroyed, this object - // would be deleted if we don't set the "no delete" flag. - __setNoDelete(true); + end = s.find(':', beg); + if (end == string::npos) + { + end = s.length(); + } + + if (end == beg) + { + throw EndpointParseException(__FILE__, __LINE__); + } + + string es = s.substr(beg, end - beg); + + // Don't store the endpoint in the adapter. The Collector + // might change it, for example, to fill in the real port + // number if a zero port number is given. + EndpointPtr endp = Endpoint::endpointFromString(es); _collectorFactories.push_back(new CollectorFactory(instance, this, endp)); - __setNoDelete(false); - } - catch(...) - { - __setNoDelete(false); - throw; + + if (end == s.length()) + { + break; + } + + beg = end + 1; } - - if (end == s.length()) + } + catch(...) + { + if (!_collectorFactories.empty()) { - break; + deactivate(); } - - beg = end + 1; + __setNoDelete(false); + throw; } - if (!_collectorFactories.size()) + __setNoDelete(false); + + if (_collectorFactories.empty()) { throw EndpointParseException(__FILE__, __LINE__); } diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp index d15f7debb7b..4ed07a562f6 100644 --- a/cpp/src/Ice/ProxyFactory.cpp +++ b/cpp/src/Ice/ProxyFactory.cpp @@ -29,6 +29,12 @@ IceInternal::ProxyFactory::stringToProxy(const string& s) return referenceToProxy(reference); } +string +IceInternal::ProxyFactory::proxyToString(const ObjectPrx& proxy) +{ + return "blahblah"; // TODO +} + ObjectPrx IceInternal::ProxyFactory::streamToProxy(Stream* s) { diff --git a/cpp/src/Ice/ProxyFactory.h b/cpp/src/Ice/ProxyFactory.h index fb0cc851685..9d7df5694d7 100644 --- a/cpp/src/Ice/ProxyFactory.h +++ b/cpp/src/Ice/ProxyFactory.h @@ -27,6 +27,8 @@ class ProxyFactory : public Shared public: ::Ice::ObjectPrx stringToProxy(const std::string&); + std::string proxyToString(const ::Ice::ObjectPrx&); + ::Ice::ObjectPrx streamToProxy(Stream*); ::Ice::ObjectPrx referenceToProxy(const ReferencePtr&); void proxyToStream(const ::Ice::ObjectPrx&, Stream*); diff --git a/cpp/src/IcePack/.depend b/cpp/src/IcePack/.depend index d79849595ff..c78ef738ff7 100644 --- a/cpp/src/IcePack/.depend +++ b/cpp/src/IcePack/.depend @@ -3,7 +3,7 @@ Grammer.o: Grammer.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h Scanner.o: Scanner.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../IcePack/Grammer.h Parser.o: Parser.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h Client.o: Client.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h -Server.o: Server.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../IcePack/Forward.h ../../include/IcePack/AdminF.h -Forward.o: Forward.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Forward.h ../../include/IcePack/AdminF.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/IcePack/Admin.h +Server.o: Server.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../IcePack/Forward.h ../../include/IcePack/AdminF.h ../IcePack/Activator.h +Forward.o: Forward.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Forward.h ../../include/IcePack/AdminF.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../IcePack/Activator.h ../../include/IcePack/Admin.h AdminI.o: AdminI.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h Activator.o: Activator.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Activator.h ../../include/IcePack/AdminF.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/IcePack/Admin.h diff --git a/cpp/src/IcePack/Activator.cpp b/cpp/src/IcePack/Activator.cpp index 590afacbb07..50cb645f710 100644 --- a/cpp/src/IcePack/Activator.cpp +++ b/cpp/src/IcePack/Activator.cpp @@ -73,7 +73,7 @@ IcePack::Activator::run() void IcePack::Activator::destroy() { - JTCSyncT<JTCMonitor> sync(*this); + JTCSyncT<JTCMutex> sync(*this); if (_destroy) // Don't destroy twice { @@ -87,7 +87,7 @@ IcePack::Activator::destroy() void IcePack::Activator::activate(const ServerDescriptionPtr& desc) { - JTCSyncT<JTCMonitor> sync(*this); + JTCSyncT<JTCMutex> sync(*this); if (_destroy) { @@ -199,7 +199,7 @@ IcePack::Activator::terminationListener() FD_SET(_fdIntrRead, &fdSet); { - JTCSyncT<JTCMonitor> sync(*this); + JTCSyncT<JTCMutex> sync(*this); if (_destroy) { @@ -232,7 +232,7 @@ IcePack::Activator::terminationListener() } { - JTCSyncT<JTCMonitor> sync(*this); + JTCSyncT<JTCMutex> sync(*this); if (FD_ISSET(_fdIntrRead, &fdSet)) { diff --git a/cpp/src/IcePack/Activator.h b/cpp/src/IcePack/Activator.h index e2869575b50..82ef29509a1 100644 --- a/cpp/src/IcePack/Activator.h +++ b/cpp/src/IcePack/Activator.h @@ -17,7 +17,7 @@ namespace IcePack { -class Activator : public JTCThread, public JTCMonitor +class Activator : public JTCThread, public JTCMutex { public: diff --git a/cpp/src/IcePack/AdminI.cpp b/cpp/src/IcePack/AdminI.cpp index f5ea3ccf9f1..b2c56c11bce 100644 --- a/cpp/src/IcePack/AdminI.cpp +++ b/cpp/src/IcePack/AdminI.cpp @@ -65,6 +65,18 @@ IcePack::AdminI::find(const ObjectPrx& p) } } +ServerDescriptions +IcePack::AdminI::getAll() +{ + ServerDescriptions result; + result.reserve(_map.size()); + for (map<ObjectPrx, ServerDescriptionPtr>::iterator p = _map.begin(); p != _map.end(); ++p) + { + result.push_back(p->second); + } + return result; +} + void IcePack::AdminI::shutdown() { diff --git a/cpp/src/IcePack/AdminI.h b/cpp/src/IcePack/AdminI.h index ebf8a7c7dca..828de030cd5 100644 --- a/cpp/src/IcePack/AdminI.h +++ b/cpp/src/IcePack/AdminI.h @@ -17,21 +17,22 @@ namespace IcePack { -class AdminI : public IcePack::Admin, public JTCMutex +class AdminI : public Admin, public JTCMutex { public: AdminI(const Ice::CommunicatorPtr&); - virtual void add(const IcePack::ServerDescriptionPtr&); + virtual void add(const ServerDescriptionPtr&); virtual void remove(const Ice::ObjectPrx&); - virtual IcePack::ServerDescriptionPtr find(const Ice::ObjectPrx&); + virtual ServerDescriptionPtr find(const Ice::ObjectPrx&); + virtual ServerDescriptions getAll(); virtual void shutdown(); private: Ice::CommunicatorPtr _communicator; - std::map<Ice::ObjectPrx, IcePack::ServerDescriptionPtr> _map; + std::map<Ice::ObjectPrx, ServerDescriptionPtr> _map; }; } diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp index 1ae63177edb..fac3185e7f8 100644 --- a/cpp/src/IcePack/Forward.cpp +++ b/cpp/src/IcePack/Forward.cpp @@ -16,9 +16,17 @@ using namespace std; using namespace Ice; using namespace IcePack; -IcePack::Forward::Forward(const AdminPtr& admin) : +IcePack::Forward::Forward(const CommunicatorPtr& communicator, const AdminPtr& admin) : + _communicator(communicator), _admin(admin) { + _activator = new Activator(_communicator); + _activator->start(); +} + +IcePack::Forward::~Forward() +{ + _activator->destroy(); } ObjectPtr @@ -29,6 +37,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity if (desc) { assert(desc->object); + _activator->activate(desc); throw LocationForward(desc->object); } return 0; diff --git a/cpp/src/IcePack/Forward.h b/cpp/src/IcePack/Forward.h index 64edb6beacf..126fb68dd60 100644 --- a/cpp/src/IcePack/Forward.h +++ b/cpp/src/IcePack/Forward.h @@ -12,6 +12,7 @@ #define ICE_PACK_FORWARD_H #include <IcePack/AdminF.h> +#include <IcePack/Activator.h> #include <map> namespace IcePack @@ -21,15 +22,18 @@ class Forward : public Ice::ObjectLocator { public: - Forward(const IcePack::AdminPtr&); - + Forward(const Ice::CommunicatorPtr& communicator, const AdminPtr&); + virtual ~Forward(); + virtual Ice::ObjectPtr locate(const Ice::ObjectAdapterPtr&, const std::string&, Ice::ObjectPtr&); virtual void finished(const Ice::ObjectAdapterPtr&, const std::string&, const Ice::ObjectPtr&, const Ice::ObjectPtr&); private: - IcePack::AdminPtr _admin; + Ice::CommunicatorPtr _communicator; + AdminPtr _admin; + ActivatorHandle _activator; }; } diff --git a/cpp/src/IcePack/Grammer.y b/cpp/src/IcePack/Grammer.y index 24dc8a9b0e8..8dfef955e99 100644 --- a/cpp/src/IcePack/Grammer.y +++ b/cpp/src/IcePack/Grammer.y @@ -25,11 +25,12 @@ yyerror(const char* s) %} +%token ICE_PACK_STRING %token ICE_PACK_EXIT %token ICE_PACK_ADD %token ICE_PACK_REMOVE +%token ICE_PACK_LIST %token ICE_PACK_SHUTDOWN -%token ICE_PACK_REFERENCE %% @@ -62,14 +63,18 @@ command { return 0; } -| ICE_PACK_ADD references ';' +| ICE_PACK_ADD strings ';' { parser->add($2); } -| ICE_PACK_REMOVE references ';' +| ICE_PACK_REMOVE strings ';' { parser->remove($2); } +| ICE_PACK_LIST ';' +{ + parser->getAll(); +} | ICE_PACK_SHUTDOWN ';' { parser->shutdown(); @@ -84,19 +89,15 @@ command ; // ---------------------------------------------------------------------- -references +strings // ---------------------------------------------------------------------- -: ICE_PACK_REFERENCE references +: ICE_PACK_STRING strings { - $1.front().erase(0, 1); - $1.front().erase($1.front().size() - 2); $$ = $2; $$.push_front($1.front()); } -| ICE_PACK_REFERENCE +| ICE_PACK_STRING { - $1.front().erase(0, 1); - $1.front().erase($1.front().size() - 2); $$ = $1 } ; diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp index 55f1c56f612..39ea972cd86 100644 --- a/cpp/src/IcePack/Parser.cpp +++ b/cpp/src/IcePack/Parser.cpp @@ -45,37 +45,85 @@ IcePack::Parser::createParser(const CommunicatorPtr& communicator, const AdminPr } void -IcePack::Parser::add(const list<string>& references) +IcePack::Parser::add(const list<string>& args) { - for (list<string>::const_iterator p = references.begin(); p != references.end(); ++p) + if (args.empty()) { - try - { - ServerDescriptionPtr desc = new ServerDescription; - desc->object = _communicator->stringToProxy(*p); - _admin->add(desc); - } - catch(const LocalException& ex) + error("`add' requires at least an object reference as argument"); + return; + } + + try + { + ServerDescriptionPtr desc = new ServerDescription; + list<string>::const_iterator p = args.begin(); + desc->object = _communicator->stringToProxy(*p); + desc->regex = false; + if (++p != args.end()) { - error(ex.toString()); + desc->path = *p; + while (++p != args.end()) + { + desc->args.push_back(*p); + } } + _admin->add(desc); + + } + catch(const LocalException& ex) + { + error(ex.toString()); } } void -IcePack::Parser::remove(const list<string>& references) +IcePack::Parser::remove(const list<string>& args) { - for (list<string>::const_iterator p = references.begin(); p != references.end(); ++p) + if (args.size() != 1) { - try - { - _admin->remove(_communicator->stringToProxy(*p)); - } - catch(const LocalException& ex) + error("`remove' takes exactly one object reference as argument"); + return; + } + + try + { + _admin->remove(_communicator->stringToProxy(args.front())); + } + catch(const LocalException& ex) + { + error(ex.toString()); + } +} + +void +IcePack::Parser::getAll() +{ + try + { + ServerDescriptions descriptions = _admin->getAll(); + ServerDescriptions::iterator p = descriptions.begin(); + while(p != descriptions.end()) { - error(ex.toString()); + cout << "object = " << _communicator->proxyToString((*p)->object) << endl; + cout << "regex = " << boolalpha << (*p)->regex << endl; + cout << "host = " << (*p)->host << endl; + cout << "path = " << (*p)->path << endl; + cout << "args ="; + for (Args::iterator q = (*p)->args.begin(); q != (*p)->args.end(); ++q) + { + cout << ' ' << *q; + } + cout << endl; + if (++p != descriptions.end()) + { + cout << endl; + } } } + catch(const LocalException& ex) + { + error(ex.toString()); + } } void @@ -89,7 +137,6 @@ IcePack::Parser::shutdown() { error(ex.toString()); } - } void diff --git a/cpp/src/IcePack/Parser.h b/cpp/src/IcePack/Parser.h index 13ba922ef7f..42282a010c2 100644 --- a/cpp/src/IcePack/Parser.h +++ b/cpp/src/IcePack/Parser.h @@ -54,6 +54,7 @@ public: void add(const std::list<std::string>&); void remove(const std::list<std::string>&); + void getAll(); void shutdown(); void nextLine(); diff --git a/cpp/src/IcePack/Scanner.l b/cpp/src/IcePack/Scanner.l index 3064f49ae83..b5cb5519df2 100644 --- a/cpp/src/IcePack/Scanner.l +++ b/cpp/src/IcePack/Scanner.l @@ -178,9 +178,7 @@ L [a-zA-Z_] "//" { // C++-style comment - int c; - do { c = yyinput(); @@ -194,11 +192,9 @@ L [a-zA-Z_] "/*" { // C-style comment - while (true) { int c = yyinput(); - if (c == '\n') { parser->nextLine(); @@ -206,11 +202,14 @@ L [a-zA-Z_] else if (c == '*') { int next = yyinput(); - if (next == '/') + { break; + } else + { unput(next); + } } else if (c == EOF) { @@ -220,6 +219,115 @@ L [a-zA-Z_] } } +\" { + // "..."-type string + string s; + while (true) + { + char c = static_cast<char>(yyinput()); + if (c == '"') + { + break; + } + else if (c == EOF) + { + parser->warning("EOF in string"); + break; + } + else if (c == '\n') + { + s += c; + parser->nextLine(); + } + else if (c == '\\') + { + char next = static_cast<char>(yyinput()); + switch (next) + { + case '\\': + case '"': + { + s += next; + break; + } + + case 'n': + { + s += '\n'; + break; + } + + case 'r': + { + s += '\r'; + break; + } + + case 't': + { + s += '\t'; + break; + } + + case 'v': + { + s += '\v'; + break; + } + + case 'f': + { + s += '\f'; + break; + } + + default: + { + s += c; + unput(next); + } + } + } + else + { + s += c; + } + } + yylval.clear(); + yylval.push_back(s); + return ICE_PACK_STRING; +} + +\' { + // '...'-type string + string s; + while (true) + { + char c = static_cast<char>(yyinput()); + if (c == '\'') + { + break; + } + else if (c == EOF) + { + parser->warning("EOF in string"); + break; + } + else if (c == '\n') + { + s += c; + parser->nextLine(); + } + else + { + s += c; + } + } + yylval.clear(); + yylval.push_back(s); + return ICE_PACK_STRING; +} + "quit"|"exit" { return ICE_PACK_EXIT; } @@ -232,14 +340,12 @@ L [a-zA-Z_] return ICE_PACK_REMOVE; } -"shutdown" { - return ICE_PACK_SHUTDOWN; +"list" { + return ICE_PACK_LIST; } -\[[^\[\]{NL}]+(:[^\[\]{NL}]+)+\] { - yylval.empty(); - yylval.push_back(yytext); - return ICE_PACK_REFERENCE; +"shutdown" { + return ICE_PACK_SHUTDOWN; } {WS}*(\\{WS}*{NL})? { diff --git a/cpp/src/IcePack/Server.cpp b/cpp/src/IcePack/Server.cpp index 9dbc4b479c9..2bec82292cb 100644 --- a/cpp/src/IcePack/Server.cpp +++ b/cpp/src/IcePack/Server.cpp @@ -72,7 +72,7 @@ run(int argc, char* argv[], CommunicatorPtr communicator) } AdminPtr admin = new AdminI(communicator); - ObjectLocatorPtr forward = new Forward(admin); + ObjectLocatorPtr forward = new Forward(communicator, admin); if (adminEndpoints.length() != 0) { diff --git a/cpp/src/Slice/Grammer.y b/cpp/src/Slice/Grammer.y index 5befb4811f6..64fe4c5c924 100644 --- a/cpp/src/Slice/Grammer.y +++ b/cpp/src/Slice/Grammer.y @@ -457,6 +457,16 @@ parameters parms->v.push_front(make_pair(type, ident->v)); $$ = parms; } +| type ',' parameters +{ + unit->error("missing declarator"); + $$ = $3 +} +| type +{ + unit->error("missing declarator"); + $$ = new TypeStringListTok; +} | { $$ = new TypeStringListTok; diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l index 3893ca99c6c..e2875da0301 100644 --- a/cpp/src/Slice/Scanner.l +++ b/cpp/src/Slice/Scanner.l @@ -46,9 +46,7 @@ L [a-zA-Z_] "//" { // C++-style comment - int c; - do { c = yyinput(); @@ -62,13 +60,11 @@ L [a-zA-Z_] "/*" { // C-style comment - string comment = yytext + 2; while (true) { int c = yyinput(); comment += static_cast<char>(c); - if (c == '\n') { unit->nextLine(); @@ -76,11 +72,14 @@ L [a-zA-Z_] else if (c == '*') { int next = yyinput(); - if (next == '/') + { break; + } else + { unput(next); + } } else if (c == EOF) { @@ -88,7 +87,6 @@ L [a-zA-Z_] break; } } - if (comment[0] == '*') { unit->setComment(comment); diff --git a/cpp/test/IcePack/simple/run.py b/cpp/test/IcePack/simple/run.py index b38976ce044..2772753b7ab 100755 --- a/cpp/test/IcePack/simple/run.py +++ b/cpp/test/IcePack/simple/run.py @@ -37,7 +37,7 @@ print "ok" print "registering server with icepack...", icePackAdminPipe = os.popen(icePackAdmin + \ r' "--Ice.Adapter.Admin.Endpoints=tcp -p 12347 -t 2000"' + \ - r' -e "add [test:tcp -p 12345 -t 2000]"') + r' -e "add \"test:tcp -p 12345 -t 2000\""') icePackAdminPipe.close() print "ok" |