DII_Arguments_Converter_Impl.cpp

Go to the documentation of this file.
00001 // $Id: DII_Arguments_Converter_Impl.cpp 78248 2007-05-02 14:03:48Z johnnyw $
00002 #include "tao/DynamicInterface/DII_Arguments_Converter_Impl.h"
00003 #include "tao/DynamicInterface/DII_Arguments.h"
00004 #include "tao/AnyTypeCode/NVList.h"
00005 #include "tao/AnyTypeCode/Any_Impl.h"
00006 #include "tao/operation_details.h"
00007 #include "tao/SystemException.h"
00008 
00009 ACE_RCSID (DynamicInterface,
00010            DII_Arguments_Converter_Impl,
00011            "$Id: DII_Arguments_Converter_Impl.cpp 78248 2007-05-02 14:03:48Z johnnyw $")
00012 
00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00014 
00015 void
00016 TAO_DII_Arguments_Converter_Impl::convert_request (
00017     TAO_ServerRequest & server_request,
00018     TAO::Argument * const args[],
00019     size_t nargs)
00020 {
00021   // The DII requests on client side always have two arguments
00022   // - one is the return argument and the other is NVList_Argument.
00023   // Since the argument list in the client side is used by server side
00024   // in collocation case and the server expects the list of arguments
00025   // and not the NVList_Argument, we need expand the NVList_Argument
00026   // to be list of Arguments.
00027 
00028   // Before expanding NVList_Argument logic was added, the
00029   // $TAO_ROOT/tests/DII_Collocated_Tests/run_test.pl should fail.
00030   // The servant will get incorrect "IN" parameter from the oneway
00031   // operation with single "IN" parameter and get access violation on
00032   // get_in_arg () from the oneway operation with multiple "IN"
00033   // parameters.
00034   CORBA::NVList_ptr lst
00035     = static_cast<TAO::NVList_Argument *> (
00036         server_request.operation_details ()->args()[1])->arg ();
00037 
00038   CORBA::ULong const sz = lst->count ();
00039 
00040   if (sz != nargs - 1)
00041     {
00042       throw ::CORBA::BAD_PARAM ();
00043     }
00044 
00045   // To avoid the use of extraction operators on CORBA::Any, we will
00046   // marshal the arguments in the NVList into an output cdr and then
00047   // demarshal them into the TAO::Argument array.
00048   TAO_OutputCDR output;
00049   for (CORBA::ULong i = 0; i < sz; ++i)
00050     {
00051       CORBA::NamedValue_ptr theitem = lst->item (i);
00052 
00053       if (!(theitem->value ()->impl ()->marshal_value (output)))
00054         {
00055           throw ::CORBA::BAD_PARAM ();
00056         }
00057     }
00058 
00059   TAO_InputCDR input (output);
00060   for (CORBA::ULong j = 0; j < sz; ++j)
00061     {
00062       if (!(args[j + 1]->demarshal (input)))
00063         {
00064           throw ::CORBA::BAD_PARAM ();
00065         }
00066     }
00067 
00068   TAO_Operation_Details* details
00069     = const_cast <TAO_Operation_Details*> (server_request.operation_details ());
00070 
00071   // The NVList_Argument in operation details is converted to skel
00072   // args, the invocation of the dii collocation requests should use
00073   // the skel args and not use the stub args.
00074   details->use_stub_args (false);
00075 }
00076 
00077 void
00078 TAO_DII_Arguments_Converter_Impl::convert_reply (
00079     TAO_ServerRequest & /* server_request */,
00080     TAO::Argument * const /*args*/[],
00081     size_t /*nargs*/)
00082 {
00083 }
00084 
00085 void
00086 TAO_DII_Arguments_Converter_Impl::handle_corba_exception (
00087   TAO_ServerRequest & /*server_request*/,
00088   CORBA::Exception *exception)
00089 {
00090   exception->_raise ();
00091 }
00092 
00093 // *********************************************************************
00094 
00095 // Initialization and registration of dynamic service object.
00096 
00097 int
00098 TAO_DII_Arguments_Converter_Impl::Initializer (void)
00099 {
00100   return ACE_Service_Config::process_directive (
00101     ace_svc_desc_TAO_DII_Arguments_Converter_Impl);
00102 }
00103 
00104 
00105 TAO_END_VERSIONED_NAMESPACE_DECL
00106 
00107 ACE_STATIC_SVC_DEFINE (
00108   TAO_DII_Arguments_Converter_Impl,
00109   ACE_TEXT ("DII_Arguments_Converter"),
00110   ACE_SVC_OBJ_T,
00111   &ACE_SVC_NAME (TAO_DII_Arguments_Converter_Impl),
00112   ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00113   0
00114   )
00115 
00116 ACE_FACTORY_DEFINE (TAO_DynamicInterface, TAO_DII_Arguments_Converter_Impl)
00117 

Generated on Sun Jan 27 13:37:31 2008 for TAO_DynamicInterface by doxygen 1.3.6