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();
}
void
ServerAMD::run(int argc, char** argv)
{
    Ice::PropertiesPtr properties = createTestProperties(argc, argv);
    //
    // Its possible to have batch oneway requests dispatched after
    // the adapter is deactivated due to thread scheduling so we
    // supress this warning.
    //
    properties->setProperty("Ice.Warn.Dispatch", "0");

    Ice::CommunicatorHolder communicator = initialize(argc, argv, properties);
    communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint());
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
    adapter->add(ICE_MAKE_SHARED(MyDerivedClassI), Ice::stringToIdentity("test"));
    adapter->activate();
    serverReady();
    communicator->waitForShutdown();
}
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;
}
Beispiel #4
0
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;
}
Beispiel #5
0
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;
}
Beispiel #6
0
int
HelloServer::run(int argc, char*[])
{
    if(argc > 1)
    {
        cerr << appName() << ": too many arguments" << endl;
        return EXIT_FAILURE;
    }

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello");
    Demo::HelloPtr hello = new HelloI;
    adapter->add(hello, communicator()->stringToIdentity("hello"));
    adapter->activate();
    communicator()->waitForShutdown();
    return EXIT_SUCCESS;
}
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;
}
Beispiel #8
0
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;
}
Beispiel #9
0
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;
}
Beispiel #10
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;
}
Beispiel #11
0
    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;
    }
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;
}
Beispiel #13
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;
}
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;
}
Beispiel #15
0
    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;
    }
Beispiel #16
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;
}
Beispiel #17
0
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;
}
Beispiel #18
0
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;
}
Beispiel #19
0
void
ServiceI::start(const string& name,
                const CommunicatorPtr& communicator,
                const StringSeq& args)
{
    Ice::PropertiesPtr properties = communicator->getProperties();
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(name);
    if(properties->getPropertyAsInt(name + ".Freeze") > 0)
    {
        //
        // We do this to ensure the dbenv directory exists.
        //
        Freeze::createConnection(communicator, name);
    }
    Ice::ObjectPtr object = new TestI(adapter, properties);
    adapter->add(object, communicator->stringToIdentity(properties->getProperty(name + ".Identity")));
    adapter->activate();
}
Beispiel #20
0
int
Server::run(int argc, char* argv[])
{
    if(argc > 1)
    {
        cerr << appName() << ": too many arguments" << endl;
        return EXIT_FAILURE;
    }

    Ice::PropertiesPtr properties = communicator()->getProperties();
    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello");
    Ice::Identity id = communicator()->stringToIdentity(properties->getProperty("Identity"));
    Demo::HelloPtr hello = new HelloI(properties->getProperty("Ice.ProgramName"));
    adapter->add(hello, id);
    adapter->activate();
    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;
}
Beispiel #22
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;
}
Beispiel #23
0
int Server::run(int argc, char* argv[])
{
    int ret;
    if ((ret = SPI_init())) return ret;

    shutdownOnInterrupt();

    Ice::ObjectAdapterPtr adapter = communicator()->
        createObjectAdapterWithEndpoints("Guitar", "default -p 10000");

    guitarlib::ApplicationI *app = new guitarlib::ApplicationI(adapter);
    adapter->add(app, communicator()->stringToIdentity("Application"));
    adapter->activate();

    communicator()->waitForShutdown();

    ret = SPI_exit();
    return ret;
}
Beispiel #24
0
int
ValueServer::run(int argc, char*[])
{
    if(argc > 1)
    {
        cerr << appName() << ": too many arguments" << endl;
        return EXIT_FAILURE;
    }

    Ice::ValueFactoryPtr factory = new ValueFactory;
    communicator()->getValueFactoryManager()->add(factory, Demo::Printer::ice_staticId());

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Value");
    Demo::InitialPtr initial = new InitialI(adapter);
    adapter->add(initial, communicator()->stringToIdentity("initial"));
    adapter->activate();
    communicator()->waitForShutdown();
    return EXIT_SUCCESS;
}
Beispiel #25
0
int
Server::run(int argc, char* argv[])
{
    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("ReplicatedAdapter");
    Ice::ObjectPtr object = new TestI(communicator()->getProperties());
    adapter->add(object, communicator()->stringToIdentity(communicator()->getProperties()->getProperty("Identity")));
    shutdownOnInterrupt();
    try
    {
        adapter->activate();
        communicator()->getAdmin();
    }
    catch(const Ice::ObjectAdapterDeactivatedException&)
    {
    }
    communicator()->waitForShutdown();
    ignoreInterrupt();
    return EXIT_SUCCESS;
}
Beispiel #26
0
	virtual int run(int argc, char* argv[])
	{
		ClientOrServer::run(argc, argv);
		
		// Register a new object adapter
		Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("SonarEventListener.Subscriber");
		
		// Subscribe to the event
		IceStorm::QoS qos;
		Ice::ObjectPrx subscriber = adapter->addWithUUID(new SonarEventPrinter);
		sonarTopic->subscribe(qos, subscriber);
		
		// Start the adapter and keep going until the program is killed
		adapter->activate();
		shutdownOnInterrupt();
		communicator()->waitForShutdown();
		sonarTopic->unsubscribe(subscriber);
		return EXIT_SUCCESS;
	}
Beispiel #27
0
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;
}
Beispiel #28
0
int
Server::run(int argc, char* argv[])
{
    Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
    Ice::PropertiesPtr properties = communicator()->getProperties();
    args = properties->parseCommandLineOptions("", args);
    Ice::stringSeqToArgs(args, argc, argv);
    if(properties->getPropertyAsInt("FailOnStartup") > 0)
    {
        return EXIT_FAILURE;
    }

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("TestAdapter");
    TestI* test = new TestI();
    Ice::ObjectPtr obj = test;
    adapter->add(test, communicator()->stringToIdentity(properties->getProperty("Ice.Admin.ServerId")));

    int delay = properties->getPropertyAsInt("ActivationDelay");
    if(delay > 0)
    {
        IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay));
    }

    shutdownOnInterrupt();
    try
    {
        adapter->activate();
    }
    catch(const Ice::ObjectAdapterDeactivatedException&)
    {
    }
    communicator()->waitForShutdown();
    ignoreInterrupt();

    delay = properties->getPropertyAsInt("DeactivationDelay");
    if(delay > 0)
    {
        IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay));
    }

    return test->isFailed() ? EXIT_FAILURE : EXIT_SUCCESS;
}
Beispiel #29
0
int
main(int argc, char* argv[])
{
    try
    {
        Ice::CommunicatorHolder icHolder = Ice::initialize(argc, argv);
        Ice::ObjectAdapterPtr adapter =
            icHolder->createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -h localhost -p 10000");
        Ice::ObjectPtr object = new PrinterI;
        adapter->add(object, Ice::stringToIdentity("SimplePrinter"));
        adapter->activate();
        icHolder->waitForShutdown();
    }
    catch(const std::exception& e)
    {
        cerr << e.what() << endl;
        return 1;
    }
    return 0;
}
Beispiel #30
0
int
Server::run(int argc, char* argv[])
{
    Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
    args = communicator()->getProperties()->parseCommandLineOptions("TestAdapter", args);
    Ice::stringSeqToArgs(args, argc, argv);

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("TestAdapter");
    shutdownOnInterrupt();
    try
    {
        adapter->activate();
    }
    catch(const Ice::ObjectAdapterDeactivatedException&)
    {
    }
    communicator()->waitForShutdown();
    ignoreInterrupt();
    return EXIT_SUCCESS;
}