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
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 #ifdef HAVE_CONFIG_H
00126 # include "config.h"
00127 #endif
00128
00129 #ifdef HAVE_GETOPT
00130 # include <unistd.h>
00131 extern char* optarg;
00132 extern int optind;
00133 #else
00134 # include "getopt.h"
00135 #endif
00136
00137 #ifdef HAVE_IOSTREAM
00138 # include <iostream>
00139 #else
00140 # include <iostream.h>
00141 #endif
00142
00143 #ifdef HAVE_STD_IOSTREAM
00144 using namespace std;
00145 #endif
00146
00147 #ifdef HAVE_STDLIB_H
00148 # include <stdlib.h>
00149 #endif
00150
00151 #ifdef HAVE_SIGNAL_H
00152 # include <signal.h>
00153 #endif
00154
00155 #include "CosEventComm.hh"
00156 #include "CosEventChannelAdmin.hh"
00157 #include "naming.h"
00158
00159 static void usage(int argc, char **argv);
00160
00161 class Supplier_i : virtual public POA_CosEventComm::PushSupplier {
00162 public:
00163 Supplier_i () {};
00164 void disconnect_push_supplier ();
00165 };
00166
00167 void
00168 Supplier_i::disconnect_push_supplier () {
00169 cout << "Push Supplier: disconnected." << endl;
00170 }
00171
00172 int main (int argc, char** argv)
00173 {
00174 long l = 0;
00175 CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv);
00176
00177
00178 int discnum =0;
00179 bool refnil =false;
00180 int sleepInterval =0;
00181 const char* channelName ="EventChannel";
00182
00183 int c;
00184 while ((c = getopt(argc,argv,"d:rs:n:h")) != EOF)
00185 {
00186 switch (c)
00187 {
00188 case 'd': discnum = atoi(optarg);
00189 break;
00190
00191 case 'r': refnil = true;
00192 break;
00193
00194 case 's': sleepInterval = atoi(optarg);
00195 break;
00196
00197 case 'n': channelName = optarg;
00198 break;
00199
00200 case 'h':
00201 default : usage(argc,argv);
00202 exit(-1);
00203 break;
00204 }
00205 }
00206
00207 #if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
00208
00209 signal(SIGPIPE, SIG_IGN);
00210 #endif
00211
00212 Supplier_i* supplier = NULL;
00213 CosEventChannelAdmin::EventChannel_var channel;
00214
00215 const char* action="";
00216 try {
00217 CORBA::Object_var obj;
00218
00219
00220
00221
00222
00223 if(!refnil)
00224 {
00225 supplier=new Supplier_i();
00226
00227 action="resolve initial reference 'RootPOA'";
00228 obj=orb->resolve_initial_references("RootPOA");
00229 PortableServer::POA_var rootPoa =PortableServer::POA::_narrow(obj);
00230 if(CORBA::is_nil(rootPoa))
00231 throw CORBA::OBJECT_NOT_EXIST();
00232
00233 action="activate the RootPOA's POAManager";
00234 PortableServer::POAManager_var pman =rootPoa->the_POAManager();
00235 pman->activate();
00236 }
00237
00238
00239
00240
00241 if(optind<argc)
00242 {
00243 action="convert URI from command line into object reference";
00244 obj=orb->string_to_object(argv[optind]);
00245 }
00246 else
00247 {
00248 action="resolve initial reference 'NameService'";
00249 obj=orb->resolve_initial_references("NameService");
00250 CosNaming::NamingContext_var rootContext=
00251 CosNaming::NamingContext::_narrow(obj);
00252 if(CORBA::is_nil(rootContext))
00253 throw CORBA::OBJECT_NOT_EXIST();
00254
00255 action="find EventChannel in NameService";
00256 cout << action << endl;
00257 obj=rootContext->resolve(str2name(channelName));
00258 }
00259
00260 action="narrow object reference to event channel";
00261 channel=CosEventChannelAdmin::EventChannel::_narrow(obj);
00262 if(CORBA::is_nil(channel))
00263 {
00264 cerr << "Failed to narrow Event Channel reference." << endl;
00265 exit(1);
00266 }
00267
00268 }
00269 catch(CORBA::ORB::InvalidName& ex) {
00270 cerr<<"Failed to "<<action<<". ORB::InvalidName"<<endl;
00178 int discnum =0;
00179 bool refnil =false;
00180 int sleepInterval =0;
00181 const char* channelName ="EventChannel";
00182
00183 int c;
00184 while ((c = getopt(argc,argv,"d:rs:n:h")) != EOF)
00185 {
00186 switch (c)
00187 {
00188 case 'd': discnum = atoi(optarg);
00189 break;
00190
00191 case 'r': refnil = true;
00192 break;
00193
00194 case 's': sleepInterval = atoi(optarg);
00195 break;
00196
00197 case 'n': channelName = optarg;
00198 break;
00199
00200 case 'h':
00201 default : usage(argc,argv);
00202 exit(-1);
00203 break;
00204 }
00205 }
00206
00207 #if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
00208
00209 signal(SIGPIPE, SIG_IGN);
00210 #endif
00211
00212 Supplier_i* supplier = NULL;
00213 CosEventChannelAdmin::EventChannel_var channel;
00214
00215 const char* action="";
00216 try {
00217 CORBA::Object_var obj;
00218
00219
00220
00221
00222
00223 if(!refnil)
00224 {
00225 supplier=new Supplier_i();
00226
00227 action="resolve initial reference 'RootPOA'";
00228 obj=orb->resolve_initial_references("RootPOA");
00229 PortableServer::POA_var rootPoa =PortableServer::POA::_narrow(obj);
00230 if(CORBA::is_nil(rootPoa))
00231 throw CORBA::OBJECT_NOT_EXIST();
00232
00233 action="activate the RootPOA's POAManager";
00234 PortableServer::POAManager_var pman =rootPoa->the_POAManager();
00235 pman->activate();
00236 }
00237
00238
00239
00240
00241 if(optind<argc)
00242 {
00243 action="convert URI from command line into object reference";
00244 obj=orb->string_to_object(argv[optind]);
00245 }
00246 else
00247 {
00248 action="resolve initial reference 'NameService'";
00249 obj=orb->resolve_initial_references("NameService");
00250 CosNaming::NamingContext_var rootContext=
00251 CosNaming::NamingContext::_narrow(obj);
00252 if(CORBA::is_nil(rootContext))
00253 throw CORBA::OBJECT_NOT_EXIST();
00254
00255 action="find EventChannel in NameService";
00256 cout << action << endl;
00257 obj=rootContext->resolve(str2name(channelName));
00258 }
00259
00260 action="narrow object reference to event channel";
00261 channel=CosEventChannelAdmin::EventChannel::_narrow(obj);
00262 if(CORBA::is_nil(channel))
00263 {
00264 cerr << "Failed to narrow Event Channel reference." << endl;
00265 exit(1);
00266 }
00267
00268 }
00269 catch(CORBA::ORB::InvalidName& ex) {
00270 cerr<<"Failed to "<<action<<". ORB::InvalidName"<<endl;
00178 int discnum =0;
00179 bool refnil =false;
00180 int sleepInterval =0;
00181 const char* channelName ="EventChannel";
00182
00183 int c;
00184 while ((c = getopt(argc,argv,"d:rs:n:h")) != EOF)
00185 {
00186 switch (c)
00187 {
00188 case 'd': discnum = atoi(optarg);
00189 break;
00190
00191 case 'r': refnil = true;
00192 break;
00193
00194 case 's': sleepInterval = atoi(optarg);
00195 break;
00196
00197 case 'n': channelName = optarg;
00198 break;
00199
00200 case 'h':
00201 default : usage(argc,argv);
00202 exit(-1);
00203 break;
00204 }
00205 }
00206
00207 #if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
00208
00209 signal(SIGPIPE, SIG_IGN);
00210 #endif
00211
00212 Supplier_i* supplier = NULL;
00213 CosEventChannelAdmin::EventChannel_var channel;
00214
00215 const char* action="";
00216 try {
00217 CORBA::Object_var obj;
00218
00219
00220
00221
00222
00223 if(!refnil)
00224 {
00225 supplier=new Supplier_i();
00226
00227 action="resolve initial reference 'RootPOA'";
00228 obj=orb->resolve_initial_references("RootPOA");
00229 PortableServer::POA_var rootPoa =PortableServer::POA::_narrow(obj);
00230 if(CORBA::is_nil(rootPoa))
00231 throw CORBA::OBJECT_NOT_EXIST();
00232
00233 action="activate the RootPOA's POAManager";
00234 PortableServer::POAManager_var pman =rootPoa->the_POAManager();
00235 pman->activate();
00236 }
00237
00238
00239
00240
00241 if(optind<argc)
00242 {
00243 action="convert URI from command line into object reference";
00244 obj=orb->string_to_object(argv[optind]);
00245 }
00246 else
00247 {
00248 action="resolve initial reference 'NameService'";
00249 obj=orb->resolve_initial_references("NameService");
00250 CosNaming::NamingContext_var rootContext=
00251 CosNaming::NamingContext::_narrow(obj);
00252 if(CORBA::is_nil(rootContext))
00253 throw CORBA::OBJECT_NOT_EXIST();
00254
00255 action="find EventChannel in NameService";
00256 cout << action << endl;
00257 obj=