00001 #include <Ice/Ice.h> 00002 #include "HelloWorld.ice.H" 00003 00004 using namespace std; 00005 using namespace Demo; 00006 00007 class HelloWorldI: public HelloWorld{ 00008 public: 00009 virtual void printString(const string& s, 00010 const Ice::Current&); 00011 }; 00012 00013 void 00014 HelloWorldI:: 00015 printString(const string& s, const Ice::Current&) 00016 { 00017 cout << s << endl; 00018 } 00019 00020 int 00021 main(int argc, char* argv[]) 00022 { 00023 int status = 0; 00024 Ice::CommunicatorPtr ic; 00025 try { 00026 ic = Ice::initialize(argc, argv); 00027 Ice::ObjectAdapterPtr adapter = 00028 ic->createObjectAdapterWithEndpoints( 00029 "SimpleHelloWorldAdapter", "default -p 10000"); 00030 Ice::ObjectPtr object = new HelloWorldI; 00031 adapter->add(object, ic->stringToIdentity("SimpleHelloWorld")); 00032 adapter->activate(); 00033 ic->waitForShutdown(); 00034 } catch (const Ice::Exception& e) { 00035 cerr << e << endl; 00036 status = 1; 00037 } catch (const char* msg) { 00038 cerr << msg << endl; 00039 status = 1; 00040 } 00041 if (ic) { 00042 try { 00043 ic->destroy(); 00044 } catch (const Ice::Exception& e) { 00045 cerr << e << endl; 00046 status = 1; 00047 } 00048 } 00049 return status; 00050 } 00051 00052