diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-09-22 06:59:51 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-09-22 06:59:51 +0000 |
commit | cbc07cd058e4466c1980d009bbb4d8abfcc7b1b3 (patch) | |
tree | 3ebe235239e02439a2831b80885dcd9e95d4e91f /TAO | |
parent | d9ad4a914a3b093a4173e5ad9af0b77f7fd72ad0 (diff) | |
download | ATCD-cbc07cd058e4466c1980d009bbb4d8abfcc7b1b3.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/examples/POA/On_Demand_Activation/README | 14 | ||||
-rwxr-xr-x | TAO/examples/POA/On_Demand_Activation/run_test.pl | 65 | ||||
-rw-r--r-- | TAO/examples/POA/On_Demand_Activation/server.cpp | 90 |
3 files changed, 163 insertions, 6 deletions
diff --git a/TAO/examples/POA/On_Demand_Activation/README b/TAO/examples/POA/On_Demand_Activation/README index 97e57170061..b23a801ef6f 100644 --- a/TAO/examples/POA/On_Demand_Activation/README +++ b/TAO/examples/POA/On_Demand_Activation/README @@ -40,7 +40,9 @@ runs the ORB. USAGE: ====== -%server [-ORBhost host ] [-ORBport port] [-ORBobjrefstyle URL ] +You can use the run_test.pl perl script or follow these directions: + +%server [-ORBport port] [-ORBobjrefstyle URL] [-f IOR file] client: ====== @@ -49,9 +51,9 @@ client: TAO/tests/POA/Generic_Servant/client i.e ../Generic_Servant/client -% client -k IOR +% client [-k IOR] [-f IOR file] -where IOR is got from the server output. +where IOR is got from the server output to the screen or to the IOR file. To Test: ======= @@ -80,14 +82,14 @@ Servant Locator: 4. The first time a client is run you should get an output - 2 + 2 (or 1) along with some diagnostic messages. 5. Subsequent runs of the client program results in the output - incremented by 2. + incremented by 2 (or 1). -6. Thus, the second run of client should give you an output 4. +6. Thus, the second run of client should give you an output 4 (or 2). diff --git a/TAO/examples/POA/On_Demand_Activation/run_test.pl b/TAO/examples/POA/On_Demand_Activation/run_test.pl new file mode 100755 index 00000000000..f8b431cb97a --- /dev/null +++ b/TAO/examples/POA/On_Demand_Activation/run_test.pl @@ -0,0 +1,65 @@ +#$Id$ +# -*- perl -*- +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +unshift @INC, '../../../../bin'; +require ACEutils; + +$iorfile = "ior"; + +$oneway = ""; +$iterations = 100; + +# Parse the arguments +for ($i = 0; $i <= $#ARGV; $i++) +{ + SWITCH: + { + if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?") + { + print "run_test [-h] [-i iterations] [-o] [-f ior file]\n"; + print "\n"; + print "-h -- prints this information\n"; + print "-f -- ior file\n"; + print "-i iterations -- specifies iterations\n"; + print "-o -- call issued are oneways\n"; + exit; + } + if ($ARGV[$i] eq "-o") + { + $oneway = "-o"; + last SWITCH; + } + if ($ARGV[$i] eq "-i") + { + $iterations = $ARGV[$i + 1]; + $i++; + last SWITCH; + } + if ($ARGV[$i] eq "-f") + { + $iorfile = $ARGV[$i + 1]; + $i++; + last SWITCH; + } + print "run_test: Unknown Option: ".$ARGV[$i]."\n"; + } +} + +$iorfile_1 = $iorfile."_1"; +$iorfile_2 = $iorfile."_2"; + +$SV = Process::Create ("server$Process::EXE_EXT", "-f $iorfile"); + +ACE::waitforfile ($iorfile_1); +ACE::waitforfile ($iorfile_2); + +$status = system ("../Generic_Servant/client$Process::EXE_EXT $oneway -i $iterations -f $iorfile_1"); +$status = system ("../Generic_Servant/client$Process::EXE_EXT $oneway -i $iterations -f $iorfile_2 -x"); + +unlink $iorfile_1; +unlink $iorfile_2; + +exit $status; diff --git a/TAO/examples/POA/On_Demand_Activation/server.cpp b/TAO/examples/POA/On_Demand_Activation/server.cpp index baa66edefe5..51c71fc9ec4 100644 --- a/TAO/examples/POA/On_Demand_Activation/server.cpp +++ b/TAO/examples/POA/On_Demand_Activation/server.cpp @@ -19,6 +19,87 @@ ACE_RCSID(On_Demand_Activation, server, "$Id$") +static char *ior_output_file = 0; + +static int +parse_args (int argc, char **argv) +{ + ACE_Get_Opt get_opts (argc, argv, "f:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'f': + ior_output_file = get_opts.optarg; + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "[-f ior_output_file]" + "\n", + argv [0]), + -1); + } + + // Indicates successful parsing of command line. + return 0; +} + +static int +write_iors_to_file (const char *first_ior, + const char *second_ior) +{ + if (ior_output_file == 0) + // No filename was specified; simply return + return 0; + + char ior_output_file_1[BUFSIZ]; + char ior_output_file_2[BUFSIZ]; + + ACE_OS::sprintf (ior_output_file_1, "%s_1", ior_output_file); + ACE_OS::sprintf (ior_output_file_2, "%s_2", ior_output_file); + + FILE *output_file_1 = ACE_OS::fopen (ior_output_file_1, "w"); + FILE *output_file_2 = ACE_OS::fopen (ior_output_file_2, "w"); + + if (output_file_1 == 0 || + output_file_2 == 0) + ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output files for writing IORs: %s, %s\n", + ior_output_file_1, + ior_output_file_2), + -1); + + int result = 0; + + result = ACE_OS::fprintf (output_file_1, + "%s", + first_ior); + if (result != ACE_OS::strlen (first_ior)) + ACE_ERROR_RETURN ((LM_ERROR, + "ACE_OS::fprintf failed while writing %s to %s\n", + first_ior, + ior_output_file_1), + -1); + + result = ACE_OS::fprintf (output_file_2, + "%s", + second_ior); + if (result != ACE_OS::strlen (second_ior)) + ACE_ERROR_RETURN ((LM_ERROR, + "ACE_OS::fprintf failed while writing %s to %s\n", + second_ior, + ior_output_file_2), + -1); + + ACE_OS::fclose (output_file_1); + ACE_OS::fclose (output_file_2); + + return 0; +} + int main (int argc, char **argv) { @@ -33,6 +114,10 @@ main (int argc, char **argv) return -1; } + int result = parse_args (argc, argv); + if (result != 0) + return result; + // Get an Object reference to RootPOA. CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); @@ -255,6 +340,11 @@ main (int argc, char **argv) first_foo_ior.in (), second_foo_ior.in ())); + int write_result = write_iors_to_file (first_foo_ior.in (), + second_foo_ior.in ()); + if (write_result != 0) + return write_result; + // Set the poa_manager state to active, ready to process requests. poa_manager->activate (env); |