summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-05-09 19:17:40 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-05-09 19:17:40 +0000
commita2259435d681f62d0d4737d086ff320c7e18b9d2 (patch)
tree18912b5f35bd95025e15272731072a8ecf69ca59
parenta1ac70398b1947bbd5de358e33490b4f9343b08d (diff)
downloadATCD-a2259435d681f62d0d4737d086ff320c7e18b9d2.tar.gz
ChangeLogTag: Wed May 09 14:07:56 2001 Jeff Parsons <parsons@cs.wustl.edu>
-rw-r--r--TAO/tao/DynamicInterface/DII_Invocation.cpp6
-rw-r--r--TAO/tao/DynamicInterface/DII_Invocation.h5
-rw-r--r--TAO/tao/DynamicInterface/DII_Invocation.inl4
-rw-r--r--TAO/tao/DynamicInterface/Request.cpp1
-rw-r--r--TAO/tao/DynamicInterface/Request.h11
-rw-r--r--TAO/tao/DynamicInterface/Request.inl14
-rw-r--r--TAO/tao/DynamicInterface/Server_Request.cpp34
-rw-r--r--TAO/tao/DynamicInterface/Server_Request.h7
-rw-r--r--TAO/tests/DSI_Gateway/DSI_Gateway_Service.dsp113
-rw-r--r--TAO/tests/DSI_Gateway/README34
-rw-r--r--TAO/tests/DSI_Gateway/client.cpp119
-rw-r--r--TAO/tests/DSI_Gateway/gateway.cpp62
-rwxr-xr-xTAO/tests/DSI_Gateway/run_exception_test.pl73
-rw-r--r--TAO/tests/DSI_Gateway/server.cpp41
-rw-r--r--TAO/tests/DSI_Gateway/test.idl11
-rw-r--r--TAO/tests/DSI_Gateway/test_dsi.cpp22
-rw-r--r--TAO/tests/DSI_Gateway/test_dsi.h24
-rw-r--r--TAO/tests/DSI_Gateway/test_dsi.i4
-rw-r--r--TAO/tests/DSI_Gateway/test_i.cpp17
-rw-r--r--TAO/tests/DSI_Gateway/test_i.h11
20 files changed, 392 insertions, 221 deletions
diff --git a/TAO/tao/DynamicInterface/DII_Invocation.cpp b/TAO/tao/DynamicInterface/DII_Invocation.cpp
index c219b68d541..d29992ccfee 100644
--- a/TAO/tao/DynamicInterface/DII_Invocation.cpp
+++ b/TAO/tao/DynamicInterface/DII_Invocation.cpp
@@ -85,7 +85,11 @@ TAO_GIOP_DII_Invocation::invoke (CORBA::ExceptionList_ptr exceptions,
}
// If we couldn't find the right exception, report it as
- // CORBA::UNKNOWN.
+ // CORBA::UNKNOWN.
+
+ // But first, save the user exception in case we
+ // are being used in a TAO gateway.
+ this->host_->raw_user_exception (this->inp_stream ());
// @@ It would seem that if the remote exception is a
// UserException we can assume that the request was
diff --git a/TAO/tao/DynamicInterface/DII_Invocation.h b/TAO/tao/DynamicInterface/DII_Invocation.h
index e25d13956b6..dfa7fe2ddd9 100644
--- a/TAO/tao/DynamicInterface/DII_Invocation.h
+++ b/TAO/tao/DynamicInterface/DII_Invocation.h
@@ -50,6 +50,7 @@ public:
CORBA::ULong opname_len,
CORBA::Boolean argument_flag,
TAO_ORB_Core *orb_core,
+ CORBA::Request_ptr host,
int byte_order = TAO_ENCAP_BYTE_ORDER);
// Constructor.
@@ -59,6 +60,10 @@ public:
ACE_THROW_SPEC ((CORBA::SystemException,CORBA::UnknownUserException));
// Send request, block until any reply comes back, and unmarshal
// reply parameters as appropriate.
+
+private:
+ CORBA::Request_ptr host_;
+ // Back pointer to the DII request that created us.
};
class TAO_DynamicInterface_Export TAO_GIOP_DII_Deferred_Invocation
diff --git a/TAO/tao/DynamicInterface/DII_Invocation.inl b/TAO/tao/DynamicInterface/DII_Invocation.inl
index ce9cb080b4e..0ea9c1448a4 100644
--- a/TAO/tao/DynamicInterface/DII_Invocation.inl
+++ b/TAO/tao/DynamicInterface/DII_Invocation.inl
@@ -9,13 +9,15 @@ TAO_GIOP_DII_Invocation::TAO_GIOP_DII_Invocation (TAO_Stub *data,
CORBA::ULong opname_len,
CORBA::Boolean argument_flag,
TAO_ORB_Core *orb_core,
+ CORBA::Request_ptr host,
int byte_order)
: TAO_GIOP_Twoway_Invocation (data,
operation,
opname_len,
argument_flag,
orb_core,
- byte_order)
+ byte_order),
+ host_ (host)
{
}
diff --git a/TAO/tao/DynamicInterface/Request.cpp b/TAO/tao/DynamicInterface/Request.cpp
index cd05ee27d04..27aa0cc686e 100644
--- a/TAO/tao/DynamicInterface/Request.cpp
+++ b/TAO/tao/DynamicInterface/Request.cpp
@@ -150,6 +150,7 @@ CORBA_Request::invoke (CORBA::Environment &ACE_TRY_ENV)
ACE_OS::strlen (this->opname_),
argument_flag,
this->orb_->orb_core (),
+ this,
this->byte_order_);
// Loop as needed for forwarding.
diff --git a/TAO/tao/DynamicInterface/Request.h b/TAO/tao/DynamicInterface/Request.h
index 9d3740fea7a..16d5225237a 100644
--- a/TAO/tao/DynamicInterface/Request.h
+++ b/TAO/tao/DynamicInterface/Request.h
@@ -147,6 +147,13 @@ public:
void _tao_byte_order (int byte_order);
// Set the byte order member.
+ void raw_user_exception (TAO_InputCDR &cdr);
+ // Hold on to a user exception in case we are part of
+ // a TAO gateway.
+
+ ACE_CString &raw_user_exception (void);
+ // Accessor for the input stream containing the exception.
+
#if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8
typedef CORBA_Request_ptr _ptr_type;
typedef CORBA_Request_var _var_type;
@@ -221,6 +228,10 @@ private:
int byte_order_;
// Can be reset by a gateway when passing along a request.
+
+ ACE_CString raw_user_exception_;
+ // Stores user exception as a CDR stream when this request is
+ // used in a TAO gateway.
};
typedef CORBA_Request* CORBA_Request_ptr;
diff --git a/TAO/tao/DynamicInterface/Request.inl b/TAO/tao/DynamicInterface/Request.inl
index 9b217fd664c..71038d5a6ae 100644
--- a/TAO/tao/DynamicInterface/Request.inl
+++ b/TAO/tao/DynamicInterface/Request.inl
@@ -147,6 +147,20 @@ CORBA_Request::_tao_byte_order (int byte_order)
this->byte_order_ = byte_order;
}
+ACE_INLINE void
+CORBA_Request::raw_user_exception (TAO_InputCDR &cdr)
+{
+ this->raw_user_exception_.set (cdr.start ()->rd_ptr (),
+ cdr.start ()->length (),
+ 1);
+}
+
+ACE_INLINE ACE_CString &
+CORBA_Request::raw_user_exception (void)
+{
+ return this->raw_user_exception_;
+}
+
// *************************************************************
// Inline operations for class CORBA_Request_var
// *************************************************************
diff --git a/TAO/tao/DynamicInterface/Server_Request.cpp b/TAO/tao/DynamicInterface/Server_Request.cpp
index dcb3fab53c8..d6913f2b1e8 100644
--- a/TAO/tao/DynamicInterface/Server_Request.cpp
+++ b/TAO/tao/DynamicInterface/Server_Request.cpp
@@ -57,7 +57,8 @@ CORBA_ServerRequest::CORBA_ServerRequest (
retval_ (0),
exception_ (0),
refcount_ (1),
- orb_server_request_ (orb_server_request)
+ orb_server_request_ (orb_server_request),
+ sent_gateway_exception_ (0)
{
this->orb_server_request_.is_dsi ();
}
@@ -153,6 +154,12 @@ CORBA_ServerRequest::set_exception (const CORBA::Any &value,
void
CORBA_ServerRequest::dsi_marshal (CORBA::Environment &ACE_TRY_ENV)
{
+ // There was a user exception, no need to marshal any parameters.
+ if (this->sent_gateway_exception_)
+ {
+ return;
+ }
+
if (this->orb_server_request_.exception_type () == TAO_GIOP_NO_EXCEPTION)
{
// In DSI, we can't rely on the skeleton to do this.
@@ -205,3 +212,28 @@ CORBA_ServerRequest::dsi_marshal (CORBA::Environment &ACE_TRY_ENV)
this->orb_server_request_.tao_send_reply ();
}
+void
+CORBA_ServerRequest::gateway_exception_reply (ACE_CString &raw_exception)
+{
+ // This defaults to 1, but just to be safe...
+ this->orb_server_request_.argument_flag (1);
+
+ // This reply path handles only user exceptions.
+ this->orb_server_request_.exception_type (TAO_GIOP_USER_EXCEPTION);
+
+ this->orb_server_request_.init_reply ();
+
+ // We know nothing about this exception, so we marshal it as a block
+ // of bytes. The outgoing stream's byte order has already been matched
+ // to the original source of the reply.
+ this->orb_server_request_.outgoing ().write_octet_array (
+ ACE_static_cast (CORBA::Octet *, raw_exception.fast_rep ()),
+ raw_exception.length () + ACE_CDR::MAX_ALIGNMENT
+ );
+
+ // This will prevent the marshaling of any parameters into this reply.
+ this->sent_gateway_exception_ = 1;
+
+ this->orb_server_request_.tao_send_reply ();
+}
+
diff --git a/TAO/tao/DynamicInterface/Server_Request.h b/TAO/tao/DynamicInterface/Server_Request.h
index a42bdabc259..44b98d6bc9f 100644
--- a/TAO/tao/DynamicInterface/Server_Request.h
+++ b/TAO/tao/DynamicInterface/Server_Request.h
@@ -116,6 +116,10 @@ public:
void _tao_reply_byte_order (int byte_order);
// Set the byte order of the outgoing CDR stream.
+ void gateway_exception_reply (ACE_CString &raw_exception);
+ // Returns a user exception through a TAO gateway without
+ // knowing its type.
+
#if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8
typedef CORBA::ServerRequest_ptr _ptr_type;
#endif /* __GNUC__ */
@@ -145,6 +149,9 @@ private:
TAO_ServerRequest &orb_server_request_;
// Request from the ORB.
+
+ int sent_gateway_exception_;
+ // Have we sent a user exception obtained from a gateway?
};
#if defined (__ACE_INLINE__)
diff --git a/TAO/tests/DSI_Gateway/DSI_Gateway_Service.dsp b/TAO/tests/DSI_Gateway/DSI_Gateway_Service.dsp
index 9d595df8818..a7220ebf358 100644
--- a/TAO/tests/DSI_Gateway/DSI_Gateway_Service.dsp
+++ b/TAO/tests/DSI_Gateway/DSI_Gateway_Service.dsp
@@ -95,14 +95,6 @@ SOURCE=.\gateway.cpp
SOURCE=.\test_dsi.cpp
# End Source File
-# Begin Source File
-
-SOURCE=.\testC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\testS.cpp
-# End Source File
# End Group
# Begin Group "Header Files"
@@ -111,14 +103,6 @@ SOURCE=.\testS.cpp
SOURCE=.\test_dsi.h
# End Source File
-# Begin Source File
-
-SOURCE=.\testC.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\testS.h
-# End Source File
# End Group
# Begin Group "Inline Files"
@@ -127,103 +111,6 @@ SOURCE=.\testS.h
SOURCE=.\test_dsi.i
# End Source File
-# Begin Source File
-
-SOURCE=.\testC.i
-# End Source File
-# Begin Source File
-
-SOURCE=.\testS.i
-# End Source File
-# End Group
-# Begin Group "IDL Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\test.idl
-
-!IF "$(CFG)" == "DSI_Gateway_Service - Win32 Release"
-
-# PROP Ignore_Default_Tool 1
-USERDEP__TEST_="..\..\..\bin\Release\tao_idl.exe"
-# Begin Custom Build - Invoking TAO IDL Compiler on $(InputPath)
-InputPath=.\test.idl
-InputName=test
-
-BuildCmds= \
- ..\..\..\bin\Release\tao_idl.exe -Ge 1 $(InputName).idl
-
-"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "DSI_Gateway_Service - Win32 Debug"
-
-# PROP Ignore_Default_Tool 1
-USERDEP__TEST_="..\..\..\bin\tao_idl.exe"
-# Begin Custom Build - Invoking TAO IDL Compiler on $(InputPath)
-InputPath=.\test.idl
-InputName=test
-
-BuildCmds= \
- ..\..\..\bin\tao_idl.exe -Ge 1 $(InputName).idl
-
-"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-# End Custom Build
-
-!ENDIF
-
-# End Source File
# End Group
# End Target
# End Project
diff --git a/TAO/tests/DSI_Gateway/README b/TAO/tests/DSI_Gateway/README
index 04949630b5d..cbdc07df1dc 100644
--- a/TAO/tests/DSI_Gateway/README
+++ b/TAO/tests/DSI_Gateway/README
@@ -2,14 +2,34 @@
A simple test for the DSI/DII gateway support. TAO can
optimize some demarshaling/marshaling and data copying in the
-implementation of DSI/DII based gateways.
+implementation of DSI/DII based gateways. The DSI/DII gateway can
+also pass requests and replies that are not in native (the
+gateway's) byte order.
- This is a smoke test and simple example for those features.
+ This is a smoke test and simple example for those
+features. Use
- Use:
+ $ server -o server.ior
+ $ gateway -k file://server.ior -o gw.ior
+ $ client -k file://gw.ior -i 100 -x
-$ server -o server.ior
-$ gateway -k file://server.ior -o gw.ior
-$ client -k file://gw.ior -i 100 -x
+or run the run_test.pl script.
- or run the run_test.pl script.
+ A second perl script, run_exception_test.pl,
+tests the exception handling of the gateway. The script
+runs the client twice, first calling a method that raises
+a user exception (containing several fields of information),
+then calling a method that raises a CORBA system exception.
+
+ To run these tests by hand, start the server and gateway
+as shown above, then use
+
+ $ client -k file://gw.ior -u
+
+for the user exception test and
+
+ $ client -k file://gw.ior -s
+
+for the system exception test. For these tests, the -x
+option (server shutdown) and -i option (# of calls)
+are inoperative. \ No newline at end of file
diff --git a/TAO/tests/DSI_Gateway/client.cpp b/TAO/tests/DSI_Gateway/client.cpp
index e81a70270e4..238c2ce1b76 100644
--- a/TAO/tests/DSI_Gateway/client.cpp
+++ b/TAO/tests/DSI_Gateway/client.cpp
@@ -10,11 +10,13 @@ ACE_RCSID(DSI_Gateway, client, "$Id$")
const char *ior = "file://gateway.ior";
int niterations = 5;
int do_shutdown = 0;
+int test_user_exception = 0;
+int test_system_exception = 0;
int
parse_args (int argc, char *argv[])
{
- ACE_Get_Opt get_opts (argc, argv, "xk:i:");
+ ACE_Get_Opt get_opts (argc, argv, "xusk:i:");
int c;
while ((c = get_opts ()) != -1)
@@ -24,6 +26,14 @@ parse_args (int argc, char *argv[])
do_shutdown = 1;
break;
+ case 'u':
+ test_user_exception = 1;
+ break;
+
+ case 's':
+ test_system_exception = 1;
+ break;
+
case 'k':
ior = get_opts.optarg;
break;
@@ -36,12 +46,16 @@ parse_args (int argc, char *argv[])
default:
ACE_ERROR_RETURN ((LM_ERROR,
"usage: %s "
+ "-x "
+ "-u "
+ "-s "
"-k <ior> "
"-i <niterations> "
"\n",
argv [0]),
-1);
}
+
// Indicates sucessful parsing of the command line
return 0;
}
@@ -56,7 +70,9 @@ main (int argc, char *argv[])
ACE_TRY_CHECK;
if (parse_args (argc, argv) != 0)
- return 1;
+ {
+ return 1;
+ }
CORBA::Object_var object =
orb->string_to_object (ior, ACE_TRY_ENV);
@@ -77,40 +93,53 @@ main (int argc, char *argv[])
Structure the_in_structure;
the_in_structure.seq.length (10);
- for (int i = 0; i != niterations; ++i)
+ if (test_user_exception == 1)
{
- the_in_structure.i = i;
- CORBA::String_var name = CORBA::string_dup ("the name");
-
- Structure_var the_out_structure;
-
- CORBA::Long r =
- server->test_method (i,
- the_in_structure,
- the_out_structure.out (),
- name.inout (),
- ACE_TRY_ENV);
+ server->raise_user_exception (ACE_TRY_ENV);
ACE_TRY_CHECK;
-
- if (TAO_debug_level > 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- "DSI_Simpler_Server ====\n"
- " x = %d\n"
- " i = %d\n"
- " length = %d\n"
- " name = <%s>\n",
- r,
- the_out_structure->i,
- the_out_structure->seq.length (),
- name.in ()));
- }
-
- if (r != i)
+ }
+ else if (test_system_exception == 1)
+ {
+ server->raise_system_exception (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+ else
+ {
+ for (int i = 0; i != niterations; ++i)
{
- ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) unexpected result = %d for %d",
- r, i));
+ the_in_structure.i = i;
+ CORBA::String_var name = CORBA::string_dup ("the name");
+
+ Structure_var the_out_structure;
+
+ CORBA::Long r =
+ server->test_method (i,
+ the_in_structure,
+ the_out_structure.out (),
+ name.inout (),
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ if (TAO_debug_level > 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "DSI_Simpler_Server ====\n"
+ " x = %d\n"
+ " i = %d\n"
+ " length = %d\n"
+ " name = <%s>\n",
+ r,
+ the_out_structure->i,
+ the_out_structure->seq.length (),
+ name.in ()));
+ }
+
+ if (r != i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) unexpected result = %d for %d",
+ r, i));
+ }
}
}
@@ -120,10 +149,32 @@ main (int argc, char *argv[])
ACE_TRY_CHECK;
}
}
+ ACE_CATCH (test_exception, ex)
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Client: exception caught - ");
+
+ ACE_DEBUG ((LM_DEBUG,
+ "error code: %d\n"
+ "error info: %s\n"
+ "status: %s\n",
+ ex.error_code,
+ ex.error_message,
+ ex.status_message));
+
+ return 0;
+ }
+ ACE_CATCH (CORBA::NO_PERMISSION, ex)
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Client: exception caught - ");
+
+ return 0;
+ }
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
- "Exception caught:");
+ "Client: exception caught - ");
return 1;
}
ACE_ENDTRY;
diff --git a/TAO/tests/DSI_Gateway/gateway.cpp b/TAO/tests/DSI_Gateway/gateway.cpp
index 439e3700fa5..8c639fcc85b 100644
--- a/TAO/tests/DSI_Gateway/gateway.cpp
+++ b/TAO/tests/DSI_Gateway/gateway.cpp
@@ -33,8 +33,8 @@ parse_args (int argc, char *argv[])
break;
case 'o':
- ior_output_file = get_opts.optarg;
- break;
+ ior_output_file = get_opts.optarg;
+ break;
case '?':
default:
@@ -43,11 +43,12 @@ parse_args (int argc, char *argv[])
"-x "
"-k <ior> "
"-i <niterations> "
- "-o <iorfile> "
+ "-o <iorfile> "
"\n",
argv [0]),
-1);
}
+
// Indicates sucessful parsing of the command line
return 0;
}
@@ -64,10 +65,13 @@ main (int argc, char *argv[])
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA", ACE_TRY_ENV);
ACE_TRY_CHECK;
+
if (CORBA::is_nil (poa_object.in ()))
- ACE_ERROR_RETURN ((LM_ERROR,
- " (%P|%t) Unable to initialize the POA.\n"),
- 1);
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to initialize the POA.\n"),
+ 1);
+ }
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in (), ACE_TRY_ENV);
@@ -81,26 +85,16 @@ main (int argc, char *argv[])
ACE_TRY_CHECK;
if (parse_args (argc, argv) != 0)
- return 1;
+ {
+ return 1;
+ }
CORBA::Object_var object =
orb->string_to_object (ior, ACE_TRY_ENV);
ACE_TRY_CHECK;
- Simple_Server_var target =
- Simple_Server::_narrow (object.in (), ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- if (CORBA::is_nil (target.in ()))
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "Object reference <%s> is nil\n",
- ior),
- 1);
- }
-
DSI_Simple_Server server_impl (orb.in (),
- target.in (),
+ object.in (),
root_poa.in ());
PortableServer::ObjectId_var oid =
root_poa->activate_object (&server_impl,
@@ -113,23 +107,27 @@ 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);
+ }
orb->run (ACE_TRY_ENV);
ACE_TRY_CHECK;
@@ -139,7 +137,7 @@ main (int argc, char *argv[])
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
- "Exception caught:");
+ "Gateway: exception caught - ");
return 1;
}
ACE_ENDTRY;
diff --git a/TAO/tests/DSI_Gateway/run_exception_test.pl b/TAO/tests/DSI_Gateway/run_exception_test.pl
new file mode 100755
index 00000000000..7ebeb4048f2
--- /dev/null
+++ b/TAO/tests/DSI_Gateway/run_exception_test.pl
@@ -0,0 +1,73 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+# $Id$
+# -*- perl -*-
+
+use lib '../../../bin';
+use PerlACE::Run_Test;
+
+$svfile = PerlACE::LocalFile ("server.ior");
+$gwfile = PerlACE::LocalFile ("gateway.ior");
+
+unlink $svfile;
+unlink $gwfile;
+
+$status = 0;
+
+$SV = new PerlACE::Process ("server", "-o $svfile");
+$GW = new PerlACE::Process ("gateway", "-k file://$svfile -o $gwfile");
+$CL = new PerlACE::Process ("client", "-k file://$gwfile -u");
+
+$SV->Spawn ();
+
+if (PerlACE::waitforfile_timed ($svfile, 5) == -1) {
+ print STDERR "ERROR: cannot find file <$svfile>\n";
+ $SV->Kill ();
+ exit 1;
+}
+
+$GW->Spawn ();
+
+if (PerlACE::waitforfile_timed ($gwfile, 5) == -1) {
+ print STDERR "ERROR: cannot find file <$gwfile>\n";
+ $SV->Kill ();
+ $GW->Kill ();
+ exit 1;
+}
+
+$client = $CL->SpawnWaitKill (60);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+}
+
+$CL = new PerlACE::Process ("client", "-k file://$gwfile -s");
+
+$client = $CL->SpawnWaitKill (60);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+}
+
+$server = $SV->Kill ();
+
+if ($server != 0) {
+ print STDERR "ERROR: server returned $server\n";
+ $status = 1;
+}
+
+$gateway = $GW->Kill ();
+
+if ($gateway != 0) {
+ print STDERR "ERROR: gateway returned $gateway\n";
+ $status = 1;
+}
+
+unlink $svfile;
+unlink $gwfile;
+
+exit $status;
diff --git a/TAO/tests/DSI_Gateway/server.cpp b/TAO/tests/DSI_Gateway/server.cpp
index fbc51b0d72b..72819309c96 100644
--- a/TAO/tests/DSI_Gateway/server.cpp
+++ b/TAO/tests/DSI_Gateway/server.cpp
@@ -52,10 +52,13 @@ main (int argc, char *argv[])
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA", ACE_TRY_ENV);
ACE_TRY_CHECK;
+
if (CORBA::is_nil (poa_object.in ()))
- ACE_ERROR_RETURN ((LM_ERROR,
- " (%P|%t) Unable to initialize the POA.\n"),
- 1);
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to initialize the POA.\n"),
+ 1);
+ }
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in (), ACE_TRY_ENV);
@@ -66,7 +69,9 @@ main (int argc, char *argv[])
ACE_TRY_CHECK;
if (parse_args (argc, argv) != 0)
- return 1;
+ {
+ return 1;
+ }
Simple_Server_i server_impl (orb.in ());
@@ -75,23 +80,27 @@ 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;
@@ -104,7 +113,7 @@ main (int argc, char *argv[])
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
- "Exception caught:");
+ "Server: exception caught - ");
return 1;
}
ACE_ENDTRY;
diff --git a/TAO/tests/DSI_Gateway/test.idl b/TAO/tests/DSI_Gateway/test.idl
index 2c2d6f0f4ec..d35c073b70d 100644
--- a/TAO/tests/DSI_Gateway/test.idl
+++ b/TAO/tests/DSI_Gateway/test.idl
@@ -10,6 +10,13 @@ struct Structure
sequence<long> seq;
};
+exception test_exception
+{
+ short error_code;
+ string error_message;
+ string status_message;
+};
+
interface Simple_Server
{
long test_method (in long x,
@@ -17,5 +24,9 @@ interface Simple_Server
out Structure the_out_structure,
inout string name);
+ void raise_user_exception () raises (test_exception);
+
+ void raise_system_exception ();
+
oneway void shutdown ();
};
diff --git a/TAO/tests/DSI_Gateway/test_dsi.cpp b/TAO/tests/DSI_Gateway/test_dsi.cpp
index 2f093fbbae8..4a96384e624 100644
--- a/TAO/tests/DSI_Gateway/test_dsi.cpp
+++ b/TAO/tests/DSI_Gateway/test_dsi.cpp
@@ -2,6 +2,7 @@
#include "test_dsi.h"
#include "tao/DynamicInterface/Request.h"
+#include "tao/DynamicInterface/Unknown_User_Exception.h"
#if !defined(__ACE_INLINE__)
#include "test_dsi.i"
@@ -45,9 +46,24 @@ DSI_Simple_Server::invoke (CORBA::ServerRequest_ptr request,
// Outgoing request must have the same byte order as the incoming one.
target_request->_tao_byte_order (request->_tao_incoming_byte_order ());
- // Updates the byte order state, if necessary.
- target_request->invoke (ACE_TRY_ENV);
- ACE_CHECK;
+ ACE_TRY
+ {
+ // Updates the byte order state, if necessary.
+ target_request->invoke (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCH (CORBA::UNKNOWN, ex)
+ {
+ ACE_UNUSED_ARG (ex);
+
+ // Outgoing reply must have the same byte order as the incoming one.
+ request->_tao_reply_byte_order (target_request->_tao_byte_order ());
+
+ request->gateway_exception_reply (target_request->raw_user_exception ());
+
+ return;
+ }
+ ACE_ENDTRY;
// Outgoing reply must have the same byte order as the incoming one.
request->_tao_reply_byte_order (target_request->_tao_byte_order ());
diff --git a/TAO/tests/DSI_Gateway/test_dsi.h b/TAO/tests/DSI_Gateway/test_dsi.h
index 3c550ff6c25..eb219d03547 100644
--- a/TAO/tests/DSI_Gateway/test_dsi.h
+++ b/TAO/tests/DSI_Gateway/test_dsi.h
@@ -16,21 +16,21 @@
#ifndef TAO_DSI_GATEWAY_TEST_DSI_H
#define TAO_DSI_GATEWAY_TEST_DSI_H
-#include "testS.h"
+#include "tao/ORB.h"
#include "tao/DynamicInterface/Server_Request.h"
#include "tao/DynamicInterface/Dynamic_Implementation.h"
class DSI_Simple_Server : public TAO_DynamicImplementation
{
// = TITLE
- // Simpler Server implementation
+ // DSI Simpler Server implementation
//
// = DESCRIPTION
- // Implements the Simple_Server interface in test.idl
+ // Implements the DSI/DII gateway.
//
public:
DSI_Simple_Server (CORBA::ORB_ptr orb,
- Simple_Server_ptr target,
+ CORBA::Object_ptr target,
PortableServer::POA_ptr poa);
// ctor
@@ -38,17 +38,23 @@ public:
virtual void invoke (CORBA::ServerRequest_ptr request,
CORBA::Environment &env)
ACE_THROW_SPEC ((CORBA::SystemException));
- virtual CORBA::RepositoryId _primary_interface (const PortableServer::ObjectId &oid,
- PortableServer::POA_ptr poa,
- CORBA::Environment &ACE_TRY_ENV)
+
+ virtual CORBA::RepositoryId _primary_interface (
+ const PortableServer::ObjectId &oid,
+ PortableServer::POA_ptr poa,
+ CORBA::Environment &ACE_TRY_ENV
+ )
ACE_THROW_SPEC (());
- virtual PortableServer::POA_ptr _default_POA (CORBA::Environment &ACE_TRY_ENV);
+
+ virtual PortableServer::POA_ptr _default_POA (
+ CORBA::Environment &ACE_TRY_ENV
+ );
private:
CORBA::ORB_var orb_;
// The ORB
- Simple_Server_var target_;
+ CORBA::Object_var target_;
// Target object, forward requests to it...
PortableServer::POA_var poa_;
diff --git a/TAO/tests/DSI_Gateway/test_dsi.i b/TAO/tests/DSI_Gateway/test_dsi.i
index ecc2df37f6c..dab987ec71e 100644
--- a/TAO/tests/DSI_Gateway/test_dsi.i
+++ b/TAO/tests/DSI_Gateway/test_dsi.i
@@ -2,10 +2,10 @@
ACE_INLINE
DSI_Simple_Server::DSI_Simple_Server (CORBA::ORB_ptr orb,
- Simple_Server_ptr target,
+ CORBA::Object_ptr target,//Simple_Server_ptr target,
PortableServer::POA_ptr poa)
: orb_ (CORBA::ORB::_duplicate (orb)),
- target_ (Simple_Server::_duplicate (target)),
+ target_ (CORBA::Object::_duplicate (target)),//Simple_Server::_duplicate (target)),
poa_ (PortableServer::POA::_duplicate (poa))
{
}
diff --git a/TAO/tests/DSI_Gateway/test_i.cpp b/TAO/tests/DSI_Gateway/test_i.cpp
index 27f8a59d204..8ea791764f6 100644
--- a/TAO/tests/DSI_Gateway/test_i.cpp
+++ b/TAO/tests/DSI_Gateway/test_i.cpp
@@ -39,6 +39,23 @@ Simple_Server_i::test_method (CORBA::Long x,
}
void
+Simple_Server_i::raise_user_exception (CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ test_exception))
+{
+ ACE_THROW (test_exception (33,
+ "reactor meltdown",
+ "kaput"));
+}
+
+void
+Simple_Server_i::raise_system_exception (CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ACE_THROW (CORBA::NO_PERMISSION ());
+}
+
+void
Simple_Server_i::shutdown (CORBA::Environment& ACE_TRY_ENV)
ACE_THROW_SPEC (())
{
diff --git a/TAO/tests/DSI_Gateway/test_i.h b/TAO/tests/DSI_Gateway/test_i.h
index a9ce586c8be..5667b55f231 100644
--- a/TAO/tests/DSI_Gateway/test_i.h
+++ b/TAO/tests/DSI_Gateway/test_i.h
@@ -35,10 +35,17 @@ public:
const Structure& the_in_structure,
Structure_out the_out_structure,
char *&name,
- CORBA::Environment&)
+ CORBA::Environment &)
ACE_THROW_SPEC (());
- void shutdown (CORBA::Environment&)
+ void raise_user_exception (CORBA::Environment &)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ test_exception));
+
+ void raise_system_exception (CORBA::Environment &)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ void shutdown (CORBA::Environment &)
ACE_THROW_SPEC (());
private: