diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-05-12 19:50:39 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-05-12 19:50:39 +0000 |
commit | f5a2a89f78d44bb9e872fc6109b2e4b77f763da2 (patch) | |
tree | 4c4f61a884ddb626cfffc49c5190d924a0ec0ebb | |
parent | af9afca8eca07f18664267658b8155538ed9e0e8 (diff) | |
download | ATCD-f5a2a89f78d44bb9e872fc6109b2e4b77f763da2.tar.gz |
ChangeLogTag:Mon May 12 14:48:12 2003 Nanbor Wang <nanbor@cs.wustl.edu>
-rw-r--r-- | TAO/CIAO/examples/handcrafted/Hello/hello.mpc | 18 | ||||
-rwxr-xr-x | TAO/CIAO/examples/handcrafted/Hello/run_simple_test.pl | 47 | ||||
-rw-r--r-- | TAO/CIAO/examples/handcrafted/Hello/simple_client.cpp | 102 |
3 files changed, 166 insertions, 1 deletions
diff --git a/TAO/CIAO/examples/handcrafted/Hello/hello.mpc b/TAO/CIAO/examples/handcrafted/Hello/hello.mpc index 902742796d0..c3f6b9537ce 100644 --- a/TAO/CIAO/examples/handcrafted/Hello/hello.mpc +++ b/TAO/CIAO/examples/handcrafted/Hello/hello.mpc @@ -57,4 +57,20 @@ project (client) : ciao_client { Source_Files { client.cpp } -}
\ No newline at end of file +} + +// Client for interacting with the Simple_Component_Server +project (simple_client) : ciao_client { + libpaths += $(CIAO_ROOT)/tools/Simple_Component_Server + depends += hello_stub Simple_Server_Stbu + libpaths += $(CIAO_ROOT)/tools/Simple_Component_Server + libs += hello_stub CIAO_Simple_Server_Stub + exename = simple_client + + IDL_Files { + } + + Source_Files { + simple_client.cpp + } +} diff --git a/TAO/CIAO/examples/handcrafted/Hello/run_simple_test.pl b/TAO/CIAO/examples/handcrafted/Hello/run_simple_test.pl new file mode 100755 index 00000000000..f09d29f3915 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/Hello/run_simple_test.pl @@ -0,0 +1,47 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +# This perl script run the Hello World component using the +# Simple Component Server + +use lib "../../../../../bin"; +use PerlACE::Run_Test; + +$iorfile = PerlACE::LocalFile ("ior"); +unlink $iorfile; +$status = 0; + +$SV = new PerlACE::Process ("../../../tools/Simple_Component_Server/Simple_Component_Server", + "-i config -o $iorfile"); + +$CL = new PerlACE::Process ("simple_client", "-i file://$iorfile -x"); + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, 5) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$client = $CL->SpawnWaitKill (300); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +$server = $SV->WaitKill (10); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; diff --git a/TAO/CIAO/examples/handcrafted/Hello/simple_client.cpp b/TAO/CIAO/examples/handcrafted/Hello/simple_client.cpp new file mode 100644 index 00000000000..39f74cf1f01 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/Hello/simple_client.cpp @@ -0,0 +1,102 @@ +// $Id$ + +#include "tools/Simple_Component_Server/Simple_ServerC.h" +#include "ace/Get_Opt.h" +#include "ace/Read_Buffer.h" +#include "helloC.h" + +char *ior = 0; +int shutdown_server = 0; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "i:x"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'x': // Shutdown server when exit? + shutdown_server = 1; + break; + + case 'i': // get component configuration + ior = get_opts.opt_arg (); + break; + + case '?': // display help for use of the server. + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s\n" + "-i <simple server ior>\n" + "-x shutdown server when exit\n" + "\n", + argv [0]), + -1); + } + + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_TRY_NEW_ENV + { + // Initialize orb + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv ACE_ENV_ARG_PARAMETER); + + if (parse_args (argc, argv) != 0) + return -1; + + CORBA::Object_var obj + = orb->string_to_object (ior ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CIAO::Simple_Server_var cserve + = CIAO::Simple_Server::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Components::CCMHome_var home = cserve->get_home (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + HelloHome_var hh = HelloHome::_narrow (home.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (hh.in ())) + ACE_ERROR_RETURN ((LM_ERROR, "Argument is not a HelloHome reference\n"), -1); + + HelloWorld_var hw = hh->create (); + + if (CORBA::is_nil (hw.in ())) + ACE_ERROR_RETURN ((LM_ERROR, "Fail to create a HelloWorld reference\n"), -1); + + CORBA::String_var hi = hw->sayhello ("Simple_Component_Server" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_INFO, "%s\n", hi.in ())); + + hh->remove_component (hw.in () + ACE_ENV_ARG_PARAMETER); + + if (shutdown_server != 0) + cserve->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + + orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Who is the culprit \n"); + cerr << "Uncaught CORBA exception" << endl; + return 1; + } + ACE_ENDTRY; + + return 0; +} |