00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifdef HAVE_CONFIG_H
00030 # include "config.h"
00031 #endif
00032
00033 #include <stdlib.h>
00034 #include <signal.h>
00035
00036 #ifdef HAVE_IOSTREAM
00037 # include <iostream>
00038 #else
00039 # include <iostream.h>
00040 #endif
00041
00042 #ifdef HAVE_STD_IOSTREAM
00043 using namespace std;
00044 #endif
00045
00046 #include <omniEvents/EventChannel.h>
00047
00049 void myShutdown(int signum)
00050 {
00051 OmniEvents::Orb::inst().shutdown(signum);
00052 }
00053
00054 int main(int argc, char **argv)
00055 {
00056
00057
00058 CORBA::ORB_var orb = CORBA::ORB_init(argc,argv);
00059
00060 const char* action="";
00061 try {
00062
00063 action="initialise OmniEvents::Orb";
00064
00065 OmniEvents::Orb::inst()._orb=orb;
00066 OmniEvents::Orb::inst().resolveInitialReferences();
00067
00068 action="activate the RootPOA's POAManager";
00069
00070
00071
00072 PortableServer::POAManager_var pman;
00073 pman=OmniEvents::Orb::inst()._RootPOA->the_POAManager();
00074 pman->activate();
00075
00076 action="create EventChannel servant";
00077
00078 OmniEvents::EventChannel_i* channelSrv =new OmniEvents::EventChannel_i();
00079
00080 action="activate EventChannel servant";
00081
00082 channelSrv->activate("MyChannel");
00083
00084
00085
00086 action="start EventChannel's thread";
00087
00088
00089 channelSrv->start();
00090
00091 action="obtain an object reference to the EventChannel";
00092 CosEventChannelAdmin::EventChannel_var channelRef =channelSrv->_this();
00093
00094
00095
00096 action="stringify the EventChannel reference";
00097 CORBA::String_var sior =orb->object_to_string(channelRef.in());
00098 cout<<sior.in()<<endl;
00099
00100 action="set signal handlers";
00101 ::signal(SIGINT , ::myShutdown);
00102 ::signal(SIGTERM, ::myShutdown);
00103
00104 action="collect orphan requests";
00105
00106
00107
00108
00109
00110 OmniEvents::Orb::inst().run();
00111
00112
00113
00114
00115
00116
00117 action="destroy orb";
00118 orb->destroy();
00119
00120 }
00121 catch(CORBA::SystemException& ex) {
00122 cerr<<"Failed to "<<action<<".";
00123 #if defined(HAVE_OMNIORB4)
00124 cerr<<" "<<ex._name();
00125 if(ex.NP_minorString())
00126 cerr<<" ("<<ex.NP_minorString()<<")";
00127 #endif
00128 cerr<<endl;
00129 ::exit(1);
00130 }
00131 catch(CORBA::Exception& ex) {
00132 cerr<<"Failed to "<<action<<"."
00133 #if defined(HAVE_OMNIORB4)
00134 " "<<ex._name()
00135 #endif
00136 <<endl;
00137 ::exit(1);
00138 }
00139
00140 return 0;
00141 }