RemoteObjectAdapterPrx RemoteCommunicatorI::createObjectAdapter(const string& name, const string& endpts, const Current& current) #endif { Ice::CommunicatorPtr com = current.adapter->getCommunicator(); const string defaultProtocol = com->getProperties()->getProperty("Ice.Default.Protocol"); int retry = 5; while(true) { try { string endpoints = endpts; if(defaultProtocol != "bt") { if(endpoints.find("-p") == string::npos) { endpoints = getTestEndpoint(com, _nextPort++, endpoints); } } com->getProperties()->setProperty(name + ".ThreadPool.Size", "1"); ObjectAdapterPtr adapter = com->createObjectAdapterWithEndpoints(name, endpoints); return ICE_UNCHECKED_CAST(RemoteObjectAdapterPrx, current.adapter->addWithUUID(ICE_MAKE_SHARED(RemoteObjectAdapterI, adapter))); } catch(const Ice::SocketException&) { if(--retry == 0) { throw; } } } }
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; }
IceObjC::Instance::Instance(const Ice::CommunicatorPtr& com, Short type, const string& protocol, bool secure) : ProtocolInstance(com, type, protocol, secure), _voip(com->getProperties()->getPropertyAsIntWithDefault("Ice.Voip", 0) > 0), _communicator(com), _proxySettings(0) { const Ice::PropertiesPtr properties = com->getProperties(); // // Proxy settings // _proxyHost = properties->getProperty("Ice.SOCKSProxyHost"); if(!_proxyHost.empty()) { #if TARGET_IPHONE_SIMULATOR != 0 throw Ice::FeatureNotSupportedException(__FILE__, __LINE__, "SOCKS proxy not supported"); #endif _proxySettings.reset(CFDictionaryCreateMutable(0, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); _proxyPort = properties->getPropertyAsIntWithDefault("Ice.SOCKSProxyPort", 1080); UniqueRef<CFStringRef> host(toCFString(_proxyHost)); CFDictionarySetValue(_proxySettings.get(), kCFStreamPropertySOCKSProxyHost, host.get()); UniqueRef<CFNumberRef> port(CFNumberCreate(0, kCFNumberSInt32Type, &_proxyPort)); CFDictionarySetValue(_proxySettings.get(), kCFStreamPropertySOCKSProxyPort, port.get()); CFDictionarySetValue(_proxySettings.get(), kCFStreamPropertySOCKSVersion, kCFStreamSocketSOCKSVersion4); } }
PersistentInstance::PersistentInstance( const string& instanceName, const string& name, const Ice::CommunicatorPtr& communicator, const Ice::ObjectAdapterPtr& publishAdapter, const Ice::ObjectAdapterPtr& topicAdapter, const Ice::ObjectAdapterPtr& nodeAdapter, const NodePrx& nodeProxy) : Instance(instanceName, name, communicator, publishAdapter, topicAdapter, nodeAdapter, nodeProxy), _dbLock(communicator->getProperties()->getPropertyWithDefault(name + ".LMDB.Path", name) + "/icedb.lock"), _dbEnv(communicator->getProperties()->getPropertyWithDefault(name + ".LMDB.Path", name), 2, IceDB::getMapSize(communicator->getProperties()->getPropertyAsInt(name + ".LMDB.MapSize"))) { try { dbContext.communicator = communicator; dbContext.encoding.minor = 1; dbContext.encoding.major = 1; IceDB::ReadWriteTxn txn(_dbEnv); _lluMap = LLUMap(txn, "llu", dbContext, MDB_CREATE); _subscriberMap = SubscriberMap(txn, "subscribers", dbContext, MDB_CREATE, compareSubscriberRecordKey); txn.commit(); } catch(...) { shutdown(); destroy(); throw; } }
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; }
RemoteObjectAdapterPrx RemoteCommunicatorI::createObjectAdapter(const string& name, const string& endpts, const Current& current) #endif { Ice::CommunicatorPtr com = current.adapter->getCommunicator(); const string defaultProtocol = com->getProperties()->getProperty("Ice.Default.Protocol"); string endpoints = endpts; if(defaultProtocol != "bt") { if(endpoints.find("-p") == string::npos) { // Use a fixed port if none is specified (bug 2896) ostringstream os; os << endpoints << " -h \"" << (com->getProperties()->getPropertyWithDefault("Ice.Default.Host", "127.0.0.1")) << "\" -p " << _nextPort++; endpoints = os.str(); } } com->getProperties()->setProperty(name + ".ThreadPool.Size", "1"); ObjectAdapterPtr adapter = com->createObjectAdapterWithEndpoints(name, endpoints); return ICE_UNCHECKED_CAST(RemoteObjectAdapterPrx, current.adapter->addWithUUID(ICE_MAKE_SHARED(RemoteObjectAdapterI, adapter))); }
RemoteConfig::RemoteConfig(const std::string& name, int argc, char** argv, const Ice::CommunicatorPtr& communicator) : _status(1) { // // If ControllerHost is defined, we are using a server on a remote host. We expect a // test controller will already be active. We let exceptions propagate out to // the caller. // // Also look for a ConfigName property, which specifies the name of the configuration // we are currently testing. // std::string controllerHost; std::string configName; for(int i = 1; i < argc; ++i) { std::string opt = argv[i]; if(opt.find("--ControllerHost") == 0) { std::string::size_type pos = opt.find('='); if(pos != std::string::npos && opt.size() > pos + 1) { controllerHost = opt.substr(pos + 1); } } else if(opt.find("--ConfigName") == 0) { std::string::size_type pos = opt.find('='); if(pos != std::string::npos && opt.size() > pos + 1) { configName = opt.substr(pos + 1); } } } Test::Common::ServerPrxPtr server; if(!controllerHost.empty()) { std::string prot = communicator->getProperties()->getPropertyWithDefault("Ice.Default.Protocol", "tcp"); std::string host; if(prot != "bt") { host = communicator->getProperties()->getProperty("Ice.Default.Host"); } Test::Common::StringSeq options; Test::Common::ControllerPrxPtr controller = ICE_CHECKED_CAST(Test::Common::ControllerPrx, communicator->stringToProxy("controller:tcp -h " + controllerHost + " -p 15000")); server = controller->runServer("cpp", name, prot, host, false, configName, options); server->waitForServer(); } _server = server; }
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; }
int run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { Ice::PropertiesPtr properties = communicator->getProperties(); properties->setProperty("Ice.Warn.Dispatch", "0"); communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::ObjectPtr object = new ThrowerI(); adapter->add(object, communicator->stringToIdentity("thrower")); adapter->activate(); communicator->waitForShutdown(); 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(); }
void allTests(Test::TestHelper* helper) { Ice::CommunicatorPtr communicator = helper->communicator(); string sref = "test:" + helper->getTestEndpoint(); Ice::ObjectPrxPtr obj = communicator->stringToProxy(sref); test(obj); int proxyPort = communicator->getProperties()->getPropertyAsInt("Ice.HTTPProxyPort"); if(proxyPort == 0) { proxyPort = communicator->getProperties()->getPropertyAsInt("Ice.SOCKSProxyPort"); } TestIntfPrxPtr test = ICE_CHECKED_CAST(TestIntfPrx, obj); test(test); cout << "testing connection... " << flush; { test->ice_ping(); } cout << "ok" << endl; cout << "testing connection information... " << flush; { Ice::IPConnectionInfoPtr info = getIPConnectionInfo(test->ice_getConnection()->getInfo()); test(info->remotePort == proxyPort); // make sure we are connected to the proxy port. } cout << "ok" << endl; cout << "shutting down server... " << flush; { test->shutdown(); } cout << "ok" << endl; cout << "testing connection failure... " << flush; { try { test->ice_ping(); test(false); } catch(const Ice::LocalException&) { } } cout << "ok" << endl; }
void MyUtil::initialize() { ServiceI& service = ServiceI::instance(); service.getAdapter()->add(&FeedFocusInvertI::instance(), service.createIdentity( "M", "")); Ice::CommunicatorPtr communicator = service.getCommunicator(); int mod = communicator->getProperties()->getPropertyAsInt( "FeedFocusInvert.Mod"); int interval = communicator->getProperties()->getPropertyAsIntWithDefault( "FeedFocusInvert.Interval", 5); xce::serverstate::ServerStateSubscriber::instance().initialize( "ControllerFeedFocusInvertR", &FeedFocusInvertI::instance(), mod, interval, new XceFeedChannel()); MCE_INFO("MyUtil::initialize. mod:" << mod << " interval:" << interval); TaskManager::instance().scheduleRepeated(&FeedFocusInvertStatTimer::instance()); }
pointcloudClient::pointcloudClient(Ice::CommunicatorPtr ic, std::string prefix, std::string proxy) { this->newData=false; this->prefix=prefix; Ice::PropertiesPtr prop; prop = ic->getProperties(); this->refreshRate=0; int fps=prop->getPropertyAsIntWithDefault(prefix+"Fps",10); this->cycle=(float)(1/(float)fps)*1000000; try{ Ice::ObjectPrx basePointCloud = ic->stringToProxy(proxy); if (0==basePointCloud){ throw prefix + " Could not create proxy"; } else { this->prx = jderobot::pointCloudPrx::checkedCast(basePointCloud); if (0==this->prx) throw "Invalid proxy" + prefix; } }catch (const Ice::Exception& ex) { std::cerr << ex << std::endl; throw "Invalid proxy" + prefix; } catch (const char* msg) { std::cerr << msg << std::endl; jderobot::Logger::getInstance()->error(prefix + " Not camera provided"); throw "Invalid proxy" + prefix; } _done=false; this->pauseStatus=false; }
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; }
laserClient::laserClient(Ice::CommunicatorPtr ic, std::string prefix, bool debug) { // TODO Auto-generated constructor stub this->prefix=prefix; this->debug= debug; Ice::PropertiesPtr prop; prop = ic->getProperties(); int fps=prop->getPropertyAsIntWithDefault(prefix+"Fps",10); this->cycle=(float)(1/(float)fps)*1000000; try{ Ice::ObjectPrx basePointCloud = ic->propertyToProxy(prefix+"Proxy"); if (0==basePointCloud){ throw prefix + " Could not create proxy"; } else { this->prx = jderobot::LaserPrx::checkedCast(basePointCloud); if (0==this->prx) throw "Invalid proxy" + prefix; } }catch (const Ice::Exception& ex) { std::cerr << ex << std::endl; } catch (const char* msg) { std::cerr << msg << std::endl; std::cout << prefix + " Not laser provided" << std::endl; } _done=false; }
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; }
RemoteObjectAdapterPrx RemoteCommunicatorI::createObjectAdapter(int timeout, int close, int heartbeat, const Current& current) { Ice::CommunicatorPtr com = current.adapter->getCommunicator(); Ice::PropertiesPtr properties = com->getProperties(); string protocol = properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp"); string host = properties->getPropertyWithDefault("Ice.Default.Host", "127.0.0.1"); string name = IceUtil::generateUUID(); if(timeout >= 0) { properties->setProperty(name + ".ACM.Timeout", toString(timeout)); } if(close >= 0) { properties->setProperty(name + ".ACM.Close", toString(close)); } if(heartbeat >= 0) { properties->setProperty(name + ".ACM.Heartbeat", toString(heartbeat)); } properties->setProperty(name + ".ThreadPool.Size", "2"); ObjectAdapterPtr adapter = com->createObjectAdapterWithEndpoints(name, protocol + " -h \"" + host + "\""); return RemoteObjectAdapterPrx::uncheckedCast(current.adapter->addWithUUID(new RemoteObjectAdapterI(adapter))); }
string cvac::getCVACDataDir(const string &detectorNameStr) { initIce(detectorNameStr); Ice::PropertiesPtr props = iceComm->getProperties(); std::string dataDir = props->getProperty("CVAC.DataDir"); return dataDir; }
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; }
TrustManager::TrustManager(const Ice::CommunicatorPtr& communicator) : _communicator(communicator) { Ice::PropertiesPtr properties = communicator->getProperties(); _traceLevel = properties->getPropertyAsInt("IceSSL.Trace.Security"); string key; try { key = "IceSSL.TrustOnly"; _all = parse(properties->getProperty(key)); key = "IceSSL.TrustOnly.Client"; _client = parse(properties->getProperty(key)); key = "IceSSL.TrustOnly.Server"; _allServer = parse(properties->getProperty(key)); Ice::PropertyDict dict = properties->getPropertiesForPrefix("IceSSL.TrustOnly.Server."); for(Ice::PropertyDict::const_iterator p = dict.begin(); p != dict.end(); ++p) { string name = p->first.substr(string("IceSSL.TrustOnly.Server.").size()); key = p->first; _server[name] = parse(p->second); } } catch(const ParseException& e) { Ice::PluginInitializationException ex(__FILE__, __LINE__); ex.reason = "IceSSL: invalid property " + key + ":\n" + e.reason; throw ex; } }
void ConnectionPoolManager::initialize() { IceUtil::RWRecMutex::WLock lock(_mutex); if (_observer || _descriptor) { return; } Ice::CommunicatorPtr ic = xiaonei_grid(); ostringstream adapterEndpoints; adapterEndpoints << "tcp -h " << ::base::Network::local_ip(); _adapter = ic->createObjectAdapterWithEndpoints("DbCxxPool", adapterEndpoints.str()); _adapter->activate(); Ice::PropertiesPtr props = ic->getProperties(); string identity = props->getPropertyWithDefault( "Service.DbDescriptor.Identity", "DCS@DbDescriptor"); if (identity != "") { _descriptor = DbDescriptorPrx::uncheckedCast( ic->stringToProxy(identity)); LOG(INFO) << "ConnectionPoolManager::DbDescriptor.Proxy -> " << _descriptor; } _observer = DbObserverPrx::uncheckedCast(_adapter->addWithUUID(this)); LOG(INFO) << "ConnectionPoolManager::DbObserver.Proxy -> " << _observer; // MyUtil::TaskManager::instance().schedule(new VerifyTimerTask(10 * 60 )); ::base::Post(boost::bind(&ConnectionPoolManager::verify, this), 10 * 60 * 1000, 0); }
int main(int argc, char* argv[]) { int status; Ice::CommunicatorPtr communicator; try { Ice::InitializationData initData; initData.properties = Ice::createProperties(argc, argv); initData.properties->setProperty("Ice.Warn.Connections", "0"); communicator = Ice::initialize(argc, argv, initData); communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { cerr << ex << endl; status = EXIT_FAILURE; } if(communicator) { try { communicator->destroy(); } catch(const Ice::Exception& ex) { cerr << ex << endl; status = EXIT_FAILURE; } } return status; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0)); communicator->getProperties()->setProperty("TestAdapter.AdapterId", "test"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::ObjectPrxPtr prx = adapter->add(ICE_MAKE_SHARED(MyDerivedClassI), Ice::stringToIdentity("test")); //adapter->activate(); // Don't activate OA to ensure collocation is used. test(!prx->ice_getConnection()); Test::MyClassPrxPtr allTests(const Ice::CommunicatorPtr&); allTests(communicator); return EXIT_SUCCESS; }
ReplayerCamera::ReplayerCamera(std::string propertyPrefix, Ice::CommunicatorPtr ic, replayer::SyncControllerPtr syncController, long long int initStateIN) : jderobot::CameraHandler(propertyPrefix,ic), syncController(syncController) { imageDescription = (new jderobot::ImageDescription()); prop = ic->getProperties(); cameraDescription = (new jderobot::CameraDescription()); imageDescription->width=prop->getPropertyAsIntWithDefault(propertyPrefix + "ImageWidth",320); imageDescription->height=prop->getPropertyAsIntWithDefault(propertyPrefix + "ImageHeight",240); this->dataPath=prop->getProperty(propertyPrefix+"Dir"); this->fileFormat=prop->getProperty(propertyPrefix+"FileFormat"); imageDescription->format = prop->getProperty(propertyPrefix+"Format"); imageDescription->size = width*height*3; LOG(INFO)<< "PATH " + this->dataPath ; LOG(INFO)<< "FORMAT: " + this->fileFormat ; this->initState=initStateIN; //sync task syncTask = new CameraSyncTask(this,this->dataPath, this->fileFormat); syncTask->start(); //reply task replyTask = new ReplyTask(this,30); //30 fps ~ real time replyTask->start(); // my own thread }
int main(int argc, char* argv[]) { int status; Ice::CommunicatorPtr communicator; try { communicator = Ice::initialize(argc, argv); communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { cerr << ex << endl; status = EXIT_FAILURE; } if(communicator) { try { communicator->destroy(); } catch(const Ice::Exception& ex) { cerr << ex << endl; status = EXIT_FAILURE; } } return status; }
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 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; }
int run(int, char**, const Ice::CommunicatorPtr& communicator, const Ice::InitializationData&) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010"); communicator->getProperties()->setProperty("TestAdapter.AdapterId", "test"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::ObjectPrx prx = adapter->add(new MyDerivedClassI, communicator->stringToIdentity("test")); //adapter->activate(); // Don't activate OA to ensure collocation is used. test(!prx->ice_getConnection()); Test::MyClassPrx allTests(const Ice::CommunicatorPtr&); allTests(communicator); return EXIT_SUCCESS; }
int run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("Ice.Warn.Dispatch", "0"); communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0)); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); adapter->addServantLocator(ICE_MAKE_SHARED(ServantLocatorI, ""), ""); adapter->addServantLocator(ICE_MAKE_SHARED(ServantLocatorI, "category"), "category"); adapter->add(ICE_MAKE_SHARED(TestI), communicator->stringToIdentity("asm")); adapter->add(ICE_MAKE_SHARED(TestActivationI), communicator->stringToIdentity("test/activation")); Test::TestIntfPrxPtr allTests(const CommunicatorPtr&); allTests(communicator); return EXIT_SUCCESS; }
int main(int argc, char** argv){ int status; Ice::CommunicatorPtr ic; try{ ic = Ice::initialize(argc,argv); std::string topicName = ic->getProperties()->getProperty("Cameraview_icestorm.Camera.TopicName"); std::cout << "Trying to conect to: " << topicName << std::endl; Ice::ObjectPrx obj=ic->propertyToProxy("Cameraview_icestorm.Camera.TopicManager"); IceStorm::TopicManagerPrx topicManager=IceStorm::TopicManagerPrx::checkedCast(obj); std::string objAdapterEndpoint = ic->getProperties()->getProperty("Cameraview_icestorm.Camera.ObjectAdapter"); Ice::ObjectAdapterPtr adapter=ic->createObjectAdapterWithEndpoints("CameraAdapter",objAdapterEndpoint); ImageConsumerI* imageConsumer = new ImageConsumerI; Ice::ObjectPrx proxy = adapter->addWithUUID(imageConsumer)->ice_oneway(); IceStorm::TopicPrx topic; try { topic = topicManager->retrieve(topicName); IceStorm::QoS qos; topic->subscribeAndGetPublisher(qos, proxy); } catch (const IceStorm::NoSuchTopic& ex) { std::cerr << ex << std::endl; } adapter->activate(); ic->waitForShutdown(); topic->unsubscribe(proxy); if (ic) ic->destroy(); return status; }catch (const Ice::Exception& ex) { std::cerr << ex << std::endl; status = 1; } catch (const char* msg) { std::cerr << msg << std::endl; status = 1; } }