3 #include "tao/AnyTypeCode/Any.h"
4 #include "tao/AnyTypeCode/NVList.h"
5 #include "tao/AnyTypeCode/ExceptionA.h"
7 #include "tao/IFR_Client/IFR_BasicC.h"
9 #include "tao/DynamicInterface/Server_Request.h"
10 #include "tao/DynamicInterface/Request.h"
11 #include "tao/DynamicInterface/Unknown_User_Exception.h"
14 #include "tao/LocalObject.h"
17 Gateway_i (CORBA::ORB_ptr orb
,
18 PortableServer::Current_ptr poa_current
)
20 poa_current_ (poa_current
)
26 Gateway_i::invoke (CORBA::ServerRequest_ptr request
)
28 PortableServer::ObjectId_var target_id
=
29 this->poa_current_
->get_object_id ();
31 CORBA::String_var stringified_object_id
=
32 PortableServer::ObjectId_to_string (target_id
.in ());
34 CORBA::Object_var target_object
=
35 this->orb_
->string_to_object (stringified_object_id
.in ());
37 // Use the IfR interfaces to query the NVList for this object...
38 CORBA::InterfaceDef_var target_interface
=
39 target_object
->_get_interface ();
41 if (CORBA::is_nil (target_interface
.in ()))
46 // This is the target operation...
47 CORBA::String_var operation_name
=
48 request
->operation ();
50 CORBA::Contained_var contained_operation
=
51 target_interface
->lookup (operation_name
.in ());
53 CORBA::OperationDef_var operation
=
54 CORBA::OperationDef::_narrow (contained_operation
.in ());
56 // Save the result typecode...
57 CORBA::TypeCode_var result_typecode
=
58 operation
.in ()->result ();
60 CORBA::ParDescriptionSeq_var parameters
=
61 operation
.in ()->params ();
63 // Build the NVList based on the info from the IfR
64 CORBA::NVList_ptr arguments
;
65 this->orb_
->create_list (parameters
->length (),
68 CORBA::Flags flags
= 0;
70 CORBA::ULong length
= parameters
->length ();
74 for (i
= 0; i
< length
; ++i
)
76 switch (parameters
[i
].mode
)
79 flags
= CORBA::ARG_IN
;
81 case CORBA::PARAM_OUT
:
82 flags
= CORBA::ARG_OUT
;
84 case CORBA::PARAM_INOUT
:
85 flags
= CORBA::ARG_INOUT
;
90 for (i
= 0; i
!= length
; ++i
)
93 any
._tao_set_typecode (parameters
[i
].type
.in ());
95 arguments
->add_value (parameters
[i
].name
,
100 // Extract the values of the arguments from the DSI ServerRequest
101 request
->arguments (arguments
);
103 // Use the NVList (with values) to create a DII Request...
104 CORBA::Request_var dii_request
;
106 CORBA::NamedValue
*named_value
= 0;
108 this->orb_
->create_named_value (named_value
);
110 CORBA::ContextList
*context_list
= 0;
111 CORBA::ExceptionList
*exceptions
= 0;
113 target_object
->_create_request (CORBA::Context::_nil (),
114 operation_name
.in (),
116 named_value
, /* Result */
118 context_list
, /* Context List */
119 dii_request
.inout (),
122 // Set the return type...
123 dii_request
->set_return_type (result_typecode
.in ());
127 // Make the DII request
128 dii_request
->invoke ();
130 // At this point the NVList contains all the out and inout
131 // arguments, but we need to extract the return value...
133 catch (CORBA::UnknownUserException
& user_ex
)
135 // Pass the exception back to the server request...
136 request
->set_exception (user_ex
.exception ());
139 catch (const CORBA::SystemException
& sys_ex
)
143 // Pass the exception back to the server request...
144 request
->set_exception (any
);
147 catch (const CORBA::Exception
&)
151 request
->set_result (dii_request
->return_value ());
152 // Using the same NVList for both the DSI Server Request and the DII
153 // Request takes care of the out and inout arguments (whew!)
157 Gateway_i::_primary_interface (const PortableServer::ObjectId
&,
158 PortableServer::POA_ptr
)