int run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0)); communicator->getProperties()->setProperty("ControllerAdapter.Endpoints", getTestEndpoint(communicator, 1, "tcp")); communicator->getProperties()->setProperty("ControllerAdapter.ThreadPool.Size", "1"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("ControllerAdapter"); #ifdef ICE_CPP11_MAPPING shared_ptr<PluginI> plugin = dynamic_pointer_cast<PluginI>(communicator->getPluginManager()->getPlugin("Test")); #else PluginI* plugin = dynamic_cast<PluginI*>(communicator->getPluginManager()->getPlugin("Test").get()); #endif assert(plugin); ConfigurationPtr configuration = plugin->getConfiguration(); BackgroundControllerIPtr backgroundController = ICE_MAKE_SHARED(BackgroundControllerI, adapter, configuration); adapter->add(ICE_MAKE_SHARED(BackgroundI, backgroundController), communicator->stringToIdentity("background")); adapter->add(ICE_MAKE_SHARED(LocatorI, backgroundController), communicator->stringToIdentity("locator")); adapter->add(ICE_MAKE_SHARED(RouterI, backgroundController), communicator->stringToIdentity("router")); adapter->activate(); adapter2->add(backgroundController, communicator->stringToIdentity("backgroundController")); adapter2->activate(); communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { IceUtil::TimerPtr timer = new IceUtil::Timer(); communicator->getProperties()->setProperty("TestAdapter1.Endpoints", getTestEndpoint(communicator, 0) + ":udp"); communicator->getProperties()->setProperty("TestAdapter1.ThreadPool.Size", "5"); communicator->getProperties()->setProperty("TestAdapter1.ThreadPool.SizeMax", "5"); communicator->getProperties()->setProperty("TestAdapter1.ThreadPool.SizeWarn", "0"); communicator->getProperties()->setProperty("TestAdapter1.ThreadPool.Serialize", "0"); Ice::ObjectAdapterPtr adapter1 = communicator->createObjectAdapter("TestAdapter1"); adapter1->add(ICE_MAKE_SHARED(HoldI, timer, adapter1), communicator->stringToIdentity("hold")); communicator->getProperties()->setProperty("TestAdapter2.Endpoints", getTestEndpoint(communicator, 1) + ":udp"); communicator->getProperties()->setProperty("TestAdapter2.ThreadPool.Size", "5"); communicator->getProperties()->setProperty("TestAdapter2.ThreadPool.SizeMax", "5"); communicator->getProperties()->setProperty("TestAdapter2.ThreadPool.SizeWarn", "0"); communicator->getProperties()->setProperty("TestAdapter2.ThreadPool.Serialize", "1"); Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("TestAdapter2"); adapter2->add(ICE_MAKE_SHARED(HoldI, timer, adapter2), communicator->stringToIdentity("hold")); adapter1->activate(); adapter2->activate(); TEST_READY communicator->waitForShutdown(); timer->destroy(); return EXIT_SUCCESS; }
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). // { std::ostringstream os; os << "default -p " << _nextPort++; serverCommunicator->getProperties()->setProperty("TestAdapter.Endpoints", os.str()); } { std::ostringstream os; os << "default -p " << _nextPort++; serverCommunicator->getProperties()->setProperty("TestAdapter2.Endpoints", os.str()); } Ice::ObjectAdapterPtr adapter = serverCommunicator->createObjectAdapter("TestAdapter"); Ice::ObjectAdapterPtr adapter2 = serverCommunicator->createObjectAdapter("TestAdapter2"); Ice::ObjectPrxPtr locator = serverCommunicator->stringToProxy("locator:default -p 12010"); 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, serverCommunicator->stringToIdentity("test"))); _registry->addObject(adapter->add(object, serverCommunicator->stringToIdentity("test2"))); adapter->add(object, serverCommunicator->stringToIdentity("test3")); adapter->activate(); adapter2->activate(); }
int run(const Ice::CommunicatorPtr& communicator, const string& envName, const string& dbName) { Ice::ObjectFactoryPtr factory = new Factory; communicator->addObjectFactory(factory, ""); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(""); Freeze::EvictorPtr evictor = Freeze::createEvictor(adapter, envName, dbName); for(int i = 0; i < 10; ++i) { string facetName = "theFacet"; Ice::Identity id; ostringstream ostr; ostr << "mainObject" << i; id.name = ostr.str(); if((i % 2) == 0) { MainObjectPtr obj = new MainObjectI; obj->boolToString = true; obj->byteToShort = 0; obj->shortToByte = 255; obj->intToShort = 32767; obj->longToInt = 2147483647; obj->floatToString = 4567.8f; obj->doubleToFloat = 8765.4; obj->stringToEnum = "E1"; obj->renamed = E2; evictor->add(obj, id); FacetObjectPtr facet = new FacetObjectI; facet->doubleToString = 901234.5; evictor->addFacet(facet, id, facetName); } else { DerivedMainObjectPtr obj = new DerivedMainObjectI; obj->boolToString = false; obj->byteToShort = 0; obj->shortToByte = -1; obj->intToShort = -32768; obj->longToInt = -2147483647 - 1; obj->floatToString = -4567.8f; obj->doubleToFloat = -8765.4; obj->stringToEnum = "E3"; obj->renamed = E1; obj->name = id.name; evictor->add(obj, id); DerivedFacetObjectPtr facet = new DerivedFacetObjectI; facet->doubleToString = -901234.5; facet->count = i; evictor->addFacet(facet, id, facetName); } } evictor->deactivate(""); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { #ifdef ICE_CPP11_MAPPING communicator->getValueFactoryManager()->add(makeFactory<II>(), "::Test::I"); communicator->getValueFactoryManager()->add(makeFactory<JI>(), "::Test::J"); communicator->getValueFactoryManager()->add(makeFactory<HI>(), "::Test::H"); #else Ice::ValueFactoryPtr factory = new MyValueFactory; communicator->getValueFactoryManager()->add(factory, "::Test::I"); communicator->getValueFactoryManager()->add(factory, "::Test::J"); communicator->getValueFactoryManager()->add(factory, "::Test::H"); #endif communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0)); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); adapter->add(ICE_MAKE_SHARED(InitialI, adapter), communicator->stringToIdentity("initial")); adapter->add(ICE_MAKE_SHARED(TestIntfI), communicator->stringToIdentity("test")); adapter->add(ICE_MAKE_SHARED(UnexpectedObjectExceptionTestI), communicator->stringToIdentity("uoet")); adapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { Ice::PropertiesPtr properties = communicator->getProperties(); int num = argc == 2 ? atoi(argv[1]) : 0; { ostringstream os; os << "default -p " << (12010 + num); properties->setProperty("ControlAdapter.Endpoints", os.str()); } { ostringstream os; os << "control" << num; properties->setProperty("ControlAdapter.AdapterId", os.str()); } properties->setProperty("ControlAdapter.ThreadPool.Size", "1"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("ControlAdapter"); { ostringstream os; os << "controller" << num; adapter->add(ICE_MAKE_SHARED(ControllerI), communicator->stringToIdentity(os.str())); } adapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { Ice::ObjectFactoryPtr factory = new MyObjectFactory; communicator->addObjectFactory(factory, "::Test::B"); communicator->addObjectFactory(factory, "::Test::C"); communicator->addObjectFactory(factory, "::Test::D"); communicator->addObjectFactory(factory, "::Test::E"); communicator->addObjectFactory(factory, "::Test::F"); communicator->addObjectFactory(factory, "::Test::I"); communicator->addObjectFactory(factory, "::Test::J"); communicator->addObjectFactory(factory, "::Test::H"); communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); InitialPtr initial = new InitialI(adapter); adapter->add(initial, communicator->stringToIdentity("initial")); UnexpectedObjectExceptionTestIPtr uoet = new UnexpectedObjectExceptionTestI; adapter->add(uoet, communicator->stringToIdentity("uoet")); InitialPrx allTests(const Ice::CommunicatorPtr&); allTests(communicator); // We must call shutdown even in the collocated case for cyclic dependency cleanup initial->shutdown(Ice::Current()); return EXIT_SUCCESS; }
int run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { IceUtilInternal::Options opts; opts.addOpt("", "array"); opts.addOpt("", "async"); vector<string> args; try { args = opts.parse(argc, (const char**)argv); } catch(const IceUtilInternal::BadOptException& e) { cout << argv[0] << ": " << e.reason << endl; return false; } bool array = opts.isSet("array"); bool async = opts.isSet("async"); communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0)); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); adapter->addServantLocator(ICE_MAKE_SHARED(ServantLocatorI, array, async), ""); adapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
DetectorPrx initIceConnection(const std::string& detectorNameStr, Ice::Identity& det_cb, DetectorCallbackHandlerPtr cr) { initIce(detectorNameStr); Ice::PropertiesPtr props = iceComm->getProperties(); std::string proxStr = detectorNameStr + ".Proxy"; DetectorPrx detector = NULL; try { detector = DetectorPrx::checkedCast( iceComm->propertyToProxy(proxStr)->ice_twoway()); } catch (const IceUtil::NullHandleException& e) { localAndClientMsg( VLogger::ERROR, NULL, "Invalid proxy: '%s'. %s\n", detectorNameStr.c_str(), e.what()); return NULL; } Ice::ObjectAdapterPtr adapter = iceComm->createObjectAdapter(""); det_cb.name = IceUtil::generateUUID(); det_cb.category = ""; adapter->add(cr, det_cb); adapter->activate(); detector->ice_getConnection()->setAdapter(adapter); // note that we need an ObjectAdapter to permit bidirectional communication // if we want to get past firewalls without Glacier2 return detector; // Success }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("TestAdapter2"); Ice::ObjectAdapterPtr adapter3 = communicator->createObjectAdapter("TestAdapter3"); Ice::ObjectPtr object = new ThrowerI(); adapter->add(object, communicator->stringToIdentity("thrower")); adapter2->add(object, communicator->stringToIdentity("thrower")); adapter3->add(object, communicator->stringToIdentity("thrower")); adapter->activate(); adapter2->activate(); adapter3->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
void setupObjectAdapter(const Ice::CommunicatorPtr& communicator) { Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(""); Ice::ObjectPtr object = new RetryI; adapter->add(object, communicator->stringToIdentity("retry")); //adapter->activate(); // Don't activate OA to ensure collocation is used. }
void HelloServiceI::start(const string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& /*args*/) { _adapter = communicator->createObjectAdapter(name); Demo::HelloPtr hello = new HelloI; _adapter->add(hello, communicator->stringToIdentity("hello")); _adapter->activate(); }
int run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { Ice::PropertiesPtr properties = communicator->getProperties(); int num = argc == 2 ? atoi(argv[1]) : 0; ostringstream os; os << "tcp -p " << (12010 + num); properties->setProperty("ControlAdapter.Endpoints", os.str()); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("ControlAdapter"); adapter->add(new TestIntfI, communicator->stringToIdentity("control")); adapter->activate(); if(num == 0) { properties->setProperty("TestAdapter.Endpoints", "udp -p 12010"); Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("TestAdapter"); adapter2->add(new TestIntfI, communicator->stringToIdentity("test")); adapter2->activate(); } string endpoint; if(properties->getProperty("Ice.IPv6") == "1") { #if defined(__APPLE__) endpoint = "udp -h \"ff02::1:1\" -p 12020 --interface \"lo0\""; #else endpoint = "udp -h \"ff01::1:1\" -p 12020"; #endif } else { endpoint = "udp -h 239.255.1.1 -p 12020"; } properties->setProperty("McastTestAdapter.Endpoints", endpoint); Ice::ObjectAdapterPtr mcastAdapter = communicator->createObjectAdapter("McastTestAdapter"); mcastAdapter->add(new TestIntfI, communicator->stringToIdentity("test")); mcastAdapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); adapter->add(ICE_MAKE_SHARED(MetricsI), Ice::stringToIdentity("metrics")); adapter->activate(); communicator->getProperties()->setProperty("ControllerAdapter.Endpoints", "default -p 12011"); Ice::ObjectAdapterPtr controllerAdapter = communicator->createObjectAdapter("ControllerAdapter"); controllerAdapter->add(ICE_MAKE_SHARED(ControllerI, adapter), Ice::stringToIdentity("controller")); controllerAdapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPtr& observer) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0)); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); adapter->add(ICE_MAKE_SHARED(MetricsI), Ice::stringToIdentity("metrics")); //adapter->activate(); // Don't activate OA to ensure collocation is used. communicator->getProperties()->setProperty("ControllerAdapter.Endpoints", getTestEndpoint(communicator, 1)); Ice::ObjectAdapterPtr controllerAdapter = communicator->createObjectAdapter("ControllerAdapter"); controllerAdapter->add(ICE_MAKE_SHARED(ControllerI, adapter), Ice::stringToIdentity("controller")); //controllerAdapter->activate(); // Don't activate OA to ensure collocation is used. MetricsPrxPtr allTests(const Ice::CommunicatorPtr&, const CommunicatorObserverIPtr&); MetricsPrxPtr metrics = allTests(communicator, observer); metrics->shutdown(); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { Ice::PropertiesPtr properties = communicator->getProperties(); properties->setProperty("Ice.Warn.Dispatch", "0"); communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000:udp"); communicator->getProperties()->setProperty("TestAdapter.ThreadPool.Size", "1"); // // First try to use an invalid priority. // communicator->getProperties()->setProperty("TestAdapter.ThreadPool.ThreadPriority", "1024"); try { Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); test(false); } catch(const IceUtil::ThreadSyscallException&) { //expected } catch(...) { test(false); } // // Now set the priority correctly. // #ifdef _WIN32 communicator->getProperties()->setProperty("Ice.ThreadPool.Server.ThreadPriority", "-1"); communicator->getProperties()->setProperty("TestAdapter.ThreadPool.ThreadPriority", "1"); #else communicator->getProperties()->setProperty("Ice.ThreadPool.Server.ThreadPriority", "10"); communicator->getProperties()->setProperty("TestAdapter.ThreadPool.ThreadPriority", "50"); #endif Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::ObjectPtr object = new PriorityI(adapter); adapter->add(object, communicator->stringToIdentity("test")); adapter->activate(); communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0)); communicator->getProperties()->setProperty("ControllerAdapter.Endpoints", getTestEndpoint(communicator, 1)); communicator->getProperties()->setProperty("ControllerAdapter.ThreadPool.Size", "1"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); adapter->add(ICE_MAKE_SHARED(TimeoutI), Ice::stringToIdentity("timeout")); adapter->activate(); Ice::ObjectAdapterPtr controllerAdapter = communicator->createObjectAdapter("ControllerAdapter"); controllerAdapter->add(ICE_MAKE_SHARED(ControllerI, adapter), Ice::stringToIdentity("controller")); controllerAdapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0)); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); adapter->add(ICE_MAKE_SHARED(InitialI), Ice::stringToIdentity("initial")); adapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); adapter->add(new InitialI(), communicator->stringToIdentity("initial")); adapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); adapter->add(new MyDerivedClassI, communicator->stringToIdentity("test")); adapter->activate(); communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010"); communicator->getProperties()->setProperty("ControllerAdapter.Endpoints", "tcp -p 12011"); communicator->getProperties()->setProperty("ControllerAdapter.ThreadPool.Size", "1"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("ControllerAdapter"); TestIntfControllerIPtr testController = new TestIntfControllerI(adapter); adapter->add(new TestIntfI(), communicator->stringToIdentity("test")); adapter->activate(); adapter2->add(testController, communicator->stringToIdentity("testController")); adapter2->activate(); communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", "tcp -p 12010"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::Identity id = communicator->stringToIdentity("factory"); adapter->add(ICE_MAKE_SHARED(ServerFactoryI), id); adapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { string endpt = getTestEndpoint(communicator, 0); communicator->getProperties()->setProperty("TestAdapter.Endpoints", endpt + ":udp"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); adapter->add(ICE_MAKE_SHARED(MyDerivedClassI), communicator->stringToIdentity("test")); adapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
void HelloServiceI::start(const string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& /*args*/) { _adapter = communicator->createObjectAdapter("Hello-" + name); string helloIdentity = communicator->getProperties()->getProperty("Hello.Identity"); Demo::HelloPtr hello = new HelloI(name); _adapter->add(hello, communicator->stringToIdentity(helloIdentity)); _adapter->activate(); }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::Identity id = communicator->stringToIdentity("factory"); adapter->add(new RemoteCommunicatorFactoryI, id); adapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); ServantLocatorPtr locator = new ServantLocatorI; adapter->addServantLocator(locator, ""); adapter->activate(); TEST_READY adapter->waitForDeactivate(); return EXIT_SUCCESS; }
void IGFaceDetectorIceServiceI::start(const string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args) { _adapter = communicator->createObjectAdapter("IGFaceDetectorIce-" + name); string helloIdentity = communicator->getProperties()->getProperty("IGFaceDetectorIce.Identity"); IGFaceDetector::IGFaceDetectorIcePtr hello = new IGFaceDetectorIceI(name); _adapter->add(hello, communicator->stringToIdentity(helloIdentity)); _adapter->activate(); }
int main(int argc, char* argv[]){ Ice::CommunicatorPtr ic = EasyIce::initialize(argc, argv); Ice::PropertiesPtr prop = ic->getProperties(); prop->setProperty("Test.Adapter.Endpoints", "tcp -h localhost -p 65000"); Ice::ObjectPtr obj = new IceMX::Metrics(); Ice::ObjectAdapterPtr adapter = ic->createObjectAdapter("Test.Adapter"); adapter->add(obj, ic->stringToIdentity("metric")); std::cout<<"\n### EXAMPLE with easyiceconfig::proxies::createProxy() ###"<<std::endl; /// Exception due empty proxy try{ easyiceconfig::proxies::createProxy<IceMX::MetricsPrx>(ic, "Test.Proxy", false); } catch (Ice::ProxyParseException ex){ std::cout<<"Expected ProxyParseException\n"<<ex<<std::endl; } IceMX::MetricsPrx pxr; /// All ok (1) /// Proxy from string do not create entry at Properties pxr = easyiceconfig::proxies::createProxy<IceMX::MetricsPrx>(ic, "metric:tcp -h localhost -p 65000", true); easyiceconfig::debug::printProperties(prop); /// All ok (2) prop->setProperty("Test.Proxy", "metric:tcp -h localhost -p 65000"); pxr = easyiceconfig::proxies::createProxy<IceMX::MetricsPrx>(ic, "Test.Proxy", false); easyiceconfig::debug::printProperties(prop); // Using it std::cout << "Gathering some info" << std::endl; std::cout << pxr->ice_id() << std::endl; std::cout << pxr->ice_toString() << std::endl; std::cout<<"\n### EXAMPLE with EasyIce::EasyProxy ###"<<std::endl; EasyIce::EasyProxy<IceMX::MetricsPrx> proxy(ic, "bad endpoint definition", true); if (proxy){ //do stuff }else std::cout<<proxy.exception()<<std::endl; // copying EasyIce::EasyProxy<IceMX::MetricsPrx> p2; p2 = EasyIce::EasyProxy<IceMX::MetricsPrx>(ic, "bad endpoint definition", true); try{ p2 = EasyIce::createProxy<IceMX::MetricsPrx>(ic, "bad endpoint definition", true); }catch(Ice::Exception){} ic->shutdown(); }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010"); communicator->getProperties()->setProperty("ControllerAdapter.Endpoints", "tcp -p 12011"); communicator->getProperties()->setProperty("ControllerAdapter.ThreadPool.Size", "1"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("ControllerAdapter"); TestIntfControllerIPtr testController = new TestIntfControllerI(adapter); adapter->add(new TestIntfI(), communicator->stringToIdentity("test")); //adapter->activate(); // Don't activate OA to ensure collocation is used. adapter2->add(testController, communicator->stringToIdentity("testController")); //adapter2->activate(); // Don't activate OA to ensure collocation is used. void allTests(const Ice::CommunicatorPtr&); allTests(communicator); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { Ice::PropertiesPtr properties = communicator->getProperties(); properties->setProperty("Ice.Warn.Dispatch", "0"); communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0) + " -t 2000"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); adapter->add(ICE_MAKE_SHARED(TestI), Ice::stringToIdentity("Test")); adapter->activate(); TEST_READY communicator->waitForShutdown(); return EXIT_SUCCESS; }