diff options
author | alex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-16 16:08:34 +0000 |
---|---|---|
committer | alex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-16 16:08:34 +0000 |
commit | 3e8cbdd0f7787d052242dd49aad3eed5343d8d49 (patch) | |
tree | 3d3e3f84998a5f64d7227cc9d485881de2312bb1 | |
parent | 54182c23b28d4dc5c40ac30a65d208145d4baf10 (diff) | |
download | ATCD-3e8cbdd0f7787d052242dd49aad3eed5343d8d49.tar.gz |
ChangeLogTag : Fri Jul 16 11:06:07 1999 Alexander Babu Arulanthu <alex@cs.wustl.edu>
-rw-r--r-- | TAO/tests/AMI/README | 34 | ||||
-rw-r--r-- | TAO/tests/AMI/client.conf | 2 | ||||
-rw-r--r-- | TAO/tests/AMI/client.cpp | 66 | ||||
-rw-r--r-- | TAO/tests/AMI/client.muxed.conf | 4 | ||||
-rwxr-xr-x | TAO/tests/AMI/run_test.pl | 112 | ||||
-rw-r--r-- | TAO/tests/AMI/server.cpp | 36 | ||||
-rw-r--r-- | TAO/tests/AMI/simple-client-exclusive.conf | 2 | ||||
-rw-r--r-- | TAO/tests/AMI/simple-client-muxed.conf | 2 | ||||
-rw-r--r-- | TAO/tests/AMI/simple-client.cpp | 63 | ||||
-rw-r--r-- | TAO/tests/AMI/test-handC.cpp | 882 | ||||
-rw-r--r-- | TAO/tests/AMI/test.idl | 14 | ||||
-rw-r--r-- | TAO/tests/AMI/test_i.cpp | 30 | ||||
-rw-r--r-- | TAO/tests/AMI/test_i.h | 12 |
13 files changed, 793 insertions, 466 deletions
diff --git a/TAO/tests/AMI/README b/TAO/tests/AMI/README index 4c1d0b89859..15a83385c47 100644 --- a/TAO/tests/AMI/README +++ b/TAO/tests/AMI/README @@ -2,13 +2,33 @@ Description: - This is a simple test for AMI callback model. Right now the -IDL compiler does not generate all the code. Therefore, you need to -copy test-handC.cpp onto testC.cpp. - - This is still in a development phase. It is not at all -complete. +This is a simple test for AMI callback model. $ server -o test.ior $ client -k file://test.ior -n 4 -i 1000 -$ simple_client -k file://test_ior + +simple-client: +============= + +$ simple_client -k file://test_ior [-i <niterations] [-x] [-d] \ + -ORBSvcConf {simple-client-muxed.conf, + simple-client-exclusive.conf} + +-d Enable debug messages. +-i Number of iterations. +-k IOR. +-x Call shutdown method. + +Issues <i> number of asynchronous requests. Then it issues a +synchronous request, which collects the replies. + +If you choose Muxed Transport configuration, then the synchronous +request will collect all the asynchronous replies also, since the +replies will arrive in order. + +But in the Exclusive Transport, the synchronous request might now +collect all the AMI replies. It might return as soon as its reply +arrives. + + + diff --git a/TAO/tests/AMI/client.conf b/TAO/tests/AMI/client.conf index 5276fe68900..c0794261618 100644 --- a/TAO/tests/AMI/client.conf +++ b/TAO/tests/AMI/client.conf @@ -1,2 +1,2 @@ -static Client_Strategy_Factory "-ORBiiopprofilelock null -ORBclientconnectionhandler RW" +static Client_Strategy_Factory "-ORBProfileLock null -ORBclientconnectionhandler ST" diff --git a/TAO/tests/AMI/client.cpp b/TAO/tests/AMI/client.cpp index 31527aa0e42..ec583f44ee6 100644 --- a/TAO/tests/AMI/client.cpp +++ b/TAO/tests/AMI/client.cpp @@ -9,16 +9,21 @@ ACE_RCSID(MT_Client, client, "$Id$") const char *ior = "file://test.ior"; int nthreads = 5; int niterations = 5; +int debug = 0; + int parse_args (int argc, char *argv[]) { - ACE_Get_Opt get_opts (argc, argv, "k:n:i:"); + ACE_Get_Opt get_opts (argc, argv, "dk:n:i:"); int c; while ((c = get_opts ()) != -1) switch (c) { + case 'd': + debug = 1; + break; case 'k': ior = get_opts.optarg; break; @@ -32,6 +37,7 @@ parse_args (int argc, char *argv[]) default: ACE_ERROR_RETURN ((LM_ERROR, "usage: %s " + "-d " "-k <ior> " "-n <nthreads> " "-i <niterations> " @@ -58,22 +64,41 @@ public: virtual int svc (void); // The thread entry point. -private: + // private: Simple_Server_var server_; // The server. int niterations_; // The number of iterations on each client thread. + + AMI_Simple_Server_Handler_var the_handler_; + // Var for ReplyHandler object. }; class Handler : public POA_AMI_Simple_Server_Handler { public: Handler (void) {}; + + void get_put_number (CORBA::Long result, + CORBA::Long out_l, + CORBA::Environment&) + { + if (debug) + { + ACE_DEBUG ((LM_DEBUG, + "(%P | %t) : Callback method called: result <%d>, out_arg <%d>\n", + result, + out_l)); + } + }; ~Handler (void) {}; }; +// ReplyHandler. +Handler handler; + int main (int argc, char *argv[]) { @@ -129,9 +154,20 @@ main (int argc, char *argv[]) "Cannot activate client threads\n"), 1); + // Main thread collects replies. It needs to collect + // <nthreads*niterations> replies. + size_t number_of_replies = nthreads * niterations; + + while (orb->work_pending () && number_of_replies--) + { + orb->perform_work (); + } + client.thr_mgr ()->wait (); ACE_DEBUG ((LM_DEBUG, "threads finished\n")); + + client.server_->shutdown (); } ACE_CATCHANY { @@ -151,6 +187,7 @@ Client::Client (Simple_Server_ptr server, : server_ (Simple_Server::_duplicate (server)), niterations_ (niterations) { + the_handler_ = handler._this (/* ACE_TRY_ENV */); } int @@ -168,26 +205,21 @@ Client::svc (void) ACE_TRY_CHECK; #endif - Handler handler; - AMI_Simple_Server_Handler_var the_handler = - handler._this (ACE_TRY_ENV); - ACE_TRY_CHECK; - - CORBA::Long number = 0; + CORBA::Long number = 931232; for (int i = 0; i < this->niterations_; ++i) { - server_->sendc_get_number (the_handler.in (), - ACE_TRY_ENV); + server_->sendc_get_put_number (the_handler_.in (), + number, + ACE_TRY_ENV); ACE_TRY_CHECK; - - if (TAO_debug_level > 0 && i % 100 == 0) - ACE_DEBUG ((LM_DEBUG, "(%P|%t) iteration = %d\n", i)); } - - number = server_->get_number (ACE_TRY_ENV); - - ACE_DEBUG ((LM_DEBUG, "(%P | %t) get_number = %d\n", number)); + if (debug) + { + ACE_DEBUG ((LM_DEBUG, + "(%P | %t):<%d> Asynchronous methods issued\n", + niterations)); + } } ACE_CATCHANY { diff --git a/TAO/tests/AMI/client.muxed.conf b/TAO/tests/AMI/client.muxed.conf index e41aabecf7a..9450aa9f905 100644 --- a/TAO/tests/AMI/client.muxed.conf +++ b/TAO/tests/AMI/client.muxed.conf @@ -1,2 +1,4 @@ -static Client_Strategy_Factory "-ORBTransportMuxStrategy MUXED -ORBiiopprofilelock null -ORBclientconnectionhandler MT" +static Client_Strategy_Factory "-ORBTransportMuxStrategy MUXED -ORBIiopProfilelock null" + + diff --git a/TAO/tests/AMI/run_test.pl b/TAO/tests/AMI/run_test.pl index 2c6a97e729e..06363f75467 100755 --- a/TAO/tests/AMI/run_test.pl +++ b/TAO/tests/AMI/run_test.pl @@ -5,59 +5,61 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # $Id$ # -*- perl -*- -unshift @INC, '../../../bin'; -require ACEutils; + # unshift @INC, '../../../bin'; + # require ACEutils; + # + # $client_conf="client.global.conf"; + # $client_process="client"; + # $debug_level='5'; + # $threads='2'; + # $iterations='1'; + # + # foreach $i (@ARGV) { + # if ($i eq '-tss') { + # $client_conf = "client.tss.conf"; + # } elsif ($i eq '-debug') { + # $debug_level = '1'; + # } elsif ($i eq '-creation') { + # $client_process = 'orb_creation'; + # $threads='2'; + # } + # } + # + # $iorfile = "server.ior"; + # $SV = Process::Create ($EXEPREFIX."server$EXE_EXT ", + # " -ORBsvcconf server.conf -ORBdebuglevel $debug_level" + # . " -o $iorfile"); + # + # if (ACE::waitforfile_timed ($iorfile, 5) == -1) { + # print STDERR "ERROR: cannot find file <$iorfile>\n"; + # $SV->Kill (); $SV->TimedWait (1); + # exit 1; + # } + # + # $CL = Process::Create ($EXEPREFIX."$client_process$EXE_EXT ", + # " -ORBsvcconf $client_conf " + # . "-ORBdebuglevel $debug_level" + # . " -k file://$iorfile " + # . " -n $threads -i $iterations"); + # + # $client = $CL->TimedWait (60); + # if ($client == -1) { + # print STDERR "ERROR: client timedout\n"; + # $CL->Kill (); $CL->TimedWait (1); + # } + # + # $server = $SV->TimedWait (5); + # if ($server == -1) { + # print STDERR "ERROR: server timedout\n"; + # $SV->Kill (); $SV->TimedWait (1); + # } + # + # unlink $iorfile; + # + # if ($server != 0 || $client != 0) { + # exit 1; + # } + # + # exit 0; + # -$client_conf="client.global.conf"; -$client_process="client"; -$debug_level='5'; -$threads='2'; -$iterations='1'; - -foreach $i (@ARGV) { - if ($i eq '-tss') { - $client_conf = "client.tss.conf"; - } elsif ($i eq '-debug') { - $debug_level = '1'; - } elsif ($i eq '-creation') { - $client_process = 'orb_creation'; - $threads='2'; - } -} - -$iorfile = "server.ior"; -$SV = Process::Create ($EXEPREFIX."server$EXE_EXT ", - " -ORBsvcconf server.conf -ORBdebuglevel $debug_level" - . " -o $iorfile"); - -if (ACE::waitforfile_timed ($iorfile, 5) == -1) { - print STDERR "ERROR: cannot find file <$iorfile>\n"; - $SV->Kill (); $SV->TimedWait (1); - exit 1; -} - -$CL = Process::Create ($EXEPREFIX."$client_process$EXE_EXT ", - " -ORBsvcconf $client_conf " - . "-ORBdebuglevel $debug_level" - . " -k file://$iorfile " - . " -n $threads -i $iterations"); - -$client = $CL->TimedWait (60); -if ($client == -1) { - print STDERR "ERROR: client timedout\n"; - $CL->Kill (); $CL->TimedWait (1); -} - -$server = $SV->TimedWait (5); -if ($server == -1) { - print STDERR "ERROR: server timedout\n"; - $SV->Kill (); $SV->TimedWait (1); -} - -unlink $iorfile; - -if ($server != 0 || $client != 0) { - exit 1; -} - -exit 0; diff --git a/TAO/tests/AMI/server.cpp b/TAO/tests/AMI/server.cpp index 9a2dfa93eb3..37f3ccf7595 100644 --- a/TAO/tests/AMI/server.cpp +++ b/TAO/tests/AMI/server.cpp @@ -17,13 +17,13 @@ parse_args (int argc, char *argv[]) switch (c) { case 'o': - ior_output_file = get_opts.optarg; - break; + ior_output_file = get_opts.optarg; + break; case '?': default: ACE_ERROR_RETURN ((LM_ERROR, "usage: %s " - "-o <iorfile>" + "-o <iorfile>" "\n", argv [0]), -1); @@ -66,36 +66,30 @@ main (int argc, char *argv[]) ACE_TRY_CHECK; CORBA::String_var ior = - orb->object_to_string (server.in (), ACE_TRY_ENV); + orb->object_to_string (server.in (), ACE_TRY_ENV); ACE_TRY_CHECK; ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ())); // If the ior_output_file exists, output the ior to it if (ior_output_file != 0) - { - FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); - if (output_file == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "Cannot open output file for writing IOR: %s", - ior_output_file), - 1); - ACE_OS::fprintf (output_file, "%s", ior.in ()); - ACE_OS::fclose (output_file); - } + { + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + } poa_manager->activate (ACE_TRY_ENV); ACE_TRY_CHECK; - CORBA::Long number = 0; - - number = server->get_number (ACE_TRY_ENV); - ACE_TRY_CHECK; - - ACE_DEBUG ((LM_DEBUG, "get_number = %d\n", number)); - if (orb->run () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "orb->run"), -1); + ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); } ACE_CATCHANY diff --git a/TAO/tests/AMI/simple-client-exclusive.conf b/TAO/tests/AMI/simple-client-exclusive.conf new file mode 100644 index 00000000000..c78e5018593 --- /dev/null +++ b/TAO/tests/AMI/simple-client-exclusive.conf @@ -0,0 +1,2 @@ + +static Client_Strategy_Factory "-ORBTransportMuxStrategy EXCLUSIVE -ORBiiopprofilelock null -ORBclientconnectionhandler ST" diff --git a/TAO/tests/AMI/simple-client-muxed.conf b/TAO/tests/AMI/simple-client-muxed.conf new file mode 100644 index 00000000000..97bca811c1b --- /dev/null +++ b/TAO/tests/AMI/simple-client-muxed.conf @@ -0,0 +1,2 @@ + +static Client_Strategy_Factory "-ORBTransportMuxStrategy MUXED -ORBiiopprofilelock null -ORBclientconnectionhandler ST" diff --git a/TAO/tests/AMI/simple-client.cpp b/TAO/tests/AMI/simple-client.cpp index 9c821f72d1b..3d9a14b5868 100644 --- a/TAO/tests/AMI/simple-client.cpp +++ b/TAO/tests/AMI/simple-client.cpp @@ -8,28 +8,37 @@ ACE_RCSID(MT_Client, client, "$Id$") const char *ior = "file://test.ior"; int niterations = 5; +int shutdown_flag = 0; +int debug = 0; int parse_args (int argc, char *argv[]) { - ACE_Get_Opt get_opts (argc, argv, "k:i:"); + ACE_Get_Opt get_opts (argc, argv, "dk:i:x"); int c; while ((c = get_opts ()) != -1) switch (c) { + case 'd': + debug = 1; + break; case 'k': ior = get_opts.optarg; break; case 'i': niterations = ACE_OS::atoi (get_opts.optarg); break; + case 'x': + shutdown_flag = 1; + break; case '?': default: ACE_ERROR_RETURN ((LM_ERROR, "usage: %s " "-k <ior> " "-i <niterations> " + "-x " "\n", argv [0]), -1); @@ -42,8 +51,23 @@ class Handler : public POA_AMI_Simple_Server_Handler { public: Handler (void) {}; - + // Constructor. + + void get_put_number (CORBA::Long result, + CORBA::Long out_l, + CORBA::Environment&) + { + if (debug) + { + ACE_DEBUG ((LM_DEBUG, + "Callback method called: result <%d>, out_arg <%d>\n", + result, + out_l)); + } + }; + ~Handler (void) {}; + // Destructor. }; int @@ -91,27 +115,42 @@ main (int argc, char *argv[]) 1); } + // Instantiate the ReplyHandler and register that with the POA. Handler handler; AMI_Simple_Server_Handler_var the_handler = handler._this (ACE_TRY_ENV); ACE_TRY_CHECK; - - CORBA::Long number = 0; + CORBA::Long l = 931247; + for (ssize_t ni = 0; ni < niterations; ni++) { - - server->sendc_get_number (the_handler.in (), - ACE_TRY_ENV); + server->sendc_get_put_number (the_handler.in (), + l, + ACE_TRY_ENV); ACE_TRY_CHECK; } - number = server->get_number (ACE_TRY_ENV); - ACE_TRY_CHECK; + if (debug) + { + ACE_DEBUG ((LM_DEBUG, + "<%d> Asynchronous methods issued\n", + niterations)); + } + + if (debug) + { + ACE_DEBUG ((LM_DEBUG, + "Issuing a synchronous method to collect the AMI replies\n")); + } - ACE_DEBUG ((LM_DEBUG, - "get_number = %d\n", - number)); + CORBA::Long number = server->get_put_number (l, + l, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (shutdown_flag) + server->shutdown (); } ACE_CATCHANY { diff --git a/TAO/tests/AMI/test-handC.cpp b/TAO/tests/AMI/test-handC.cpp index b0bda5a45b0..41d00eaf173 100644 --- a/TAO/tests/AMI/test-handC.cpp +++ b/TAO/tests/AMI/test-handC.cpp @@ -16,50 +16,37 @@ Simple_Server_ptr Simple_Server::_narrow ( CORBA::Object_ptr obj, - CORBA::Environment &env + CORBA::Environment &ACE_TRY_ENV ) { if (CORBA::is_nil (obj)) return Simple_Server::_nil (); - if (!obj->_is_a ("IDL:Simple_Server:1.0", env)) + CORBA::Boolean is_a = obj->_is_a ("IDL:Simple_Server:1.0", ACE_TRY_ENV); + ACE_CHECK_RETURN (Simple_Server::_nil ()); + if (is_a == 0) return Simple_Server::_nil (); - return Simple_Server::_unchecked_narrow (obj, env); + return Simple_Server::_unchecked_narrow (obj, ACE_TRY_ENV); } Simple_Server_ptr Simple_Server::_unchecked_narrow ( CORBA::Object_ptr obj, - CORBA::Environment &ACE_TRY_ENV + CORBA::Environment & ) { - ACE_UNUSED_ARG (ACE_TRY_ENV); if (CORBA::is_nil (obj)) return Simple_Server::_nil (); TAO_Stub* stub = obj->_stubobj (); stub->_incr_refcnt (); - void* servant = 0; - if (obj->_is_collocated () && obj->_servant() != 0) - servant = obj->_servant()->_downcast ("IDL:omg.org/CORBA/Object:1.0"); - if (servant != 0) + if (obj->_is_collocated () && _TAO_collocation_Simple_Server_Stub_Factory_function_pointer != 0) { - Simple_Server_ptr retv = ACE_reinterpret_cast ( - Simple_Server_ptr, - ACE_reinterpret_cast ( - PortableServer::Servant, - servant - ) - ->_create_collocated_objref ( - "IDL:Simple_Server:1.0", - TAO_ORB_Core::ORB_CONTROL, - stub - ) - ); + Simple_Server_ptr retv = _TAO_collocation_Simple_Server_Stub_Factory_function_pointer (obj); if (retv != 0) return retv; } return new Simple_Server(stub); } -Simple_Server_ptr +Simple_Server_ptr Simple_Server::_duplicate (Simple_Server_ptr obj) { if (!CORBA::is_nil (obj)) @@ -67,34 +54,42 @@ Simple_Server::_duplicate (Simple_Server_ptr obj) return obj; } -CORBA::Long Simple_Server::get_number ( +CORBA::Long Simple_Server::get_put_number ( + CORBA::Long_out out_l, + CORBA::Long in_l, CORBA::Environment &ACE_TRY_ENV ) ACE_THROW_SPEC (( CORBA::SystemException )) { - + CORBA::Long _tao_retval = 0; + TAO_Stub *istub = this->_stubobj (); if (istub == 0) ACE_THROW_RETURN (CORBA::INTERNAL (), _tao_retval); - + TAO_GIOP_Twoway_Invocation _tao_call ( istub, - "get_number", + "get_put_number", istub->orb_core () ); - + for (;;) { - ACE_TRY_ENV.clear (); _tao_call.start (ACE_TRY_ENV); ACE_CHECK_RETURN (_tao_retval); + TAO_OutputCDR &_tao_out = _tao_call.out_stream (); + if (!( + (_tao_out << in_l) + )) + ACE_THROW_RETURN (CORBA::MARSHAL (), _tao_retval); + int _invoke_status = _tao_call.invoke (0, 0, ACE_TRY_ENV); ACE_CHECK_RETURN (_tao_retval); @@ -109,42 +104,49 @@ CORBA::Long Simple_Server::get_number ( } break; - + } TAO_InputCDR &_tao_in = _tao_call.inp_stream (); if (!( - (_tao_in >> _tao_retval) + (_tao_in >> _tao_retval) && + (_tao_in >> out_l) )) ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES), _tao_retval); return _tao_retval; } void -Simple_Server::sendc_get_number ( +Simple_Server::sendc_get_put_number ( AMI_Simple_Server_Handler_ptr _tao_ami_handler, + CORBA::Long in_l, CORBA::Environment &ACE_TRY_ENV ) { - + TAO_Stub *istub = this->_stubobj (); if (istub == 0) ACE_THROW (CORBA::INV_OBJREF ()); - + TAO_GIOP_Twoway_Asynch_Invocation _tao_call ( istub, - "get_number", + "get_put_number", istub->orb_core (), - &AMI_Simple_Server_Handler::get_number_skel, + &AMI_Simple_Server_Handler::get_put_number_skel, _tao_ami_handler ); - + for (;;) { - ACE_TRY_ENV.clear (); _tao_call.start (ACE_TRY_ENV); ACE_CHECK; + TAO_OutputCDR &_tao_out = _tao_call.out_stream (); + if (!( + (_tao_out << in_l) + )) + ACE_THROW (CORBA::MARSHAL ()); + int _invoke_status = _tao_call.invoke (0, 0, ACE_TRY_ENV); ACE_CHECK; @@ -159,19 +161,66 @@ Simple_Server::sendc_get_number ( } break; - + } return; } -CORBA::Boolean Simple_Server::_is_a (const CORBA::Char *value, CORBA::Environment &env) +void Simple_Server::shutdown ( + CORBA::Environment &ACE_TRY_ENV + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + + + + + TAO_Stub *istub = this->_stubobj (); + if (istub == 0) + ACE_THROW (CORBA::INTERNAL ()); + + + TAO_GIOP_Oneway_Invocation _tao_call ( + istub, + "shutdown", + istub->orb_core () + ); + + + for (;;) + { + _tao_call.start (ACE_TRY_ENV); + ACE_CHECK; + + int _invoke_status = + _tao_call.invoke (ACE_TRY_ENV); + ACE_CHECK; + + if (_invoke_status == TAO_INVOKE_RESTART) + continue; + // if (_invoke_status == TAO_INVOKE_EXCEPTION) + // cannot happen + if (_invoke_status != TAO_INVOKE_OK) + { + ACE_THROW (CORBA::UNKNOWN (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES)); + + } + break; + + } + +} + +CORBA::Boolean Simple_Server::_is_a (const CORBA::Char *value, CORBA::Environment &ACE_TRY_ENV) { if ( (!ACE_OS::strcmp ((char *)value, "IDL:Simple_Server:1.0")) || - (!ACE_OS::strcmp ((char *)value, CORBA::_tc_Object->id (env)))) + (!ACE_OS::strcmp ((char *)value, "IDL:omg.org/CORBA/Object:1.0"))) return 1; // success using local knowledge else - return this->CORBA_Object::_is_a (value, env); + return this->CORBA_Object::_is_a (value, ACE_TRY_ENV); } const char* Simple_Server::_interface_repository_id (void) const @@ -202,38 +251,23 @@ AMI_Simple_Server_Handler_ptr AMI_Simple_Server_Handler::_narrow ( AMI_Simple_Server_Handler_ptr AMI_Simple_Server_Handler::_unchecked_narrow ( CORBA::Object_ptr obj, - CORBA::Environment &ACE_TRY_ENV + CORBA::Environment & ) { - ACE_UNUSED_ARG (ACE_TRY_ENV); if (CORBA::is_nil (obj)) return AMI_Simple_Server_Handler::_nil (); TAO_Stub* stub = obj->_stubobj (); stub->_incr_refcnt (); - void* servant = 0; - if (obj->_is_collocated () && obj->_servant() != 0) - servant = obj->_servant()->_downcast ("IDL:omg.org/CORBA/Object:1.0"); - if (servant != 0) + if (obj->_is_collocated () && _TAO_collocation_AMI_Simple_Server_Handler_Stub_Factory_function_pointer != 0) { - AMI_Simple_Server_Handler_ptr retv = ACE_reinterpret_cast ( - AMI_Simple_Server_Handler_ptr, - ACE_reinterpret_cast ( - PortableServer::Servant, - servant - ) - ->_create_collocated_objref ( - "IDL:AMI_Simple_Server_Handler:1.0", - TAO_ORB_Core::ORB_CONTROL, - stub - ) - ); + AMI_Simple_Server_Handler_ptr retv = _TAO_collocation_AMI_Simple_Server_Handler_Stub_Factory_function_pointer (obj); if (retv != 0) return retv; } return new AMI_Simple_Server_Handler(stub); } -AMI_Simple_Server_Handler_ptr +AMI_Simple_Server_Handler_ptr AMI_Simple_Server_Handler::_duplicate (AMI_Simple_Server_Handler_ptr obj) { if (!CORBA::is_nil (obj)) @@ -241,153 +275,296 @@ AMI_Simple_Server_Handler::_duplicate (AMI_Simple_Server_Handler_ptr obj) return obj; } -void -AMI_Simple_Server_Handler::get_number ( - CORBA::Long _tao_ami_result, +void +AMI_Simple_Server_Handler::get_put_number ( + CORBA::Long _tao_retval, + CORBA::Long out_l, CORBA::Environment &ACE_TRY_ENV ) ACE_THROW_SPEC ((CORBA::SystemException)) + { - - TAO_Stub *istub = this->_stubobj (); - if (istub == 0) - ACE_THROW (CORBA::INTERNAL ()); - - TAO_GIOP_Twoway_Invocation _tao_call ( - istub, - "get_number", - istub->orb_core () - ); - - for (;;) + TAO_Stub *istub = this->_stubobj (); + if (istub == 0) + ACE_THROW (CORBA::INTERNAL ()); + + TAO_GIOP_Twoway_Invocation _tao_call ( + istub, + "get_put_number", + istub->orb_core () + ); + + + for (;;) + { + ACE_TRY_ENV.clear (); + _tao_call.start (ACE_TRY_ENV); + ACE_CHECK; + TAO_OutputCDR &_tao_out = _tao_call.out_stream (); + if (!( + (_tao_out << _tao_retval) && + (_tao_out << out_l) + )) + ACE_THROW (CORBA::MARSHAL ()); + int _invoke_status = + _tao_call.invoke (0, 0, ACE_TRY_ENV); + ACE_CHECK; + if (_invoke_status == TAO_INVOKE_RESTART) + continue; + // if (_invoke_status == TAO_INVOKE_EXCEPTION) + // cannot happen + if (_invoke_status != TAO_INVOKE_OK) { - ACE_TRY_ENV.clear (); - _tao_call.start (ACE_TRY_ENV); -ACE_CHECK; - TAO_OutputCDR &_tao_out = _tao_call.out_stream (); - if (!( -(_tao_out << _tao_ami_result) - - )) - ACE_THROW (CORBA::MARSHAL ()); - int _invoke_status = - _tao_call.invoke (0, 0, ACE_TRY_ENV); - ACE_CHECK; - if (_invoke_status == TAO_INVOKE_RESTART) - continue; - // if (_invoke_status == TAO_INVOKE_EXCEPTION) - // cannot happen - if (_invoke_status != TAO_INVOKE_OK) - { - ACE_THROW (CORBA::UNKNOWN (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES)); - } - break; - + ACE_THROW (CORBA::UNKNOWN (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES)); } - + break; + } +} + + void -AMI_Simple_Server_Handler::get_number_skel (TAO_InputCDR &_tao_reply_cdr, - Messaging::ReplyHandler_ptr _tao_reply_handler, - CORBA::Environment &ACE_TRY_ENV) -{ - // Retrive Reply Handler object. - AMI_Simple_Server_Handler_var _tao_reply_handler_object = - AMI_Simple_Server_Handler::_narrow (_tao_reply_handler, - ACE_TRY_ENV); +AMI_Simple_Server_Handler::get_put_number_skel ( + TAO_InputCDR &_tao_in, + Messaging::ReplyHandler_ptr _tao_reply_handler, + CORBA::Environment &ACE_TRY_ENV +) +{ + + // Retrieve Reply Handler object. + AMI_Simple_Server_Handler_var _tao_reply_handler_object = + AMI_Simple_Server_Handler::_narrow(_tao_reply_handler, ACE_TRY_ENV); ACE_CHECK; - // @@ Error handling. - - // Demarshall all the arguments. - CORBA::Long l; - _tao_reply_cdr >> l; - + // @@ Error handling + + //Demarshall all the arguments. + CORBA::Long _tao_retval = 0; + CORBA::Long out_l; + if (!( + (_tao_in >> _tao_retval) && + (_tao_in >> out_l) + )) + ACE_THROW (CORBA::MARSHAL ()); + // Invoke the call back method. - _tao_reply_handler_object->get_number (l, ACE_TRY_ENV); -} + _tao_reply_handler_object->get_put_number ( + _tao_retval, + out_l, + ACE_TRY_ENV + ); + ACE_CHECK; + +}; + +void +AMI_Simple_Server_Handler::shutdown ( + CORBA::Environment &ACE_TRY_ENV + ) + ACE_THROW_SPEC ((CORBA::SystemException)) + +{ + + + TAO_Stub *istub = this->_stubobj (); + if (istub == 0) + ACE_THROW (CORBA::INTERNAL ()); + + TAO_GIOP_Oneway_Invocation _tao_call ( + istub, + "shutdown", + istub->orb_core () + ); - CORBA::Boolean AMI_Simple_Server_Handler::_is_a (const CORBA::Char *value, CORBA::Environment &env) + + for (;;) { - if ( + ACE_TRY_ENV.clear (); + _tao_call.start (ACE_TRY_ENV); + ACE_CHECK; + int _invoke_status = + _tao_call.invoke (ACE_TRY_ENV); + ACE_CHECK; + if (_invoke_status == TAO_INVOKE_RESTART) + continue; + // if (_invoke_status == TAO_INVOKE_EXCEPTION) + // cannot happen + if (_invoke_status != TAO_INVOKE_OK) + { + ACE_THROW (CORBA::UNKNOWN (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES)); + } + break; + + } + +} + +CORBA::Boolean AMI_Simple_Server_Handler::_is_a (const CORBA::Char *value, CORBA::Environment &env) +{ + if ( (!ACE_OS::strcmp ((char *)value, "IDL:AMI_Simple_Server_Handler:1.0")) || - (!ACE_OS::strcmp ((char *)value, "IDL:omg.org/Messaging/ReplyHandler:1.0")) || - (!ACE_OS::strcmp ((char *)value, CORBA::_tc_Object->id (env)))) + (!ACE_OS::strcmp ((char *)value, "IDL:omg.org/Messaging/ReplyHandler:1.0")) || + (!ACE_OS::strcmp ((char *)value, CORBA::_tc_Object->id (env)))) return 1; // success using local knowledge - else - return this->CORBA_Object::_is_a (value, env); - } + else + return this->CORBA_Object::_is_a (value, env); +} - const char* AMI_Simple_Server_Handler::_interface_repository_id (void) const - { - return "IDL:AMI_Simple_Server_Handler:1.0"; - } +const char* AMI_Simple_Server_Handler::_interface_repository_id (void) const +{ + return "IDL:AMI_Simple_Server_Handler:1.0"; +} - static const CORBA::Long _oc_AMI_Simple_Server_Handler[] = - { - TAO_ENCAP_BYTE_ORDER, // byte order - 34, ACE_NTOHL (0x49444c3a), ACE_NTOHL (0x414d495f), ACE_NTOHL (0x53696d70), ACE_NTOHL (0x6c655f53), ACE_NTOHL (0x65727665), ACE_NTOHL (0x725f4861), ACE_NTOHL (0x6e646c65), ACE_NTOHL (0x723a312e), ACE_NTOHL (0x30000000), // repository ID = IDL:AMI_Simple_Server_Handler:1.0 - 26, ACE_NTOHL (0x414d495f), ACE_NTOHL (0x53696d70), ACE_NTOHL (0x6c655f53), ACE_NTOHL (0x65727665), ACE_NTOHL (0x725f4861), ACE_NTOHL (0x6e646c65), ACE_NTOHL (0x72000000), // name = AMI_Simple_Server_Handler +static const CORBA::Long _oc_AMI_Simple_Server_Handler[] = +{ + TAO_ENCAP_BYTE_ORDER, // byte order + 34, ACE_NTOHL (0x49444c3a), ACE_NTOHL (0x414d495f), ACE_NTOHL (0x53696d70), ACE_NTOHL (0x6c655f53), ACE_NTOHL (0x65727665), ACE_NTOHL (0x725f4861), ACE_NTOHL (0x6e646c65), ACE_NTOHL (0x723a312e), ACE_NTOHL (0x30000000), // repository ID = IDL:AMI_Simple_Server_Handler:1.0 + 26, ACE_NTOHL (0x414d495f), ACE_NTOHL (0x53696d70), ACE_NTOHL (0x6c655f53), ACE_NTOHL (0x65727665), ACE_NTOHL (0x725f4861), ACE_NTOHL (0x6e646c65), ACE_NTOHL (0x72000000), // name = AMI_Simple_Server_Handler }; - static CORBA::TypeCode _tc_TAO_tc_AMI_Simple_Server_Handler (CORBA::tk_objref, sizeof (_oc_AMI_Simple_Server_Handler), (char *) &_oc_AMI_Simple_Server_Handler, 0, sizeof (AMI_Simple_Server_Handler)); - CORBA::TypeCode_ptr _tc_AMI_Simple_Server_Handler = &_tc_TAO_tc_AMI_Simple_Server_Handler; +static CORBA::TypeCode _tc_TAO_tc_AMI_Simple_Server_Handler (CORBA::tk_objref, sizeof (_oc_AMI_Simple_Server_Handler), (char *) &_oc_AMI_Simple_Server_Handler, 0, sizeof (AMI_Simple_Server_Handler)); +CORBA::TypeCode_ptr _tc_AMI_Simple_Server_Handler = &_tc_TAO_tc_AMI_Simple_Server_Handler; - void operator<<= (CORBA::Any &_tao_any, Simple_Server_ptr _tao_elem) - { - CORBA::Object_ptr *_tao_obj_ptr = 0; - ACE_TRY_NEW_ENV - { - ACE_NEW (_tao_obj_ptr, CORBA::Object_ptr); - *_tao_obj_ptr = Simple_Server::_duplicate (_tao_elem); - _tao_any.replace (_tc_Simple_Server, _tao_obj_ptr, 1, ACE_TRY_ENV); - ACE_TRY_CHECK; - } - ACE_CATCHANY +class TAO_AMI_Simple_Server_Handler_Perfect_Hash_OpTable : public TAO_Perfect_Hash_OpTable +{ +private: + unsigned int hash (const char *str, unsigned int len); +public: + const TAO_operation_db_entry * lookup (const char *str, unsigned int len); +}; +/* starting time is 23:22:01 */ +/* C++ code produced by gperf version 2.8 (ACE version) */ +/* Command-line: /project/danzontmp/alex/ami_phase3/sun5_CC/bin/gperf -m -M -J -c -C -D -E -T -f 0 -F 0 -a -o -t -p -K opname_ -L C++ -Z TAO_AMI_Simple_Server_Handler_Perfect_Hash_OpTable -N lookup */ +unsigned int +TAO_AMI_Simple_Server_Handler_Perfect_Hash_OpTable::hash (const char *str, unsigned int len) +{ + static const unsigned char asso_values[] = { - delete _tao_obj_ptr; - } - ACE_ENDTRY; - } +#if defined (ACE_MVS) + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, + 15, 15, 15, 15, 15, 0, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, + 15, 15, 15, 0, 15, 15, 15, 15, 15, 15, + 15, 15, 0, 0, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, +#else + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 0, 15, 0, 15, 15, + 15, 15, 15, 0, 15, 15, 15, 15, 15, 15, + 0, 15, 15, 15, 0, 0, 0, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, +#endif /* ACE_MVS */ + }; + return len + asso_values[str[len - 1]] + asso_values[str[0]]; +} - CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, Simple_Server_ptr &_tao_elem) - { - CORBA::Object_ptr *tmp = 0; - ACE_TRY_NEW_ENV +const class TAO_operation_db_entry * +TAO_AMI_Simple_Server_Handler_Perfect_Hash_OpTable::lookup (const char *str, unsigned int len) +{ + enum { - _tao_elem = Simple_Server::_nil (); - CORBA::TypeCode_var type = _tao_any.type (); - if (!type->equal (_tc_Simple_Server, ACE_TRY_ENV)) return 0; // not equal - ACE_TRY_CHECK; - TAO_InputCDR stream (_tao_any._tao_get_cdr ()); - CORBA::Object_var _tao_obj_var; - ACE_NEW_RETURN (tmp, CORBA::Object_ptr, 0); - if (stream.decode (_tc_Simple_Server, &_tao_obj_var.out (), 0, ACE_TRY_ENV) - == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - _tao_elem = Simple_Server::_narrow (_tao_obj_var.in (), ACE_TRY_ENV); - ACE_TRY_CHECK; - *tmp = (CORBA::Object_ptr) _tao_elem; // any owns the object - ((CORBA::Any *)&_tao_any)->replace (_tc_Simple_Server, tmp, 1, ACE_TRY_ENV); - ACE_TRY_CHECK; - return 1; - } - // failure + TOTAL_KEYWORDS = 4, + MIN_WORD_LENGTH = 5, + MAX_WORD_LENGTH = 14, + MIN_HASH_VALUE = 5, + MAX_HASH_VALUE = 14, + HASH_VALUE_RANGE = 10, + DUPLICATES = 0 + }; + + static const class TAO_operation_db_entry wordlist[] = + { + {"",0},{"",0},{"",0},{"",0},{"",0}, + {"_is_a", &POA_AMI_Simple_Server_Handler::_is_a_skel}, + {"",0},{"",0}, + {"shutdown", &POA_AMI_Simple_Server_Handler::shutdown_skel}, + {"",0},{"",0},{"",0},{"",0}, + {"_non_existent", &POA_AMI_Simple_Server_Handler::_non_existent_skel}, + {"get_put_number", &POA_AMI_Simple_Server_Handler::get_put_number_skel}, + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + unsigned int key = hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE) + { + const char *s = wordlist[key].opname_; + + if (*str == *s && !strncmp (str + 1, s + 1, len - 1)) + return &wordlist[key]; + } } - ACE_CATCHANY + return 0; +} +/* ending time is 23:22:01 */ +static TAO_AMI_Simple_Server_Handler_Perfect_Hash_OpTable tao_AMI_Simple_Server_Handler_optable; + +AMI_Simple_Server_Handler_ptr _TAO_collocation_POA_AMI_Simple_Server_Handler_Stub_Factory ( + CORBA::Object_ptr obj + ) +{ + TAO_Stub *stub = obj->_stubobj (); + + switch (stub->servant_orb_var ()->orb_core ()->get_collocation_strategy ()) { - delete tmp; - return 0; + case TAO_ORB_Core::THRU_POA: + return new _tao_thru_poa_collocated_AMI_Simple_Server_Handler (stub); + case TAO_ORB_Core::DIRECT: + break; + default: + break; } - ACE_ENDTRY; - return 0; - } + return 0; +} + +int _TAO_collocation_POA_AMI_Simple_Server_Handler_Stub_Factory_Initializer (long dummy) +{ + ACE_UNUSED_ARG (dummy); + + _TAO_collocation_AMI_Simple_Server_Handler_Stub_Factory_function_pointer = + _TAO_collocation_POA_AMI_Simple_Server_Handler_Stub_Factory; + + return 0; +} + +static int _TAO_collocation_POA_AMI_Simple_Server_Handler_Stub_Factory_Initializer_Scarecrow = + _TAO_collocation_POA_AMI_Simple_Server_Handler_Stub_Factory_Initializer (ACE_reinterpret_cast (long, _TAO_collocation_POA_AMI_Simple_Server_Handler_Stub_Factory_Initializer)); // skeleton constructor POA_AMI_Simple_Server_Handler::POA_AMI_Simple_Server_Handler (void) { + this->optable_ = &tao_AMI_Simple_Server_Handler_optable; } // copy ctor @@ -400,8 +577,75 @@ POA_AMI_Simple_Server_Handler::~POA_AMI_Simple_Server_Handler (void) { } +void POA_AMI_Simple_Server_Handler::get_put_number ( + CORBA::Long _tao_retval, + CORBA::Long out_l, + CORBA::Environment &ACE_TRY_ENV + ) + ACE_THROW_SPEC ((CORBA::SystemException)) + +{ + ACE_DEBUG ((LM_DEBUG, + "(%P | %t):POA_AMI_Simple_Server_Handler\n")); + +} + +void POA_AMI_Simple_Server_Handler::get_put_number_skel ( + CORBA::ServerRequest &_tao_server_request, + void *_tao_object_reference, + void * /* context */, + CORBA::Environment &ACE_TRY_ENV +) +{ + TAO_InputCDR &_tao_in = _tao_server_request.incoming (); + POA_AMI_Simple_Server_Handler *_tao_impl = (POA_AMI_Simple_Server_Handler *)_tao_object_reference; + + CORBA::Long _tao_retval = 0; + CORBA::Long out_l; + if (!( + (_tao_in >> _tao_retval) && + (_tao_in >> out_l) + )) + ACE_THROW (CORBA::MARSHAL () ); + + _tao_impl->get_put_number ( + _tao_retval, + out_l, + ACE_TRY_ENV + ); + ACE_CHECK; +_tao_server_request.init_reply (ACE_TRY_ENV); +} + +void POA_AMI_Simple_Server_Handler::shutdown ( + CORBA::Environment &ACE_TRY_ENV + ) + ACE_THROW_SPEC ((CORBA::SystemException)) + +{ + ACE_DEBUG ((LM_DEBUG, + "(%P | %t):POA_AMI_Simple_Server_Handler\n")); + +} + +void POA_AMI_Simple_Server_Handler::shutdown_skel ( + CORBA::ServerRequest &_tao_server_request, + void *_tao_object_reference, + void * /* context */, + CORBA::Environment &ACE_TRY_ENV +) +{ + POA_AMI_Simple_Server_Handler *_tao_impl = (POA_AMI_Simple_Server_Handler *)_tao_object_reference; + + _tao_impl->shutdown ( + ACE_TRY_ENV + ); + ACE_CHECK; +_tao_server_request.init_reply (ACE_TRY_ENV); +} + void POA_AMI_Simple_Server_Handler::_is_a_skel ( - CORBA::ServerRequest &_tao_server_request, + CORBA::ServerRequest &_tao_server_request, void * _tao_object_reference, void * /* context */, CORBA::Environment &ACE_TRY_ENV @@ -413,10 +657,10 @@ void POA_AMI_Simple_Server_Handler::_is_a_skel ( CORBA::String_var value; if (!((_tao_in >> value.out ()))) ACE_THROW (CORBA::MARSHAL ()); - + _tao_retval = _tao_impl->_is_a (value.in (), ACE_TRY_ENV); ACE_CHECK; - + _tao_server_request.init_reply (ACE_TRY_ENV); ACE_CHECK; TAO_OutputCDR &_tao_out = _tao_server_request.outgoing (); @@ -425,7 +669,7 @@ void POA_AMI_Simple_Server_Handler::_is_a_skel ( } void POA_AMI_Simple_Server_Handler::_non_existent_skel ( - CORBA::ServerRequest &_tao_server_request, + CORBA::ServerRequest &_tao_server_request, void * _tao_object_reference, void * /* context */, CORBA::Environment &ACE_TRY_ENV @@ -434,7 +678,7 @@ void POA_AMI_Simple_Server_Handler::_non_existent_skel ( POA_AMI_Simple_Server_Handler *_tao_impl = (POA_AMI_Simple_Server_Handler *) _tao_object_reference; CORBA::Boolean _tao_retval = _tao_impl->_non_existent (ACE_TRY_ENV); ACE_CHECK; - + _tao_server_request.init_reply (ACE_TRY_ENV); ACE_CHECK; TAO_OutputCDR &_tao_out = _tao_server_request.outgoing (); @@ -459,9 +703,9 @@ void* POA_AMI_Simple_Server_Handler::_downcast ( const char* logical_type_id ) { - if (ACE_OS::strcmp (logical_type_id, "IDL:AMI_Simple_Server_Handler:1.0") == 0) +if (ACE_OS::strcmp (logical_type_id, "IDL:AMI_Simple_Server_Handler:1.0") == 0) return ACE_static_cast (POA_AMI_Simple_Server_Handler_ptr, this); - if (ACE_OS::strcmp (logical_type_id, "IDL:omg.org/CORBA/Object:1.0") == 0) + if (ACE_OS::strcmp (logical_type_id, "IDL:omg.org/CORBA/Object:1.0") == 0) return ACE_static_cast(PortableServer::Servant, this); return 0; } @@ -485,161 +729,195 @@ const char* POA_AMI_Simple_Server_Handler::_interface_repository_id (void) const return "IDL:AMI_Simple_Server_Handler:1.0"; } - AMI_Simple_Server_Handler* POA_AMI_Simple_Server_Handler::_this (CORBA_Environment &ACE_TRY_ENV) { TAO_Stub *stub = this->_create_stub (ACE_TRY_ENV); ACE_CHECK_RETURN (0); - return new _tao_collocated_AMI_Simple_Server_Handler (this, stub); + switch (stub->servant_orb_var ()->orb_core ()->get_collocation_strategy ()) + { + case TAO_ORB_Core::THRU_POA: + return new _tao_thru_poa_collocated_AMI_Simple_Server_Handler (stub); + case TAO_ORB_Core::DIRECT: + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + default: + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + } } -void* -POA_AMI_Simple_Server_Handler::_create_collocated_objref (const char* repository_id, CORBA::ULong type, TAO_Stub *stub) +_tao_thru_poa_collocated_AMI_Simple_Server_Handler::_tao_thru_poa_collocated_AMI_Simple_Server_Handler ( + TAO_Stub *stub +) + : AMI_Simple_Server_Handler (), + CORBA_Object (stub, 0, 1) { - if (!ACE_OS::strcmp ("IDL:AMI_Simple_Server_Handler:1.0", repository_id)) - return ACE_static_cast ( - AMI_Simple_Server_Handler_ptr, - new _tao_collocated_AMI_Simple_Server_Handler (this, stub) - ); - return 0; } -void -POA_AMI_Simple_Server_Handler::get_number (CORBA::Long l, CORBA::Environment &) -{ - ACE_DEBUG ((LM_DEBUG, - "(%P | %t):POA_AMI_Simple_Server_Handler::get_number = %d\n", - l)); -} +CORBA::Boolean _tao_thru_poa_collocated_AMI_Simple_Server_Handler::_is_a( + const CORBA::Char *logical_type_id, + CORBA_Environment &ACE_TRY_ENV + ) -void -POA_AMI_Simple_Server_Handler::get_number_skel (CORBA::ServerRequest &_tao_server_request, - void *_tao_object_reference, - void *_tao_context, - CORBA::Environment &ACE_TRY_ENV) { - TAO_InputCDR &_tao_in = _tao_server_request.incoming (); - POA_AMI_Simple_Server_Handler *_tao_impl = (POA_AMI_Simple_Server_Handler *)_tao_object_reference; - - CORBA::Long l; - if (!( - (_tao_in >> l) - )) - ACE_THROW (CORBA::MARSHAL () ); - - _tao_impl->get_number ( - l); - ACE_CHECK; - _tao_server_request.init_reply (ACE_TRY_ENV); + TAO_Object_Adapter::Servant_Upcall servant_upcall ( + *this->_stubobj ()->servant_orb_var ()->orb_core ()->object_adapter () + ); + servant_upcall.prepare_for_upcall ( + this->_object_key (), + "_is_a", + ACE_TRY_ENV + ); + ACE_CHECK_RETURN (0); + return ACE_reinterpret_cast ( + POA_AMI_Simple_Server_Handler_ptr, + servant_upcall.servant ()->_downcast ( + "IDL:AMI_Simple_Server_Handler:1.0" + ) + )->_is_a (logical_type_id, ACE_TRY_ENV); } -// ********************************************************************* -_tao_collocated_AMI_Simple_Server_Handler::_tao_collocated_AMI_Simple_Server_Handler ( - POA_AMI_Simple_Server_Handler_ptr servant, - TAO_Stub *stub +CORBA::Boolean _tao_thru_poa_collocated_AMI_Simple_Server_Handler::_non_existent( + CORBA_Environment &ACE_TRY_ENV ) - : AMI_Simple_Server_Handler (), - CORBA_Object (stub, servant, 1), - servant_ (servant) + { + TAO_Object_Adapter::Servant_Upcall servant_upcall ( + *this->_stubobj ()->servant_orb_var ()->orb_core ()->object_adapter () + ); + servant_upcall.prepare_for_upcall ( + this->_object_key (), + "_non_existent", + ACE_TRY_ENV + ); + ACE_CHECK_RETURN (0); + return ACE_reinterpret_cast ( + POA_AMI_Simple_Server_Handler_ptr, + servant_upcall.servant ()->_downcast ( + "IDL:AMI_Simple_Server_Handler:1.0" + ) + )->_non_existent (ACE_TRY_ENV); } -CORBA::Boolean _tao_collocated_AMI_Simple_Server_Handler::_is_a( - const CORBA::Char *logical_type_id, - CORBA_Environment &ACE_TRY_ENV + +void _tao_thru_poa_collocated_AMI_Simple_Server_Handler::get_put_number ( + CORBA::Long _tao_retval, + CORBA::Long out_l, + CORBA::Environment &ACE_TRY_ENV ) + ACE_THROW_SPEC ((CORBA::SystemException)) { - if (this->_stubobj ()->orb_core ()->get_collocation_strategy () == TAO_ORB_Core::THRU_POA) - { - TAO_Object_Adapter::Servant_Upcall servant_upcall ( - *this->_stubobj ()->servant_orb_var ()->orb_core ()->object_adapter () - ); - servant_upcall.prepare_for_upcall ( - this->_object_key (), - "_is_a", - ACE_TRY_ENV - ); - ACE_CHECK_RETURN (0); - return ACE_reinterpret_cast ( - POA_AMI_Simple_Server_Handler_ptr, - servant_upcall.servant ()->_downcast ( - "IDL:AMI_Simple_Server_Handler:1.0" - ) - )->_is_a (logical_type_id, ACE_TRY_ENV); - } - return this->servant_->_is_a (logical_type_id, ACE_TRY_ENV); + TAO_Object_Adapter::Servant_Upcall servant_upcall ( + *this->_stubobj ()->servant_orb_var ()->orb_core ()->object_adapter () + ); + servant_upcall.prepare_for_upcall ( + this->_object_key (), + "get_put_number", + ACE_TRY_ENV + ); + ACE_CHECK; + ACE_reinterpret_cast ( + POA_AMI_Simple_Server_Handler_ptr, + servant_upcall.servant ()->_downcast ( + "IDL:AMI_Simple_Server_Handler:1.0" + ) + )->get_put_number ( + _tao_retval, + out_l, + ACE_TRY_ENV + ); + return; } +void _tao_thru_poa_collocated_AMI_Simple_Server_Handler::shutdown ( + CORBA::Environment &ACE_TRY_ENV + ) + ACE_THROW_SPEC ((CORBA::SystemException)) -POA_AMI_Simple_Server_Handler_ptr _tao_collocated_AMI_Simple_Server_Handler::_get_servant (void) const { - return this->servant_; + TAO_Object_Adapter::Servant_Upcall servant_upcall ( + *this->_stubobj ()->servant_orb_var ()->orb_core ()->object_adapter () + ); + servant_upcall.prepare_for_upcall ( + this->_object_key (), + "shutdown", + ACE_TRY_ENV + ); + ACE_CHECK; + ACE_reinterpret_cast ( + POA_AMI_Simple_Server_Handler_ptr, + servant_upcall.servant ()->_downcast ( + "IDL:AMI_Simple_Server_Handler:1.0" + ) + )->shutdown ( + ACE_TRY_ENV + ); + return; } -CORBA::Boolean _tao_collocated_AMI_Simple_Server_Handler::_non_existent( - CORBA_Environment &ACE_TRY_ENV - ) + +Simple_Server_ptr (*_TAO_collocation_Simple_Server_Stub_Factory_function_pointer) ( + CORBA::Object_ptr obj + ) = 0; +AMI_Simple_Server_Handler_ptr (*_TAO_collocation_AMI_Simple_Server_Handler_Stub_Factory_function_pointer) ( + CORBA::Object_ptr obj + ) = 0; +void operator<<= (CORBA::Any &_tao_any, Simple_Server_ptr _tao_elem) { - if (this->_stubobj ()->orb_core ()->get_collocation_strategy () == TAO_ORB_Core::THRU_POA) - { - TAO_Object_Adapter::Servant_Upcall servant_upcall ( - *this->_stubobj ()->servant_orb_var ()->orb_core ()->object_adapter () - ); - servant_upcall.prepare_for_upcall ( - this->_object_key (), - "_non_existent", - ACE_TRY_ENV - ); - ACE_CHECK_RETURN (0); - return ACE_reinterpret_cast ( - POA_AMI_Simple_Server_Handler_ptr, - servant_upcall.servant ()->_downcast ( - "IDL:AMI_Simple_Server_Handler:1.0" - ) - )->_non_existent (ACE_TRY_ENV); - } - return this->servant_->_non_existent (ACE_TRY_ENV); + CORBA::Object_ptr *_tao_obj_ptr = 0; + ACE_TRY_NEW_ENV + { + ACE_NEW (_tao_obj_ptr, CORBA::Object_ptr); + *_tao_obj_ptr = Simple_Server::_duplicate (_tao_elem); + _tao_any.replace (_tc_Simple_Server, _tao_obj_ptr, 1, ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + delete _tao_obj_ptr; + } + ACE_ENDTRY; } -void -_tao_collocated_AMI_Simple_Server_Handler::get_number (CORBA::Long l, CORBA::Environment &) +CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, Simple_Server_ptr &_tao_elem) { - ACE_DECLARE_NEW_CORBA_ENV; - - if (this->_stubobj ()->orb_core ()->get_collocation_strategy () == TAO_ORB_Core::THRU_POA) + CORBA::Object_ptr *tmp = 0; + ACE_TRY_NEW_ENV + { + _tao_elem = Simple_Server::_nil (); + CORBA::TypeCode_var type = _tao_any.type (); + if (!type->equal (_tc_Simple_Server, ACE_TRY_ENV)) return 0; // not equal + ACE_TRY_CHECK; + TAO_InputCDR stream (_tao_any._tao_get_cdr ()); + CORBA::Object_var _tao_obj_var; + ACE_NEW_RETURN (tmp, CORBA::Object_ptr, 0); + if (stream.decode (_tc_Simple_Server, &_tao_obj_var.out (), 0, ACE_TRY_ENV) + == CORBA::TypeCode::TRAVERSE_CONTINUE) { - TAO_Object_Adapter::Servant_Upcall servant_upcall ( - *this->_stubobj ()->servant_orb_var ()->orb_core ()->object_adapter () - ); - servant_upcall.prepare_for_upcall ( - this->_object_key (), - "get_number", - ACE_TRY_ENV - ); - ACE_CHECK; - ACE_reinterpret_cast ( - POA_AMI_Simple_Server_Handler_ptr, - servant_upcall.servant ()->_downcast ( - "IDL:AMI_Simple_Server_Handler:1.0" - ) - )->get_number ( - l); - return; + _tao_elem = Simple_Server::_narrow (_tao_obj_var.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + *tmp = (CORBA::Object_ptr) _tao_elem; // any owns the object + ((CORBA::Any *)&_tao_any)->replace (_tc_Simple_Server, tmp, 1, ACE_TRY_ENV); + ACE_TRY_CHECK; + return 1; } - this->servant_->get_number ( - l ); - + // failure + } + ACE_CATCHANY + { + delete tmp; + return 0; + } + ACE_ENDTRY; + return 0; } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - template class TAO_Object_Field_T<Simple_Server>; - template class TAO_Object_Field_T<AMI_Simple_Server_Handler>; - #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - # pragma instantiate TAO_Object_Field_T<Simple_Server> - # pragma instantiate TAO_Object_Field_T<AMI_Simple_Server_Handler> - #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - + template class TAO_Object_Field_T<Simple_Server,Simple_Server_var>; +template class TAO_Object_Manager<Simple_Server,Simple_Server_var>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +# pragma instantiate TAO_Object_Field_T<Simple_Server,Simple_Server_var> +# pragma instantiate TAO_Object_Manager<Simple_Server,Simple_Server_var> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/tests/AMI/test.idl b/TAO/tests/AMI/test.idl index 376da4a58c6..8fa715984b1 100644 --- a/TAO/tests/AMI/test.idl +++ b/TAO/tests/AMI/test.idl @@ -4,13 +4,9 @@ interface Simple_Server { - // void test_method (); - - long get_number (); - - // void put_number (in long l); - - // long get_put_number (out long out_l, in long in_l); - - // oneway void shutdown (); + long get_put_number (out long out_l, in long in_l); + // Get the number as the return value as well as the out value and + // also puts the value. + + oneway void shutdown (); }; diff --git a/TAO/tests/AMI/test_i.cpp b/TAO/tests/AMI/test_i.cpp index 1b199315a26..19e5d65be99 100644 --- a/TAO/tests/AMI/test_i.cpp +++ b/TAO/tests/AMI/test_i.cpp @@ -9,36 +9,6 @@ ACE_RCSID(MT_Client, test_i, "$Id$") -void -Simple_Server_i::test_method (CORBA::Environment&) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "%N:%l:(%P:%t):Simple_Server_i::test_method called\n")); -} - -CORBA::Long -Simple_Server_i::get_number (CORBA::Environment&) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "%N:%l:(%P:%t):Simple_Server_i::get_number called\n")); - return this->number_++; -} - -void -Simple_Server_i::put_number (CORBA::Long l, - CORBA::Environment &) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "%N:%l:(%P:%t):Simple_Server_i::put_number: %d\n", - l)); -} - CORBA::Long Simple_Server_i::get_put_number (CORBA::Long_out out_l, CORBA::Long in_l, diff --git a/TAO/tests/AMI/test_i.h b/TAO/tests/AMI/test_i.h index c050a2795d8..b6567cec81e 100644 --- a/TAO/tests/AMI/test_i.h +++ b/TAO/tests/AMI/test_i.h @@ -31,21 +31,11 @@ public: // ctor // = The Simple_Server methods. - void test_method (CORBA::Environment&) - ACE_THROW_SPEC ((CORBA::SystemException)); - - CORBA::Long get_number (CORBA::Environment&) - ACE_THROW_SPEC ((CORBA::SystemException)); - - void put_number (CORBA::Long l, - CORBA::Environment &) - ACE_THROW_SPEC ((CORBA::SystemException)); - CORBA::Long get_put_number (CORBA::Long_out out_l, CORBA::Long in_l, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)); - + void shutdown (CORBA::Environment&) ACE_THROW_SPEC ((CORBA::SystemException)); |