本文整理汇总了C++中ice::ObjectAdapterPtr::destroy方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectAdapterPtr::destroy方法的具体用法?C++ ObjectAdapterPtr::destroy怎么用?C++ ObjectAdapterPtr::destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::ObjectAdapterPtr
的用法示例。
在下文中一共展示了ObjectAdapterPtr::destroy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runParser
int
PhoneBookCollocated::run(int argc, char* argv[])
{
Ice::PropertiesPtr properties = communicator()->getProperties();
//
// Create and install a factory for contacts.
//
ContactFactoryPtr contactFactory = new ContactFactory();
communicator()->addObjectFactory(contactFactory, Demo::Contact::ice_staticId());
//
// Create the name index.
//
NameIndexPtr index = new NameIndex("name");
vector<Freeze::IndexPtr> indices;
indices.push_back(index);
//
// Create an object adapter, use the evictor as servant locator.
//
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PhoneBook");
//
// Create an evictor for contacts.
//
// When Freeze.Evictor.db.contacts.PopulateEmptyIndices is not 0
// and the Name index is empty, Freeze will traverse the database
// to recreate the index during createXXXEvictor(). Therefore the
// factories for the objects stored in evictor (contacts here)
// must be registered before the call to createXXXEvictor().
//
Freeze::EvictorPtr evictor = Freeze::createBackgroundSaveEvictor(adapter, _envName, "contacts", 0, indices);
adapter->addServantLocator(evictor, "contact");
Ice::Int evictorSize = properties->getPropertyAsInt("EvictorSize");
if(evictorSize > 0)
{
evictor->setSize(evictorSize);
}
//
// Completes the initialization of the contact factory. Note that ContactI/
// ContactFactoryI uses this evictor only when a Contact is destroyed,
// which cannot happen during createXXXEvictor().
//
contactFactory->setEvictor(evictor);
//
// Create the phonebook, and add it to the Object Adapter.
//
PhoneBookIPtr phoneBook = new PhoneBookI(evictor, contactFactory, index);
adapter->add(phoneBook, communicator()->stringToIdentity("phonebook"));
//
// Everything ok, let's go.
//
int runParser(int, char*[], const Ice::CommunicatorPtr&);
int status = runParser(argc, argv, communicator());
adapter->destroy();
return status;
}
示例2: is
void
allTests(Test::TestHelper* helper)
{
Ice::CommunicatorPtr communicator = helper->communicator();
cout << "testing proxy endpoint information... " << flush;
{
Ice::ObjectPrxPtr p1 =
communicator->stringToProxy("test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:"
"udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:"
"opaque -e 1.8 -t 100 -v ABCD");
Ice::EndpointSeq endps = p1->ice_getEndpoints();
Ice::EndpointInfoPtr info = endps[0]->getInfo();
Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(info);
test(ipEndpoint);
test(ipEndpoint->host == "tcphost");
test(ipEndpoint->port == 10000);
test(ipEndpoint->timeout == 1200);
#if !defined(ICE_OS_UWP)
test(ipEndpoint->sourceAddress == "10.10.10.10");
#endif
test(ipEndpoint->compress);
test(!ipEndpoint->datagram());
test((ipEndpoint->type() == Ice::TCPEndpointType && !ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::SSLEndpointType && ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSEndpointType && !ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSSEndpointType && ipEndpoint->secure()));
test((ipEndpoint->type() == Ice::TCPEndpointType && ICE_DYNAMIC_CAST(Ice::TCPEndpointInfo, info)) ||
(ipEndpoint->type() == Ice::SSLEndpointType && ICE_DYNAMIC_CAST(IceSSL::EndpointInfo, info)) ||
(ipEndpoint->type() == Ice::WSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, info)) ||
(ipEndpoint->type() == Ice::WSSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, info)));
Ice::UDPEndpointInfoPtr udpEndpoint = ICE_DYNAMIC_CAST(Ice::UDPEndpointInfo, endps[1]->getInfo());
test(udpEndpoint);
test(udpEndpoint->host == "udphost");
test(udpEndpoint->port == 10001);
#if !defined(ICE_OS_UWP)
test(udpEndpoint->sourceAddress == "10.10.10.10");
#endif
test(udpEndpoint->mcastInterface == "eth0");
test(udpEndpoint->mcastTtl == 5);
test(udpEndpoint->timeout == -1);
test(!udpEndpoint->compress);
test(!udpEndpoint->secure());
test(udpEndpoint->datagram());
test(udpEndpoint->type() == Ice::UDPEndpointType);
Ice::OpaqueEndpointInfoPtr opaqueEndpoint = ICE_DYNAMIC_CAST(Ice::OpaqueEndpointInfo, endps[2]->getInfo());
test(opaqueEndpoint);
Ice::EncodingVersion rev;
rev.major = 1;
rev.minor = 8;
test(opaqueEndpoint->rawEncoding == rev);
}
cout << "ok" << endl;
string defaultHost = communicator->getProperties()->getProperty("Ice.Default.Host");
#ifdef ICE_OS_UWP
bool uwp = true;
#else
bool uwp = false;
#endif
if(!uwp || (communicator->getProperties()->getProperty("Ice.Default.Protocol") != "ssl" &&
communicator->getProperties()->getProperty("Ice.Default.Protocol") != "wss"))
{
cout << "test object adapter endpoint information... " << flush;
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints",
"default -h 127.0.0.1 -t 15000:udp -h 127.0.0.1");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
Ice::EndpointSeq endpoints = adapter->getEndpoints();
test(endpoints.size() == 2);
Ice::EndpointSeq publishedEndpoints = adapter->getPublishedEndpoints();
test(endpoints == publishedEndpoints);
Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(endpoints[0]->getInfo());
test(ipEndpoint);
test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == Ice::SSLEndpointType ||
ipEndpoint->type() == Ice::WSEndpointType || ipEndpoint->type() == Ice::WSSEndpointType);
test(ipEndpoint->host == "127.0.0.1");
test(ipEndpoint->port > 0);
test(ipEndpoint->timeout == 15000);
Ice::UDPEndpointInfoPtr udpEndpoint = ICE_DYNAMIC_CAST(Ice::UDPEndpointInfo, endpoints[1]->getInfo());
test(udpEndpoint);
test(udpEndpoint->host == "127.0.0.1");
test(udpEndpoint->datagram());
test(udpEndpoint->port > 0);
endpoints.pop_back();
test(endpoints.size() == 1);
adapter->setPublishedEndpoints(endpoints);
publishedEndpoints = adapter->getPublishedEndpoints();
test(endpoints == publishedEndpoints);
adapter->destroy();
//.........这里部分代码省略.........
示例3: seq
//.........这里部分代码省略.........
// endpoint timeouts.
//
Ice::InitializationData initData;
initData.properties = communicator->getProperties()->clone();
initData.properties->setProperty("Ice.Override.Timeout", "250");
Ice::CommunicatorPtr comm = Ice::initialize(initData);
TimeoutPrxPtr to = ICE_CHECKED_CAST(TimeoutPrx, comm->stringToProxy(sref));
timeout->holdAdapter(700);
try
{
to->sendData(seq);
test(false);
}
catch(const Ice::TimeoutException&)
{
// Expected.
}
//
// Calling ice_timeout() should have no effect.
//
timeout->op(); // Ensure adapter is active.
to = ICE_CHECKED_CAST(TimeoutPrx, to->ice_timeout(1000));
timeout->holdAdapter(500);
try
{
to->sendData(seq);
test(false);
}
catch(const Ice::TimeoutException&)
{
// Expected.
}
comm->destroy();
}
{
//
// Test Ice.Override.ConnectTimeout.
//
Ice::InitializationData initData;
initData.properties = communicator->getProperties()->clone();
initData.properties->setProperty("Ice.Override.ConnectTimeout", "250");
Ice::CommunicatorPtr comm = Ice::initialize(initData);
timeout->holdAdapter(750);
TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, comm->stringToProxy(sref));
try
{
to->op();
test(false);
}
catch(const Ice::ConnectTimeoutException&)
{
// Expected.
}
//
// Calling ice_timeout() should have no effect on the connect timeout.
//
timeout->op(); // Ensure adapter is active.
timeout->holdAdapter(750);
to = ICE_UNCHECKED_CAST(TimeoutPrx, to->ice_timeout(1000));
try
{
to->op();
test(false);
}
catch(const Ice::ConnectTimeoutException&)
示例4: getTestEndpoint
//.........这里部分代码省略.........
test(false);
}
catch(...)
{
test(false);
}
try
{
test->relayKnownPreservedAsKnownPreserved(relay);
test(false);
}
catch(const KnownPreservedDerived& ex)
{
test(ex.b == "base");
test(ex.kp == "preserved");
test(ex.kpd == "derived");
}
catch(const Ice::OperationNotExistException&)
{
}
catch(...)
{
test(false);
}
try
{
test->relayUnknownPreservedAsBase(relay);
test(false);
}
catch(const Preserved2& ex)
{
test(ex.b == "base");
test(ex.kp == "preserved");
test(ex.kpd == "derived");
test(ex.p1->ice_id() == PreservedClass::ice_staticId());
PreservedClassPtr pc = ICE_DYNAMIC_CAST(PreservedClass, ex.p1);
test(pc->bc == "bc");
test(pc->pc == "pc");
test(ex.p2 == ex.p1);
}
catch(const Ice::OperationNotExistException&)
{
}
catch(const KnownPreservedDerived& ex)
{
//
// For the 1.0 encoding, the unknown exception is sliced to KnownPreserved.
//
test(test->ice_getEncodingVersion() == Ice::Encoding_1_0);
test(ex.b == "base");
test(ex.kp == "preserved");
test(ex.kpd == "derived");
}
catch(...)
{
test(false);
}
try
{
test->relayUnknownPreservedAsKnownPreserved(relay);
test(false);
}
catch(const Ice::OperationNotExistException&)
{
}
catch(const Preserved2& ex)
{
test(ex.b == "base");
test(ex.kp == "preserved");
test(ex.kpd == "derived");
test(ex.p1->ice_id() == PreservedClass::ice_staticId());
PreservedClassPtr pc = ICE_DYNAMIC_CAST(PreservedClass, ex.p1);
test(pc->bc == "bc");
test(pc->pc == "pc");
test(ex.p2 == ex.p1);
}
catch(const KnownPreservedDerived& ex)
{
//
// For the 1.0 encoding, the unknown exception is sliced to KnownPreserved.
//
test(test->ice_getEncodingVersion() == Ice::Encoding_1_0);
test(ex.b == "base");
test(ex.kp == "preserved");
test(ex.kpd == "derived");
}
catch(...)
{
test(false);
}
adapter->destroy();
}
cout << "ok" << endl;
return test;
}
示例5: while
void
ServerManagerI::startServer(const Ice::Current&)
{
for(::std::vector<Ice::CommunicatorPtr>::const_iterator i = _communicators.begin(); i != _communicators.end(); ++i)
{
(*i)->waitForShutdown();
(*i)->destroy();
}
_communicators.clear();
//
// Simulate a server: create a new communicator and object
// adapter. The object adapter is started on a system allocated
// port. The configuration used here contains the Ice.Locator
// configuration variable. The new object adapter will register
// its endpoints with the locator and create references containing
// the adapter id instead of the endpoints.
//
Ice::CommunicatorPtr serverCommunicator = Ice::initialize(_initData);
_communicators.push_back(serverCommunicator);
//
// Use fixed port to ensure that OA re-activation doesn't re-use previous port from
// another OA (e.g.: TestAdapter2 is re-activated using port of TestAdapter).
//
int nRetry = 10;
while(--nRetry > 0)
{
Ice::ObjectAdapterPtr adapter;
Ice::ObjectAdapterPtr adapter2;
try
{
Ice::PropertiesPtr props = _initData.properties;
serverCommunicator->getProperties()->setProperty("TestAdapter.Endpoints",
getTestEndpoint(props, _nextPort++));
serverCommunicator->getProperties()->setProperty("TestAdapter2.Endpoints",
getTestEndpoint(props, _nextPort++));
adapter = serverCommunicator->createObjectAdapter("TestAdapter");
adapter2 = serverCommunicator->createObjectAdapter("TestAdapter2");
Ice::ObjectPrxPtr locator = serverCommunicator->stringToProxy("locator:" + getTestEndpoint(props, 0));
adapter->setLocator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, locator));
adapter2->setLocator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, locator));
Ice::ObjectPtr object = ICE_MAKE_SHARED(TestI, adapter, adapter2, _registry);
_registry->addObject(adapter->add(object, Ice::stringToIdentity("test")));
_registry->addObject(adapter->add(object, Ice::stringToIdentity("test2")));
adapter->add(object, Ice::stringToIdentity("test3"));
adapter->activate();
adapter2->activate();
break;
}
catch(const Ice::SocketException&)
{
if(nRetry == 0)
{
throw;
}
// Retry, if OA creation fails with EADDRINUSE (this can occur when running with JS web
// browser clients if the driver uses ports in the same range as this test, ICE-8148)
if(adapter)
{
adapter->destroy();
}
if(adapter2)
{
adapter2->destroy();
}
}
}
}
示例6: is
void
allTests(const Ice::CommunicatorPtr& communicator)
{
cout << "testing proxy endpoint information... " << flush;
{
Ice::ObjectPrx p1 =
communicator->stringToProxy("test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:"
"udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:"
"opaque -e 1.8 -t 100 -v ABCD");
Ice::EndpointSeq endps = p1->ice_getEndpoints();
Ice::IPEndpointInfoPtr ipEndpoint = Ice::IPEndpointInfoPtr::dynamicCast(endps[0]->getInfo());
test(ipEndpoint);
test(ipEndpoint->host == "tcphost");
test(ipEndpoint->port == 10000);
test(ipEndpoint->timeout == 1200);
#if !defined(ICE_OS_WINRT)
test(ipEndpoint->sourceAddress == "10.10.10.10");
#endif
test(ipEndpoint->compress);
test(!ipEndpoint->datagram());
test((ipEndpoint->type() == Ice::TCPEndpointType && !ipEndpoint->secure()) ||
(ipEndpoint->type() == IceSSL::EndpointType && ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSEndpointType && !ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSSEndpointType && ipEndpoint->secure()));
test((ipEndpoint->type() == Ice::TCPEndpointType && Ice::TCPEndpointInfoPtr::dynamicCast(ipEndpoint)) ||
(ipEndpoint->type() == IceSSL::EndpointType && IceSSL::EndpointInfoPtr::dynamicCast(ipEndpoint)) ||
(ipEndpoint->type() == Ice::WSEndpointType && Ice::EndpointInfoPtr::dynamicCast(ipEndpoint)) ||
(ipEndpoint->type() == Ice::WSSEndpointType && Ice::EndpointInfoPtr::dynamicCast(ipEndpoint)));
Ice::UDPEndpointInfoPtr udpEndpoint = Ice::UDPEndpointInfoPtr::dynamicCast(endps[1]->getInfo());
test(udpEndpoint);
test(udpEndpoint->host == "udphost");
test(udpEndpoint->port == 10001);
#if !defined(ICE_OS_WINRT)
test(udpEndpoint->sourceAddress == "10.10.10.10");
#endif
test(udpEndpoint->mcastInterface == "eth0");
test(udpEndpoint->mcastTtl == 5);
test(udpEndpoint->timeout == -1);
test(!udpEndpoint->compress);
test(!udpEndpoint->secure());
test(udpEndpoint->datagram());
test(udpEndpoint->type() == Ice::UDPEndpointType);
Ice::OpaqueEndpointInfoPtr opaqueEndpoint = Ice::OpaqueEndpointInfoPtr::dynamicCast(endps[2]->getInfo());
test(opaqueEndpoint);
Ice::EncodingVersion rev;
rev.major = 1;
rev.minor = 8;
test(opaqueEndpoint->rawEncoding == rev);
}
cout << "ok" << endl;
string defaultHost = communicator->getProperties()->getProperty("Ice.Default.Host");
cout << "test object adapter endpoint information... " << flush;
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -t 15000:udp");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
Ice::EndpointSeq endpoints = adapter->getEndpoints();
test(endpoints.size() == 2);
Ice::EndpointSeq publishedEndpoints = adapter->getPublishedEndpoints();
test(endpoints == publishedEndpoints);
Ice::IPEndpointInfoPtr ipEndpoint = Ice::IPEndpointInfoPtr::dynamicCast(endpoints[0]->getInfo());
test(ipEndpoint);
test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == IceSSL::EndpointType ||
ipEndpoint->type() == Ice::WSEndpointType || ipEndpoint->type() == Ice::WSSEndpointType);
test(ipEndpoint->host == defaultHost);
test(ipEndpoint->port > 0);
test(ipEndpoint->timeout == 15000);
Ice::UDPEndpointInfoPtr udpEndpoint = Ice::UDPEndpointInfoPtr::dynamicCast(endpoints[1]->getInfo());
test(udpEndpoint);
test(udpEndpoint->host == defaultHost);
test(udpEndpoint->datagram());
test(udpEndpoint->port > 0);
adapter->destroy();
communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -h * -p 12020");
communicator->getProperties()->setProperty("TestAdapter.PublishedEndpoints", "default -h 127.0.0.1 -p 12020");
adapter = communicator->createObjectAdapter("TestAdapter");
endpoints = adapter->getEndpoints();
test(endpoints.size() >= 1);
publishedEndpoints = adapter->getPublishedEndpoints();
test(publishedEndpoints.size() == 1);
for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
ipEndpoint = Ice::IPEndpointInfoPtr::dynamicCast((*p)->getInfo());
test(ipEndpoint->port == 12020);
}
ipEndpoint = Ice::IPEndpointInfoPtr::dynamicCast(publishedEndpoints[0]->getInfo());
test(ipEndpoint->host == "127.0.0.1");
test(ipEndpoint->port == 12020);
//.........这里部分代码省略.........