本文整理汇总了C++中ice::ObjectAdapterPtr::addDefaultServant方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectAdapterPtr::addDefaultServant方法的具体用法?C++ ObjectAdapterPtr::addDefaultServant怎么用?C++ ObjectAdapterPtr::addDefaultServant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::ObjectAdapterPtr
的用法示例。
在下文中一共展示了ObjectAdapterPtr::addDefaultServant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
virtual int run(int, char*[])
{
//
// Terminate cleanly on receipt of a signal
//
shutdownOnInterrupt();
//
// Create an object adapter
//
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("MapFilesystem");
//
// Open a connection to the files and directories database. This should remain open
// for the duration of the application for performance reasons.
//
const Freeze::ConnectionPtr connection(Freeze::createConnection(communicator(), _envName));
const IdentityFileEntryMap fileDB(connection, FileI::filesDB());
const IdentityDirectoryEntryMap dirDB(connection, DirectoryI::directoriesDB());
//
// Add default servants for the file and directory.
//
adapter->addDefaultServant(new FileI(communicator(), _envName), "file");
adapter->addDefaultServant(new DirectoryI(communicator(), _envName), "");
//
// Ready to accept requests now
//
adapter->activate();
//
// Wait until we are done
//
communicator()->waitForShutdown();
//
// Clean up
//
if(interrupted())
{
cerr << appName() << ": received signal, shutting down" << endl;
}
return 0;
}
示例2: test
void
allTests(const Ice::CommunicatorPtr& communicator)
{
Ice::ObjectAdapterPtr oa = communicator->createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");
oa->activate();
Ice::ObjectPtr servant = ICE_MAKE_SHARED(MyObjectI);
//
// Register default servant with category "foo"
//
oa->addDefaultServant(servant, "foo");
//
// Start test
//
cout << "testing single category... " << flush;
Ice::ObjectPtr r = oa->findDefaultServant("foo");
test(r == servant);
r = oa->findDefaultServant("bar");
test(r == 0);
Ice::Identity identity;
identity.category = "foo";
string names[] = { "foo", "bar", "x", "y", "abcdefg" };
int idx;
for(idx = 0; idx < 5; ++idx)
{
identity.name = names[idx];
MyObjectPrxPtr prx = ICE_UNCHECKED_CAST(MyObjectPrx, oa->createProxy(identity));
prx->ice_ping();
test(prx->getName() == names[idx]);
}
identity.name = "ObjectNotExist";
MyObjectPrxPtr prx = ICE_UNCHECKED_CAST(MyObjectPrx, oa->createProxy(identity));
try
{
prx->ice_ping();
test(false);
}
catch(const Ice::ObjectNotExistException&)
{
// Expected
}
try
{
prx->getName();
test(false);
}
catch(const Ice::ObjectNotExistException&)
{
// Expected
}
identity.name = "FacetNotExist";
prx = ICE_UNCHECKED_CAST(MyObjectPrx, oa->createProxy(identity));
try
{
prx->ice_ping();
test(false);
}
catch(const Ice::FacetNotExistException&)
{
// Expected
}
try
{
prx->getName();
test(false);
}
catch(const Ice::FacetNotExistException&)
{
// Expected
}
identity.category = "bar";
for(idx = 0; idx < 5; idx++)
{
identity.name = names[idx];
prx = ICE_UNCHECKED_CAST(MyObjectPrx, oa->createProxy(identity));
try
{
prx->ice_ping();
test(false);
}
catch(const Ice::ObjectNotExistException&)
{
// Expected
}
try
//.........这里部分代码省略.........