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="obtain an object reference to the EventChannel";
00087 CosEventChannelAdmin::EventChannel_var channelRef =channelSrv->_this();
00088
00089
00090
00091 action="stringify the EventChannel reference";
00092 CORBA::String_var sior =orb->object_to_string(channelRef.in());
00093 cout<<sior.in()<<endl;
00094
00095 action="set signal handlers";
00096 ::signal(SIGINT , ::myShutdown);
00097 ::signal(SIGTERM, ::myShutdown);
00098
00099 action="collect orphan requests";
00100
00101
00102
00103
00104
00105 OmniEvents::Orb::inst().run();
00106
00107
00108
00109
00110
00111
00112 action="destroy orb";
00113 orb->destroy();
00114
00115 }
00116 catch(CORBA::SystemException& ex) {
00117 cerr<<"Failed to "<<action<<".";
00118 #if defined(HAVE_OMNIORB4)
00119 cerr<<" "<<ex._name();
00120 if(ex.NP_minorString())
00121 cerr<<" ("<<ex.NP_minorString()<<")";
00122 #endif
00123 cerr<<endl;
00124 ::exit(1);
00125 }
00126 catch(CORBA::Exception& ex) {
00127 cerr<<"Failed to "<<action<<"."
00128 #if defined(HAVE_OMNIORB4)
00129 " "<<ex._name()
00130 #endif
00131 <<endl;
00132 ::exit(1);
00133 }
00134
00135 return 0;
00136 }