diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2000-12-31 21:51:11 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2000-12-31 21:51:11 +0000 |
commit | 9151b99f5c47665ed63348c0b7633194ef1fb51a (patch) | |
tree | 41154378a125d555104ef4c4da2c05055240ea63 /TAO/tests/Portable_Interceptors | |
parent | c1fe5f554878423239da9b42c2ede56f599b38ec (diff) | |
download | ATCD-9151b99f5c47665ed63348c0b7633194ef1fb51a.tar.gz |
ChangeLogTag:Sun Dec 31 13:45:15 2000 Ossama Othman <ossama@uci.edu>
Diffstat (limited to 'TAO/tests/Portable_Interceptors')
24 files changed, 2082 insertions, 3 deletions
diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/Client_ORBInitializer.cpp b/TAO/tests/Portable_Interceptors/ForwardRequest/Client_ORBInitializer.cpp new file mode 100644 index 00000000000..5679d03a868 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/Client_ORBInitializer.cpp @@ -0,0 +1,69 @@ +// -*- C++ -*- + +#include "Client_ORBInitializer.h" + +ACE_RCSID (ForwardRequest, + Client_ORBInitializer, + "$Id$") + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "Client_Request_Interceptor.h" + +#include "tao/StringSeqC.h" + +void +Client_ORBInitializer::pre_init ( + PortableInterceptor::ORBInitInfo_ptr + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Client_ORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_ENV_ARG_DEFN; + + CORBA::String_var orb_id = info->orb_id (ACE_TRY_ENV); + ACE_CHECK; + + CORBA::StringSeq_var args = info->arguments (ACE_TRY_ENV); + ACE_CHECK; + + CORBA::String_var forward_str; + + // Extract the last forward reference from the argument list. + CORBA::ULong args_len = args->length (); + for (CORBA::ULong i = 0; i < args_len; ++i) + if (ACE_OS_String::strcmp ("-k", args[i].in ()) == 0 + && i < (args_len - 1)) + forward_str = args[i + 1]; + + PortableInterceptor::ClientRequestInterceptor_ptr interceptor = + PortableInterceptor::ClientRequestInterceptor::_nil (); + + // Install the client request interceptor. + ACE_NEW_THROW_EX (interceptor, + Client_Request_Interceptor (orb_id.in (), + forward_str.in ()), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + PortableInterceptor::ClientRequestInterceptor_var + client_interceptor = interceptor; + + info->add_client_request_interceptor (client_interceptor.in () + TAO_ENV_ARG_PARAMETER); + ACE_CHECK; + +} + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/Client_ORBInitializer.h b/TAO/tests/Portable_Interceptors/ForwardRequest/Client_ORBInitializer.h new file mode 100644 index 00000000000..015848c743c --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/Client_ORBInitializer.h @@ -0,0 +1,65 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Client_ORBInitializer.h + * + * $Id$ + * + * Implementation header for the PortableInterceptor::ForwardRequest + * exception test client side ORB initializer. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +#ifndef TAO_CLIENT_ORB_INITIALIZER_H +#define TAO_CLIENT_ORB_INITIALIZER_H + +#include "ace/pre.h" + +#include "tao/corbafwd.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/// Client side ORB initializer. +class Client_ORBInitializer : + public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + +#include "ace/post.h" + +#endif /* TAO_CLIENT_ORB_INITIALIZER_H */ diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/Client_Request_Interceptor.cpp b/TAO/tests/Portable_Interceptors/ForwardRequest/Client_Request_Interceptor.cpp new file mode 100644 index 00000000000..c5bcd77cf94 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/Client_Request_Interceptor.cpp @@ -0,0 +1,144 @@ +// -*- C++ -*- + +#include "Client_Request_Interceptor.h" +#include "testC.h" + +ACE_RCSID (ForwardRequest, + Client_Request_Interceptor, + "$Id$") + +Client_Request_Interceptor::Client_Request_Interceptor ( + const char *orb_id, + const char *forward_str) + : orb_id_ (CORBA::string_dup (orb_id)), + orb_ (), + request_count_ (0), + forward_str_ (CORBA::string_dup (forward_str)) +{ +} + +char * +Client_Request_Interceptor::name ( + TAO_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup ("Client_Request_Interceptor"); +} + +void +Client_Request_Interceptor::send_request ( + PortableInterceptor::ClientRequestInfo_ptr ri + TAO_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + TAO_ENV_ARG_DEFN; + + ++this->request_count_; + + CORBA::Boolean response_expected = + ri->response_expected (ACE_TRY_ENV); + ACE_CHECK; + + if (!response_expected) // A one-way request. + return; + + // Request 1 -- non-forwarded + // Request 2 -- forwarded by this interception point. + + if (this->request_count_ == 2) + { + if (CORBA::is_nil (this->orb_.in ())) + { + int argc = 0; + this->orb_ = CORBA::ORB_init (argc, + 0, + this->orb_id_.in (), + ACE_TRY_ENV); + ACE_CHECK; + } + + CORBA::Object_var forward = + this->orb_->string_to_object (this->forward_str_.in (), + ACE_TRY_ENV); + ACE_CHECK; + + CORBA::String_var forward_str = + this->orb_->object_to_string (forward.in (), + ACE_TRY_ENV); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "CLIENT (%P|%t) Request %d will be forwarded " + "to object 2\n" + "CLIENT (%P|%t) via send_request().\n", + this->request_count_)); + + // Notice that this is not a permanent forward. + ACE_THROW (PortableInterceptor::ForwardRequest (forward.in (), + 0)); + } +} + +void +Client_Request_Interceptor::send_poll ( + PortableInterceptor::ClientRequestInfo_ptr + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Client_Request_Interceptor::receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Client_Request_Interceptor::receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ +} + +void +Client_Request_Interceptor::receive_other ( + PortableInterceptor::ClientRequestInfo_ptr ri + TAO_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + TAO_ENV_ARG_DEFN; + + CORBA::Boolean response_expected = + ri->response_expected (ACE_TRY_ENV); + ACE_CHECK; + + PortableInterceptor::ReplyStatus reply_status = + ri->reply_status (ACE_TRY_ENV); + ACE_CHECK; + + if (!response_expected // A one-way or asynchronous request. + || reply_status == PortableInterceptor::TRANSPORT_RETRY) // A retry. + return; + + // If we get this far then we should have received a + // LOCATION_FORWARD reply, either from another client request + // interceptor (not this one) or from the server. + + // This will throw an exception if a location forward has not + // occured. If an exception is thrown then something is wrong with + // the PortableInterceptor::ForwardRequest support. + CORBA::Object_var forward = ri->forward_reference (ACE_TRY_ENV); + ACE_CHECK; + + if (CORBA::is_nil (forward.in ())) + ACE_THROW (CORBA::INTERNAL ()); + + ACE_DEBUG ((LM_DEBUG, + "CLIENT (%P|%t) Received LOCATION_FORWARD reply.\n")); +} diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/Client_Request_Interceptor.h b/TAO/tests/Portable_Interceptors/ForwardRequest/Client_Request_Interceptor.h new file mode 100644 index 00000000000..aa2dceb45f2 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/Client_Request_Interceptor.h @@ -0,0 +1,123 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Client_Request_Interceptor.h + * + * $Id$ + * + * Implementation header for the client request interceptor for the + * PortableInterceptor::ForwardRequest test. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +#ifndef CLIENT_REQUEST_INTERCEPTOR_H +#define CLIENT_REQUEST_INTERCEPTOR_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" +#include "tao/ORB.h" +#include "tao/CORBA_String.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class Client_Request_Interceptor + * + * @brief Client request interceptor that exercises + * PortableInterceptor::ForwardRequest support. + * + * This client request interceptor forwards a request to a secondary + * object by throwing the PortableInterceptor::ForwardRequest + * exception from within the send_request() interception point. It + * only forwards the initial request. See the README file for + * details. + */ +class Client_Request_Interceptor + : public virtual PortableInterceptor::ClientRequestInterceptor, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /// Constructor. + Client_Request_Interceptor (const char *orb_id, + const char *forward_str); + + /** + * @name Methods Required by the Client Request Interceptor + * Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all client request interceptors. + */ + //@{ + /// Return the name of this ClientRequestinterceptor. + virtual char * name (TAO_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_request ( + PortableInterceptor::ClientRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_poll ( + PortableInterceptor::ClientRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_other ( + PortableInterceptor::ClientRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + //@} + +private: + + ///The ID of the ORB this interceptor is registered with. + CORBA::String_var orb_id_; + + /// Pseudo-reference to the ORB this interceptor is registered + /// with. + CORBA::ORB_var orb_; + + /// The number of requests intercepted by this interceptor. + CORBA::ULong request_count_; + + /// Stringified reference to the object the initial request will be + /// forwarded to by this interceptor. + CORBA::String_var forward_str_; + +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* CLIENT_REQUEST_INTERCEPTOR_H */ diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/ForwardRequest.dsw b/TAO/tests/Portable_Interceptors/ForwardRequest/ForwardRequest.dsw new file mode 100644 index 00000000000..fd21a726477 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/ForwardRequest.dsw @@ -0,0 +1,41 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "ForwardRequest Client"=.\client.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "ForwardRequest Server"=.\server.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/Makefile b/TAO/tests/Portable_Interceptors/ForwardRequest/Makefile new file mode 100644 index 00000000000..578a445d168 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/Makefile @@ -0,0 +1,68 @@ +#---------------------------------------------------------------------------- +# +# $Id$ +# +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif # ! TAO_ROOT + +LDLIBS = -lTAO + +IDL_FILES = test +IDL_SRC = testC.cpp testS.cpp +BIN_UNCHECKED = client server + +SRC = $(addsuffix .cpp, $(BIN_UNCHECKED) test_i Client_Request_Interceptor Client_ORBInitializer Server_ORBInitializer Server_Request_Interceptor) $(IDL_SRC) + +CLIENT_OBJS = \ + client.o \ + testC.o \ + Client_ORBInitializer.o \ + Client_Request_Interceptor.o + +SERVER_OBJS = \ + server.o \ + test_i.o \ + Server_ORBInitializer.o \ + Server_Request_Interceptor.o \ + $(IDL_SRC:.cpp=.o) + +TAO_IDLFLAGS += -Ge 1 +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(TAO_ROOT)/rules.tao.GNU + +ifeq ($(interceptors), 1) +BIN = $(BIN_UNCHECKED) +endif # interceptors + +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +.PRECIOUS: $(foreach ext, $(IDL_EXT), test$(ext)) + +server: $(addprefix $(VDIR),$(SERVER_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(TAO_SRVR_LIBS) $(POSTLINK) + +client: $(addprefix $(VDIR),$(CLIENT_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(TAO_CLNT_LIBS) $(POSTLINK) + +realclean: clean + -$(RM) $(foreach ext, $(IDL_EXT), test$(ext)) + diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/Makefile.bor b/TAO/tests/Portable_Interceptors/ForwardRequest/Makefile.bor new file mode 100644 index 00000000000..1224510c2f9 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/Makefile.bor @@ -0,0 +1,7 @@ +# +# Makefile for building the Interceptors test executables +# + +MAKEFILES = server.bor client.bor + +!include <$(ACE_ROOT)\include\makeinclude\recurse.bor> diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/README b/TAO/tests/Portable_Interceptors/ForwardRequest/README new file mode 100644 index 00000000000..493c17fe369 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/README @@ -0,0 +1,71 @@ +# $Id$ + +This test verifies that the PortableInterceptor::ForwardRequest +exception support is working properly. There are three cases that it +tests: + + - PortableInterceptor::ForwardRequest exception thrown from a client + request interception point. + - PortableInterceptor::ForwardRequest exception thrown from the + receive_request_service_contexts() server request interception + point. + - PortableInterceptor::ForwardRequest exception thrown from the + receive_request() server request interception point. + +The reason why there are two server side cases is because the +receive_request_service_contexts() interception point occurs before +the operation is dispatched to the servant. Hence, the implementation +of the PortableInterceptor::ForwardRequest-to-LOCATION_FORWARD GIOP +reply conversion in that interception point differs from the +conversion that occurs in interception points in servant skeletons. + +Two servants are activated. Their corresponding references are then +passed to the client. The following sequence of operations then +occurs: + + 1) Issue client request. + 2) Intercept the request on the client side. + 3) Forward the request to servant two by throwing the + PortableInterceptor::ForwardRequest in the + ClientRequestInterceptor::send_reply() interception point. + 4) The server will receive the request. + 5) However, it will be intercepted by the server request + interceptor. + 6) The ServerRequestInterceptor::receive_request_service_contexts() + then forwards the client request back to servant one by throwing + the PortableInterceptor::ForwardRequest exception. + 7) That exception will be converted to a LOCATION_FORWARD GIOP + reply. + 8) The client will receive the LOCATION_FORWARD reply, and then + transparently forward its request to servant one. + 9) The ServerRequestInterceptor::receive_request() interception + point will then throw the PortableInterceptor::ForwardRequest + exception to cause the request to be forwarded back to servant + two. + 10) At this point, the request will actually be handled by servant + two. + +Test output should be similar to the following: + +==== Running PortableInterceptor::ForwardRequest test + +ForwardRequestTest::test servant 1: <IOR:010000002000...> +ForwardRequestTest::test servant 2: <IOR:010000002001...> +CLIENT: Issuing request 1. +CLIENT: Request 1 handled by object 1. +CLIENT: Issuing request 2. +CLIENT (1376|1540) Request 2 will be forwarded to object 2 +CLIENT (1376|1540) via send_request(). +CLIENT: Request 2 handled by object 2. +CLIENT: Issuing request 3. +SERVER (1604|1276) Request 3 will be forwarded to object 1 +SERVER (1604|1276) via receive_request_service_contexts(). +CLIENT (1376|1540) Received LOCATION_FORWARD reply. +CLIENT: Request 3 handled by object 1. +CLIENT: Issuing request 4. +SERVER (1604|1276) Request 4 will be forwarded to object 2 +SERVER (1604|1276) via receive_request(). +CLIENT (1376|1540) Received LOCATION_FORWARD reply. +CLIENT: Request 4 handled by object 2. +Server is shutting down via object 2. +Event loop finished. diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/Server_ORBInitializer.cpp b/TAO/tests/Portable_Interceptors/ForwardRequest/Server_ORBInitializer.cpp new file mode 100644 index 00000000000..ddda2fc0c5b --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/Server_ORBInitializer.cpp @@ -0,0 +1,58 @@ +// -*- C++ -*- + +#include "Server_ORBInitializer.h" + +ACE_RCSID (ForwardRequest, + Server_ORBInitializer, + "$Id$") + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "Server_Request_Interceptor.h" + +Server_ORBInitializer::Server_ORBInitializer (void) + : server_interceptor_ (0) +{ +} + +void +Server_ORBInitializer::pre_init ( + PortableInterceptor::ORBInitInfo_ptr + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Server_ORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_ENV_ARG_DEFN; + + // Install the server request interceptor. + ACE_NEW_THROW_EX (this->server_interceptor_, + Server_Request_Interceptor, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + PortableInterceptor::ServerRequestInterceptor_var + server_interceptor = this->server_interceptor_; + + info->add_server_request_interceptor (server_interceptor.in () + TAO_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +Server_Request_Interceptor * +Server_ORBInitializer::server_interceptor (void) +{ + return this->server_interceptor_; +} + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/Server_ORBInitializer.h b/TAO/tests/Portable_Interceptors/ForwardRequest/Server_ORBInitializer.h new file mode 100644 index 00000000000..5172f660f17 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/Server_ORBInitializer.h @@ -0,0 +1,81 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Server_ORBInitializer.h + * + * $Id$ + * + * Implementation header for the PortableInterceptor::ForwardRequest + * exception test server side ORB initializer. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +#ifndef TAO_SERVER_ORB_INITIALIZER_H +#define TAO_SERVER_ORB_INITIALIZER_H + +#include "ace/pre.h" + +#include "tao/corbafwd.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +// Forward declaration. +class Server_Request_Interceptor; + +/// Server side ORB initializer. +class Server_ORBInitializer : + public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /// Constructor. + Server_ORBInitializer (void); + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Return the created server request interceptor. Only valid after + /// post_init(), i.e. ORB_init(), has been called. + Server_Request_Interceptor *server_interceptor (void); + +private: + + /// Pointer to the server request interceptor. ORB is responsible + /// for storage. + Server_Request_Interceptor *server_interceptor_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + +#include "ace/post.h" + +#endif /* TAO_SERVER_ORB_INITIALIZER_H */ diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/Server_Request_Interceptor.cpp b/TAO/tests/Portable_Interceptors/ForwardRequest/Server_Request_Interceptor.cpp new file mode 100644 index 00000000000..cc5df510bab --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/Server_Request_Interceptor.cpp @@ -0,0 +1,176 @@ +// -*- C++ -*- + +#include "Server_Request_Interceptor.h" + +ACE_RCSID (ForwardRequest, + Server_Request_Interceptor, + "$Id$") + +Server_Request_Interceptor::Server_Request_Interceptor (void) + : request_count_ (0) +{ + this->obj_[0] = CORBA::Object::_nil (); + this->obj_[1] = CORBA::Object::_nil (); +} + +Server_Request_Interceptor::~Server_Request_Interceptor (void) +{ + CORBA::release (this->obj_[0]); + CORBA::release (this->obj_[1]); +} + +void +Server_Request_Interceptor::forward_references ( + CORBA::Object_ptr obj1, + CORBA::Object_ptr obj2, + CORBA::Environment &ACE_TRY_ENV) +{ + if (CORBA::is_nil (obj1) || CORBA::is_nil (obj2)) + ACE_THROW (CORBA::INV_OBJREF ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + EINVAL), + CORBA::COMPLETED_NO)); + + this->obj_[0] = CORBA::Object::_duplicate (obj1); + this->obj_[1] = CORBA::Object::_duplicate (obj2); +} + +char * +Server_Request_Interceptor::name (TAO_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup ("Server_Request_Interceptor"); +} + +void +Server_Request_Interceptor::receive_request_service_contexts ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + TAO_ENV_ARG_DEFN; + + this->request_count_++; + + CORBA::Boolean response_expected = + ri->response_expected (ACE_TRY_ENV); + ACE_CHECK; + + if (!response_expected) // A one-way request. + return; + + // Request 1 -- non-forwarded + // Request 2 -- forwarded by client request interceptor + // Request 3 -- forwarded by this interception point + + if (this->request_count_ == 3) + { + // The client request interceptor should have already forwarded + // the request to obj_[1], so we re-forward the request back to + // obj_[0]. + + ACE_DEBUG ((LM_DEBUG, + "SERVER (%P|%t) Request %d will be forwarded " + "to object 1\n" // "object 1" as in "obj_[0]" + "SERVER (%P|%t) via " + "receive_request_service_contexts().\n", + this->request_count_)); + + // Notice that this is not a permanent forward. + ACE_THROW (PortableInterceptor::ForwardRequest ( + this->obj_[0], + 0)); + } +} + +void +Server_Request_Interceptor::receive_request ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + TAO_ENV_ARG_DEFN; + + CORBA::Boolean response_expected = + ri->response_expected (ACE_TRY_ENV); + ACE_CHECK; + + if (!response_expected) // A one-way request. + return; + + // Request 1 -- non-forwarded + // Request 2 -- forwarded by client request interceptor + // Request 3 -- forwarded by receive_request_service_contexts() + // Request 4 -- non-forwarded (give client chance to print result) + // Request 5 -- forwarded by this interception point + + if (this->request_count_ == 5) + { + // This interceptor should have already forwarded the request to + // obj_[0] so re-forward it to obj_[1]. This will be the last + // location forward. + + + ACE_DEBUG ((LM_DEBUG, + "SERVER (%P|%t) Request %d will be forwarded " + "to object 2\n" // "object 2" as in "obj_[1]" + "SERVER (%P|%t) via receive_request().\n", + this->request_count_ - 1)); + // "request_count_ - 1" is used above since there was a location + // forward. + + // Notice that this is not a permanent forward. + ACE_THROW (PortableInterceptor::ForwardRequest ( + this->obj_[1], + 0)); + } +} + +void +Server_Request_Interceptor::send_reply ( + PortableInterceptor::ServerRequestInfo_ptr + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Server_Request_Interceptor::send_exception ( + PortableInterceptor::ServerRequestInfo_ptr + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ +} + +void +Server_Request_Interceptor::send_other ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + TAO_ENV_ARG_DEFN; + + CORBA::Boolean response_expected = + ri->response_expected (ACE_TRY_ENV); + ACE_CHECK; + + if (!response_expected) // A one-way request. + return; + + // If we get this far then we should have received a + // LOCATION_FORWARD reply. + + // This will throw an exception if a location forward has not + // occured. If an exception is thrown then something is wrong with + // the PortableInterceptor::ForwardRequest support. + CORBA::Object_var forward = ri->forward_reference (ACE_TRY_ENV); + ACE_CHECK; + + if (CORBA::is_nil (forward.in ())) + ACE_THROW (CORBA::INTERNAL ()); +} diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/Server_Request_Interceptor.h b/TAO/tests/Portable_Interceptors/ForwardRequest/Server_Request_Interceptor.h new file mode 100644 index 00000000000..5e888a0e412 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/Server_Request_Interceptor.h @@ -0,0 +1,131 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Server_Request_Interceptor.h + * + * $Id$ + * + * Implementation header for the server request interceptor for the + * PortableInterceptor::ForwardRequest test. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +#ifndef SERVER_REQUEST_INTERCEPTOR_H +#define SERVER_REQUEST_INTERCEPTOR_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class Server_Request_Interceptor + * + * @brief Simple concrete server request interceptor. + * + * This server request interceptor forwards an initial client request + * to the primary server since the client request interceptor should + * have attempted to forward a request to the secondary server. That + * request will then be forwarded back to the primary server, at which + * point the request will be handled. + * + * The PortableInterceptor::ForwardRequest code for the + * receive_request_service_contexts() interception point (which is not + * in the servant skeleton) is slightly different from the + * corresponding code in the server skeleton. Hence, + * PortableInterceptor::ForwardRequest support is tested for both + * cases by throwing that exception in the + * receive_request_service_contexts() and the receive_request() + * interception points. + * + * See the README file for test details. + */ +class Server_Request_Interceptor + : public virtual PortableInterceptor::ServerRequestInterceptor, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /// Constructorl + Server_Request_Interceptor (void); + + /// Destructor. + ~Server_Request_Interceptor (void); + + /// Set the references to which requests will be forwarded. + void forward_references (CORBA::Object_ptr obj1, + CORBA::Object_ptr obj2, + CORBA::Environment &ACE_TRY_ENV); + + /** + * @name Methods Required by the Server Request Interceptor + * Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all server request interceptors. + */ + //@{ + /// Return the name of this ServerRequestinterceptor. + virtual char * name (TAO_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_request_service_contexts ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_request ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_reply ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_exception ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_other ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + //@} + +private: + + /// The number of requests intercepted by this interceptor. + CORBA::ULong request_count_; + + /// References to the two objects used in this test. + CORBA::Object_ptr obj_[2]; + +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* SERVER_REQUEST_INTERCEPTOR_H */ diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/client.bor b/TAO/tests/Portable_Interceptors/ForwardRequest/client.bor new file mode 100644 index 00000000000..5143eaa97b1 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/client.bor @@ -0,0 +1,37 @@ +# +# Makefile for building the Interceptors client +# + +NAME = client + +TAO_IDL = $(CORE_BINDIR)\tao_idl -I../../.. -g $(CORE_BINDIR)\gperf.exe -Ge 1 + +OBJFILES = \ + $(OBJDIR)\testC.obj \ + $(OBJDIR)\client.obj \ + $(OBJDIR)\FOO_ClientRequestInterceptor.obj \ + $(OBJDIR)\FOO_Client_ORBInitializer.obj + +CFLAGS = \ + $(ACE_CFLAGS) \ + $(TAO_CFLAGS) + +LIBFILES = \ + $(ACE_LIB) \ + $(TAO_LIB) + +IDLFILES = \ + $(IDLDIR)\test.idl + +CPPDIR = . + +IDLDIR = . + +!include <$(ACE_ROOT)\include\makeinclude\build_exe.bor> + +# +# IDL Build rules +# + +$(IDLDIR)\testS.cpp $(IDLDIR)\testC.cpp: $(IDLDIR)\test.idl + $(TAO_IDL) $** diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/client.cpp b/TAO/tests/Portable_Interceptors/ForwardRequest/client.cpp new file mode 100644 index 00000000000..21b3831e875 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/client.cpp @@ -0,0 +1,127 @@ +// -*- C++ -*- + +#include "ace/Get_Opt.h" + +#include "testC.h" +#include "Client_ORBInitializer.h" + +ACE_RCSID(ForwardRequest, + client, + "$Id$") + +const char *ior1 = 0; +const char *ior2 = 0; + +int +parse_args (int argc, char *argv[]) +{ + if (argc != 5) // foo -k IOR_1 -k IOR_2 + ACE_ERROR_RETURN ((LM_ERROR, + "Wrong number of arguments.\n"), + -1); + + ACE_Get_Opt get_opts (argc, argv, "k:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + + if (ior1 == 0) + ior1 = get_opts.optarg; + else if (ior2 == 0) + ior2 = get_opts.optarg; + + break; + default: + ACE_ERROR_RETURN ((LM_ERROR, + "Usage: %s " + "-k IOR_1 -k IOR_2\n", + argv[0]), + -1); + } + + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + PortableInterceptor::ORBInitializer_ptr temp_initializer = + PortableInterceptor::ORBInitializer::_nil (); + + ACE_NEW_RETURN (temp_initializer, + Client_ORBInitializer, + -1); // No exceptions yet! + PortableInterceptor::ORBInitializer_var orb_initializer = + temp_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::ORB_var orb = CORBA::ORB_init (argc, + argv, + "Client ORB", + ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (::parse_args (argc, argv) != 0) + return -1; + + // Start out with the first IOR. Interaction with the second + // IOR occurs during the various interceptions executed during + // this test. + CORBA::Object_var object = + orb->string_to_object (ior1, ACE_TRY_ENV); + ACE_TRY_CHECK; + + ForwardRequestTest::test_var server = + ForwardRequestTest::test::_narrow (object.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (CORBA::is_nil (server.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Object reference <%s> is nil\n", + ior1), + 1); + } + + // Invoke the operation four times. By design, the last three + // invocations in this test will cause + // PortableInterceptor::ForwardRequest exceptions to be thrown, + // thus causing the request to be forwarded to another object. + + for (int i = 1; i <= 4; ++i) + { + ACE_DEBUG ((LM_INFO, + "CLIENT: Issuing request %d.\n", + i)); + + CORBA::Short number = server->number (ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_INFO, + "CLIENT: Request %d handled by object %d.\n", + i, + number)); + } + + server->shutdown (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Caught exception:"); + return -1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/client.dsp b/TAO/tests/Portable_Interceptors/ForwardRequest/client.dsp new file mode 100644 index 00000000000..3083345d9e0 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/client.dsp @@ -0,0 +1,220 @@ +# Microsoft Developer Studio Project File - Name="ForwardRequest Client" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=ForwardRequest Client - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "client.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "client.mak" CFG="ForwardRequest Client - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ForwardRequest Client - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "ForwardRequest Client - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ForwardRequest Client - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../../.." /I "../../.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 tao.lib ace.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao"
+
+!ELSEIF "$(CFG)" == "ForwardRequest Client - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../../../.." /I "../../.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 taod.lib aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao"
+
+!ENDIF
+
+# Begin Target
+
+# Name "ForwardRequest Client - Win32 Release"
+# Name "ForwardRequest Client - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter ".cpp"
+# Begin Source File
+
+SOURCE=.\client.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Client_ORBInitializer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Client_Request_Interceptor.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\testC.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h"
+# Begin Source File
+
+SOURCE=.\Client_ORBInitializer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Client_Request_Interceptor.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\testC.h
+# End Source File
+# End Group
+# Begin Group "IDL Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\test.idl
+
+!IF "$(CFG)" == "ForwardRequest Client - Win32 Release"
+
+# PROP Ignore_Default_Tool 1
+USERDEP__TEST_="..\..\..\..\bin\Release\tao_idl.exe"
+# Begin Custom Build - Invoking TAO_IDL Compiler
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\Release\tao_idl -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "ForwardRequest Client - Win32 Debug"
+
+USERDEP__TEST_="..\..\..\..\bin\tao_idl.exe"
+# Begin Custom Build - Invoking TAO_IDL Compiler
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\tao_idl -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Group "Inline Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\testC.i
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/run_test.pl b/TAO/tests/Portable_Interceptors/ForwardRequest/run_test.pl new file mode 100755 index 00000000000..6556e3ecae7 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/run_test.pl @@ -0,0 +1,58 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# -*- perl -*- +# +# $Id$ + + +unshift @INC, '../../../../bin'; +require Process; +require ACEutils; +use Cwd; + +$cwd = getcwd(); +ACE::checkForTarget($cwd); + +print STDERR "\n\n==== Running PortableInterceptor::ForwardRequest test\n"; + +$file1 = "$cwd$DIR_SEPARATOR" . "test1.ior"; +$file2 = "$cwd$DIR_SEPARATOR" . "test2.ior"; + +unlink $file1; +unlink $file2; + +$SV = Process::Create ($EXEPREFIX."server".$EXE_EXT, + "-o $file1 -o $file2"); +if (ACE::waitforfile_timed ($file1, 15) == -1 + || ACE::waitforfile_timed ($file2, 15) == -1) { + print STDERR "ERROR: cannot find file <$file1> or <$file2>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$CL = Process::Create ($EXEPREFIX."client".$EXE_EXT, + "-k file://$file1 -k file://$file2"); + + +$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); +} + +if ($client == -1 || $server == -1) { + exit 1; +} + +unlink $file1; +unlink $file2; + +exit 0; diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/server.bor b/TAO/tests/Portable_Interceptors/ForwardRequest/server.bor new file mode 100644 index 00000000000..9adf8bf91aa --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/server.bor @@ -0,0 +1,41 @@ +# +# Makefile for building the Interceptors server +# + +NAME = server + +TAO_IDL = $(CORE_BINDIR)\tao_idl -I../../.. -g $(CORE_BINDIR)\gperf.exe -Ge 1 + +OBJFILES = \ + $(OBJDIR)\testC.obj \ + $(OBJDIR)\testS.obj \ + $(OBJDIR)\server.obj \ + $(OBJDIR)\test_i.obj \ + $(OBJDIR)\FOO_IORInterceptor.obj \ + $(OBJDIR)\FOO_IORInterceptor_ORBInitializer.obj + +CFLAGS = \ + $(ACE_CFLAGS) \ + $(TAO_CFLAGS) \ + $(TAO_PORTABLESERVER_CFLAGS) + +LIBFILES = \ + $(ACE_LIB) \ + $(TAO_LIB) \ + $(TAO_PORTABLESERVER_LIB) + +IDLFILES = \ + $(IDLDIR)\test.idl + +CPPDIR = . + +IDLDIR = . + +!include <$(ACE_ROOT)\include\makeinclude\build_exe.bor> + +# +# IDL Build rules +# + +$(IDLDIR)\testS.cpp $(IDLDIR)\testC.cpp: $(IDLDIR)\test.idl + $(TAO_IDL) $** diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/server.cpp b/TAO/tests/Portable_Interceptors/ForwardRequest/server.cpp new file mode 100644 index 00000000000..189f48a22a6 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/server.cpp @@ -0,0 +1,204 @@ +// -*- C++ -*- + +#include "ace/Get_Opt.h" +#include "test_i.h" +#include "Server_ORBInitializer.h" +#include "Server_Request_Interceptor.h" + +ACE_RCSID (ForwardRequest, + server, + "$Id$") + +const char *ior1_file = 0; +const char *ior2_file = 0; + +int +parse_args (int argc, char *argv[]) +{ + if (argc != 5) // foo -o IOR_1 -o IOR_2 + ACE_ERROR_RETURN ((LM_ERROR, + "Wrong number of arguments.\n"), + -1); + + ACE_Get_Opt get_opts (argc, argv, "o:"); + int c; + + int ior_count = 1; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + + if (ior_count == 1) + { + ior1_file = get_opts.optarg; + ++ior_count; + } + else if (ior_count == 2) + { + ior2_file = get_opts.optarg; + ++ior_count; + } + + break; + default: + ACE_ERROR_RETURN ((LM_ERROR, + "Usage: %s " + "-o IOR_1 -o IOR_2\n", + argv[0]), + -1); + } + + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + Server_ORBInitializer *temp_initializer = 0; + ACE_NEW_RETURN (temp_initializer, + Server_ORBInitializer, + -1); // No exceptions yet! + PortableInterceptor::ORBInitializer_var orb_initializer = + temp_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "Server ORB", ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::Object_var poa_object = + orb->resolve_initial_references ("RootPOA"); + if (CORBA::is_nil (poa_object.in ())) + 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); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (::parse_args (argc, argv) != 0) + return -1; + + CORBA::PolicyList policies; // Empty policy list. + + // Servant 1 + test_i servant1 (1, orb.in ()); + + PortableServer::POA_var first_poa = + root_poa->create_POA ("first POA", + poa_manager.in (), + policies, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + PortableServer::ObjectId_var oid1 = + first_poa->activate_object (&servant1, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::Object_var obj1 = + first_poa->servant_to_reference (&servant1, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::String_var ior1 = + orb->object_to_string (obj1.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "ForwardRequestTest::test servant 1: <%s>\n", + ior1.in ())); + + // Servant 2 + test_i servant2 (2, orb.in ()); + + PortableServer::POA_var second_poa = + root_poa->create_POA ("second POA", + poa_manager.in (), + policies, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + PortableServer::ObjectId_var oid2 = + second_poa->activate_object (&servant2, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::Object_var obj2 = + second_poa->servant_to_reference (&servant2, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::String_var ior2 = + orb->object_to_string (obj2.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "ForwardRequestTest::test servant 2: <%s>\n", + ior2.in ())); + + poa_manager->activate (ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Set the forward references in the server request interceptor. + Server_Request_Interceptor *server_interceptor = + temp_initializer->server_interceptor (); + + server_interceptor->forward_references (obj1.in (), + obj2.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Write each IOR to a file. + + // IOR 1 + FILE *output_file= ACE_OS::fopen (ior1_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file <%s> for writing " + "IOR: %s", + + ior1), + 1); + ACE_OS::fprintf (output_file, "%s", ior1.in ()); + ACE_OS::fclose (output_file); + + // IOR 2 + output_file= ACE_OS::fopen (ior2_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior2), + 1); + ACE_OS::fprintf (output_file, "%s", ior2.in ()); + ACE_OS::fclose (output_file); + + // Run the ORB event loop. + orb->run (ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Event loop finished.\n")); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Caught exception:"); + return -1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/server.dsp b/TAO/tests/Portable_Interceptors/ForwardRequest/server.dsp new file mode 100644 index 00000000000..f57acf02934 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/server.dsp @@ -0,0 +1,240 @@ +# Microsoft Developer Studio Project File - Name="ForwardRequest Server" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=ForwardRequest Server - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "server.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "server.mak" CFG="ForwardRequest Server - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ForwardRequest Server - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "ForwardRequest Server - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ForwardRequest Server - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../../.." /I "../../.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib TAO.lib TAO_PortableServer.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\tao\PortableServer"
+
+!ELSEIF "$(CFG)" == "ForwardRequest Server - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../../../.." /I "../../.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib TAOd.lib TAO_PortableServerd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\tao\PortableServer"
+
+!ENDIF
+
+# Begin Target
+
+# Name "ForwardRequest Server - Win32 Release"
+# Name "ForwardRequest Server - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter ".cpp"
+# Begin Source File
+
+SOURCE=.\server.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Server_ORBInitializer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Server_Request_Interceptor.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_i.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"
+
+# PROP Default_Filter ".h"
+# Begin Source File
+
+SOURCE=.\Server_ORBInitializer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Server_Request_Interceptor.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_i.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\testS.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\testS_T.h
+# End Source File
+# End Group
+# Begin Group "IDL Files"
+
+# PROP Default_Filter ".idl"
+# Begin Source File
+
+SOURCE=.\test.idl
+
+!IF "$(CFG)" == "ForwardRequest Server - Win32 Release"
+
+# PROP Ignore_Default_Tool 1
+USERDEP__TEST_="..\..\..\..\bin\Release\tao_idl.exe"
+# Begin Custom Build - Invoking TAO_IDL Compiler
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\Release\tao_idl -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "ForwardRequest Server - Win32 Debug"
+
+USERDEP__TEST_="..\..\..\..\bin\tao_idl.exe"
+# Begin Custom Build - Invoking TAO_IDL Compiler
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\tao_idl -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Group "Inline Files"
+
+# PROP Default_Filter ".i"
+# Begin Source File
+
+SOURCE=.\testC.i
+# End Source File
+# Begin Source File
+
+SOURCE=.\testS.i
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/test.idl b/TAO/tests/Portable_Interceptors/ForwardRequest/test.idl new file mode 100644 index 00000000000..d4bdd89bc2b --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/test.idl @@ -0,0 +1,30 @@ +// -*- IDL -*- + +//============================================================================= +/** + * @file test.idl + * + * $Id$ + * + * Simple IDL file to test PortableInterceptor::ForwardRequest + * support. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + + +module ForwardRequestTest +{ + + interface test + { + /// Return the number assigned to the current object. For + /// example, object one will return "1," and object two will + /// return "2." + short number (); + + oneway void shutdown (); + }; + +}; diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/test_i.cpp b/TAO/tests/Portable_Interceptors/ForwardRequest/test_i.cpp new file mode 100644 index 00000000000..c1ed912b164 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/test_i.cpp @@ -0,0 +1,31 @@ +// -*- C++ -*- + +#include "test_i.h" + +ACE_RCSID (ForwardRequest, + test_i, + "$Id$") + +test_i::test_i (CORBA::Short num, + CORBA::ORB_ptr orb) + : number_ (num), + orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +CORBA::Short +test_i::number (CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->number_; +} + +void +test_i::shutdown (CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, + "Server is shutting down via object %d.\n", + this->number_)); + this->orb_->shutdown (0, ACE_TRY_ENV); +} diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/test_i.h b/TAO/tests/Portable_Interceptors/ForwardRequest/test_i.h new file mode 100644 index 00000000000..0498d1a778e --- /dev/null +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/test_i.h @@ -0,0 +1,56 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file test_i.h + * + * $Id$ + * + * Implementation header for the "test" IDL interface for the + * PortableInterceptor::ForwardRequest test. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +#ifndef TEST_I_H +#define TEST_I_H + +#include "testS.h" + +/** + * @class test_i + * + * @brief Simple test class. + * + * This class implements the "test" interface used in this test. + */ +class test_i : public virtual POA_ForwardRequestTest::test +{ +public: + + /// Constructor. + test_i (CORBA::Short num, + CORBA::ORB_ptr orb); + + /// Return the number assigned to this object. + virtual CORBA::Short number (CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Shutdown the ORB. + virtual void shutdown (CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + + /// The number assigned to this object. + CORBA::Short number_; + + /// Pseudo-reference to the ORB. + CORBA::ORB_var orb_; + +}; + +#endif /* TEST_I_H */ diff --git a/TAO/tests/Portable_Interceptors/Makefile b/TAO/tests/Portable_Interceptors/Makefile index c324cd86d21..1b8884c225d 100644 --- a/TAO/tests/Portable_Interceptors/Makefile +++ b/TAO/tests/Portable_Interceptors/Makefile @@ -14,7 +14,8 @@ DIRS = \ Dynamic \ Benchmark \ Service_Context_Manipulation \ - IORInterceptor + IORInterceptor \ + ForwardRequest ifndef TAO_ROOT TAO_ROOT = $(ACE_ROOT)/TAO diff --git a/TAO/tests/Portable_Interceptors/Makefile.bor b/TAO/tests/Portable_Interceptors/Makefile.bor index 8b4c31bb436..d03617fa998 100644 --- a/TAO/tests/Portable_Interceptors/Makefile.bor +++ b/TAO/tests/Portable_Interceptors/Makefile.bor @@ -6,7 +6,7 @@ DIRS = \ Benchmark \ Dynamic \ Service_Context_Manipulation \ - IORInterceptor - + IORInterceptor \ + ForwardRequest !include <$(ACE_ROOT)\include\makeinclude\recurse.bor> |