本文整理汇总了C++中ice::ObjectAdapterPtr::addWithUUID方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectAdapterPtr::addWithUUID方法的具体用法?C++ ObjectAdapterPtr::addWithUUID怎么用?C++ ObjectAdapterPtr::addWithUUID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::ObjectAdapterPtr
的用法示例。
在下文中一共展示了ObjectAdapterPtr::addWithUUID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sigaction
int
ClientApp::run(int, char*[])
{
#ifndef _WIN32
//
// Check SIGPIPE is now SIG_IGN
//
struct sigaction action;
sigaction(SIGPIPE, 0, &action);
test(action.sa_handler == SIG_IGN);
#endif
//
// Create OA and servants
//
Ice::ObjectAdapterPtr oa = communicator()->createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");
Ice::ObjectPtr servant = ICE_MAKE_SHARED(MyObjectI);
InterceptorIPtr interceptor = ICE_MAKE_SHARED(InterceptorI, servant);
AMDInterceptorIPtr amdInterceptor = ICE_MAKE_SHARED(AMDInterceptorI, servant);
Test::MyObjectPrxPtr prx = ICE_UNCHECKED_CAST(Test::MyObjectPrx, oa->addWithUUID(interceptor));
Test::MyObjectPrxPtr prxForAMD = ICE_UNCHECKED_CAST(Test::MyObjectPrx, oa->addWithUUID(amdInterceptor));
cout << "Collocation optimization on" << endl;
int rs = run(prx, interceptor);
if(rs != 0)
{
return rs;
}
cout << "Now with AMD" << endl;
rs = runAmd(prxForAMD, amdInterceptor);
if(rs != 0)
{
return rs;
}
oa->activate(); // Only necessary for non-collocation optimized tests
cout << "Collocation optimization off" << endl;
interceptor->clear();
prx = ICE_UNCHECKED_CAST(Test::MyObjectPrx, prx->ice_collocationOptimized(false));
rs = run(prx, interceptor);
if(rs != 0)
{
return rs;
}
cout << "Now with AMD" << endl;
amdInterceptor->clear();
prxForAMD = ICE_UNCHECKED_CAST(Test::MyObjectPrx, prxForAMD->ice_collocationOptimized(false));
rs = runAmd(prxForAMD, amdInterceptor);
return rs;
}
示例2: CCamCtrl
CHdwIce::CHdwIce( Ice::ObjectAdapterPtr adapter )
: Hdw::CHdw()
{
m_camCtrl = new CCamCtrl();
m_motoCtrl = new CMotoCtrl();
m_cam = new CCamIce( m_camCtrl );
m_moto = new CMotoIce( m_motoCtrl );
m_camPrx = Hdw::CCamPrx::uncheckedCast( adapter->addWithUUID( m_cam ) );
m_motoPrx = Hdw::CMotoPrx::uncheckedCast( adapter->addWithUUID( m_moto ) );
}
示例3: communicator
int
HelloClient::run(int argc, char* argv[])
{
Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
args = communicator()->getProperties()->parseCommandLineOptions("Discover", args);
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("DiscoverReply");
DiscoverReplyIPtr replyI = new DiscoverReplyI;
DiscoverReplyPrx reply = DiscoverReplyPrx::uncheckedCast(adapter->addWithUUID(replyI));
adapter->activate();
DiscoverPrx discover = DiscoverPrx::uncheckedCast(
communicator()->propertyToProxy("Discover.Proxy")->ice_datagram());
discover->lookup(reply);
Ice::ObjectPrx base = replyI->waitReply(IceUtil::Time::seconds(2));
if(!base)
{
cerr << argv[0] << ": no replies" << endl;
return EXIT_FAILURE;
}
HelloPrx hello = HelloPrx::checkedCast(base);
if(!hello)
{
cerr << argv[0] << ": invalid reply" << endl;
return EXIT_FAILURE;
}
hello->sayHello();
return EXIT_SUCCESS;
}
示例4: sigaction
int
Client::run(int, char*[])
{
#ifndef _WIN32
//
// Check SIGPIPE is now SIG_IGN
//
struct sigaction action;
sigaction(SIGPIPE, 0, &action);
test(action.sa_handler == SIG_IGN);
#endif
//
// Create OA and servants
//
Ice::ObjectAdapterPtr oa = communicator()->createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");
Ice::ObjectPtr servant = new MyObjectI;
InterceptorIPtr interceptor = new InterceptorI(servant);
Test::MyObjectPrx prx = Test::MyObjectPrx::uncheckedCast(oa->addWithUUID(interceptor));
oa->activate();
cout << "Collocation optimization on" << endl;
int rs = run(prx, interceptor);
if(rs == 0)
{
cout << "Collocation optimization off" << endl;
interceptor->clear();
prx = Test::MyObjectPrx::uncheckedCast(prx->ice_collocationOptimized(false));
rs = run(prx, interceptor);
if(rs == 0)
{
cout << "Now with AMD" << endl;
AMDInterceptorIPtr amdInterceptor = new AMDInterceptorI(servant);
prx = Test::MyObjectPrx::uncheckedCast(oa->addWithUUID(amdInterceptor));
prx = Test::MyObjectPrx::uncheckedCast(prx->ice_collocationOptimized(false));
rs = runAmd(prx, amdInterceptor);
}
}
return rs;
}
示例5: catch
Glacier2::FilterManager::FilterManager(const InstancePtr& instance, const Glacier2::StringSetIPtr& categories,
const Glacier2::StringSetIPtr& adapters,
const Glacier2::IdentitySetIPtr& identities) :
_categories(categories),
_adapters(adapters),
_identities(identities),
_instance(instance)
{
try
{
Ice::ObjectAdapterPtr adapter = _instance->serverObjectAdapter();
if(adapter)
{
_categoriesPrx = Glacier2::StringSetPrx::uncheckedCast(adapter->addWithUUID(_categories));
_adapterIdsPrx = Glacier2::StringSetPrx::uncheckedCast(adapter->addWithUUID(_adapters));
_identitiesPrx = Glacier2::IdentitySetPrx::uncheckedCast(adapter->addWithUUID(_identities));
}
}
catch(...)
{
destroy();
throw;
}
}
示例6: uncheckedCast
IceGrid::LocatorPrx
RegistryI::setupLocator(const Ice::ObjectAdapterPtr& clientAdapter,
const Ice::ObjectAdapterPtr& registryAdapter,
const Ice::LocatorRegistryPrx& locatorRegistry,
const RegistryPrx& registry,
const QueryPrx& query)
{
LocatorPtr locator = new LocatorI(_communicator, _database, locatorRegistry, registry, query);
Identity locatorId;
locatorId.category = _instanceName;
locatorId.name = "Locator";
clientAdapter->add(locator, locatorId);
locatorId.name = "Locator-" + _replicaName;
clientAdapter->add(locator, locatorId);
return LocatorPrx::uncheckedCast(registryAdapter->addWithUUID(locator));
}
示例7: run
virtual int run(int argc, char* argv[])
{
ClientOrServer::run(argc, argv);
// Register a new object adapter
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("SonarEventListener.Subscriber");
// Subscribe to the event
IceStorm::QoS qos;
Ice::ObjectPrx subscriber = adapter->addWithUUID(new SonarEventPrinter);
sonarTopic->subscribe(qos, subscriber);
// Start the adapter and keep going until the program is killed
adapter->activate();
shutdownOnInterrupt();
communicator()->waitForShutdown();
sonarTopic->unsubscribe(subscriber);
return EXIT_SUCCESS;
}
示例8: communicator
int
HelloServer::run(int argc, char* argv[])
{
Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
args = communicator()->getProperties()->parseCommandLineOptions("Discover", args);
for( auto arg : args) {
std::cout << arg << std::endl;
};
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello");
Ice::ObjectAdapterPtr discoverAdapter = communicator()->createObjectAdapter("Discover");
Ice::ObjectPrx hello = adapter->addWithUUID(new HelloI);
DiscoverPtr d = new DiscoverI(hello);
discoverAdapter->add(d, communicator()->stringToIdentity("discover"));
discoverAdapter->activate();
adapter->activate();
communicator()->waitForShutdown();
return EXIT_SUCCESS;
}
示例9: ObserverTopic
NodeObserverTopic::NodeObserverTopic(const IceStorm::TopicManagerPrx& topicManager,
const Ice::ObjectAdapterPtr& adapter) :
ObserverTopic(topicManager, "NodeObserver")
{
_publishers = getPublishers<NodeObserverPrx>();
try
{
const_cast<NodeObserverPrx&>(_externalPublisher) = NodeObserverPrx::uncheckedCast(adapter->addWithUUID(this));
}
catch(const Ice::LocalException&)
{
}
}
示例10: if
int
Client::run(int argc, char* argv[])
{
if(argc > 1)
{
cerr << appName() << ": too many arguments" << endl;
return EXIT_FAILURE;
}
Ice::PropertiesPtr properties = communicator()->getProperties();
const string proxyProperty = "Counter.Proxy";
string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
{
cerr << appName() << ": property `" << proxyProperty << "' not set" << endl;
return EXIT_FAILURE;
}
CounterPrx counter = CounterPrx::uncheckedCast(communicator()->stringToProxy(proxy));
if(!counter)
{
cerr << appName() << ": invalid proxy" << endl;
return EXIT_FAILURE;
}
MTPrinterPtr printer = new MTPrinter();
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("Observer", "tcp");
CounterObserverPrx observer =
CounterObserverPrx::uncheckedCast(adapter->addWithUUID(new CounterObserverI(printer)));
adapter->activate();
counter->subscribe(observer);
menu(printer);
char c;
do
{
try
{
printer->print("==> ");
cin >> c;
if(c == 'i')
{
counter->inc(1);
}
else if(c == 'd')
{
counter->inc(-1);
}
else if(c == 'x')
{
// Nothing to do
}
else if(c == '?')
{
menu(printer);
}
else
{
cout << "unknown command `" << c << "'" << endl;
menu(printer);
}
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
}
}
while(cin.good() && c != 'x');
counter->unsubscribe(observer);
return EXIT_SUCCESS;
}
示例11: loadConfig
int
InterceptorTestApplication::run(int argc, char* argv[])
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties();
loadConfig(initData.properties);
initData.properties->setProperty("Ice.Warn.Dispatch", "0");
initData.logger = getLogger();
setCommunicator(Ice::initialize(argc, argv, initData));
//
// Create OA and servants
//
Ice::ObjectAdapterPtr oa = communicator()->createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");
Ice::ObjectPtr servant = new MyObjectI;
InterceptorIPtr interceptor = new InterceptorI(servant);
Test::MyObjectPrx prx = Test::MyObjectPrx::uncheckedCast(oa->addWithUUID(interceptor));
oa->activate();
tprintf("testing simple interceptor... ");
test(interceptor->getLastOperation().empty());
prx->ice_ping();
test(interceptor->getLastOperation() == "ice_ping");
test(interceptor->getLastStatus() == Ice::DispatchOK);
string typeId = prx->ice_id();
test(interceptor->getLastOperation() == "ice_id");
test(interceptor->getLastStatus() == Ice::DispatchOK);
test(prx->ice_isA(typeId));
test(interceptor->getLastOperation() == "ice_isA");
test(interceptor->getLastStatus() == Ice::DispatchOK);
test(prx->add(33, 12) == 45);
test(interceptor->getLastOperation() == "add");
test(interceptor->getLastStatus() == Ice::DispatchOK);
tprintf("ok\n");
tprintf("testing retry... ");
test(prx->addWithRetry(33, 12) == 45);
test(interceptor->getLastOperation() == "addWithRetry");
test(interceptor->getLastStatus() == Ice::DispatchOK);
tprintf("ok\n");
tprintf("testing user exception... ");
try
{
prx->badAdd(33, 12);
test(false);
}
catch(const Test::InvalidInputException&)
{
// expected
}
test(interceptor->getLastOperation() == "badAdd");
test(interceptor->getLastStatus() == Ice::DispatchUserException);
tprintf("ok\n");
tprintf("testing ONE... ");
interceptor->clear();
try
{
prx->notExistAdd(33, 12);
test(false);
}
catch(const Ice::ObjectNotExistException&)
{
// expected
}
test(interceptor->getLastOperation() == "notExistAdd");
tprintf("ok\n");
tprintf("testing system exception... ");
interceptor->clear();
try
{
prx->badSystemAdd(33, 12);
test(false);
}
catch(const Ice::UnknownLocalException&)
{
}
catch(...)
{
test(false);
}
test(interceptor->getLastOperation() == "badSystemAdd");
tprintf("ok\n");
return 0;
}
示例12: seq
//.........这里部分代码省略.........
{
to->sendData(seq);
test(false);
}
catch(const Ice::TimeoutException&)
{
// Expected.
}
comm->destroy();
}
{
//
// Test Ice.Override.CloseTimeout.
//
Ice::InitializationData initData;
initData.properties = communicator->getProperties()->clone();
initData.properties->setProperty("Ice.Override.CloseTimeout", "250");
Ice::CommunicatorPtr comm = Ice::initialize(initData);
Ice::ConnectionPtr connection = comm->stringToProxy(sref)->ice_getConnection();
timeout->holdAdapter(500);
IceUtil::Time now = IceUtil::Time::now();
comm->destroy();
test(IceUtil::Time::now() - now < IceUtil::Time::milliSeconds(400));
}
cout << "ok" << endl;
cout << "testing invocation timeouts with collocated calls... " << flush;
{
communicator->getProperties()->setProperty("TimeoutCollocated.AdapterId", "timeoutAdapter");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TimeoutCollocated");
adapter->activate();
TimeoutPrxPtr timeout = ICE_UNCHECKED_CAST(TimeoutPrx, adapter->addWithUUID(ICE_MAKE_SHARED(TimeoutI)));
timeout = timeout->ice_invocationTimeout(100);
try
{
timeout->sleep(300);
test(false);
}
catch(const Ice::InvocationTimeoutException&)
{
}
try
{
#ifdef ICE_CPP11_MAPPING
timeout->sleep_async(300).get();
#else
timeout->end_sleep(timeout->begin_sleep(300));
#endif
test(false);
}
catch(const Ice::InvocationTimeoutException&)
{
}
TimeoutPrxPtr batchTimeout = timeout->ice_batchOneway();
batchTimeout->ice_ping();
batchTimeout->ice_ping();
batchTimeout->ice_ping();
// Keep the server thread pool busy.
#ifdef ICE_CPP11_MAPPING
timeout->ice_invocationTimeout(-1)->sleep_async(300);
#else
示例13: getTestEndpoint
//.........这里部分代码省略.........
{
//
// An UnknownUserException is raised for the compact format because the
// most-derived type is unknown and the exception cannot be sliced.
//
test(test->ice_getEncodingVersion() != Ice::Encoding_1_0);
}
catch(const Ice::OperationNotExistException&)
{
}
catch(...)
{
test(false);
}
}
cout << "ok" << endl;
cout << "preserved exceptions... " << flush;
string localOAEndpoint;
{
ostringstream ostr;
if(communicator->getProperties()->getProperty("Ice.Default.Protocol") == "bt")
{
ostr << "default -a *";
}
else
{
ostr << "default -h *";
}
localOAEndpoint = ostr.str();
}
{
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Relay", localOAEndpoint);
RelayPrxPtr relay = ICE_UNCHECKED_CAST(RelayPrx, adapter->addWithUUID(ICE_MAKE_SHARED(RelayI)));
adapter->activate();
try
{
test->relayKnownPreservedAsBase(relay);
test(false);
}
catch(const KnownPreservedDerived& ex)
{
test(ex.b == "base");
test(ex.kp == "preserved");
test(ex.kpd == "derived");
}
catch(const Ice::OperationNotExistException&)
{
}
catch(const Ice::LocalException& ex)
{
cout << endl << "** OOPS" << endl << ex << endl;
test(false);
}
catch(...)
{
test(false);
}
try
{
test->relayKnownPreservedAsKnownPreserved(relay);
test(false);
}
catch(const KnownPreservedDerived& ex)
示例14: test
void
allTests(const Ice::CommunicatorPtr& communicator)
{
{
cout << "Testing Glacier2 stub... " << flush;
char** argv = 0;
int argc = 0;
SessionHelperClient client;
client.run(argc, argv);
cout << "ok" << endl;
}
{
cout << "Testing IceStorm stub... " << flush;
IceStorm::TopicManagerPrxPtr manager =
ICE_UNCHECKED_CAST(IceStorm::TopicManagerPrx, communicator->stringToProxy("test:default -p 12010"));
IceStorm::QoS qos;
IceStorm::TopicPrxPtr topic;
string topicName = "time";
try
{
topic = manager->retrieve(topicName);
test(false);
}
catch(const IceStorm::NoSuchTopic&)
{
test(false);
}
catch(const Ice::LocalException&)
{
}
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("subscriber" ,"tcp");
Ice::ObjectPrxPtr subscriber = adapter->addWithUUID(ICE_MAKE_SHARED(ClockI));
adapter->activate();
#ifdef ICE_CPP11_MAPPING
assert(!topic);
#else
try
{
topic->subscribeAndGetPublisher(qos, subscriber);
test(false);
}
catch(const IceStorm::AlreadySubscribed&)
{
test(false);
}
catch(const IceUtil::NullHandleException&)
{
}
#endif
cout << "ok" << endl;
}
{
cout << "Testing IceGrid stub... " << flush;
Ice::ObjectPrxPtr base = communicator->stringToProxy("test:default -p 12010");
IceGrid::RegistryPrxPtr registry = ICE_UNCHECKED_CAST(IceGrid::RegistryPrx, base);
IceGrid::AdminSessionPrxPtr session;
IceGrid::AdminPrxPtr admin;
try
{
session = registry->createAdminSession("username", "password");
test(false);
}
catch(const IceGrid::PermissionDeniedException&)
{
test(false);
}
catch(const Ice::LocalException&)
{
}
#ifdef ICE_CPP11_MAPPING
assert(!admin);
#else
try
{
admin = session->getAdmin();
test(false);
}
catch(const IceUtil::NullHandleException&)
{
}
#endif
cout << "ok" << endl;
}
}
示例15: while
void
allTests(const CommunicatorPtr& communicator)
{
communicator->getProperties()->setProperty("ReplyAdapter.Endpoints", "udp -p 12030");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("ReplyAdapter");
PingReplyIPtr replyI = new PingReplyI;
PingReplyPrx reply = PingReplyPrx::uncheckedCast(adapter->addWithUUID(replyI))->ice_datagram();
adapter->activate();
cout << "testing udp... " << flush;
ObjectPrx base = communicator->stringToProxy("test -d:udp -p 12010");
TestIntfPrx obj = TestIntfPrx::uncheckedCast(base);
int nRetry = 5;
bool ret;
while(nRetry-- > 0)
{
replyI->reset();
obj->ping(reply);
obj->ping(reply);
obj->ping(reply);
ret = replyI->waitReply(3, IceUtil::Time::seconds(2));
if(ret)
{
break; // Success
}
// If the 3 datagrams were not received within the 2 seconds, we try again to
// receive 3 new datagrams using a new object. We give up after 5 retries.
replyI = new PingReplyI;
reply = PingReplyPrx::uncheckedCast(adapter->addWithUUID(replyI))->ice_datagram();
}
test(ret);
if(communicator->getProperties()->getPropertyAsInt("Ice.Override.Compress") == 0)
{
//
// Only run this test if compression is disabled, the test expect fixed message size
// to be sent over the wire.
//
Test::ByteSeq seq;
try
{
seq.resize(1024);
while(true)
{
seq.resize(seq.size() * 2 + 10);
replyI->reset();
obj->sendByteSeq(seq, reply);
replyI->waitReply(1, IceUtil::Time::seconds(10));
}
}
catch(const DatagramLimitException&)
{
test(seq.size() > 16384);
}
obj->ice_getConnection()->close(false);
communicator->getProperties()->setProperty("Ice.UDP.SndSize", "64000");
seq.resize(50000);
try
{
replyI->reset();
obj->sendByteSeq(seq, reply);
test(!replyI->waitReply(1, IceUtil::Time::milliSeconds(500)));
}
catch(const Ice::LocalException& ex)
{
cerr << ex << endl;
test(false);
}
}
cout << "ok" << endl;
string endpoint;
if(communicator->getProperties()->getProperty("Ice.IPv6") == "1")
{
#ifdef __APPLE__
endpoint = "udp -h \"ff15::1:1\" -p 12020 --interface \"::1\"";
#else
endpoint = "udp -h \"ff15::1:1\" -p 12020";
#endif
}
else
{
endpoint = "udp -h 239.255.1.1 -p 12020";
}
base = communicator->stringToProxy("test -d:" + endpoint);
TestIntfPrx objMcast = TestIntfPrx::uncheckedCast(base);
#if !defined(ICE_OS_WINRT) && (!defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE))
cout << "testing udp multicast... " << flush;
nRetry = 5;
while(nRetry-- > 0)
{
replyI->reset();
objMcast->ping(reply);
ret = replyI->waitReply(5, IceUtil::Time::seconds(2));
if(ret)
//.........这里部分代码省略.........