当前位置: 首页>>代码示例>>C++>>正文


C++ ObjectAdapterPtr::activate方法代码示例

本文整理汇总了C++中ice::ObjectAdapterPtr::activate方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectAdapterPtr::activate方法的具体用法?C++ ObjectAdapterPtr::activate怎么用?C++ ObjectAdapterPtr::activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ice::ObjectAdapterPtr的用法示例。


在下文中一共展示了ObjectAdapterPtr::activate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: appName

int
LatencyServer::run(int argc, char*[])
{
    if(argc > 1)
    {
        cerr << appName() << ": too many arguments" << endl;
        return EXIT_FAILURE;
    }

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Latency");
    Ice::ObjectPtr object = new Ping;
    adapter->add(object, Ice::stringToIdentity("ping"));
    adapter->activate();
    communicator()->waitForShutdown();
    return EXIT_SUCCESS;
}
开发者ID:zhangwei5095,项目名称:zeroc-ice-demos,代码行数:16,代码来源:Server.cpp

示例2: setProcessStringConverter

void
Server::run(int argc, char** argv)
{
    setProcessStringConverter(ICE_MAKE_SHARED(Test::StringConverterI));
    setProcessWstringConverter(ICE_MAKE_SHARED(Test::WstringConverterI));
    Ice::CommunicatorHolder communicator = initialize(argc, argv);
    communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint());
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
    adapter->add(ICE_MAKE_SHARED(TestIntfI), Ice::stringToIdentity("TEST"));
    adapter->add(ICE_MAKE_SHARED(Test1::WstringClassI), Ice::stringToIdentity("WSTRING1"));
    adapter->add(ICE_MAKE_SHARED(Test2::WstringClassI), Ice::stringToIdentity("WSTRING2"));

    adapter->activate();
    serverReady();
    communicator->waitForShutdown();
}
开发者ID:zeroc-ice,项目名称:ice-debian-packaging,代码行数:16,代码来源:Server.cpp

示例3: appName

int
ThroughputServer::run(int argc, char*[])
{
    if(argc > 1)
    {
        cerr << appName() << ": too many arguments" << endl;
        return EXIT_FAILURE;
    }

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Throughput");
    Demo::ThroughputPtr servant = new ThroughputI;
    adapter->add(servant, communicator()->stringToIdentity("throughput"));
    adapter->activate();
    communicator()->waitForShutdown();
    return EXIT_SUCCESS;
}
开发者ID:Ben1225513527,项目名称:ice-demos,代码行数:16,代码来源:Server.cpp

示例4: appName

int
CallbackServer::run(int argc, char*[])
{
    if(argc > 1)
    {
        cerr << appName() << ": too many arguments" << endl;
        return EXIT_FAILURE;
    }

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Server");
    CallbackSenderPtr cbs = new CallbackSenderI;
    adapter->add(cbs, communicator()->stringToIdentity("callbackSender"));
    adapter->activate();
    communicator()->waitForShutdown();
    return EXIT_SUCCESS;
}
开发者ID:2008hatake,项目名称:zeroc-ice,代码行数:16,代码来源:Server.cpp

示例5: start

bool RobotBrainServiceService::start(int argc, char* argv[])
{
  char adapterStr[255];

LINFO("Starting XBox Controller...");
  //Create the topics
 // SimEventsUtils::createTopic(communicator(), "XBox360RemoteControlMessageTopic");

  //Create the adapter
  int port = RobotBrainObjects::RobotBrainPort;
  bool connected = false;

  while(!connected)
    {
      try
        {
          LINFO("Trying Port:%d", port);
          sprintf(adapterStr, "default -p %i", port);
          itsAdapter = communicator()->createObjectAdapterWithEndpoints("XBox360RemoteControl",
                                                                        adapterStr);
          connected = true;
        }
      catch(Ice::SocketException)
        {
          port++;
        }
    }

  //Create the manager and its objects
  itsMgr = new ModelManager("XBox360RemoteControlService");

  LINFO("Starting XBox360RemoteControl");
  nub::ref<XBox360RemoteControlI> ret(new XBox360RemoteControlI(0, *itsMgr, "XBox360RemoteControl1", "XBox360RemoteControl2"));
  LINFO("XBox360RemoteControl Created");
  itsMgr->addSubComponent(ret);
  LINFO("XBox360RemoteControl Added As Sub Component");
  ret->init(communicator(), itsAdapter);
  LINFO("XBox360RemoteControl Inited");

  itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0);

  itsAdapter->activate();

  itsMgr->start();

  return true;
}
开发者ID:ulyssesrr,项目名称:carmen_lcad,代码行数:47,代码来源:test-XBox360RemoteControl.C

示例6: appName

int
NestedServer::run(int argc, char*[])
{
    if(argc > 1)
    {
        cerr << appName() << ": too many arguments" << endl;
        return EXIT_FAILURE;
    }

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Nested.Server");
    NestedPrx self = NestedPrx::uncheckedCast(adapter->createProxy(communicator()->stringToIdentity("nestedServer")));
    NestedPtr servant = new NestedI(self);
    adapter->add(servant, communicator()->stringToIdentity("nestedServer"));
    adapter->activate();
    communicator()->waitForShutdown();
    return EXIT_SUCCESS;
}
开发者ID:pedia,项目名称:zeroc-ice,代码行数:17,代码来源:Server.cpp

示例7: main

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;
}
开发者ID:IntNull93,项目名称:51_55,代码行数:46,代码来源:Server.cpp

