示例#1
0
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;
}
示例#2
0
文件: server.cpp 项目: dbondin/progs
int
main(int argc, char* argv[])
{
    int status = 0;
    Ice::CommunicatorPtr ic;
    try {
        ic = Ice::initialize(argc, argv);
        Ice::ObjectAdapterPtr adapter =
            ic->createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
        Ice::ObjectPtr object = new PrinterI;
        adapter->add(object, ic->stringToIdentity("SimplePrinter"));
        adapter->activate();
        ic->waitForShutdown();
    } catch (const Ice::Exception& e) {
        cerr << e << endl;
        status = 1;
    } catch (const char* msg) {
        cerr << msg << endl;
        status = 1;
    }
    if (ic) {
        try {
            ic->destroy();
        } catch (const Ice::Exception& e) {
            cerr << e << endl;
            status = 1;
        }
    }
    return status;
}
示例#3
0
文件: Server.cpp 项目: herclogon/ice
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(new ControllerI, communicator->stringToIdentity(os.str()));
    }
    adapter->activate();

    TEST_READY

    communicator->waitForShutdown();
    return EXIT_SUCCESS;
}
示例#4
0
int main(int argc, char* argv[])
{
  int status = 0;
  Ice::CommunicatorPtr ic;
  try {
    ic = Ice::initialize(argc, argv);

    if (argc != 4) {
      cerr << "Usage: " << argv[0] << " servername NameService-host local-port\n";
      goto clean_up;
    }

    // Look up the name service.
    ostringstream ns_formatter;
    ns_formatter << "NameService:tcp -h " << argv[2] << " -p 9010";
    Ice::ObjectPrx base =
      ic->stringToProxy(ns_formatter.str().c_str());
    NameServicePrx ns = NameServicePrx::checkedCast(base);
    if (!ns)
      throw "Invalid NameService";

    // Create local chat display object and support infrastructure.
    ostringstream server_formatter;
    server_formatter << "tcp -p " << argv[3];
    Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(
      "ChatterAdapter", server_formatter.str().c_str());
    Ice::ObjectPtr object = new RoomManager_impl(adapter);
    Ice::ObjectPrx server =
      adapter->add(object, ic->stringToIdentity("RoomManager"));
    adapter->activate();

    // Register object.
    // ns->registerName(argv[1], server);

    ic->waitForShutdown();
  }
  catch (const Ice::Exception& e) {
    cerr << e << endl;
    status = 1;
  }
  catch (const char* msg) {
    cerr << msg << endl;
    status = 1;
  }

 clean_up:
  // We must call ic->destroy() even if an exception is throw above.
  if (ic) {
    try {
      ic->destroy();
    }
    catch (const Ice::Exception& e) {
      cerr << e << endl;
      status = 1;
    }
  }
  return status;
}
示例#5
0
文件: Server.cpp 项目: Jonavin/ice
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;
}
示例#6
0
文件: Server.cpp 项目: hadoop835/ice
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;
}
示例#7
0
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;
}
示例#8
0
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;
}
示例#9
0
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;
}
示例#10
0
文件: Server.cpp 项目: Venom4W/ice
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;
}
示例#11
0
int main(int argc, char **argv)
{
	Ice::CommunicatorPtr ic;
	int status = 0;
	std::string port("20000");

	if (argc > 1) {
		try {
			std::stoul(argv[1]);
		}
		catch (const std::exception& e) {
			std::cerr << "Invalid port number: " << argv[1] << '\n';
			return 1;
		}

		port = argv[1];
	}

	try {
		ic = Ice::initialize(argc, argv);
		Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("PocketSphinxServerAdapter", "default -p " + port);
		PocketSphinxServer* srv = new PocketSphinxServer;
		std::cout << "init done\n";
		Ice::ObjectPtr object = srv;
		adapter->add(object, ic->stringToIdentity("PocketSphinxServer"));
		adapter->activate();
		ic->waitForShutdown();
	}
	catch (const Ice::Exception& e) {
		std::cerr << e << std::endl;
		status = 1;
	}
	catch (const std::exception& e) {
		std::cerr << e.what() << std::endl;
		status = 1;
	}
	catch (...) {
		status = 1;
	}

	if (ic) {
		try {
			ic->destroy();
		}
		catch (const Ice::Exception& e) {
			std::cerr << e << std::endl;
			status = 1;
		}
	}

	return status;
}
示例#12
0
int main(int argc, char** argv){


	killed=false;
	struct sigaction sigIntHandler;

   sigIntHandler.sa_handler = exitApplication;
   sigemptyset(&sigIntHandler.sa_mask);
   sigIntHandler.sa_flags = 0;

   sigaction(SIGINT, &sigIntHandler, NULL);

	Ice::PropertiesPtr prop;
	std::string componentPrefix("myComponent");

	
	

	try{
			ic = Ice::initialize(argc,argv);
			prop = ic->getProperties();
	}
	catch (const Ice::Exception& ex) {
			std::cerr << ex << std::endl;
			return 1;
	}
	catch (const char* msg) {
			std::cerr <<"Error :" << msg << std::endl;
			return 1;
	}

	std::string Endpoints = prop->getProperty(componentPrefix + ".Endpoints");
	Ice::ObjectAdapterPtr adapter =ic->createObjectAdapterWithEndpoints(componentPrefix, Endpoints);

	// for each interface:

	std::string objPrefix="myInterface";
	std::string Name = "pointcloud1";
	std::cout << "Creating pointcloud1 " << Name << std::endl;
	interface1 = new myClassI();
	adapter->add(interface1, ic->stringToIdentity(Name));

	//starting the adapter
	adapter->activate();
	ic->waitForShutdown();

	if (!killed)
		exitApplication(1);
   
   return 0;

}
示例#13
0
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
    adapter->add(new TestIntfI(communicator), communicator->stringToIdentity("test"));
    adapter->add(new Test1::WstringClassI, communicator->stringToIdentity("wstring1"));
    adapter->add(new Test2::WstringClassI, communicator->stringToIdentity("wstring2"));

    adapter->activate();
    communicator->waitForShutdown();

    return EXIT_SUCCESS;
}
示例#14
0
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;
}
示例#15
0
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;
}
示例#16
0
文件: main.cpp 项目: varhub/JdeRobot
int main(int argc, char** argv)
{
    Ice::ObjectPtr viewerPtr;
    //signal(SIGINT,signalHandler);
    Ice::CommunicatorPtr ic;
    try{
        ic = EasyIce::initialize(argc, argv);

        Ice::PropertiesPtr prop = ic->getProperties();
        std::string Endpoints = prop->getProperty("Visualization.Endpoints");

        // Naming Service
        int nsActive = prop->getPropertyAsIntWithDefault("NamingService.Enabled", 0);

        if (nsActive)
        {
            std::string ns_proxy = prop->getProperty("NamingService.Proxy");
            try
            {
                namingService = new jderobot::ns(ic, ns_proxy);
            }
            catch (Ice::ConnectionRefusedException& ex)
            {
                jderobot::Logger::getInstance()->error("Impossible to connect with NameService!");
                exit(-1);
            }
        }

        Ice::ObjectAdapterPtr adapter =ic->createObjectAdapterWithEndpoints("Visualization", Endpoints);
        std::string objPrefix("Visualization.");
        std::string viewerName = prop->getProperty(objPrefix + "Name");
        Ice::ObjectPtr object = new visualization::VisualizationI(objPrefix, ic);

        adapter->add(object, ic->stringToIdentity(viewerName));

        if (namingService)
            namingService->bind(viewerName, Endpoints, object->ice_staticId());


        adapter->activate();
        ic->waitForShutdown();

    }catch (const Ice::Exception& ex) {
        std::cerr << ex<<" 1 " << std::endl;
        exit(-1);
    } catch (const char* msg) {
        std::cerr << msg<< " 2 " << std::endl;
        exit(-1);
    }

}
示例#17
0
int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
    communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0));
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
    adapter->add(new TestIntfI(communicator), communicator->stringToIdentity("test"));
    adapter->add(new Test1::WstringClassI, communicator->stringToIdentity("wstring1"));
    adapter->add(new Test2::WstringClassI, communicator->stringToIdentity("wstring2"));

    adapter->activate();
    TEST_READY
    communicator->waitForShutdown();

    return EXIT_SUCCESS;
}
示例#18
0
int main(int argc, char* argv[]) {
    int status = 0;
    Ice::CommunicatorPtr ic;
    try {
        ic = Ice::initialize(argc, argv);
        if (argc < 5 || 5 < argc)
            throw "Incorrect arguments\n"
            "Take a look at docs/html/index.html for more info.\n\n";
        int model = atoi(argv[1]);
        int server_id = atoi(argv[2]);
        int num_clients = atoi(argv[3]);
        string host_port(argv[4]);
        cerr << "Attaching DM_Server_Adapter to endpoint "
                << LDAUtil::DM_Server_Names::get_server_endpoint(host_port)
                << endl;
        Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(
                "DM_Server_Adapter",
                LDAUtil::DM_Server_Names::get_server_endpoint(host_port));

        Server_Helper* helper = NULL;
        if (model == Model::UNIGRAM)
            helper = new Unigram_Model_Server_Helper;
        Ice::ObjectPtr object = new DM_Server(num_clients, *helper);
        cerr << "Adding servant with name "
                << LDAUtil::DM_Server_Names::get_servant_name(server_id)
                << endl;
        adapter->add(object, ic->stringToIdentity(
                LDAUtil::DM_Server_Names::get_servant_name(server_id)));
        adapter->activate();
        ic->waitForShutdown();
        delete helper;
    } catch (const Ice::Exception& e) {
        cerr << e << endl;
        status = 1;
    } catch (const char* msg) {
        cerr << msg << endl;
        status = 1;
    }
    if (ic) {
        try {
            ic->destroy();
        } catch (const Ice::Exception& e) {
            cerr << e << endl;
            status = 1;
        }
    }
    return status;
}
示例#19
0
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;
}
示例#20
0
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;
  }
}
示例#21
0
int main(int argc, char* argv[])
{
	int status = 0;
	Ice::CommunicatorPtr ic;
	//status变量含有程序的退出状态,而类型为 Ice::Communicator 的 ic 变量含有 Ice run time 的主句柄.

	try {
		ic = Ice::initialize(argc, argv);
	//initialize 调用返回的是一个智能指针,指向一个 Ice::Communicator 对象,这个指针是 Ice run time 的主句柄

		Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
//创建对象适配器.传入参数"SimplePrinterAdapter"(适配器名字)和"default -p 10000",适配器用缺省协议(TCP/IP)在端口 10000 处侦听到来的请求

		Ice::ObjectPtr object = new PrinterI;
	//服务器端 run time 已经初始化,我们实例化一个 PrinterI 对象,为 Printer 接口创建一个 servant

		adapter->add(object,ic->stringToIdentity("SimplePrinter"));
//调用适配器的add,告诉它有了一个新的servant;传给 add 的参数是我们刚才实例化的 servant,再加上一个标识符.
//"SimplePrinter"串是servant的名字

		adapter->activate();
	//调用适配器的 activate 方法激活适配器.一旦适配器被激活,服务器就会开始处理来自客户的请求
/*
适配器开始是在扣留(holding)状态创建的;这种做法在下面这样的情况下很有用:我们有多个 servant,它们共享同一个适配器,
而在所有 servant实例化之前我们不想处理请求
*/
		ic->waitForShutdown();
// waitForShutdown方法挂起发出调用的线程,直到服务器实现终止为止:或者是通过发出一个调用关闭 run time,或者是对某个信号作出响应


	//第一个处理器捕捉 Ice run time 可能抛出的所有异常
	} catch (const Ice::Exception & e) {
		cerr << e << endl;
		status = 1;
	//第二个处理器捕捉串常量
	} catch (const char * msg) {
		cerr << msg << endl;
		status = 1;
	}

	if (ic)//清理代码调用通信器的 destroy 方法,(前提是通信器进行过初始化)
		ic->destroy();
	//清理调用之所以在 try 块的外部,原因是:不管代码是正常终止,还是由于异常而终止,我们都必须确保 Ice run time 得以执行结束工作 

	return status;
}
示例#22
0
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;
}
示例#23
0
文件: Server.cpp 项目: 465060874/ice
int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
    communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0));
    communicator->getProperties()->setProperty("TestAdapter.ACM.Timeout", "0");
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
    Ice::Identity id = communicator->stringToIdentity("communicator");
    adapter->add(ICE_MAKE_SHARED(RemoteCommunicatorI), id);
    adapter->activate();

    TEST_READY

    // Disable ready print for further adapters.
    communicator->getProperties()->setProperty("Ice.PrintAdapterReady", "0");

    communicator->waitForShutdown();
    return EXIT_SUCCESS;
}
示例#24
0
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
    communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000");
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
    Ice::ObjectPtr d = new DI;
    adapter->add(d, communicator->stringToIdentity("d"));
    adapter->addFacet(d, communicator->stringToIdentity("d"), "facetABCD");
    Ice::ObjectPtr f = new FI;
    adapter->addFacet(f, communicator->stringToIdentity("d"), "facetEF");
    Ice::ObjectPtr h = new HI(communicator);
    adapter->addFacet(h, communicator->stringToIdentity("d"), "facetGH");

    adapter->activate();
    communicator->waitForShutdown();

    return EXIT_SUCCESS;
}
示例#25
0
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)
{
    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;
}
示例#27
0
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, const string& envName)
{
    communicator->getProperties()->setProperty("Factory.Endpoints", "default -p 12010");
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Factory");

    communicator->addObjectFactory(new ServantFactory, "::Test::Servant");
    communicator->addObjectFactory(new FacetFactory, "::Test::Facet");
    communicator->addObjectFactory(new AccountFactory, "::Test::Account");

    Test::RemoteEvictorFactoryPtr factory = new Test::RemoteEvictorFactoryI(envName);
    adapter->add(factory, communicator->stringToIdentity("factory"));

    adapter->activate();

    communicator->waitForShutdown();

    return EXIT_SUCCESS;
}
示例#28
0
文件: Server.cpp 项目: Jonavin/ice
int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
    Ice::ObjectFactoryPtr factory = new MyObjectFactory;
    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"));
    adapter->activate();
    TEST_READY
    communicator->waitForShutdown();
    return EXIT_SUCCESS;
}
示例#29
0
文件: Server.cpp 项目: ming-hai/ice
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;
}
示例#30
0
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;
}