[hydra-commits] kpfleming: branch techdemo/kpfleming/slicing r578 - /techdemo/team/kpfleming/...
SVN commits to the Hydra project
hydra-commits at lists.digium.com
Mon Apr 12 13:28:37 CDT 2010
Author: kpfleming
Date: Mon Apr 12 13:28:36 2010
New Revision: 578
URL: https://origsvn.digium.com/svn-view/hydra?view=rev&rev=578
Log:
add unsliceable exceptions support to the AMD version of the server
Modified:
techdemo/team/kpfleming/slicing/exceptions/ServerAMD.cpp
techdemo/team/kpfleming/slicing/exceptions/TestAMD.ice
techdemo/team/kpfleming/slicing/exceptions/TestAMDI.cpp
techdemo/team/kpfleming/slicing/exceptions/TestAMDI.h
Modified: techdemo/team/kpfleming/slicing/exceptions/ServerAMD.cpp
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/exceptions/ServerAMD.cpp?view=diff&rev=578&r1=577&r2=578
==============================================================================
--- techdemo/team/kpfleming/slicing/exceptions/ServerAMD.cpp (original)
+++ techdemo/team/kpfleming/slicing/exceptions/ServerAMD.cpp Mon Apr 12 13:28:36 2010
@@ -15,11 +15,11 @@
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
- Ice::PropertiesPtr properties = communicator->getProperties();
+ Ice::PropertiesPtr properties(communicator->getProperties());
properties->setProperty("Ice.Warn.Dispatch", "0");
- communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 2000");
- Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
- Ice::ObjectPtr object = new TestI();
+ properties->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 2000");
+ Ice::ObjectAdapterPtr adapter(communicator->createObjectAdapter("TestAdapter"));
+ Ice::ObjectPtr object(new TestI(communicator));
adapter->add(object, communicator->stringToIdentity("Test"));
adapter->activate();
communicator->waitForShutdown();
Modified: techdemo/team/kpfleming/slicing/exceptions/TestAMD.ice
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/exceptions/TestAMD.ice?view=diff&rev=578&r1=577&r2=578
==============================================================================
--- techdemo/team/kpfleming/slicing/exceptions/TestAMD.ice (original)
+++ techdemo/team/kpfleming/slicing/exceptions/TestAMD.ice Mon Apr 12 13:28:36 2010
@@ -33,6 +33,17 @@
string kmd;
};
+exception BaseUnsliceable extends Base
+{
+};
+
+interface ClientIntf
+{
+ void baseAsBase() throws Base;
+ void unknownDerivedAsBase() throws Base;
+ void unsliceableDerivedAsBase() throws Base;
+};
+
["ami", "amd"] interface TestIntf
{
void baseAsBase() throws Base;
@@ -51,6 +62,13 @@
void unknownMostDerived1AsKnownIntermediate() throws KnownIntermediate;
void unknownMostDerived2AsBase() throws Base;
+ void clientBaseAsBasePass(ClientIntf* client) throws Base;
+ void clientUnknownDerivedAsBasePass(ClientIntf* client) throws Base;
+ void clientUnsliceableDerivedAsBasePass(ClientIntf* client) throws Base;
+ void clientBaseAsBaseRethrow(ClientIntf* client) throws Base;
+ void clientUnknownDerivedAsBaseRethrow(ClientIntf* client) throws Base;
+ void clientUnsliceableDerivedAsBaseRethrow(ClientIntf* client) throws Base;
+
void shutdown();
};
Modified: techdemo/team/kpfleming/slicing/exceptions/TestAMDI.cpp
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/exceptions/TestAMDI.cpp?view=diff&rev=578&r1=577&r2=578
==============================================================================
--- techdemo/team/kpfleming/slicing/exceptions/TestAMDI.cpp (original)
+++ techdemo/team/kpfleming/slicing/exceptions/TestAMDI.cpp Mon Apr 12 13:28:36 2010
@@ -10,10 +10,49 @@
#include <TestAMDI.h>
#include <Ice/Ice.h>
+using namespace std;
using namespace Test;
-TestI::TestI()
-{
+template <typename T>
+class PreserverFactory : public IceInternal::UserExceptionFactory
+{
+public:
+ void createAndThrow() {
+ throw Preserver();
+ }
+private:
+ class Preserver : virtual public T
+ {
+ public:
+ vector< ::Ice::Byte > __skippedSlices;
+ void __write(IceInternal::BasicStream* stream) const
+ {
+ stream->writeBlob(__skippedSlices);
+ T::__write(stream);
+ }
+ void __read(IceInternal::BasicStream* stream, bool rid)
+ {
+ stream->readSkippedSlicesBlob(__skippedSlices);
+ T::__read(stream, rid);
+ }
+ void ice_throw() const
+ {
+ throw *this;
+ }
+ ~Preserver() throw() {}
+ };
+};
+
+TestI::TestI(const Ice::CommunicatorPtr& communicator)
+{
+ // the factoryTable interface is... interesting. if you add an exception factory
+ // with the same name as one already in the table, it just increments the reference
+ // count on the existing factory, without even comparing the factory object
+ // handles to see if it is in fact the same factory being added. so for now we
+ // need to explicitly remove the factory that the slice2cpp translator generated
+ // before adding our own
+ IceInternal::factoryTable->removeExceptionFactory("::Test::BaseUnsliceable");
+ IceInternal::factoryTable->addExceptionFactory("::Test::BaseUnsliceable", new PreserverFactory<BaseUnsliceable>);
}
void
@@ -101,8 +140,7 @@
}
void
-TestI::
-knownMostDerivedAsKnownMostDerived_async(const AMD_TestIntf_knownMostDerivedAsKnownMostDerivedPtr& cb,
+TestI::knownMostDerivedAsKnownMostDerived_async(const AMD_TestIntf_knownMostDerivedAsKnownMostDerivedPtr& cb,
const ::Ice::Current&)
{
KnownMostDerived kmd;
@@ -144,6 +182,81 @@
}
void
+TestI::clientBaseAsBasePass_async(
+ const Test::AMD_TestIntf_clientBaseAsBasePassPtr&,
+ const Test::ClientIntfPrx& client,
+ const ::Ice::Current&)
+{
+ client->baseAsBase();
+}
+
+void
+TestI::clientUnknownDerivedAsBasePass_async(
+ const Test::AMD_TestIntf_clientUnknownDerivedAsBasePassPtr&,
+ const Test::ClientIntfPrx& client,
+ const ::Ice::Current&)
+{
+ client->unknownDerivedAsBase();
+}
+
+void
+TestI::clientUnsliceableDerivedAsBasePass_async(
+ const Test::AMD_TestIntf_clientUnsliceableDerivedAsBasePassPtr&,
+ const Test::ClientIntfPrx& client,
+ const ::Ice::Current&)
+{
+ client->unsliceableDerivedAsBase();
+}
+
+void
+TestI::clientBaseAsBaseRethrow_async(
+ const Test::AMD_TestIntf_clientBaseAsBaseRethrowPtr& cb,
+ const Test::ClientIntfPrx& client,
+ const ::Ice::Current&)
+{
+ try
+ {
+ client->baseAsBase();
+ }
+ catch (const Base& ex)
+ {
+ cb->ice_exception(ex);
+ }
+}
+
+void
+TestI::clientUnknownDerivedAsBaseRethrow_async(
+ const Test::AMD_TestIntf_clientUnknownDerivedAsBaseRethrowPtr& cb,
+ const Test::ClientIntfPrx& client,
+ const ::Ice::Current&)
+{
+ try
+ {
+ client->unknownDerivedAsBase();
+ }
+ catch (const Base& ex)
+ {
+ cb->ice_exception(ex);
+ }
+}
+
+void
+TestI::clientUnsliceableDerivedAsBaseRethrow_async(
+ const Test::AMD_TestIntf_clientUnsliceableDerivedAsBaseRethrowPtr& cb,
+ const Test::ClientIntfPrx& client,
+ const ::Ice::Current&)
+{
+ try
+ {
+ client->unsliceableDerivedAsBase();
+ }
+ catch (const Base& ex)
+ {
+ cb->ice_exception(ex);
+ }
+}
+
+void
TestI::shutdown_async(const AMD_TestIntf_shutdownPtr& cb, const ::Ice::Current& current)
{
current.adapter->getCommunicator()->shutdown();
Modified: techdemo/team/kpfleming/slicing/exceptions/TestAMDI.h
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/exceptions/TestAMDI.h?view=diff&rev=578&r1=577&r2=578
==============================================================================
--- techdemo/team/kpfleming/slicing/exceptions/TestAMDI.h (original)
+++ techdemo/team/kpfleming/slicing/exceptions/TestAMDI.h Mon Apr 12 13:28:36 2010
@@ -16,7 +16,7 @@
{
public:
- TestI();
+ TestI(const Ice::CommunicatorPtr&);
virtual void baseAsBase_async(const ::Test::AMD_TestIntf_baseAsBasePtr&, const ::Ice::Current&);
virtual void unknownDerivedAsBase_async(const ::Test::AMD_TestIntf_unknownDerivedAsBasePtr&, const ::Ice::Current&);
@@ -50,6 +50,31 @@
const ::Test::AMD_TestIntf_unknownMostDerived2AsBasePtr&,
const ::Ice::Current&);
+ virtual void clientBaseAsBasePass_async(
+ const Test::AMD_TestIntf_clientBaseAsBasePassPtr&,
+ const Test::ClientIntfPrx&,
+ const ::Ice::Current&);
+ virtual void clientUnknownDerivedAsBasePass_async(
+ const Test::AMD_TestIntf_clientUnknownDerivedAsBasePassPtr&,
+ const Test::ClientIntfPrx&,
+ const ::Ice::Current&);
+ virtual void clientUnsliceableDerivedAsBasePass_async(
+ const Test::AMD_TestIntf_clientUnsliceableDerivedAsBasePassPtr&,
+ const Test::ClientIntfPrx&,
+ const ::Ice::Current&);
+ virtual void clientBaseAsBaseRethrow_async(
+ const Test::AMD_TestIntf_clientBaseAsBaseRethrowPtr&,
+ const Test::ClientIntfPrx&,
+ const ::Ice::Current&);
+ virtual void clientUnknownDerivedAsBaseRethrow_async(
+ const Test::AMD_TestIntf_clientUnknownDerivedAsBaseRethrowPtr&,
+ const Test::ClientIntfPrx&,
+ const ::Ice::Current&);
+ virtual void clientUnsliceableDerivedAsBaseRethrow_async(
+ const Test::AMD_TestIntf_clientUnsliceableDerivedAsBaseRethrowPtr&,
+ const Test::ClientIntfPrx&,
+ const ::Ice::Current&);
+
virtual void shutdown_async(const ::Test::AMD_TestIntf_shutdownPtr&, const ::Ice::Current&);
};
More information about the asterisk-scf-commits
mailing list