示例8: run

    virtual int run(int, char*[])
    {
        //
        // Terminate cleanly on receipt of a signal
        //
        shutdownOnInterrupt();

        //
        // Create an object adapter
        //
        Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("MapFilesystem");

        //
        // Open a connection to the files and directories database. This should remain open
        // for the duration of the application for performance reasons.
        //
        const Freeze::ConnectionPtr connection(Freeze::createConnection(communicator(), _envName));
        const IdentityFileEntryMap fileDB(connection, FileI::filesDB());
        const IdentityDirectoryEntryMap dirDB(connection, DirectoryI::directoriesDB());

        //
        // Add default servants for the file and directory.
        //
        adapter->addDefaultServant(new FileI(communicator(), _envName), "file");
        adapter->addDefaultServant(new DirectoryI(communicator(), _envName), "");

        //
        // Ready to accept requests now
        //
        adapter->activate();

        //
        // Wait until we are done
        //
        communicator()->waitForShutdown();

        //
        // Clean up
        //
        if(interrupted())
        {
            cerr << appName() << ": received signal, shutting down" << endl;
        }

        return 0;
    }
开发者ID:bholl,项目名称:zeroc-ice,代码行数:46,代码来源:Server.cpp

示例9: ServantLocatorAMDI

int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
    communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010:udp");
    communicator->getProperties()->setProperty("Ice.Warn.Dispatch", "0");

    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
    
    adapter->addServantLocator(new ServantLocatorAMDI(""), "");
    adapter->addServantLocator(new ServantLocatorAMDI("category"), "category");
    adapter->add(new TestAMDI, communicator->stringToIdentity("asm"));
    adapter->add(new TestActivationI, communicator->stringToIdentity("test/activation"));
    adapter->activate();
    TEST_READY
    adapter->waitForDeactivate();
    return EXIT_SUCCESS;
}
开发者ID:dayongxie,项目名称:zeroc-ice-androidndk,代码行数:17,代码来源:ServerAMD.cpp

示例10: getTestEndpoint

int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
    communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0) + ":udp");
    communicator->getProperties()->setProperty("Ice.Warn.Dispatch", "0");

    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");

    adapter->addServantLocator(ICE_MAKE_SHARED(ServantLocatorAMDI, ""), "");
    adapter->addServantLocator(ICE_MAKE_SHARED(ServantLocatorAMDI, "category"), "category");
    adapter->add(ICE_MAKE_SHARED(TestAMDI), communicator->stringToIdentity("asm"));
    adapter->add(ICE_MAKE_SHARED(TestActivationI), communicator->stringToIdentity("test/activation"));
    adapter->activate();
    TEST_READY
    adapter->waitForDeactivate();
    return EXIT_SUCCESS;
}
开发者ID:chenbk85,项目名称:ice,代码行数:17,代码来源:ServerAMD.cpp

示例11: 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;
}
开发者ID:dayongxie,项目名称:zeroc-ice-androidndk,代码行数:46,代码来源:Client.cpp

示例12: ThrowerI

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;
}
开发者ID:RichardChengshaojin,项目名称:ice,代码行数:17,代码来源:ServerAMD.cpp

示例13: run

    virtual int
    run(int argc, char* argv[])
    {
        Ice::InitializationData initData;
        initData.properties = Ice::createProperties();
        loadConfig(initData.properties);
        initData.logger = getLogger();
        setCommunicator(Ice::initialize(argc, argv, initData));

        int port = 0;
        for(int i = 1; i < argc; ++i)
        {
            if(argv[i][0] == '-')
            {
                tprintf("%s: unknown option `%s'\n", argv[0], argv[i]);
                usage(argv[0]);
                return EXIT_FAILURE;
            }

            if(port > 0)
            {
                tprintf("%s: only one port can be specified\n", argv[0]);
                usage(argv[0]);
                return EXIT_FAILURE;
            }

            port = atoi(argv[i]);
        }

        if(port <= 0)
        {
            tprintf("%s: no port specified\n", argv[0]);
            usage(argv[0]);
            return EXIT_FAILURE;
        }

        char buf[32];
        sprintf(buf, "default -p %d", port);
        communicator()->getProperties()->setProperty("TestAdapter.Endpoints", buf);
        Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("TestAdapter");
        Ice::ObjectPtr object = new TestI(adapter);
        adapter->add(object, communicator()->stringToIdentity("test"));
        adapter->activate();
        communicator()->waitForShutdown();
        return EXIT_SUCCESS;
    }
开发者ID:glockwork,项目名称:dfu,代码行数:46,代码来源:Server.cpp

示例14: appName

int
Server::run(int argc, char*[])
{
    if(argc > 1)
    {
        cerr << appName() << ": too many arguments" << endl;
        return EXIT_FAILURE;
    }

    Ice::PropertiesPtr properties = communicator()->getProperties();
    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Pricing");
    Ice::Identity id = communicator()->stringToIdentity(properties->getProperty("Identity"));
    Demo::PricingEnginePtr pricing = new PricingI(properties->getPropertyAsList("Currencies"));
    adapter->add(pricing, id);
    adapter->activate();
    communicator()->waitForShutdown();
    return EXIT_SUCCESS;
}
开发者ID:MemoRyAxis,项目名称:ice-demos,代码行数:18,代码来源:Server.cpp

示例15: getTestEndpoint

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;
}
开发者ID:465060874,项目名称:ice,代码行数:18,代码来源:Server.cpp


注:本文中的ice::ObjectAdapterPtr::activate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。