diff options
author | elliott_c <elliott_c@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-12-22 14:54:51 +0000 |
---|---|---|
committer | elliott_c <elliott_c@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-12-22 14:54:51 +0000 |
commit | 64eaebceb32fd85d4a49edcd7fd87aa717e0b842 (patch) | |
tree | fc6af8395f38530adade43b8c51065c302328602 /TAO | |
parent | db305c92235da8407e44056618396f49fba9c7df (diff) | |
download | ATCD-64eaebceb32fd85d4a49edcd7fd87aa717e0b842.tar.gz |
ChangeLogTag: Thu Dec 22 08:54:09 2005 Chad Elliott <elliott_c@ociweb.com>
Diffstat (limited to 'TAO')
77 files changed, 5510 insertions, 244 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 78e0c5bb075..9ecf749e9ce 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,150 @@ +Thu Dec 22 08:54:09 2005 Chad Elliott <elliott_c@ociweb.com> + + Committing these changes on behalf of Time Bradley + <bradley_t@ociweb.com>. + + The following changes were made in order to support a new + feature that is described in the CORBA 3.1 draft specification. + The new feature consists of adding the capability to register + Portable Interceptors with an associated set of Policy objects. + In addition, a new Policy was introduced: the + PortableInterceptor::ProcessingModePolicy. This policy can be + applied to either client request interceptors or server request + interceptors. There are three possible ProcessingMode values: + + - LOCAL_AND_REMOTE (the default) + - LOCAL_ONLY + - REMOTE_ONLY + + The policy is used during the dispatching of a CORBA request. + It comes into play for remote requests as well as collocated + (thru-poa) requests. When the policy value is something other + than the default value, the interception points on the + corresponding interceptor may or may not be invoked. For the + LOCAL_ONLY policy value, the interception points are only invoked + on the interceptor if the request is a collocated (thru-poa) + request. If it is a remote request, the LOCAL_ONLY policy value + causes the interceptor to not apply to the current request. + The REMOTE_ONLY has the opposite effect - only remote requests + cause the interception points to be invoked in the interceptor. + + * tao/IORInterceptor/IORInterceptor_Details.cpp: + * tao/IORInterceptor/IORInterceptor_Details.h: + * tao/IORInterceptor/IORInterceptor_Details.inl: + * tao/PI/ClientRequestDetails.cpp: + * tao/PI/ClientRequestDetails.h: + * tao/PI/ClientRequestDetails.inl: + * tao/PI/PI_ORBInitializer.cpp: + * tao/PI/PI_ORBInitializer.h: + * tao/PI/PI_PolicyFactory.cpp: + * tao/PI/PI_PolicyFactory.h: + * tao/PI/ProcessingModePolicy.cpp: + * tao/PI/ProcessingModePolicy.h: + * tao/PI/ProcessingModePolicy.pidl: + * tao/PI/ProcessingModePolicyC.cpp: + * tao/PI/ProcessingModePolicyC.h: + * tao/PI/ProcessingModePolicyS.h: + * tao/PI_Server/ServerRequestDetails.cpp: + * tao/PI_Server/ServerRequestDetails.h: + * tao/PI_Server/ServerRequestDetails.inl: + + The files listed above have been added as part of the + the new PI Policy support (including the new + PI ProcessingModePolicy). + + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Client_Task.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Client_Task.h: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Collocated_Test.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Echo_Collocated_ORBInitializer.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Echo_Collocated_ORBInitializer.h: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/interceptors.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/interceptors.h: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/PI_ProcMode_Collocated.mpc: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/run_test.pl: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Server_Task.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Server_Task.h: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test_i.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test.idl: + * tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test_i.h: + + The files listed above make up a new "collocated" test for the + new PortableInterceptor::ProcessingModePolicy "feature". + + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_interceptor.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_interceptor.h: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_main.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Client_Task.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Client_Task.h: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Client_ORBInitializer.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Client_ORBInitializer.h: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Server_ORBInitializer.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Server_ORBInitializer.h: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/PI_ProcMode_Remote.mpc: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/run_test.pl: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_interceptor.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_interceptor.h: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_main.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Server_Task.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Server_Task.h: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test_i.cpp: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test.idl: + * tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test_i.h: + + The files listed above make up a new "remote" test for the + new PortableInterceptor::ProcessingModePolicy "feature". + + * tao/PortableServer/Upcall_Wrapper.cpp: + + The Upcall_Wrapper class was modified to fix a bug that + was observed while testing the new ProcessingModePolicy. + The server request portable interceptors were being supplied + with a ServerRequestInfo object that referenced uninitialized + operation arguments in the collocated (thru_poa) case. + + * tao/PI/ClientRequestInfo.cpp: + + During testing of the new ProcessingModePolicy, another bug + was observed. Client request interceptors were not getting + the proper "result argument" (both collocated and remote cases). + The changes made to the tao/PI/ClientRequestInfo.cpp file fixes + this bug. + + * tao/ClientRequestInterceptor_Adapter.h: + * tao/Collocated_Invocation.cpp: + * tao/IORInterceptor_Adapter.h: + * tao/Invocation_Base.cpp: + * tao/Invocation_Base.h: + * tao/Invocation_Base.inl: + * tao/ORB_Core.cpp: + * tao/ORB_Core.h: + * tao/Remote_Invocation.cpp: + * tao/ServerRequestInterceptor_Adapter.h: + * tao/IORInterceptor/IORInterceptor_Adapter_Impl.cpp: + * tao/IORInterceptor/IORInterceptor_Adapter_Impl.h: + * tao/PI/ClientRequestInterceptor_Adapter_Impl.cpp: + * tao/PI/ClientRequestInterceptor_Adapter_Impl.h: + * tao/PI/Interceptor_List_T.cpp: + * tao/PI/Interceptor_List_T.h: + * tao/PI/ORBInitInfo.cpp: + * tao/PI/ORBInitInfo.h: + * tao/PI/ORBInitInfo.pidl: + * tao/PI/ORBInitInfoC.cpp: + * tao/PI/ORBInitInfoC.h: + * tao/PI/ORBInitInfoS.h: + * tao/PI/PI.cpp: + * tao/PI_Server/ServerInterceptorAdapter.cpp: + * tao/PI_Server/ServerInterceptorAdapter.h: + + The files listed above were modified as part of the + changes made to support policies at PI registration-time + and the new PI ProcessingModePolicy. + + * tests/Portable_Interceptors/Collocated/Dynamic/test_i.cpp: + + Added a sleep before the shutdown to allow the client thread to + complete the collocated call before shutting down the ORB to avoid + BAD_INV_ORDER exceptions on fast multi-processor machines. + Thu Dec 22 14:04:12 UTC 2005 Johnny Willemsen <jwillemsen@remedy.nl> * tests/RTCORBA/Dynamic_Thread_Pool/client.cpp: diff --git a/TAO/tao/ClientRequestInterceptor_Adapter.h b/TAO/tao/ClientRequestInterceptor_Adapter.h index e05d9bf63a6..4e9220a98f7 100644 --- a/TAO/tao/ClientRequestInterceptor_Adapter.h +++ b/TAO/tao/ClientRequestInterceptor_Adapter.h @@ -42,6 +42,11 @@ namespace PortableInterceptor typedef CORBA::Short ReplyStatus; } +namespace CORBA +{ + class PolicyList; +} + namespace TAO { class Invocation_Base; @@ -95,6 +100,12 @@ namespace TAO PortableInterceptor::ClientRequestInterceptor_ptr interceptor ACE_ENV_ARG_DECL) = 0; + /// Register an interceptor with policies. + virtual void add_interceptor ( + PortableInterceptor::ClientRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL) = 0; + virtual void destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL) = 0; /// Convert TAO Invocation status to a PI status diff --git a/TAO/tao/Collocated_Invocation.cpp b/TAO/tao/Collocated_Invocation.cpp index f3b08462ad9..50f030251c2 100644 --- a/TAO/tao/Collocated_Invocation.cpp +++ b/TAO/tao/Collocated_Invocation.cpp @@ -28,7 +28,8 @@ namespace TAO et, stub, detail, - response_expected) + response_expected, + false /* request_is_remote */ ) { } diff --git a/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.cpp b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.cpp index 0124de24c1e..4e9ecb68d5a 100644 --- a/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.cpp +++ b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.cpp @@ -31,6 +31,19 @@ TAO_IORInterceptor_Adapter_Impl::add_interceptor ( } void +TAO_IORInterceptor_Adapter_Impl::add_interceptor ( + PortableInterceptor::IORInterceptor_ptr i, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL + ) +{ + this->ior_interceptor_list_.add_interceptor (i, + policies + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void TAO_IORInterceptor_Adapter_Impl::destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL) { this->ior_interceptor_list_.destroy_interceptors (ACE_ENV_SINGLE_ARG_PARAMETER); diff --git a/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.h b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.h index d9d0bfd7a3e..949f4be9611 100644 --- a/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.h +++ b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.h @@ -25,12 +25,14 @@ #include "tao/IORInterceptor/IORInterceptor.h" #include "tao/IORInterceptor_Adapter.h" #include "tao/PI/Interceptor_List_T.h" +#include "IORInterceptor_Details.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { - typedef Interceptor_List< ::PortableInterceptor::IORInterceptor> + typedef Interceptor_List< ::PortableInterceptor::IORInterceptor, + IORInterceptor_Details> IORInterceptor_List; } @@ -55,6 +57,11 @@ public: PortableInterceptor::IORInterceptor_ptr interceptor ACE_ENV_ARG_DECL); + virtual void add_interceptor ( + PortableInterceptor::IORInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL); + virtual void destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL); virtual void establish_components (TAO_Root_POA *poa ACE_ENV_ARG_DECL) diff --git a/TAO/tao/IORInterceptor/IORInterceptor_Details.cpp b/TAO/tao/IORInterceptor/IORInterceptor_Details.cpp new file mode 100644 index 00000000000..90fcd105861 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInterceptor_Details.cpp @@ -0,0 +1,28 @@ +#include "IORInterceptor_Details.h" + +#if !defined (__ACE_INLINE__) +#include "IORInterceptor_Details.inl" +#endif /* defined INLINE */ + +ACE_RCSID (PI, + IORInterceptor_Details, + "$Id$") + +#include "tao/SystemException.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + void + IORInterceptor_Details::apply_policies ( + const CORBA::PolicyList &policies + ACE_ENV_ARG_DECL) + { + // There are currently no policies that apply to IOR Interceptors. + ACE_UNUSED_ARG (policies); + ACE_THROW (CORBA::INV_POLICY ()); + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/IORInterceptor/IORInterceptor_Details.h b/TAO/tao/IORInterceptor/IORInterceptor_Details.h new file mode 100644 index 00000000000..f9587e88693 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInterceptor_Details.h @@ -0,0 +1,71 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file IORInterceptor_Details.h + * + * $Id$ + * + * This file declares a class that manages the details + * about a registered client request interceptor. Policies can be + * used when interceptors are registered, and the policy values + * will be processed and used to modify the values of the + * IORInterceptor_Details object associated with the registered + * client request interceptor. + * + * @author Tim Bradley <bradley_t@ociweb.com> + */ +//============================================================================= + +#ifndef TAO_IOR_INTERCEPTOR_DETAILS_H +#define TAO_IOR_INTERCEPTOR_DETAILS_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/orbconf.h" + +#include "tao/Policy_ForwardC.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class IORInterceptor_Details + * + * @brief The policy-driven details for a registered IOR interceptor + * + * Each time an IOR interceptor is registered with an ORB, an + * IORInterceptor_Details object will be created and associated with + * the registered IOR interceptor. If the interceptor is + * registered with policies, the policies will be used to adjust the + * values in the IORInterceptor_Details appropriately. + * + * Currently, there are no policies that are applicable to + * IOR Interceptors. + */ + class IORInterceptor_Details + { + public: + + IORInterceptor_Details (void); + ~IORInterceptor_Details (void); + + void apply_policies (const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL); + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "IORInterceptor_Details.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_IOR_INTERCEPTOR_DETAILS_H */ diff --git a/TAO/tao/IORInterceptor/IORInterceptor_Details.inl b/TAO/tao/IORInterceptor/IORInterceptor_Details.inl new file mode 100644 index 00000000000..a82589f3410 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInterceptor_Details.inl @@ -0,0 +1,20 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + ACE_INLINE + IORInterceptor_Details::IORInterceptor_Details (void) + { + } + + ACE_INLINE + IORInterceptor_Details::~IORInterceptor_Details (void) + { + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/IORInterceptor_Adapter.h b/TAO/tao/IORInterceptor_Adapter.h index 587b3e8f902..ea337f5c9f3 100644 --- a/TAO/tao/IORInterceptor_Adapter.h +++ b/TAO/tao/IORInterceptor_Adapter.h @@ -67,6 +67,12 @@ public: ACE_ENV_ARG_DECL ) = 0; + virtual void add_interceptor ( + PortableInterceptor::IORInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL + ) = 0; + virtual void destroy_interceptors ( ACE_ENV_SINGLE_ARG_DECL ) = 0; diff --git a/TAO/tao/Invocation_Base.cpp b/TAO/tao/Invocation_Base.cpp index f3e715f88e4..bc2d641348f 100644 --- a/TAO/tao/Invocation_Base.cpp +++ b/TAO/tao/Invocation_Base.cpp @@ -30,7 +30,8 @@ namespace TAO CORBA::Object_ptr t, TAO_Stub *stub, TAO_Operation_Details &details, - bool response_expected) + bool response_expected, + bool request_is_remote) : details_ (details) , forwarded_to_ (0) , response_expected_ (response_expected) @@ -43,8 +44,12 @@ namespace TAO , stack_size_ (0) , invoke_status_ (TAO_INVOKE_START) , caught_exception_ (0) + , is_remote_request_ (request_is_remote) #endif /*TAO_HAS_INTERCEPTORS == 1*/ { +#if TAO_HAS_INTERCEPTORS == 0 + ACE_UNUSED_ARG (request_is_remote); +#endif /*TAO_HAS_INTERCEPTORS == 0*/ } Invocation_Base::~Invocation_Base (void) diff --git a/TAO/tao/Invocation_Base.h b/TAO/tao/Invocation_Base.h index 75370bf25bb..0d497371678 100644 --- a/TAO/tao/Invocation_Base.h +++ b/TAO/tao/Invocation_Base.h @@ -127,7 +127,8 @@ namespace TAO CORBA::Object_ptr target, TAO_Stub *stub, TAO_Operation_Details &op, - bool response_expected); + bool response_expected, + bool request_is_remote); protected: /// The operation details on which we are operating on. @@ -189,6 +190,11 @@ namespace TAO PortableInterceptor::ReplyStatus reply_status (void) const; + /// Accessor used to determine if the current invocation is part + /// of a remote request, and if not, it will be considered to be + /// part of a collocated request. + bool is_remote_request() const; + protected: /// Helper method to invoke send_request interception call to all /// the registered interceptors. @@ -225,6 +231,10 @@ namespace TAO private: /// Pointer to the caught exception. CORBA::Exception *caught_exception_; + + /// Flag used to distinguish a remote invocation versus a collocated + /// (thru-poa) invocation. + bool is_remote_request_; #endif /*TAO_HAS_INTERCEPTORS*/ //@} }; diff --git a/TAO/tao/Invocation_Base.inl b/TAO/tao/Invocation_Base.inl index 30e4c6c16d3..c6a27ca28ab 100644 --- a/TAO/tao/Invocation_Base.inl +++ b/TAO/tao/Invocation_Base.inl @@ -84,6 +84,12 @@ namespace TAO { return this->invoke_status_; } + + ACE_INLINE bool + Invocation_Base::is_remote_request (void) const + { + return this->is_remote_request_; + } #endif /* TAO_HAS_INTERCEPTORS */ } diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index f84bc6a98ab..1e3f0bfe020 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -2981,7 +2981,6 @@ TAO_ORB_Core::clientrequestinterceptor_adapter_i (void) return this->client_request_interceptor_adapter_; } - void TAO_ORB_Core::add_interceptor ( PortableInterceptor::ServerRequestInterceptor_ptr interceptor @@ -3004,6 +3003,58 @@ TAO_ORB_Core::add_interceptor ( } } +void +TAO_ORB_Core::add_interceptor ( + PortableInterceptor::ClientRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL) +{ + if (this->clientrequestinterceptor_adapter_i ()) + { + this->client_request_interceptor_adapter_->add_interceptor ( + interceptor, + policies + ACE_ENV_ARG_PARAMETER); + + ACE_CHECK; + } + else + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("ERROR: ORB Core unable to find the ") + ACE_TEXT ("Client Request Interceptor Adapter Factory instance"))); + + ACE_THROW (CORBA::INTERNAL ()); + } +} + +void +TAO_ORB_Core::add_interceptor ( + PortableInterceptor::ServerRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL) +{ + if (this->serverrequestinterceptor_adapter_i ()) + { + this->server_request_interceptor_adapter_->add_interceptor ( + interceptor, + policies + ACE_ENV_ARG_PARAMETER); + + ACE_CHECK; + } + else + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("ERROR: ORB Core unable to find the ") + ACE_TEXT ("Server Request Interceptor Adapter Factory instance"))); + + ACE_THROW (CORBA::INTERNAL ()); + } +} + TAO::ServerRequestInterceptor_Adapter * TAO_ORB_Core::serverrequestinterceptor_adapter_i (void) { diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 00da0667814..d53e25d49a7 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -791,6 +791,18 @@ public: PortableInterceptor::ServerRequestInterceptor_ptr interceptor ACE_ENV_ARG_DECL); + /// Register a client request interceptor with policies. + void add_interceptor ( + PortableInterceptor::ClientRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL); + + /// Register a server request interceptor with policies. + void add_interceptor ( + PortableInterceptor::ServerRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL); + /// Get the Client Request Interceptor adapter. /// Will not create a new one if not available yet. TAO::ClientRequestInterceptor_Adapter *clientrequestinterceptor_adapter (void); diff --git a/TAO/tao/PI/ClientRequestDetails.cpp b/TAO/tao/PI/ClientRequestDetails.cpp new file mode 100644 index 00000000000..6dd19106e38 --- /dev/null +++ b/TAO/tao/PI/ClientRequestDetails.cpp @@ -0,0 +1,77 @@ +#include "ClientRequestDetails.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#if !defined (__ACE_INLINE__) +#include "ClientRequestDetails.inl" +#endif /* defined INLINE */ + +ACE_RCSID (PI, + ClientRequestDetails, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + void + ClientRequestDetails::apply_policies ( + const CORBA::PolicyList &policies + ACE_ENV_ARG_DECL) + { + // Flag to check for duplicate ProcessingModePolicy objects in the list. + bool processing_mode_applied = false; + + const CORBA::ULong plen = policies.length (); + + for (CORBA::ULong i = 0; i < plen; ++i) + { + CORBA::Policy_var policy = policies[i]; + + if (CORBA::is_nil (policy.in ())) + { + // Just ignore nil policies... + continue; + } + + // Obtain the PolicyType from the current Policy object. + const CORBA::PolicyType policy_type = + policy->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (policy_type == PortableInterceptor::PROCESSING_MODE_POLICY_TYPE) + { + if (processing_mode_applied) + { + // This is the second time we have run into this policy type, + // and that is not allowed. + ACE_THROW (CORBA::INV_POLICY ()); + } + + // Flip the flag to true in order to trap any dupes. + processing_mode_applied = true; + + // Narrow the Policy to the ProcessingModePolicy interface. + PortableInterceptor::ProcessingModePolicy_var pm_policy = + PortableInterceptor::ProcessingModePolicy::_narrow ( + policy.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Save the value of the ProcessingModePolicy in our data member. + this->processing_mode_ = + pm_policy->processing_mode (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + else + { + // We don't support the current policy type. + ACE_THROW (CORBA::INV_POLICY ()); + } + } + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/TAO/tao/PI/ClientRequestDetails.h b/TAO/tao/PI/ClientRequestDetails.h new file mode 100644 index 00000000000..59c551f8b93 --- /dev/null +++ b/TAO/tao/PI/ClientRequestDetails.h @@ -0,0 +1,85 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ClientRequestDetails.h + * + * $Id$ + * + * This file declares a class that manages the details + * about a registered client request interceptor. Policies can be + * used when interceptors are registered, and the policy values + * will be processed and used to modify the values of the + * ClientRequestDetails object associated with the registered + * client request interceptor. + * + * @author Tim Bradley <bradley_t@ociweb.com> + */ +//============================================================================= + +#ifndef TAO_CLIENT_REQUEST_DETAILS_H +#define TAO_CLIENT_REQUEST_DETAILS_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/orbconf.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "ProcessingModePolicyC.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class ClientRequestDetails + * + * @brief The policy-driven details for a registered client request + * interceptor + * + * Each time a client request interceptor is registered with an ORB, + * a ClientRequestDetails object will be created and associated with + * the registered client request interceptor. If the interceptor is + * registered with policies, the policies will be used to adjust the + * values in the ClientRequestDetails appropriately. + */ + class ClientRequestDetails + { + public: + + ClientRequestDetails (void); + ~ClientRequestDetails (void); + + void apply_policies (const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL); + + /// Returns true if the ProcessingMode setting permits the "firing" + /// of the associated client request interceptor based upon the + /// remote vs. collocated nature of the current servant request + /// that is being dispatched. + bool should_be_processed (bool is_remote_request) const; + + private: + + /// The ProcessingMode setting that can be adjusted via the + /// PortableInterceptor::ProcessingModePolicy. + PortableInterceptor::ProcessingMode processing_mode_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ClientRequestDetails.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + +#include /**/ "ace/post.h" + +#endif /* TAO_CLIENT_REQUEST_DETAILS_H */ diff --git a/TAO/tao/PI/ClientRequestDetails.inl b/TAO/tao/PI/ClientRequestDetails.inl new file mode 100644 index 00000000000..7ea1ecbb12f --- /dev/null +++ b/TAO/tao/PI/ClientRequestDetails.inl @@ -0,0 +1,32 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + ACE_INLINE + ClientRequestDetails::ClientRequestDetails (void) + : processing_mode_(PortableInterceptor::LOCAL_AND_REMOTE) + { + } + + ACE_INLINE + ClientRequestDetails::~ClientRequestDetails (void) + { + } + + ACE_INLINE + bool + ClientRequestDetails::should_be_processed (bool is_remote_request) const + { + return ((this->processing_mode_ == PortableInterceptor::LOCAL_AND_REMOTE) || + ((this->processing_mode_ == PortableInterceptor::REMOTE_ONLY) && + (is_remote_request)) || + ((this->processing_mode_ == PortableInterceptor::LOCAL_ONLY) && + (!is_remote_request))); + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/PI/ClientRequestInfo.cpp b/TAO/tao/PI/ClientRequestInfo.cpp index 00f25e22d2c..4bd5af7ebdd 100644 --- a/TAO/tao/PI/ClientRequestInfo.cpp +++ b/TAO/tao/PI/ClientRequestInfo.cpp @@ -603,8 +603,10 @@ TAO_ClientRequestInfo::result (ACE_ENV_SINGLE_ARG_DECL) bool TAO_ClientRequestInfo::result (CORBA::Any *any) { - for (CORBA::ULong i = 0; i != this->invocation_->operation_details ().args_num (); ++i) - (*this->invocation_->operation_details ().args ()[i]).interceptor_value (any); + // Result is always first element in TAO::Argument array. + TAO::Argument * const r = this->invocation_->operation_details ().args ()[0]; + + r->interceptor_value (any); return true; } diff --git a/TAO/tao/PI/ClientRequestInterceptor_Adapter_Impl.cpp b/TAO/tao/PI/ClientRequestInterceptor_Adapter_Impl.cpp index 3c05b186fcf..4c15fb3bd61 100644 --- a/TAO/tao/PI/ClientRequestInterceptor_Adapter_Impl.cpp +++ b/TAO/tao/PI/ClientRequestInterceptor_Adapter_Impl.cpp @@ -28,16 +28,25 @@ namespace TAO { // This method implements one of the "starting" client side // interception point. + + bool is_remote_request = invocation.is_remote_request(); + ACE_TRY { TAO_ClientRequestInfo ri (&invocation); for (size_t i = 0 ; i < this->interceptor_list_.size (); ++i) { - this->interceptor_list_.interceptor (i)-> - send_request (&ri - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ClientRequestInterceptor_List::RegisteredInterceptor& registered = + this->interceptor_list_.registered_interceptor (i); + + if (registered.details_.should_be_processed (is_remote_request)) + { + registered.interceptor_-> + send_request (&ri + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } // The starting interception point completed successfully. // Push the interceptor on to the flow stack. @@ -63,6 +72,8 @@ namespace TAO // This is an "ending" interception point so we only process the // interceptors pushed on to the flow stack. + bool is_remote_request = invocation.is_remote_request(); + // Notice that the interceptors are processed in the opposite order // they were pushed onto the stack since this is an "ending" // interception point. @@ -79,11 +90,18 @@ namespace TAO // invoked in another "ending" interception point. --invocation.stack_size (); - this->interceptor_list_.interceptor (invocation.stack_size ())-> - receive_reply ( - &ri - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ClientRequestInterceptor_List::RegisteredInterceptor& registered = + this->interceptor_list_.registered_interceptor ( + invocation.stack_size ()); + + if (registered.details_.should_be_processed (is_remote_request)) + { + registered.interceptor_-> + receive_reply ( + &ri + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } } // The receive_reply() interception point does not raise a @@ -99,6 +117,8 @@ namespace TAO // This is an "ending" interception point so we only process the // interceptors pushed on to the flow stack. + bool is_remote_request = invocation.is_remote_request(); + // Notice that the interceptors are processed in the opposite order // they were pushed onto the stack since this is an "ending" // interception point. @@ -116,11 +136,18 @@ namespace TAO // being invoked in another "ending" interception point. --invocation.stack_size (); - this->interceptor_list_.interceptor (invocation.stack_size ())-> - receive_exception ( - &ri - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ClientRequestInterceptor_List::RegisteredInterceptor& registered = + this->interceptor_list_.registered_interceptor ( + invocation.stack_size ()); + + if (registered.details_.should_be_processed (is_remote_request)) + { + registered.interceptor_-> + receive_exception ( + &ri + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } } } ACE_CATCH (PortableInterceptor::ForwardRequest, exc) @@ -169,6 +196,8 @@ namespace TAO // This is an "ending" interception point so we only process the // interceptors pushed on to the flow stack. + bool is_remote_request = invocation.is_remote_request(); + // Notice that the interceptors are processed in the opposite order // they were pushed onto the stack since this is an "ending" // interception point. @@ -187,11 +216,18 @@ namespace TAO // being invoked in another "ending" interception point. --invocation.stack_size (); - this->interceptor_list_.interceptor (invocation.stack_size ())-> - receive_other ( - &ri - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ClientRequestInterceptor_List::RegisteredInterceptor& registered = + this->interceptor_list_.registered_interceptor ( + invocation.stack_size ()); + + if (registered.details_.should_be_processed (is_remote_request)) + { + registered.interceptor_-> + receive_other ( + &ri + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } } } ACE_CATCH (PortableInterceptor::ForwardRequest, exc) @@ -229,6 +265,18 @@ namespace TAO } void + ClientRequestInterceptor_Adapter_Impl::add_interceptor ( + PortableInterceptor::ClientRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL) + { + this->interceptor_list_.add_interceptor (interceptor, + policies + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + void ClientRequestInterceptor_Adapter_Impl::destroy_interceptors ( ACE_ENV_SINGLE_ARG_DECL) { diff --git a/TAO/tao/PI/ClientRequestInterceptor_Adapter_Impl.h b/TAO/tao/PI/ClientRequestInterceptor_Adapter_Impl.h index f76c07b3a55..a4145cfd95a 100644 --- a/TAO/tao/PI/ClientRequestInterceptor_Adapter_Impl.h +++ b/TAO/tao/PI/ClientRequestInterceptor_Adapter_Impl.h @@ -32,13 +32,15 @@ #include "Interceptor_List_T.h" #include "ClientRequestInterceptorC.h" +#include "ClientRequestDetails.h" #include "tao/ClientRequestInterceptor_Adapter.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { - typedef Interceptor_List< ::PortableInterceptor::ClientRequestInterceptor> + typedef Interceptor_List< ::PortableInterceptor::ClientRequestInterceptor, + ClientRequestDetails> ClientRequestInterceptor_List; } @@ -100,6 +102,12 @@ namespace TAO PortableInterceptor::ClientRequestInterceptor_ptr interceptor ACE_ENV_ARG_DECL); + /// Register an interceptor with policies. + virtual void add_interceptor ( + PortableInterceptor::ClientRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL); + virtual void destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL); virtual PortableInterceptor::ReplyStatus reply_status ( diff --git a/TAO/tao/PI/Interceptor_List_T.cpp b/TAO/tao/PI/Interceptor_List_T.cpp index bbb53171661..a62542fc6b8 100644 --- a/TAO/tao/PI/Interceptor_List_T.cpp +++ b/TAO/tao/PI/Interceptor_List_T.cpp @@ -14,28 +14,36 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { - template <typename InterceptorType> - Interceptor_List<InterceptorType>::Interceptor_List (void) + template <typename InterceptorType, typename DetailsType> + Interceptor_List<InterceptorType,DetailsType>::Interceptor_List (void) { } - template <typename InterceptorType> - typename Interceptor_List<InterceptorType>::InterceptorType_ptr_type - Interceptor_List<InterceptorType>::interceptor (size_t index) + template <typename InterceptorType, typename DetailsType> + typename Interceptor_List<InterceptorType,DetailsType>::RegisteredInterceptor& + Interceptor_List<InterceptorType,DetailsType>::registered_interceptor ( + size_t index) { - return this->interceptors_[index].in (); + return this->interceptors_[index]; } - template <typename InterceptorType> + template <typename InterceptorType, typename DetailsType> + typename Interceptor_List<InterceptorType,DetailsType>::InterceptorType_ptr_type + Interceptor_List<InterceptorType,DetailsType>::interceptor (size_t index) + { + return this->interceptors_[index].interceptor_.in (); + } + + template <typename InterceptorType, typename DetailsType> size_t - Interceptor_List<InterceptorType>::size (void) + Interceptor_List<InterceptorType,DetailsType>::size (void) { return this->interceptors_.size (); } - template <typename InterceptorType> + template <typename InterceptorType, typename DetailsType> void - Interceptor_List<InterceptorType>::add_interceptor ( + Interceptor_List<InterceptorType,DetailsType>::add_interceptor ( InterceptorType_ptr_type interceptor ACE_ENV_ARG_DECL) { @@ -90,7 +98,91 @@ namespace TAO this->interceptors_.size (new_len); // Add the interceptor - this->interceptors_[old_len] = InterceptorType::_duplicate (interceptor); + this->interceptors_[old_len].interceptor_ = + InterceptorType::_duplicate (interceptor); + } + else + { + ACE_THROW ( + CORBA::INV_OBJREF ( + CORBA::SystemException::_tao_minor_code ( + 0, + EINVAL + ), + CORBA::COMPLETED_NO + ) + ); + } + } + + template <typename InterceptorType, typename DetailsType> + void + Interceptor_List<InterceptorType,DetailsType>::add_interceptor ( + InterceptorType_ptr_type interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL) + { + if (!CORBA::is_nil (interceptor)) + { + const size_t old_len = this->interceptors_.size (); + + // Don't bother checking the name for duplicates if no + // interceptors have been registered. This saves an + // allocation. + if (old_len > 0) + { + /// If the Interceptor is not anonymous, make sure an + /// Interceptor with the same isn't already registered. + CORBA::String_var name = + interceptor->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (ACE_OS::strlen (name.in ()) != 0) + { + // @@ This simple search algorithm isn't the greatest + // thing in the world, but since we only register + // interceptors when bootstrapping an ORB, there will + // be no runtime penalty. + // + // Another source of inefficiency is that + // Interceptors duplicate their name each time the + // name() accessor is called! This can slow down + // bootstrap time noticeably when registering a huge + // number of interceptors. We could cache the names + // somewhere, but since this is only a bootstrapping + // issue there's no rush to implement such a scheme. + + // Prevent interceptors with the same name from being + // registered. Anonymous interceptors are okay. + for (size_t i = 0; i < old_len; ++i) + { + CORBA::String_var existing_name = + this->interceptor (i)->name (); + + if (ACE_OS::strcmp (existing_name.in (), + name.in ()) == 0) + { + ACE_THROW (PortableInterceptor::ORBInitInfo::DuplicateName ()); + } + } + } + } + + // Create a DetailsType object, and attempt to apply the policies. + DetailsType details; + details.apply_policies(policies ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + /// Increase the length of the Interceptor sequence by one. + const size_t new_len = old_len + 1; + this->interceptors_.size (new_len); + + // Add the interceptor + this->interceptors_[old_len].interceptor_ = + InterceptorType::_duplicate (interceptor); + + // Set the details + this->interceptors_[old_len].details_ = details; } else { @@ -106,9 +198,9 @@ namespace TAO } } - template <typename InterceptorType> + template <typename InterceptorType, typename DetailsType> void - Interceptor_List<InterceptorType>::destroy_interceptors ( + Interceptor_List<InterceptorType,DetailsType>::destroy_interceptors ( ACE_ENV_SINGLE_ARG_DECL) { const size_t len = this->interceptors_.size (); diff --git a/TAO/tao/PI/Interceptor_List_T.h b/TAO/tao/PI/Interceptor_List_T.h index c6f11f4d75b..24f7d0c1e5d 100644 --- a/TAO/tao/PI/Interceptor_List_T.h +++ b/TAO/tao/PI/Interceptor_List_T.h @@ -32,6 +32,11 @@ namespace PortableInterceptor typedef Interceptor *Interceptor_ptr; } +namespace CORBA +{ + class PolicyList; +} + namespace TAO { /** @@ -42,14 +47,19 @@ namespace TAO * Template for the various portable interceptor lists used * internally by TAO. */ - template <typename InterceptorType> + template <typename InterceptorType, typename DetailsType> class Interceptor_List { public: /// Define the traits for the underlying portable interceptor array. typedef typename InterceptorType::_var_type InterceptorType_var_type; typedef typename InterceptorType::_ptr_type InterceptorType_ptr_type; - typedef ACE_Array_Base<InterceptorType_var_type> TYPE; + + struct RegisteredInterceptor + { + InterceptorType_var_type interceptor_; + DetailsType details_; + }; /// Constructor. Interceptor_List (void); @@ -58,17 +68,28 @@ namespace TAO InterceptorType_ptr_type i ACE_ENV_ARG_DECL); + /// Register an interceptor with policies. + void add_interceptor (InterceptorType_ptr_type i, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL); + void destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL); + /// Return the registered interceptor in sequence element @a index. + RegisteredInterceptor& registered_interceptor ( + size_t index); + /// Return the interceptor in sequence element @a index. InterceptorType_ptr_type interceptor (size_t index); size_t size (void); private: - /// Dynamic array of registered interceptors. - TYPE interceptors_; + typedef ACE_Array_Base<RegisteredInterceptor > RegisteredArray; + + /// Dynamic array of registered interceptors. + RegisteredArray interceptors_; }; } diff --git a/TAO/tao/PI/ORBInitInfo.cpp b/TAO/tao/PI/ORBInitInfo.cpp index 4819da4e5c6..787c3b858ee 100644 --- a/TAO/tao/PI/ORBInitInfo.cpp +++ b/TAO/tao/PI/ORBInitInfo.cpp @@ -260,6 +260,86 @@ TAO_ORBInitInfo::add_ior_interceptor ( ACE_ENV_ARG_PARAMETER); } +void +TAO_ORBInitInfo::add_client_request_interceptor_with_policy ( + PortableInterceptor::ClientRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ORBInitInfo::DuplicateName, + CORBA::PolicyError)) +{ +# if TAO_HAS_INTERCEPTORS == 1 + this->check_validity (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->orb_core_->add_interceptor (interceptor, + policies + ACE_ENV_ARG_PARAMETER); +#else + ACE_UNUSED_ARG (interceptor); + ACE_UNUSED_ARG (policies); + ACE_THROW (CORBA::NO_IMPLEMENT ( + CORBA::SystemException::_tao_minor_code ( + 0, + ENOTSUP), + CORBA::COMPLETED_NO)); +#endif /* TAO_HAS_INTERCEPTORS == 1 */ +} + +void +TAO_ORBInitInfo::add_server_request_interceptor_with_policy ( + PortableInterceptor::ServerRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ORBInitInfo::DuplicateName, + CORBA::PolicyError)) +{ +# if TAO_HAS_INTERCEPTORS == 1 + this->check_validity (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->orb_core_->add_interceptor (interceptor, + policies + ACE_ENV_ARG_PARAMETER); + +#else + ACE_UNUSED_ARG (interceptor); + ACE_UNUSED_ARG (policies); + ACE_THROW (CORBA::NO_IMPLEMENT ( + CORBA::SystemException::_tao_minor_code ( + 0, + ENOTSUP), + CORBA::COMPLETED_NO)); +#endif /* TAO_HAS_INTERCEPTORS == 1 */ +} + +void +TAO_ORBInitInfo::add_ior_interceptor_with_policy ( + PortableInterceptor::IORInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ORBInitInfo::DuplicateName, + CORBA::PolicyError)) +{ + this->check_validity (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // Since there are currently no PI Policies that pertain to + // IOR Interceptors, we will always raise the NO_IMPLEMENT + // CORBA System Exception here to indicate that this method + // is currently not implemented/supported. + ACE_UNUSED_ARG (interceptor); + ACE_UNUSED_ARG (policies); + ACE_THROW (CORBA::NO_IMPLEMENT ( + CORBA::SystemException::_tao_minor_code ( + 0, + ENOTSUP), + CORBA::COMPLETED_NO)); +} + PortableInterceptor::SlotId TAO_ORBInitInfo::allocate_slot_id (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) diff --git a/TAO/tao/PI/ORBInitInfo.h b/TAO/tao/PI/ORBInitInfo.h index 0598088c330..729d9ecac13 100644 --- a/TAO/tao/PI/ORBInitInfo.h +++ b/TAO/tao/PI/ORBInitInfo.h @@ -50,14 +50,14 @@ typedef TAO_Objref_Out_T<TAO_ORBInitInfo> /** * @class TAO_ORBInitInfo * - * @brief An implementation of the PortableInterceptor::ORBInitInfo + * @brief An implementation of the PortableInterceptor::ORBInitInfo_3_1 * interface. * * This class encapsulates the data passed to ORBInitializers during * ORB initialization. */ class TAO_PI_Export TAO_ORBInitInfo - : public virtual PortableInterceptor::ORBInitInfo, + : public virtual PortableInterceptor::ORBInitInfo_3_1, public virtual TAO_Local_RefCounted_Object { public: @@ -142,6 +142,36 @@ public: ACE_THROW_SPEC ((CORBA::SystemException, PortableInterceptor::ORBInitInfo::DuplicateName)); + /// Register a client request interceptor with the ORB currently + /// being initialized, along with a list of policies. + virtual void add_client_request_interceptor_with_policy ( + PortableInterceptor::ClientRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ORBInitInfo::DuplicateName, + CORBA::PolicyError)); + + /// Register a server request interceptor with the ORB currently + /// being initialized, along with a list of policies. + virtual void add_server_request_interceptor_with_policy ( + PortableInterceptor::ServerRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ORBInitInfo::DuplicateName, + CORBA::PolicyError)); + + /// Register an IOR interceptor with the ORB currently being + /// initialized, along with a list of policies. + virtual void add_ior_interceptor_with_policy ( + PortableInterceptor::IORInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ORBInitInfo::DuplicateName, + CORBA::PolicyError)); + /// Reserve a slot in table found within the /// PortableInterceptor::Current object. virtual PortableInterceptor::SlotId allocate_slot_id ( diff --git a/TAO/tao/PI/ORBInitInfo.pidl b/TAO/tao/PI/ORBInitInfo.pidl index 714ad493171..91dcbdf06f7 100644 --- a/TAO/tao/PI/ORBInitInfo.pidl +++ b/TAO/tao/PI/ORBInitInfo.pidl @@ -68,6 +68,23 @@ module PortableInterceptor { in CORBA::PolicyType type, in PolicyFactory policy_factory); }; + + local interface ORBInitInfo_3_1 : ORBInitInfo + { + void add_client_request_interceptor_with_policy( + in ClientRequestInterceptor interceptor, + in CORBA::PolicyList policies) + raises (DuplicateName, CORBA::PolicyError); + void add_server_request_interceptor_with_policy( + in ServerRequestInterceptor interceptor, + in CORBA::PolicyList policies) + raises (DuplicateName, CORBA::PolicyError); + void add_ior_interceptor_with_policy( + in IORInterceptor interceptor, + in CORBA::PolicyList policies) + raises (DuplicateName, CORBA::PolicyError); + }; + }; #endif /* _ORBINITINFO_PIDL_ */ diff --git a/TAO/tao/PI/ORBInitInfoC.cpp b/TAO/tao/PI/ORBInitInfoC.cpp index 59150dfa366..52663736295 100644 --- a/TAO/tao/PI/ORBInitInfoC.cpp +++ b/TAO/tao/PI/ORBInitInfoC.cpp @@ -26,7 +26,7 @@ // http://www.cs.wustl.edu/~schmidt/TAO.html // TAO_IDL - Generated from -// be\be_codegen.cpp:277 +// be/be_codegen.cpp:292 #include "ORBInitInfoC.h" @@ -43,11 +43,13 @@ #include "tao/AnyTypeCode/Any_Dual_Impl_T.h" #include "ace/OS_NS_string.h" -// TAO_IDL - Generated from -// be\be_visitor_arg_traits.cpp:70 - TAO_BEGIN_VERSIONED_NAMESPACE_DECL + + +// TAO_IDL - Generated from +// be/be_visitor_arg_traits.cpp:70 + // Arg traits specializations. namespace TAO { @@ -55,7 +57,7 @@ namespace TAO // TAO_IDL - Generated from -// be\be_visitor_interface/interface_cs.cpp:60 +// be/be_visitor_interface/interface_cs.cpp:60 // Traits specializations for PortableInterceptor::ORBInitInfo. @@ -83,7 +85,7 @@ TAO::Objref_Traits<PortableInterceptor::ORBInitInfo>::nil (void) ::CORBA::Boolean TAO::Objref_Traits<PortableInterceptor::ORBInitInfo>::marshal ( - PortableInterceptor::ORBInitInfo_ptr p, + const PortableInterceptor::ORBInitInfo_ptr p, TAO_OutputCDR & cdr ) { @@ -91,7 +93,7 @@ TAO::Objref_Traits<PortableInterceptor::ORBInitInfo>::marshal ( } // TAO_IDL - Generated from -// be\be_visitor_typecode/alias_typecode.cpp:50 +// be/be_visitor_typecode/alias_typecode.cpp:50 static TAO::TypeCode::Alias<char const *, ::CORBA::TypeCode_ptr const *, @@ -101,12 +103,12 @@ static TAO::TypeCode::Alias<char const *, "IDL:omg.org/PortableInterceptor/ORBInitInfo/ObjectId:1.0", "ObjectId", &CORBA::_tc_string); - + ::CORBA::TypeCode_ptr const PortableInterceptor::ORBInitInfo::_tc_ObjectId = &_tao_tc_PortableInterceptor_ORBInitInfo_ObjectId; -// TAO_IDL - Generated from -// be\be_visitor_exception/exception_cs.cpp:63 +// TAO_IDL - Generated from +// be/be_visitor_exception/exception_cs.cpp:63 PortableInterceptor::ORBInitInfo::DuplicateName::DuplicateName (void) : ::CORBA::UserException ( @@ -199,7 +201,7 @@ void PortableInterceptor::ORBInitInfo::DuplicateName::_tao_decode ( // TAO_IDL - Generated from -// be\be_visitor_exception/exception_ctor.cpp:66 +// be/be_visitor_exception/exception_ctor.cpp:66 PortableInterceptor::ORBInitInfo::DuplicateName::DuplicateName ( const char * _tao_name @@ -219,12 +221,12 @@ PortableInterceptor::ORBInitInfo::DuplicateName::DuplicateName ( } // TAO_IDL - Generated from -// be\be_visitor_typecode/struct_typecode.cpp:89 +// be/be_visitor_typecode/struct_typecode.cpp:89 static TAO::TypeCode::Struct_Field<char const *, ::CORBA::TypeCode_ptr const *> const _tao_fields_PortableInterceptor_ORBInitInfo_DuplicateName[] = { { "name", &CORBA::_tc_string } - + }; static TAO::TypeCode::Struct<char const *, ::CORBA::TypeCode_ptr const *, @@ -236,12 +238,12 @@ static TAO::TypeCode::Struct<char const *, "DuplicateName", _tao_fields_PortableInterceptor_ORBInitInfo_DuplicateName, 1); - + ::CORBA::TypeCode_ptr const PortableInterceptor::ORBInitInfo::_tc_DuplicateName = &_tao_tc_PortableInterceptor_ORBInitInfo_DuplicateName; -// TAO_IDL - Generated from -// be\be_visitor_exception/exception_cs.cpp:63 +// TAO_IDL - Generated from +// be/be_visitor_exception/exception_cs.cpp:63 PortableInterceptor::ORBInitInfo::InvalidName::InvalidName (void) : ::CORBA::UserException ( @@ -336,7 +338,7 @@ void PortableInterceptor::ORBInitInfo::InvalidName::_tao_decode ( } // TAO_IDL - Generated from -// be\be_visitor_typecode/struct_typecode.cpp:89 +// be/be_visitor_typecode/struct_typecode.cpp:89 static TAO::TypeCode::Struct_Field<char const *, ::CORBA::TypeCode_ptr const *> const * const _tao_fields_PortableInterceptor_ORBInitInfo_InvalidName = 0; static TAO::TypeCode::Struct<char const *, @@ -349,7 +351,7 @@ static TAO::TypeCode::Struct<char const *, "InvalidName", _tao_fields_PortableInterceptor_ORBInitInfo_InvalidName, 0); - + ::CORBA::TypeCode_ptr const PortableInterceptor::ORBInitInfo::_tc_InvalidName = &_tao_tc_PortableInterceptor_ORBInitInfo_InvalidName; @@ -388,7 +390,7 @@ PortableInterceptor::ORBInitInfo::_duplicate (ORBInitInfo_ptr obj) { obj->_add_ref (); } - + return obj; } @@ -439,7 +441,7 @@ PortableInterceptor::ORBInitInfo::marshal (TAO_OutputCDR &) } // TAO_IDL - Generated from -// be\be_visitor_typecode/objref_typecode.cpp:76 +// be/be_visitor_typecode/objref_typecode.cpp:76 static TAO::TypeCode::Objref<char const *, TAO::Null_RefCount_Policy> @@ -447,7 +449,7 @@ static TAO::TypeCode::Objref<char const *, ::CORBA::tk_local_interface, "IDL:omg.org/PortableInterceptor/ORBInitInfo:1.0", "ORBInitInfo"); - + namespace PortableInterceptor { ::CORBA::TypeCode_ptr const _tc_ORBInitInfo = @@ -455,4 +457,151 @@ namespace PortableInterceptor } + +// TAO_IDL - Generated from +// be/be_visitor_interface/interface_cs.cpp:60 + +// Traits specializations for PortableInterceptor::ORBInitInfo_3_1. + +PortableInterceptor::ORBInitInfo_3_1_ptr +TAO::Objref_Traits<PortableInterceptor::ORBInitInfo_3_1>::duplicate ( + PortableInterceptor::ORBInitInfo_3_1_ptr p + ) +{ + return PortableInterceptor::ORBInitInfo_3_1::_duplicate (p); +} + +void +TAO::Objref_Traits<PortableInterceptor::ORBInitInfo_3_1>::release ( + PortableInterceptor::ORBInitInfo_3_1_ptr p + ) +{ + CORBA::release (p); +} + +PortableInterceptor::ORBInitInfo_3_1_ptr +TAO::Objref_Traits<PortableInterceptor::ORBInitInfo_3_1>::nil (void) +{ + return PortableInterceptor::ORBInitInfo_3_1::_nil (); +} + +::CORBA::Boolean +TAO::Objref_Traits<PortableInterceptor::ORBInitInfo_3_1>::marshal ( + const PortableInterceptor::ORBInitInfo_3_1_ptr p, + TAO_OutputCDR & cdr + ) +{ + return ::CORBA::Object::marshal (p, cdr); +} + +PortableInterceptor::ORBInitInfo_3_1::ORBInitInfo_3_1 (void) +{} + +PortableInterceptor::ORBInitInfo_3_1::~ORBInitInfo_3_1 (void) +{} + +PortableInterceptor::ORBInitInfo_3_1_ptr +PortableInterceptor::ORBInitInfo_3_1::_narrow ( + ::CORBA::Object_ptr _tao_objref + ACE_ENV_ARG_DECL_NOT_USED + ) +{ + return ORBInitInfo_3_1::_duplicate ( + dynamic_cast<ORBInitInfo_3_1_ptr> (_tao_objref) + ); +} + +PortableInterceptor::ORBInitInfo_3_1_ptr +PortableInterceptor::ORBInitInfo_3_1::_unchecked_narrow ( + ::CORBA::Object_ptr _tao_objref + ACE_ENV_ARG_DECL_NOT_USED + ) +{ + return ORBInitInfo_3_1::_duplicate ( + dynamic_cast<ORBInitInfo_3_1_ptr> (_tao_objref) + ); +} + +PortableInterceptor::ORBInitInfo_3_1_ptr +PortableInterceptor::ORBInitInfo_3_1::_duplicate (ORBInitInfo_3_1_ptr obj) +{ + if (! CORBA::is_nil (obj)) + { + obj->_add_ref (); + } + + return obj; +} + +void +PortableInterceptor::ORBInitInfo_3_1::_tao_release (ORBInitInfo_3_1_ptr obj) +{ + CORBA::release (obj); +} + +::CORBA::Boolean +PortableInterceptor::ORBInitInfo_3_1::_is_a ( + const char *value + ACE_ENV_ARG_DECL_NOT_USED + ) +{ + if ( + !ACE_OS::strcmp ( + value, + "IDL:omg.org/PortableInterceptor/ORBInitInfo:1.0" + ) || + !ACE_OS::strcmp ( + value, + "IDL:omg.org/PortableInterceptor/ORBInitInfo_3_1:1.0" + ) || + !ACE_OS::strcmp ( + value, + "IDL:omg.org/CORBA/LocalObject:1.0" + ) || + !ACE_OS::strcmp ( + value, + "IDL:omg.org/CORBA/Object:1.0" + ) + ) + { + return true; // success using local knowledge + } + else + { + return false; + } +} + +const char* PortableInterceptor::ORBInitInfo_3_1::_interface_repository_id (void) const +{ + return "IDL:omg.org/PortableInterceptor/ORBInitInfo_3_1:1.0"; +} + +::CORBA::Boolean +PortableInterceptor::ORBInitInfo_3_1::marshal (TAO_OutputCDR &) +{ + return false; +} + +// TAO_IDL - Generated from +// be/be_visitor_typecode/objref_typecode.cpp:76 + +static TAO::TypeCode::Objref<char const *, + TAO::Null_RefCount_Policy> + _tao_tc_PortableInterceptor_ORBInitInfo_3_1 ( + ::CORBA::tk_local_interface, + "IDL:omg.org/PortableInterceptor/ORBInitInfo_3_1:1.0", + "ORBInitInfo_3_1"); + +namespace PortableInterceptor +{ + ::CORBA::TypeCode_ptr const _tc_ORBInitInfo_3_1 = + &_tao_tc_PortableInterceptor_ORBInitInfo_3_1; +} + + + + TAO_END_VERSIONED_NAMESPACE_DECL + + diff --git a/TAO/tao/PI/ORBInitInfoC.h b/TAO/tao/PI/ORBInitInfoC.h index 58baf32bb58..7ba6d29d08a 100644 --- a/TAO/tao/PI/ORBInitInfoC.h +++ b/TAO/tao/PI/ORBInitInfoC.h @@ -26,10 +26,10 @@ // http://www.cs.wustl.edu/~schmidt/TAO.html // TAO_IDL - Generated from -// be\be_codegen.cpp:154 +// be/be_codegen.cpp:164 -#ifndef _TAO_IDL_ORBINITINFOC_H_ -#define _TAO_IDL_ORBINITINFOC_H_ +#ifndef _TAO_IDL_ORIG_ORBINITINFOC_H_ +#define _TAO_IDL_ORIG_ORBINITINFOC_H_ #include /**/ "ace/pre.h" @@ -46,11 +46,13 @@ #include "tao/SystemException.h" #include "tao/Environment.h" #include "tao/Object.h" +#include "tao/Managed_Types.h" #include "tao/AnyTypeCode/StringSeqA.h" #include "tao/CodecFactory/IOP_Codec_includeA.h" #include "tao/AnyTypeCode/PI_ForwardA.h" #include "tao/AnyTypeCode/PolicyA.h" #include "tao/Objref_VarOut_T.h" +#include "tao/Versioned_Namespace.h" #include "tao/StringSeqC.h" #include "tao/CodecFactory/IOP_Codec_includeC.h" @@ -62,29 +64,31 @@ #endif #define TAO_EXPORT_MACRO TAO_PI_Export -// TAO_IDL - Generated from -// be\be_visitor_module/module_ch.cpp:49 - TAO_BEGIN_VERSIONED_NAMESPACE_DECL + + +// TAO_IDL - Generated from +// be/be_visitor_module/module_ch.cpp:49 + namespace PortableInterceptor { - + // TAO_IDL - Generated from - // be\be_interface.cpp:646 + // be/be_interface.cpp:646 #if !defined (_PORTABLEINTERCEPTOR_CLIENTREQUESTINTERCEPTOR__VAR_OUT_CH_) #define _PORTABLEINTERCEPTOR_CLIENTREQUESTINTERCEPTOR__VAR_OUT_CH_ - + class ClientRequestInterceptor; typedef ClientRequestInterceptor *ClientRequestInterceptor_ptr; - + typedef TAO_Objref_Var_T< ClientRequestInterceptor > ClientRequestInterceptor_var; - + typedef TAO_Objref_Out_T< ClientRequestInterceptor @@ -92,22 +96,22 @@ namespace PortableInterceptor ClientRequestInterceptor_out; #endif /* end #if !defined */ - + // TAO_IDL - Generated from - // be\be_interface.cpp:646 + // be/be_interface.cpp:646 #if !defined (_PORTABLEINTERCEPTOR_SERVERREQUESTINTERCEPTOR__VAR_OUT_CH_) #define _PORTABLEINTERCEPTOR_SERVERREQUESTINTERCEPTOR__VAR_OUT_CH_ - + class ServerRequestInterceptor; typedef ServerRequestInterceptor *ServerRequestInterceptor_ptr; - + typedef TAO_Objref_Var_T< ServerRequestInterceptor > ServerRequestInterceptor_var; - + typedef TAO_Objref_Out_T< ServerRequestInterceptor @@ -115,22 +119,22 @@ namespace PortableInterceptor ServerRequestInterceptor_out; #endif /* end #if !defined */ - + // TAO_IDL - Generated from - // be\be_interface.cpp:646 + // be/be_interface.cpp:646 #if !defined (_PORTABLEINTERCEPTOR_IORINTERCEPTOR__VAR_OUT_CH_) #define _PORTABLEINTERCEPTOR_IORINTERCEPTOR__VAR_OUT_CH_ - + class IORInterceptor; typedef IORInterceptor *IORInterceptor_ptr; - + typedef TAO_Objref_Var_T< IORInterceptor > IORInterceptor_var; - + typedef TAO_Objref_Out_T< IORInterceptor @@ -138,22 +142,22 @@ namespace PortableInterceptor IORInterceptor_out; #endif /* end #if !defined */ - + // TAO_IDL - Generated from - // be\be_interface.cpp:646 + // be/be_interface.cpp:646 #if !defined (_PORTABLEINTERCEPTOR_POLICYFACTORY__VAR_OUT_CH_) #define _PORTABLEINTERCEPTOR_POLICYFACTORY__VAR_OUT_CH_ - + class PolicyFactory; typedef PolicyFactory *PolicyFactory_ptr; - + typedef TAO_Objref_Var_T< PolicyFactory > PolicyFactory_var; - + typedef TAO_Objref_Out_T< PolicyFactory @@ -161,22 +165,22 @@ namespace PortableInterceptor PolicyFactory_out; #endif /* end #if !defined */ - + // TAO_IDL - Generated from - // be\be_interface.cpp:646 + // be/be_interface.cpp:646 #if !defined (_PORTABLEINTERCEPTOR_ORBINITINFO__VAR_OUT_CH_) #define _PORTABLEINTERCEPTOR_ORBINITINFO__VAR_OUT_CH_ - + class ORBInitInfo; typedef ORBInitInfo *ORBInitInfo_ptr; - + typedef TAO_Objref_Var_T< ORBInitInfo > ORBInitInfo_var; - + typedef TAO_Objref_Out_T< ORBInitInfo @@ -184,78 +188,78 @@ namespace PortableInterceptor ORBInitInfo_out; #endif /* end #if !defined */ - + // TAO_IDL - Generated from - // be\be_visitor_interface/interface_ch.cpp:54 + // be/be_visitor_interface/interface_ch.cpp:54 #if !defined (_PORTABLEINTERCEPTOR_ORBINITINFO_CH_) #define _PORTABLEINTERCEPTOR_ORBINITINFO_CH_ - + class TAO_PI_Export ORBInitInfo : public virtual ::CORBA::Object { public: typedef ORBInitInfo_ptr _ptr_type; typedef ORBInitInfo_var _var_type; - + // The static operations. static ORBInitInfo_ptr _duplicate (ORBInitInfo_ptr obj); - + static void _tao_release (ORBInitInfo_ptr obj); - + static ORBInitInfo_ptr _narrow ( ::CORBA::Object_ptr obj ACE_ENV_ARG_DECL_WITH_DEFAULTS ); - + static ORBInitInfo_ptr _unchecked_narrow ( ::CORBA::Object_ptr obj ACE_ENV_ARG_DECL_WITH_DEFAULTS ); - + static ORBInitInfo_ptr _nil (void) { return static_cast<ORBInitInfo_ptr> (0); } - - - + + + // TAO_IDL - Generated from - // be\be_visitor_typedef/typedef_ch.cpp:413 - + // be/be_visitor_typedef/typedef_ch.cpp:413 + typedef char * ObjectId; typedef ::CORBA::String_var ObjectId_var; typedef ::CORBA::String_out ObjectId_out; - + // TAO_IDL - Generated from - // be\be_visitor_typecode/typecode_decl.cpp:49 - + // be/be_visitor_typecode/typecode_decl.cpp:49 + static ::CORBA::TypeCode_ptr const _tc_ObjectId; - + // TAO_IDL - Generated from - // be\be_visitor_exception/exception_ch.cpp:53 + // be/be_visitor_exception/exception_ch.cpp:53 #if !defined (_PORTABLEINTERCEPTOR_ORBINITINFO_DUPLICATENAME_CH_) #define _PORTABLEINTERCEPTOR_ORBINITINFO_DUPLICATENAME_CH_ - + class TAO_PI_Export DuplicateName : public ::CORBA::UserException { public: - + TAO_String_Manager name; DuplicateName (void); DuplicateName (const DuplicateName &); ~DuplicateName (void); DuplicateName &operator= (const DuplicateName &); - + static void _tao_any_destructor (void *); - + static DuplicateName *_downcast ( ::CORBA::Exception *); static const DuplicateName *_downcast ( ::CORBA::Exception const *); - + static ::CORBA::Exception *_alloc (void); - + virtual ::CORBA::Exception *_tao_duplicate (void) const; virtual void _raise (void) const; @@ -264,52 +268,52 @@ namespace PortableInterceptor TAO_OutputCDR & ACE_ENV_ARG_DECL ) const; - + virtual void _tao_decode ( TAO_InputCDR & ACE_ENV_ARG_DECL ); - + // TAO_IDL - Generated from - // be\be_visitor_exception/exception_ctor.cpp:66 - + // be/be_visitor_exception/exception_ctor.cpp:66 + DuplicateName ( const char * _tao_name ); - + virtual ::CORBA::TypeCode_ptr _tao_type (void) const; }; - + // TAO_IDL - Generated from - // be\be_visitor_typecode/typecode_decl.cpp:49 - + // be/be_visitor_typecode/typecode_decl.cpp:49 + static ::CORBA::TypeCode_ptr const _tc_DuplicateName; #endif /* end #if !defined */ - + // TAO_IDL - Generated from - // be\be_visitor_exception/exception_ch.cpp:53 + // be/be_visitor_exception/exception_ch.cpp:53 #if !defined (_PORTABLEINTERCEPTOR_ORBINITINFO_INVALIDNAME_CH_) #define _PORTABLEINTERCEPTOR_ORBINITINFO_INVALIDNAME_CH_ - + class TAO_PI_Export InvalidName : public ::CORBA::UserException { public: - + InvalidName (void); InvalidName (const InvalidName &); ~InvalidName (void); InvalidName &operator= (const InvalidName &); - + static void _tao_any_destructor (void *); - + static InvalidName *_downcast ( ::CORBA::Exception *); static const InvalidName *_downcast ( ::CORBA::Exception const *); - + static ::CORBA::Exception *_alloc (void); - + virtual ::CORBA::Exception *_tao_duplicate (void) const; virtual void _raise (void) const; @@ -318,55 +322,55 @@ namespace PortableInterceptor TAO_OutputCDR & ACE_ENV_ARG_DECL ) const; - + virtual void _tao_decode ( TAO_InputCDR & ACE_ENV_ARG_DECL ); - + virtual ::CORBA::TypeCode_ptr _tao_type (void) const; }; - + // TAO_IDL - Generated from - // be\be_visitor_typecode/typecode_decl.cpp:49 - + // be/be_visitor_typecode/typecode_decl.cpp:49 + static ::CORBA::TypeCode_ptr const _tc_InvalidName; #endif /* end #if !defined */ - + // TAO_IDL - Generated from - // be\be_visitor_operation/operation_ch.cpp:46 - + // be/be_visitor_operation/operation_ch.cpp:46 + virtual ::CORBA::StringSeq * arguments ( ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS ) ACE_THROW_SPEC (( ::CORBA::SystemException )) = 0; - + // TAO_IDL - Generated from - // be\be_visitor_operation/operation_ch.cpp:46 - + // be/be_visitor_operation/operation_ch.cpp:46 + virtual char * orb_id ( ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS ) ACE_THROW_SPEC (( ::CORBA::SystemException )) = 0; - + // TAO_IDL - Generated from - // be\be_visitor_operation/operation_ch.cpp:46 - + // be/be_visitor_operation/operation_ch.cpp:46 + virtual ::IOP::CodecFactory_ptr codec_factory ( ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS ) ACE_THROW_SPEC (( ::CORBA::SystemException )) = 0; - + // TAO_IDL - Generated from - // be\be_visitor_operation/operation_ch.cpp:46 - + // be/be_visitor_operation/operation_ch.cpp:46 + virtual void register_initial_reference ( const char * id, ::CORBA::Object_ptr obj @@ -376,10 +380,10 @@ namespace PortableInterceptor ::CORBA::SystemException, ::PortableInterceptor::ORBInitInfo::InvalidName )) = 0; - + // TAO_IDL - Generated from - // be\be_visitor_operation/operation_ch.cpp:46 - + // be/be_visitor_operation/operation_ch.cpp:46 + virtual ::CORBA::Object_ptr resolve_initial_references ( const char * id ACE_ENV_ARG_DECL_WITH_DEFAULTS @@ -388,10 +392,10 @@ namespace PortableInterceptor ::CORBA::SystemException, ::PortableInterceptor::ORBInitInfo::InvalidName )) = 0; - + // TAO_IDL - Generated from - // be\be_visitor_operation/operation_ch.cpp:46 - + // be/be_visitor_operation/operation_ch.cpp:46 + virtual void add_client_request_interceptor ( ::PortableInterceptor::ClientRequestInterceptor_ptr interceptor ACE_ENV_ARG_DECL_WITH_DEFAULTS @@ -400,10 +404,10 @@ namespace PortableInterceptor ::CORBA::SystemException, ::PortableInterceptor::ORBInitInfo::DuplicateName )) = 0; - + // TAO_IDL - Generated from - // be\be_visitor_operation/operation_ch.cpp:46 - + // be/be_visitor_operation/operation_ch.cpp:46 + virtual void add_server_request_interceptor ( ::PortableInterceptor::ServerRequestInterceptor_ptr interceptor ACE_ENV_ARG_DECL_WITH_DEFAULTS @@ -412,10 +416,10 @@ namespace PortableInterceptor ::CORBA::SystemException, ::PortableInterceptor::ORBInitInfo::DuplicateName )) = 0; - + // TAO_IDL - Generated from - // be\be_visitor_operation/operation_ch.cpp:46 - + // be/be_visitor_operation/operation_ch.cpp:46 + virtual void add_ior_interceptor ( ::PortableInterceptor::IORInterceptor_ptr interceptor ACE_ENV_ARG_DECL_WITH_DEFAULTS @@ -424,20 +428,20 @@ namespace PortableInterceptor ::CORBA::SystemException, ::PortableInterceptor::ORBInitInfo::DuplicateName )) = 0; - + // TAO_IDL - Generated from - // be\be_visitor_operation/operation_ch.cpp:46 - + // be/be_visitor_operation/operation_ch.cpp:46 + virtual ::PortableInterceptor::SlotId allocate_slot_id ( ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS ) ACE_THROW_SPEC (( ::CORBA::SystemException )) = 0; - + // TAO_IDL - Generated from - // be\be_visitor_operation/operation_ch.cpp:46 - + // be/be_visitor_operation/operation_ch.cpp:46 + virtual void register_policy_factory ( ::CORBA::PolicyType type, ::PortableInterceptor::PolicyFactory_ptr policy_factory @@ -446,45 +450,176 @@ namespace PortableInterceptor ACE_THROW_SPEC (( ::CORBA::SystemException )) = 0; - + // TAO_IDL - Generated from - // be\be_visitor_interface/interface_ch.cpp:210 - + // be/be_visitor_interface/interface_ch.cpp:210 + virtual ::CORBA::Boolean _is_a ( const char *type_id ACE_ENV_ARG_DECL_WITH_DEFAULTS ); - + virtual const char* _interface_repository_id (void) const; virtual ::CORBA::Boolean marshal (TAO_OutputCDR &cdr); - + protected: // Abstract or local interface only. ORBInitInfo (void); - + virtual ~ORBInitInfo (void); - + private: // Private and unimplemented for concrete interfaces. ORBInitInfo (const ORBInitInfo &); - + void operator= (const ORBInitInfo &); }; #endif /* end #if !defined */ - + // TAO_IDL - Generated from - // be\be_visitor_typecode/typecode_decl.cpp:49 - + // be/be_visitor_typecode/typecode_decl.cpp:49 + extern TAO_PI_Export ::CORBA::TypeCode_ptr const _tc_ORBInitInfo; + // TAO_IDL - Generated from + // be/be_interface.cpp:646 + +#if !defined (_PORTABLEINTERCEPTOR_ORBINITINFO_3_1__VAR_OUT_CH_) +#define _PORTABLEINTERCEPTOR_ORBINITINFO_3_1__VAR_OUT_CH_ + + class ORBInitInfo_3_1; + typedef ORBInitInfo_3_1 *ORBInitInfo_3_1_ptr; + + typedef + TAO_Objref_Var_T< + ORBInitInfo_3_1 + > + ORBInitInfo_3_1_var; + + typedef + TAO_Objref_Out_T< + ORBInitInfo_3_1 + > + ORBInitInfo_3_1_out; + +#endif /* end #if !defined */ + + // TAO_IDL - Generated from + // be/be_visitor_interface/interface_ch.cpp:54 + +#if !defined (_PORTABLEINTERCEPTOR_ORBINITINFO_3_1_CH_) +#define _PORTABLEINTERCEPTOR_ORBINITINFO_3_1_CH_ + + class TAO_PI_Export ORBInitInfo_3_1 + : public virtual ::PortableInterceptor::ORBInitInfo + { + public: + typedef ORBInitInfo_3_1_ptr _ptr_type; + typedef ORBInitInfo_3_1_var _var_type; + + // The static operations. + static ORBInitInfo_3_1_ptr _duplicate (ORBInitInfo_3_1_ptr obj); + + static void _tao_release (ORBInitInfo_3_1_ptr obj); + + static ORBInitInfo_3_1_ptr _narrow ( + ::CORBA::Object_ptr obj + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ); + + static ORBInitInfo_3_1_ptr _unchecked_narrow ( + ::CORBA::Object_ptr obj + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ); + + static ORBInitInfo_3_1_ptr _nil (void) + { + return static_cast<ORBInitInfo_3_1_ptr> (0); + } + + + + // TAO_IDL - Generated from + // be/be_visitor_operation/operation_ch.cpp:46 + + virtual void add_client_request_interceptor_with_policy ( + ::PortableInterceptor::ClientRequestInterceptor_ptr interceptor, + const ::CORBA::PolicyList & policies + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::PortableInterceptor::ORBInitInfo::DuplicateName, + ::CORBA::PolicyError + )) = 0; + + // TAO_IDL - Generated from + // be/be_visitor_operation/operation_ch.cpp:46 + + virtual void add_server_request_interceptor_with_policy ( + ::PortableInterceptor::ServerRequestInterceptor_ptr interceptor, + const ::CORBA::PolicyList & policies + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::PortableInterceptor::ORBInitInfo::DuplicateName, + ::CORBA::PolicyError + )) = 0; + + // TAO_IDL - Generated from + // be/be_visitor_operation/operation_ch.cpp:46 + + virtual void add_ior_interceptor_with_policy ( + ::PortableInterceptor::IORInterceptor_ptr interceptor, + const ::CORBA::PolicyList & policies + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::PortableInterceptor::ORBInitInfo::DuplicateName, + ::CORBA::PolicyError + )) = 0; + + // TAO_IDL - Generated from + // be/be_visitor_interface/interface_ch.cpp:210 + + virtual ::CORBA::Boolean _is_a ( + const char *type_id + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ); + + virtual const char* _interface_repository_id (void) const; + virtual ::CORBA::Boolean marshal (TAO_OutputCDR &cdr); + + protected: + // Abstract or local interface only. + ORBInitInfo_3_1 (void); + + virtual ~ORBInitInfo_3_1 (void); + + private: + // Private and unimplemented for concrete interfaces. + ORBInitInfo_3_1 (const ORBInitInfo_3_1 &); + + void operator= (const ORBInitInfo_3_1 &); + }; + +#endif /* end #if !defined */ + + // TAO_IDL - Generated from + // be/be_visitor_typecode/typecode_decl.cpp:49 + + extern TAO_PI_Export ::CORBA::TypeCode_ptr const _tc_ORBInitInfo_3_1; + // TAO_IDL - Generated from -// be\be_visitor_module/module_ch.cpp:78 +// be/be_visitor_module/module_ch.cpp:78 } // module PortableInterceptor // TAO_IDL - Generated from -// be\be_visitor_traits.cpp:61 +// be/be_visitor_traits.cpp:62 // Traits specializations. namespace TAO @@ -492,7 +627,7 @@ namespace TAO #if !defined (_PORTABLEINTERCEPTOR_CLIENTREQUESTINTERCEPTOR__TRAITS_) #define _PORTABLEINTERCEPTOR_CLIENTREQUESTINTERCEPTOR__TRAITS_ - + template<> struct TAO_PI_Export Objref_Traits< ::PortableInterceptor::ClientRequestInterceptor> { @@ -504,7 +639,7 @@ namespace TAO ); static ::PortableInterceptor::ClientRequestInterceptor_ptr nil (void); static ::CORBA::Boolean marshal ( - ::PortableInterceptor::ClientRequestInterceptor_ptr p, + const ::PortableInterceptor::ClientRequestInterceptor_ptr p, TAO_OutputCDR & cdr ); }; @@ -513,7 +648,7 @@ namespace TAO #if !defined (_PORTABLEINTERCEPTOR_SERVERREQUESTINTERCEPTOR__TRAITS_) #define _PORTABLEINTERCEPTOR_SERVERREQUESTINTERCEPTOR__TRAITS_ - + template<> struct TAO_PI_Export Objref_Traits< ::PortableInterceptor::ServerRequestInterceptor> { @@ -525,7 +660,7 @@ namespace TAO ); static ::PortableInterceptor::ServerRequestInterceptor_ptr nil (void); static ::CORBA::Boolean marshal ( - ::PortableInterceptor::ServerRequestInterceptor_ptr p, + const ::PortableInterceptor::ServerRequestInterceptor_ptr p, TAO_OutputCDR & cdr ); }; @@ -534,7 +669,7 @@ namespace TAO #if !defined (_PORTABLEINTERCEPTOR_IORINTERCEPTOR__TRAITS_) #define _PORTABLEINTERCEPTOR_IORINTERCEPTOR__TRAITS_ - + template<> struct TAO_PI_Export Objref_Traits< ::PortableInterceptor::IORInterceptor> { @@ -546,7 +681,7 @@ namespace TAO ); static ::PortableInterceptor::IORInterceptor_ptr nil (void); static ::CORBA::Boolean marshal ( - ::PortableInterceptor::IORInterceptor_ptr p, + const ::PortableInterceptor::IORInterceptor_ptr p, TAO_OutputCDR & cdr ); }; @@ -555,7 +690,7 @@ namespace TAO #if !defined (_PORTABLEINTERCEPTOR_POLICYFACTORY__TRAITS_) #define _PORTABLEINTERCEPTOR_POLICYFACTORY__TRAITS_ - + template<> struct TAO_PI_Export Objref_Traits< ::PortableInterceptor::PolicyFactory> { @@ -567,7 +702,7 @@ namespace TAO ); static ::PortableInterceptor::PolicyFactory_ptr nil (void); static ::CORBA::Boolean marshal ( - ::PortableInterceptor::PolicyFactory_ptr p, + const ::PortableInterceptor::PolicyFactory_ptr p, TAO_OutputCDR & cdr ); }; @@ -576,7 +711,7 @@ namespace TAO #if !defined (_PORTABLEINTERCEPTOR_ORBINITINFO__TRAITS_) #define _PORTABLEINTERCEPTOR_ORBINITINFO__TRAITS_ - + template<> struct TAO_PI_Export Objref_Traits< ::PortableInterceptor::ORBInitInfo> { @@ -588,7 +723,28 @@ namespace TAO ); static ::PortableInterceptor::ORBInitInfo_ptr nil (void); static ::CORBA::Boolean marshal ( - ::PortableInterceptor::ORBInitInfo_ptr p, + const ::PortableInterceptor::ORBInitInfo_ptr p, + TAO_OutputCDR & cdr + ); + }; + +#endif /* end #if !defined */ + +#if !defined (_PORTABLEINTERCEPTOR_ORBINITINFO_3_1__TRAITS_) +#define _PORTABLEINTERCEPTOR_ORBINITINFO_3_1__TRAITS_ + + template<> + struct TAO_PI_Export Objref_Traits< ::PortableInterceptor::ORBInitInfo_3_1> + { + static ::PortableInterceptor::ORBInitInfo_3_1_ptr duplicate ( + ::PortableInterceptor::ORBInitInfo_3_1_ptr + ); + static void release ( + ::PortableInterceptor::ORBInitInfo_3_1_ptr + ); + static ::PortableInterceptor::ORBInitInfo_3_1_ptr nil (void); + static ::CORBA::Boolean marshal ( + const ::PortableInterceptor::ORBInitInfo_3_1_ptr p, TAO_OutputCDR & cdr ); }; @@ -597,7 +753,7 @@ namespace TAO } // TAO_IDL - Generated from -// be\be_codegen.cpp:1040 +// be/be_codegen.cpp:1101 TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/PI/PI.cpp b/TAO/tao/PI/PI.cpp index 1d4592cc6ca..5fe8f1dca9e 100644 --- a/TAO/tao/PI/PI.cpp +++ b/TAO/tao/PI/PI.cpp @@ -3,6 +3,9 @@ #include "PolicyFactory_Loader.h" #include "ClientRequestInterceptor_Factory_Impl.h" #include "PICurrent_Loader.h" +#include "PI_ORBInitializer.h" +#include "tao/ORBInitializer_Registry.h" +#include "tao/ORB_Constants.h" ACE_RCSID (PI, PI, @@ -19,7 +22,46 @@ TAO_PI_Init::Initializer (void) ACE_Service_Config::process_directive (ace_svc_desc_TAO_PICurrent_Loader); #endif /* TAO_HAS_INTERCEPTORS == 1 */ - return ACE_Service_Config::process_directive (ace_svc_desc_ORBInitializer_Registry); + int status = ACE_Service_Config::process_directive ( + ace_svc_desc_ORBInitializer_Registry); +#if TAO_HAS_INTERCEPTORS == 1 + PortableInterceptor::ORBInitializer_ptr temp_orb_initializer = + PortableInterceptor::ORBInitializer::_nil (); + + PortableInterceptor::ORBInitializer_var orb_initializer; + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + /// Register the PI ORBInitializer. + + ACE_NEW_THROW_EX (temp_orb_initializer, + TAO_PI_ORBInitializer, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_TRY_CHECK; + + orb_initializer = temp_orb_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + if (TAO_debug_level > 0) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "(%P | %t) Caught exception:"); + } + return -1; + } + ACE_ENDTRY; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + return status; } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/PI/PI_ORBInitializer.cpp b/TAO/tao/PI/PI_ORBInitializer.cpp new file mode 100644 index 00000000000..4c7e1daee95 --- /dev/null +++ b/TAO/tao/PI/PI_ORBInitializer.cpp @@ -0,0 +1,103 @@ +// -*- C++ -*- + +#include "tao/PI/PI_ORBInitializer.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "tao/PI/PI_PolicyFactory.h" +#include "tao/PI/ProcessingModePolicyC.h" +#include "tao/ORB_Core.h" +#include "ORBInitInfoC.h" + +ACE_RCSID (tao, + PI_ORBInitializer, + "$Id$") + +void +TAO_PI_ORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_UNUSED_ARG (info); +} + + +void +TAO_PI_ORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // The PI policy factory is stateless and reentrant, so share a + // single instance between all ORBs. + if (CORBA::is_nil (this->policy_factory_.in ())) + { + PortableInterceptor::PolicyFactory_ptr policy_factory; + ACE_NEW_THROW_EX (policy_factory, + TAO_PI_PolicyFactory, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + this->policy_factory_ = policy_factory; + } + + + this->register_policy_factories (info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + + +void +TAO_PI_ORBInitializer::register_policy_factories ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) +{ + // Register the PI policy factory. + + // Bind the same policy factory to all PortableInterceptor related policy + // types since a single policy factory is used to create each of the + // different types of PortableInterceptor policies. + CORBA::PolicyType type[] = { + PortableInterceptor::PROCESSING_MODE_POLICY_TYPE + }; + + const CORBA::PolicyType *end = type + sizeof (type) / sizeof (type[0]); + + for (CORBA::PolicyType *i = type; i != end; ++i) + { + ACE_TRY + { + info->register_policy_factory (*i, + this->policy_factory_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::BAD_INV_ORDER, ex) + { + if (ex.minor () == (CORBA::OMGVMCID | 16)) + { + // The factory is already there, it happens because the + // magic initializer in PI_Initializer.cpp registers + // with the ORB multiple times. This is an indication + // that we should do no more work in this + // ORBInitializer. + return; + } + ACE_RE_THROW; + } + ACE_CATCHANY + { + // Rethrow any other exceptions... + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; + } +} + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/TAO/tao/PI/PI_ORBInitializer.h b/TAO/tao/PI/PI_ORBInitializer.h new file mode 100644 index 00000000000..5219913a274 --- /dev/null +++ b/TAO/tao/PI/PI_ORBInitializer.h @@ -0,0 +1,80 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file PI_ORBInitializer.h + * + * $Id$ + * + * @author Tim Bradley <bradley_t@ociweb.com> + */ +//============================================================================= + +#ifndef TAO_PI_ORB_INITIALIZER_H +#define TAO_PI_ORB_INITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "tao/orbconf.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "tao/TAO_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/LocalObject.h" +#include "ORBInitializerC.h" +#include "PolicyFactoryC.h" + +/// Forward Declarations +class TAO_PI_PolicyFactory; + +/// PortableServer ORB initializer. +class TAO_Export TAO_PI_ORBInitializer + : public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /** + * @name PortableInterceptor::ORBInitializer methods + * + * The following methods are required by the + * PortableInterceptor::ORBInitializer interface. + */ + //@{ + + void pre_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void post_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + //@} + + +private: + + /// Register PortableInterceptor policy factories. + void register_policy_factories (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL); + + + /// Instance of the PI policy factory. + /** + * The PI policy factory is stateless and reentrant, so share + * a single instance between all ORBs. + */ + PortableInterceptor::PolicyFactory_var policy_factory_; +}; + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + +#include /**/ "ace/post.h" + +#endif /* TAO_PI_ORB_INITIALIZER_H */ diff --git a/TAO/tao/PI/PI_PolicyFactory.cpp b/TAO/tao/PI/PI_PolicyFactory.cpp new file mode 100644 index 00000000000..70778de1af4 --- /dev/null +++ b/TAO/tao/PI/PI_PolicyFactory.cpp @@ -0,0 +1,46 @@ +#include "tao/PI/PI_PolicyFactory.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "tao/PI/ProcessingModePolicy.h" +#include "tao/ORB_Constants.h" + +ACE_RCSID (tao, + PI_PolicyFactory, + "$Id$") + +CORBA::Policy_ptr +TAO_PI_PolicyFactory::create_policy ( + CORBA::PolicyType type, + const CORBA::Any &value + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CORBA::PolicyError)) +{ +// TBD - Should there be a "#if (TAO_HAS_MINIMUM_POA == 0)" check here? + + if (type == PortableInterceptor::PROCESSING_MODE_POLICY_TYPE) + { + TAO_ProcessingModePolicy *processing_mode_policy = 0; + PortableInterceptor::ProcessingMode policy_value; + + if ((value >>= policy_value) == 0) + { + ACE_THROW_RETURN (CORBA::PolicyError (CORBA::BAD_POLICY_VALUE), + CORBA::Policy::_nil ()); + } + + ACE_NEW_THROW_EX (processing_mode_policy, + TAO_ProcessingModePolicy (policy_value), + CORBA::NO_MEMORY (TAO::VMCID, + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + return processing_mode_policy; + } + + ACE_THROW_RETURN (CORBA::PolicyError (CORBA::BAD_POLICY_TYPE), + CORBA::Policy::_nil ()); +} + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/TAO/tao/PI/PI_PolicyFactory.h b/TAO/tao/PI/PI_PolicyFactory.h new file mode 100644 index 00000000000..42ad04cbf51 --- /dev/null +++ b/TAO/tao/PI/PI_PolicyFactory.h @@ -0,0 +1,48 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file PI_PolicyFactory.h + * + * $Id$ + * + * @author Tim Bradley <bradley_t@ociweb.com> + */ +//============================================================================= + +#ifndef TAO_PI_POLICY_FACTORY_H +#define TAO_PI_POLICY_FACTORY_H + +#include /**/ "ace/pre.h" + +#include "tao/orbconf.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "tao/TAO_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/LocalObject.h" +#include "PolicyFactoryC.h" + +/// Policy factory for all PortableInterceptor related policies. +class TAO_Export TAO_PI_PolicyFactory + : public virtual PortableInterceptor::PolicyFactory, + public virtual TAO_Local_RefCounted_Object +{ +public: + CORBA::Policy_ptr create_policy (CORBA::PolicyType type, + const CORBA::Any & value + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + CORBA::PolicyError)); +}; + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + +#include /**/ "ace/post.h" + +#endif /* TAO_PI_POLICY_FACTORY_H */ diff --git a/TAO/tao/PI/ProcessingModePolicy.cpp b/TAO/tao/PI/ProcessingModePolicy.cpp new file mode 100644 index 00000000000..0bedfa260b1 --- /dev/null +++ b/TAO/tao/PI/ProcessingModePolicy.cpp @@ -0,0 +1,55 @@ +// $Id$ + +#include "ProcessingModePolicy.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "tao/PortableInterceptorC.h" + +ACE_RCSID (tao, + ProcessingModePolicy, + "$Id$") + +// Should this all be wrapped in #if (TAO_HAS_MINIMUM_POA == 0)? + +TAO_ProcessingModePolicy::TAO_ProcessingModePolicy + (PortableInterceptor::ProcessingMode mode) + : processing_mode_ (mode) +{ +} + +CORBA::Policy_ptr +TAO_ProcessingModePolicy::copy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_ProcessingModePolicy *copy = 0; + ACE_NEW_THROW_EX (copy, + TAO_ProcessingModePolicy (this->processing_mode_), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + return copy; +} + +void +TAO_ProcessingModePolicy::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +PortableInterceptor::ProcessingMode +TAO_ProcessingModePolicy::processing_mode (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return processing_mode_; +} + +CORBA::PolicyType +TAO_ProcessingModePolicy::policy_type (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return PortableInterceptor::PROCESSING_MODE_POLICY_TYPE; +} + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + diff --git a/TAO/tao/PI/ProcessingModePolicy.h b/TAO/tao/PI/ProcessingModePolicy.h new file mode 100644 index 00000000000..e5bfd4f2b0c --- /dev/null +++ b/TAO/tao/PI/ProcessingModePolicy.h @@ -0,0 +1,79 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file ProcessingModePolicy.h + * + * $Id$ + * + * @author Tim Bradley (bradley_t@ociweb.com) + */ +//============================================================================= + +#ifndef TAO_PROCESSING_MODE_POLICY_H +#define TAO_PROCESSING_MODE_POLICY_H + +#include /**/ "ace/pre.h" + +#include "tao/orbconf.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "tao/TAO_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/LocalObject.h" +#include "ProcessingModePolicyC.h" + +// TBD - Should this be wrapped in a check for (TAO_HAS_MINIMUM_POA == 0)? + + +/** + * @class TAO_ProcessingModePolicy + * + * @brief Implementation class for Portable Interceptor ProcessingModePolicy. + * + * This policy is used to specify which kinds of requests (collocated vs. + * remote) should (or should not) cause a Portable Interceptor to be used. + */ + +class TAO_Export TAO_ProcessingModePolicy + : public PortableInterceptor::ProcessingModePolicy, + public TAO_Local_RefCounted_Object +{ +public: + /// Constructor. + TAO_ProcessingModePolicy (PortableInterceptor::ProcessingMode mode); + + virtual PortableInterceptor::ProcessingMode processing_mode + (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::PolicyType policy_type (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::Policy_ptr copy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // TBD - Should these be overridden? + + // Return the cached policy type for this policy. + // virtual TAO_Cached_Policy_Type _tao_cached_type (void) const; + + // Return the scope at which this policy can be applied. See orbconf.h. + // virtual TAO_Policy_Scope _tao_scope (void) const; + +private: + /// The attribute + PortableInterceptor::ProcessingMode processing_mode_; +}; + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + +#include /**/ "ace/post.h" +#endif /* TAO_PROCESSING_MODE_POLICY_H */ diff --git a/TAO/tao/PI/ProcessingModePolicy.pidl b/TAO/tao/PI/ProcessingModePolicy.pidl new file mode 100644 index 00000000000..0b0243a0ad3 --- /dev/null +++ b/TAO/tao/PI/ProcessingModePolicy.pidl @@ -0,0 +1,42 @@ +/** + * @file ProcessingModePolicy.pidl + * + * $Id$ + * + * @brief Pre-compiled IDL source for the ProcessingModePolicy within + * the PortableInterceptor module. + * + * tao_idl \ + * -o orig -Gp -Gd -Ge 1 -GT -Sc -GA \ + * -Wb,export_include="tao/TAO_Export.h" \ + * -Wb,export_macro=TAO_Export \ + * -Wb,pre_include="ace/pre.h" \ + * -Wb,post_include="ace/post.h" \ + * ProcessingModePolicy.pidl + */ + +#ifndef _PROCESSING_MODE_POLICY_PIDL_ +#define _PROCESSING_MODE_POLICY_PIDL_ + +#include <tao/Policy.pidl> + +module PortableInterceptor +{ + + // ProcessingMode Policy (default = LOCAL_AND_REMOTE) + typedef short ProcessingMode; + const ProcessingMode LOCAL_AND_REMOTE = 0; + const ProcessingMode REMOTE_ONLY = 1; + const ProcessingMode LOCAL_ONLY = 2; + + // TBD - Need to get the proper Policy Type code from OMG + const CORBA::PolicyType PROCESSING_MODE_POLICY_TYPE = 100; + + local interface ProcessingModePolicy : CORBA::Policy + { + readonly attribute ProcessingMode processing_mode; + }; + +}; + +#endif /* _PROCESSING_MODE_POLICY_PIDL_ */ diff --git a/TAO/tao/PI_Server/ServerInterceptorAdapter.cpp b/TAO/tao/PI_Server/ServerInterceptorAdapter.cpp index 076bc989ab6..b38a0fa0a19 100644 --- a/TAO/tao/PI_Server/ServerInterceptorAdapter.cpp +++ b/TAO/tao/PI_Server/ServerInterceptorAdapter.cpp @@ -39,6 +39,7 @@ TAO::ServerRequestInterceptor_Adapter_Impl::tao_ft_interception_point ( { // This method implements one of the "starting" server side // interception point. + bool is_remote_request = !server_request.collocated (); ACE_TRY { @@ -53,11 +54,17 @@ TAO::ServerRequestInterceptor_Adapter_Impl::tao_ft_interception_point ( for (size_t i = 0 ; i < this->interceptor_list_.size(); ++i) { - this->interceptors_[i]->tao_ft_interception_point ( - ri, - oc - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ServerRequestInterceptor_List::RegisteredInterceptor& registered = + this->interceptor_list_.registered_interceptor (i); + + if (registered.details_.should_be_processed (is_remote_request)) + { + registered.interceptor_-> + tao_ft_interception_point (ri, + oc + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } if (oc != 0) { @@ -98,6 +105,8 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request_service_contexts ( { // This method implements one of the "intermediate" server side // interception point. + bool is_remote_request = !server_request.collocated (); + if (this->interceptor_list_.size() != this->server_request.interceptor_count ()) { // This method (i.e. the receive_request() interception point) @@ -122,10 +131,16 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request_service_contexts ( for (size_t i = 0 ; i < server_request.interceptor_count (); ++i) { - this->interceptors_[i]->receive_request_service_contexts ( - ri - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ServerRequestInterceptor_List::RegisteredInterceptor& registered = + this->interceptor_list_.registered_interceptor (i); + + if (registered.details_.should_be_processed (is_remote_request)) + { + registered.interceptor_-> + receive_request_service_contexts (ri + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } } } ACE_CATCH (PortableInterceptor::ForwardRequest, exc) @@ -156,10 +171,11 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request_service_contexts ( CORBA::ULong nexceptions ACE_ENV_ARG_DECL) { - // This method implements one of the "starting" server side // interception point if extended interceptors are not in place. + bool is_remote_request = !server_request.collocated (); + TAO::ServerRequestInfo request_info (server_request, args, nargs, @@ -179,11 +195,16 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request_service_contexts ( for (size_t i = 0 ; i < this->interceptor_list_.size(); ++i) { - this->interceptor_list_.interceptor(i)-> - receive_request_service_contexts ( - &request_info - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ServerRequestInterceptor_List::RegisteredInterceptor& registered = + this->interceptor_list_.registered_interceptor (i); + + if (registered.details_.should_be_processed (is_remote_request)) + { + registered.interceptor_-> + receive_request_service_contexts (&request_info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } // The starting interception point completed successfully. // Push the interceptor on to the flow stack. @@ -223,6 +244,8 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request ( // point. Interceptors are invoked in the same order they were // pushed on to the flow stack. + bool is_remote_request = !server_request.collocated (); + if (this->interceptor_list_.size() != server_request.interceptor_count ()) { // This method (i.e. the receive_request() interception point) @@ -250,10 +273,16 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request ( { for (size_t i = 0; i < server_request.interceptor_count (); ++i) { - this->interceptor_list_.interceptor(i)->receive_request ( - &request_info - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ServerRequestInterceptor_List::RegisteredInterceptor& registered = + this->interceptor_list_.registered_interceptor (i); + + if (registered.details_.should_be_processed (is_remote_request)) + { + registered.interceptor_-> + receive_request (&request_info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } // Note that no interceptors are pushed on to or popped off // of the flow stack in this interception point since it is @@ -291,6 +320,8 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_reply ( // This is an "ending" interception point so we only process the // interceptors pushed on to the flow stack. + bool is_remote_request = !server_request.collocated (); + // Notice that the interceptors are processed in the opposite order // they were pushed onto the stack since this is an "ending" // interception point. @@ -312,11 +343,17 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_reply ( // invoked in another "ending" interception point. --server_request.interceptor_count (); - this->interceptor_list_.interceptor ( - server_request.interceptor_count ())->send_reply ( - &request_info - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ServerRequestInterceptor_List::RegisteredInterceptor& registered = + this->interceptor_list_.registered_interceptor ( + server_request.interceptor_count ()); + + if (registered.details_.should_be_processed (is_remote_request)) + { + registered.interceptor_-> + send_reply (&request_info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } } // The send_reply() interception point does not raise a @@ -337,6 +374,8 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_exception ( // This is an "ending" server side interception point so we only // process the interceptors pushed on to the flow stack. + bool is_remote_request = !server_request.collocated (); + // Notice that the interceptors are processed in the opposite order // they were pushed onto the stack since this is an "ending" server // side interception point. @@ -360,11 +399,17 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_exception ( // being invoked in another "ending" interception point. --server_request.interceptor_count (); - this->interceptor_list_.interceptor ( - server_request.interceptor_count ())->send_exception ( - &request_info - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ServerRequestInterceptor_List::RegisteredInterceptor& registered = + this->interceptor_list_.registered_interceptor ( + server_request.interceptor_count ()); + + if (registered.details_.should_be_processed (is_remote_request)) + { + registered.interceptor_-> + send_exception (&request_info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } } } ACE_CATCH (PortableInterceptor::ForwardRequest, exc) @@ -430,6 +475,8 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_other ( // This is an "ending" server side interception point so we only // process the interceptors pushed on to the flow stack. + bool is_remote_request = !server_request.collocated (); + TAO::ServerRequestInfo request_info (server_request, args, nargs, @@ -453,11 +500,17 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_other ( // being invoked in another "ending" interception point. --server_request.interceptor_count (); - this->interceptor_list_.interceptor( - server_request.interceptor_count ())->send_other ( - &request_info - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ServerRequestInterceptor_List::RegisteredInterceptor& registered = + this->interceptor_list_.registered_interceptor ( + server_request.interceptor_count ()); + + if (registered.details_.should_be_processed (is_remote_request)) + { + registered.interceptor_-> + send_other (&request_info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } } } ACE_CATCH (PortableInterceptor::ForwardRequest, exc) @@ -477,7 +530,6 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_other ( ACE_CHECK; } - void TAO::ServerRequestInterceptor_Adapter_Impl::add_interceptor ( PortableInterceptor::ServerRequestInterceptor_ptr interceptor @@ -487,6 +539,17 @@ TAO::ServerRequestInterceptor_Adapter_Impl::add_interceptor ( } void +TAO::ServerRequestInterceptor_Adapter_Impl::add_interceptor ( + PortableInterceptor::ServerRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL) +{ + this->interceptor_list_.add_interceptor (interceptor, + policies + ACE_ENV_ARG_PARAMETER); +} + +void TAO::ServerRequestInterceptor_Adapter_Impl::destroy_interceptors ( ACE_ENV_SINGLE_ARG_DECL) { diff --git a/TAO/tao/PI_Server/ServerInterceptorAdapter.h b/TAO/tao/PI_Server/ServerInterceptorAdapter.h index 6cb2878b1e6..82424e9018c 100644 --- a/TAO/tao/PI_Server/ServerInterceptorAdapter.h +++ b/TAO/tao/PI_Server/ServerInterceptorAdapter.h @@ -34,16 +34,23 @@ #include "tao/PI/Interceptor_List_T.h" #include "tao/ServerRequestInterceptor_Adapter.h" #include "tao/Basic_Types.h" +#include "ServerRequestDetails.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { - typedef Interceptor_List< ::PortableInterceptor::ServerRequestInterceptor> + typedef Interceptor_List< ::PortableInterceptor::ServerRequestInterceptor, + ServerRequestDetails> ServerRequestInterceptor_List; } +namespace CORBA +{ + class PolicyList; +} + class TAO_ServerRequest; namespace TAO @@ -154,6 +161,11 @@ namespace TAO PortableInterceptor::ServerRequestInterceptor_ptr interceptor ACE_ENV_ARG_DECL); + virtual void add_interceptor ( + PortableInterceptor::ServerRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL); + virtual void destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL); virtual TAO::PICurrent_Impl *allocate_pi_current (void); diff --git a/TAO/tao/PI_Server/ServerRequestDetails.cpp b/TAO/tao/PI_Server/ServerRequestDetails.cpp new file mode 100644 index 00000000000..4479564bd1c --- /dev/null +++ b/TAO/tao/PI_Server/ServerRequestDetails.cpp @@ -0,0 +1,77 @@ +#include "ServerRequestDetails.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#if !defined (__ACE_INLINE__) +#include "ServerRequestDetails.inl" +#endif /* defined INLINE */ + +ACE_RCSID (PI_Server, + ServerRequestDetails, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + void + ServerRequestDetails::apply_policies ( + const CORBA::PolicyList &policies + ACE_ENV_ARG_DECL) + { + // Flag to check for duplicate ProcessingModePolicy objects in the list. + bool processing_mode_applied = false; + + const CORBA::ULong plen = policies.length (); + + for (CORBA::ULong i = 0; i < plen; ++i) + { + CORBA::Policy_var policy = policies[i]; + + if (CORBA::is_nil (policy.in ())) + { + // Just ignore nil policies... + continue; + } + + // Obtain the PolicyType from the current Policy object. + const CORBA::PolicyType policy_type = + policy->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (policy_type == PortableInterceptor::PROCESSING_MODE_POLICY_TYPE) + { + if (processing_mode_applied) + { + // This is the second time we have run into this policy type, + // and that is not allowed. + ACE_THROW (CORBA::INV_POLICY ()); + } + + // Flip the flag to true in order to trap any dupes. + processing_mode_applied = true; + + // Narrow the Policy to the ProcessingModePolicy interface. + PortableInterceptor::ProcessingModePolicy_var pm_policy = + PortableInterceptor::ProcessingModePolicy::_narrow ( + policy.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Save the value of the ProcessingModePolicy in our data member. + this->processing_mode_ = + pm_policy->processing_mode (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + else + { + // We don't support the current policy type. + ACE_THROW (CORBA::INV_POLICY ()); + } + } + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/TAO/tao/PI_Server/ServerRequestDetails.h b/TAO/tao/PI_Server/ServerRequestDetails.h new file mode 100644 index 00000000000..8f7aa99ad7d --- /dev/null +++ b/TAO/tao/PI_Server/ServerRequestDetails.h @@ -0,0 +1,85 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ServerRequestDetails.h + * + * $Id$ + * + * This file declares a class that manages the details + * about a registered server request interceptor. Policies can be + * used when interceptors are registered, and the policy values + * will be processed and used to modify the values of the + * ServerRequestDetails object associated with the registered + * server request interceptor. + * + * @author Tim Bradley <bradley_t@ociweb.com> + */ +//============================================================================= + +#ifndef TAO_SERVER_REQUEST_DETAILS_H +#define TAO_SERVER_REQUEST_DETAILS_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/orbconf.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "tao/PI/ProcessingModePolicyC.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class ServerRequestDetails + * + * @brief The policy-driven details for a registered server request + * interceptor + * + * Each time a server request interceptor is registered with an ORB, + * a ServerRequestDetails object will be created and associated with + * the registered server request interceptor. If the interceptor is + * registered with policies, the policies will be used to adjust the + * values in the ServerRequestDetails appropriately. + */ + class ServerRequestDetails + { + public: + + ServerRequestDetails (void); + ~ServerRequestDetails (void); + + void apply_policies (const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL); + + /// Returns true if the ProcessingMode setting permits the "firing" + /// of the associated server request interceptor based upon the + /// remote vs. collocated nature of the current servant request + /// that is being dispatched. + bool should_be_processed (bool is_remote_request) const; + + private: + + /// The ProcessingMode setting that can be adjusted via the + /// PortableInterceptor::ProcessingModePolicy. + PortableInterceptor::ProcessingMode processing_mode_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ServerRequestDetails.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + +#include /**/ "ace/post.h" + +#endif /* TAO_SERVER_REQUEST_DETAILS_H */ diff --git a/TAO/tao/PI_Server/ServerRequestDetails.inl b/TAO/tao/PI_Server/ServerRequestDetails.inl new file mode 100644 index 00000000000..dd05eeb04d5 --- /dev/null +++ b/TAO/tao/PI_Server/ServerRequestDetails.inl @@ -0,0 +1,32 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + ACE_INLINE + ServerRequestDetails::ServerRequestDetails (void) + : processing_mode_(PortableInterceptor::LOCAL_AND_REMOTE) + { + } + + ACE_INLINE + ServerRequestDetails::~ServerRequestDetails (void) + { + } + + ACE_INLINE + bool + ServerRequestDetails::should_be_processed (bool is_remote_request) const + { + return ((this->processing_mode_ == PortableInterceptor::LOCAL_AND_REMOTE) || + ((this->processing_mode_ == PortableInterceptor::REMOTE_ONLY) && + (is_remote_request)) || + ((this->processing_mode_ == PortableInterceptor::LOCAL_ONLY) && + (!is_remote_request))); + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/PortableServer/Upcall_Wrapper.cpp b/TAO/tao/PortableServer/Upcall_Wrapper.cpp index 76e668873bc..352ff184aeb 100644 --- a/TAO/tao/PortableServer/Upcall_Wrapper.cpp +++ b/TAO/tao/PortableServer/Upcall_Wrapper.cpp @@ -14,6 +14,7 @@ #include "tao/TAO_Server_Request.h" #include "tao/CDR.h" #include "tao/Argument.h" +#include "tao/operation_details.h" #include "ace/Log_Msg.h" ACE_RCSID (PortableServer, @@ -48,6 +49,32 @@ TAO::Upcall_Wrapper::upcall (TAO_ServerRequest & server_request, #if TAO_HAS_INTERCEPTORS == 1 + // Make sure that, for the collocated case, we use the client-side + // arguments. For the non-collocated case, we will use the server-side + // arguments since they got set up in our pre_upcall() method. Note that + // our pre_upcall() method doesn't get invoked in the collocated case, + // and is the reason why we need to provide the client-side args instead + // of the (never set or initialized) server-side args. + // + // Before the following logic was added, the + // $TAO_ROOT/tests/Portable_Interceptors/Collocated/run_test.pl + // showed that the server-side request interceptor was getting bogus + // values when it took a look at the request arguments. Some + // additional testing revealed that this only occurred in the + // collocated request case. + + // By default, we assume that we will use the server-side args. + TAO::Argument * const * the_args = args; + size_t the_nargs = nargs; + + if (server_request.collocated()) + { + // It is a collocated request so we need to use the client-side + // args instead. + the_args = server_request.operation_details()->args(); + the_nargs = server_request.operation_details()->args_num(); + } + TAO::ServerRequestInterceptor_Adapter *interceptor_adapter = server_request.orb_core ()->serverrequestinterceptor_adapter (); @@ -58,8 +85,8 @@ TAO::Upcall_Wrapper::upcall (TAO_ServerRequest & server_request, { // Invoke intermediate server side interception points. interceptor_adapter->receive_request (server_request, - args, - nargs, + the_args, + the_nargs, servant_upcall, exceptions, nexceptions @@ -113,8 +140,8 @@ TAO::Upcall_Wrapper::upcall (TAO_ServerRequest & server_request, // No location forward by interceptors and successful upcall. server_request.reply_status (PortableInterceptor::SUCCESSFUL); interceptor_adapter->send_reply (server_request, - args, - nargs, + the_args, + the_nargs, servant_upcall, exceptions, nexceptions @@ -137,8 +164,8 @@ TAO::Upcall_Wrapper::upcall (TAO_ServerRequest & server_request, if (interceptor_adapter != 0) { interceptor_adapter->send_exception (server_request, - args, - nargs, + the_args, + the_nargs, servant_upcall, exceptions, nexceptions @@ -173,8 +200,8 @@ TAO::Upcall_Wrapper::upcall (TAO_ServerRequest & server_request, if (interceptor_adapter != 0) { interceptor_adapter->send_exception (server_request, - args, - nargs, + the_args, + the_nargs, servant_upcall, exceptions, nexceptions diff --git a/TAO/tao/Remote_Invocation.cpp b/TAO/tao/Remote_Invocation.cpp index aae02a33237..01a39121e30 100644 --- a/TAO/tao/Remote_Invocation.cpp +++ b/TAO/tao/Remote_Invocation.cpp @@ -27,7 +27,8 @@ namespace TAO resolver.object (), resolver.stub (), detail, - response_expected) + response_expected, + true /* request_is_remote */ ) , resolver_ (resolver) { } diff --git a/TAO/tao/ServerRequestInterceptor_Adapter.h b/TAO/tao/ServerRequestInterceptor_Adapter.h index 50126db4e1b..2781dc111c2 100644 --- a/TAO/tao/ServerRequestInterceptor_Adapter.h +++ b/TAO/tao/ServerRequestInterceptor_Adapter.h @@ -27,7 +27,6 @@ #include "ace/CORBA_macros.h" #include "tao/SystemException.h" - TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace PortableInterceptor @@ -38,6 +37,11 @@ namespace PortableInterceptor typedef CORBA::Short ReplyStatus; } +namespace CORBA +{ + class PolicyList; +} + class TAO_ServerRequest; namespace TAO @@ -144,6 +148,12 @@ namespace TAO PortableInterceptor::ServerRequestInterceptor_ptr interceptor ACE_ENV_ARG_DECL) = 0; + /// Register an interceptor with policies. + virtual void add_interceptor ( + PortableInterceptor::ServerRequestInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL) = 0; + virtual void destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL) = 0; virtual TAO::PICurrent_Impl *allocate_pi_current (void) = 0; diff --git a/TAO/tests/Portable_Interceptors/Collocated/Dynamic/test_i.cpp b/TAO/tests/Portable_Interceptors/Collocated/Dynamic/test_i.cpp index 3f4b1a38bb3..949bea21eb6 100644 --- a/TAO/tests/Portable_Interceptors/Collocated/Dynamic/test_i.cpp +++ b/TAO/tests/Portable_Interceptors/Collocated/Dynamic/test_i.cpp @@ -1,6 +1,7 @@ // $Id$ #include "test_i.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(Dynamic, test_i, "$Id$") @@ -51,5 +52,9 @@ Visual_i::shutdown (ACE_ENV_SINGLE_ARG_DECL) this->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; + // Give the client thread time to return from the collocated + // call to this method before shutting down the ORB. We sleep + // to avoid BAD_INV_ORDER exceptions on fast dual processor machines. + ACE_OS::sleep (1); this->orb_->shutdown (); } diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Client_Task.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Client_Task.cpp new file mode 100644 index 00000000000..fca62b6fe50 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Client_Task.cpp @@ -0,0 +1,98 @@ +// +// $Id$ +// + +#include "Client_Task.h" +#include "testC.h" +#include "interceptors.h" + +ACE_RCSID(Muxing, Client_Task, "$Id$") + +Client_Task::Client_Task (const char *ior, + CORBA::ORB_ptr corb, + ACE_Thread_Manager *thr_mgr) + : ACE_Task_Base (thr_mgr) + , input_ (ior) + , corb_ (CORBA::ORB::_duplicate (corb)) + +{ +} + +int +Client_Task::svc (void) +{ + ACE_TRY_NEW_ENV + { + + CORBA::Object_var object = + corb_->string_to_object (input_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Test_Interceptors::Visual_var server = + Test_Interceptors::Visual::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (server.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Object reference <%s> is nil\n", + this->input_), + 1); + } + + run_test (server.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + server->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught in client task:"); + return 1; + } + ACE_ENDTRY; + + return 0; + +} + + +void +Client_Task::run_test (Test_Interceptors::Visual_ptr server + ACE_ENV_ARG_DECL) +{ + server->normal (10 ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long one = 1, two = 1; + (void) server->calculate (one, + two + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_TRY + { + (void) server->user (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (Test_Interceptors::Silly, userex) + { + ACE_DEBUG ((LM_DEBUG, "As expected, Caught Silly\n")); + } + ACE_ENDTRY; + ACE_CHECK; + + ACE_TRY_EX (SYS) + { + server->system (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK_EX (SYS); + } + ACE_CATCH (CORBA::INV_OBJREF, sysex) + { + ACE_DEBUG ((LM_DEBUG, "As expected, Caught CORBA::INV_OBJREF\n")); + } + ACE_ENDTRY; + ACE_CHECK; +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Client_Task.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Client_Task.h new file mode 100644 index 00000000000..49074e04e89 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Client_Task.h @@ -0,0 +1,45 @@ +// +// $Id$ +// + +#ifndef COLLOCATED_TEST_CLIENT_TASK_H +#define COLLOCATED_TEST_CLIENT_TASK_H +#include /**/ "ace/pre.h" +#include "ace/Task.h" +#include "testS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "tao/ORB.h" + + +/// Implement a Task to run the client as a thread +class Client_Task : public ACE_Task_Base +{ +public: + + /// Constructor + Client_Task (const char *input, + CORBA::ORB_ptr corb, + ACE_Thread_Manager *thr_mgr); + + /// Thread entry point + int svc (void); + + void run_test (Test_Interceptors::Visual_ptr server + ACE_ENV_ARG_DECL); + + /// The status of the svc loop + int status (void) const; + +private: + const char *input_; + + CORBA::ORB_var corb_; + + int status_; +}; + +#include /**/ "ace/post.h" +#endif /* COLLOCATED_TEST_CLIENT_TASK_H */ diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Collocated_Test.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Collocated_Test.cpp new file mode 100644 index 00000000000..430b47fc6d8 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Collocated_Test.cpp @@ -0,0 +1,223 @@ +//$Id$ +#include "Server_Task.h" +#include "Client_Task.h" +#include "ace/Get_Opt.h" +#include "ace/Argv_Type_Converter.h" +#include "ace/SString.h" +#include "ace/Manual_Event.h" +#include "Echo_Collocated_ORBInitializer.h" +#include "tao/ORBInitializer_Registry.h" +#include "interceptors.h" + +const char *output = "test.ior"; +const char *input = "file://test.ior"; + +ACE_CString server_proc_mode_str; +ACE_CString client_proc_mode_str; +ACE_CString server_orb; +ACE_CString client_orb; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "s:c:k:o"); + int c; + + server_proc_mode_str.set ("LOCAL_AND_REMOTE"); + client_proc_mode_str.set ("LOCAL_AND_REMOTE"); + + while ((c = get_opts ()) != -1) + { + switch (c) + { + case 's': + server_proc_mode_str.set (get_opts.opt_arg ()); + break; + case 'c': + client_proc_mode_str.set (get_opts.opt_arg ()); + break; + case 'o': + output = get_opts.opt_arg (); + break; + case 'k': + input = get_opts.opt_arg (); + break; + case '?': + default: + return 0; + } + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + if (parse_args (argc, + argv) == -1) + return -1; + + server_orb.set ("server_orb"); + client_orb.set ("client_orb"); + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + PortableInterceptor::ORBInitializer_ptr temp_initializer = + PortableInterceptor::ORBInitializer::_nil (); + + // Set up our default expectations. + CORBA::ULong expected_server_interceptor_check = 10; + CORBA::ULong expected_client_interceptor_check = 10; + + PortableInterceptor::ProcessingMode client_proc_mode = + PortableInterceptor::LOCAL_AND_REMOTE; + + if (client_proc_mode_str == "LOCAL_ONLY") + { + client_proc_mode = PortableInterceptor::LOCAL_ONLY; + ACE_DEBUG((LM_DEBUG, + "Using LOCAL_ONLY for client-side ProcessingMode.\n")); + } + else if (client_proc_mode_str == "REMOTE_ONLY") + { + client_proc_mode = PortableInterceptor::REMOTE_ONLY; + ACE_DEBUG((LM_DEBUG, + "Using REMOTE_ONLY for client-side ProcessingMode.\n")); + + // Since all of the calls are collocated, setting the client-side + // ProcessingMode to REMOTE_ONLY will cause the client request + // interceptor to not fire. Thus, we expect 0 calls on the + // client interceptor. + expected_client_interceptor_check = 0; + } + else + { + ACE_DEBUG((LM_DEBUG, + "Using LOCAL_AND_REMOTE for client-side ProcessingMode.\n")); + } + + PortableInterceptor::ProcessingMode server_proc_mode = + PortableInterceptor::LOCAL_AND_REMOTE; + + if (server_proc_mode_str == "LOCAL_ONLY") + { + server_proc_mode = PortableInterceptor::LOCAL_ONLY; + ACE_DEBUG((LM_DEBUG, + "Using LOCAL_ONLY for server-side ProcessingMode.\n")); + } + else if (server_proc_mode_str == "REMOTE_ONLY") + { + server_proc_mode = PortableInterceptor::REMOTE_ONLY; + ACE_DEBUG((LM_DEBUG, + "Using REMOTE_ONLY for server-side ProcessingMode.\n")); + + // Since all of the calls are collocated, setting the server-side + // ProcessingMode to REMOTE_ONLY will cause the server request + // interceptor to not fire. Thus, we expect 0 calls on the + // server interceptor. + expected_server_interceptor_check = 0; + } + else + { + ACE_DEBUG((LM_DEBUG, + "Using LOCAL_AND_REMOTE for server-side ProcessingMode.\n")); + } + + ACE_NEW_RETURN (temp_initializer, + Echo_Collocated_ORBInitializer (server_proc_mode, + client_proc_mode), + -1); // No exceptions yet! + PortableInterceptor::ORBInitializer_var orb_initializer = + temp_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_Argv_Type_Converter satc (argc, argv); + CORBA::ORB_var sorb = + CORBA::ORB_init (satc.get_argc (), + satc.get_TCHAR_argv (), + server_orb.c_str () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_Manual_Event me; + Server_Task server_task (output, + sorb.in (), + me, + ACE_Thread_Manager::instance ()); + + if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, + 1, + 1) == -1) + { + ACE_ERROR ((LM_ERROR, "Error activating server task\n")); + } + + // Wait for the server thread to do some processing + me.wait (); + + ACE_Argv_Type_Converter catc (argc, argv); + CORBA::ORB_var corb = + CORBA::ORB_init (catc.get_argc (), + catc.get_TCHAR_argv (), + client_orb.c_str () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Client_Task client_task (input, + corb.in (), + ACE_Thread_Manager::instance ()); + + if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, + 1, + 1) == -1) + { + ACE_ERROR ((LM_ERROR, "Error activating client task\n")); + } + + ACE_Thread_Manager::instance ()->wait (); + + bool failed_check = false; + + CORBA::ULong number_called = + Echo_Server_Request_Interceptor::server_interceptor_check_; + + if (number_called != expected_server_interceptor_check) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR: Server-Side Interceptors not " + "called properly, called %d times, expected %d.\n", + number_called, expected_server_interceptor_check)); + failed_check = true; + } + + number_called = + Echo_Client_Request_Interceptor::client_interceptor_check_; + + if (number_called != expected_client_interceptor_check) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR:Client-Side Interceptors not called " + "properly, called %d times, expected %d.\n", + number_called, expected_client_interceptor_check)); + failed_check = true; + } + + if (failed_check) + { + return 1; + } + } + ACE_CATCHANY + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR: Some exception was caught in main().\n")); + return 1; + } + ACE_ENDTRY; + return 0; +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Echo_Collocated_ORBInitializer.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Echo_Collocated_ORBInitializer.cpp new file mode 100644 index 00000000000..b9773fde351 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Echo_Collocated_ORBInitializer.cpp @@ -0,0 +1,138 @@ +// -*- C++ -*- +// +// $Id$ + +#include "Echo_Collocated_ORBInitializer.h" +#include "interceptors.h" +#include "tao/PI/ORBInitInfo.h" +#include "tao/ORB_Core.h" +#include "ace/OS_NS_string.h" + +Echo_Collocated_ORBInitializer::Echo_Collocated_ORBInitializer ( + PortableInterceptor::ProcessingMode server_proc_mode, + PortableInterceptor::ProcessingMode client_proc_mode) + : server_processing_mode_(server_proc_mode), + client_processing_mode_(client_proc_mode) +{ +} + +void +Echo_Collocated_ORBInitializer::pre_init ( + PortableInterceptor::ORBInitInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Echo_Collocated_ORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::String_var orb_id = + info->orb_id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // TAO-Specific way to get to the ORB Core (and thus, the ORB). + TAO_ORBInitInfo_var tao_info = + TAO_ORBInitInfo::_narrow (info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ORB_var orb = CORBA::ORB::_duplicate(tao_info->orb_core()->orb()); + + if (CORBA::is_nil(orb.in())) + { + ACE_THROW (CORBA::INTERNAL ()); + ACE_CHECK; + } + + PortableInterceptor::ORBInitInfo_3_1_var info_3_1 = + PortableInterceptor::ORBInitInfo_3_1::_narrow(info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil(info_3_1.in())) + { + ACE_THROW (CORBA::INTERNAL ()); + ACE_CHECK; + } + + if (!ACE_OS::strcmp (orb_id.in (), "client_orb")) + { + PortableInterceptor::ClientRequestInterceptor_ptr interceptor = + PortableInterceptor::ClientRequestInterceptor::_nil (); + + // Install the Echo client request interceptor + ACE_NEW_THROW_EX (interceptor, + Echo_Client_Request_Interceptor, + CORBA::NO_MEMORY ()); + ACE_CHECK; + + PortableInterceptor::ClientRequestInterceptor_var + client_interceptor = interceptor; + + CORBA::Any client_proc_mode_as_any; + client_proc_mode_as_any <<= this->client_processing_mode_; + + CORBA::PolicyList policy_list (1); + + policy_list.length (1); + policy_list[0] = + orb->create_policy (PortableInterceptor::PROCESSING_MODE_POLICY_TYPE, + client_proc_mode_as_any + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + info_3_1->add_client_request_interceptor_with_policy ( + client_interceptor.in (), + policy_list + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policy_list[0]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + policy_list[0] = CORBA::Policy::_nil (); + } + else if (!ACE_OS::strcmp (orb_id.in (), "server_orb")) + { + PortableInterceptor::ServerRequestInterceptor_ptr interceptor = + PortableInterceptor::ServerRequestInterceptor::_nil (); + + // Install the Echo server request interceptor + ACE_NEW_THROW_EX (interceptor, + Echo_Server_Request_Interceptor, + CORBA::NO_MEMORY ()); + ACE_CHECK; + + PortableInterceptor::ServerRequestInterceptor_var + server_interceptor = interceptor; + + CORBA::Any server_proc_mode_as_any; + server_proc_mode_as_any <<= this->server_processing_mode_; + + CORBA::PolicyList policy_list (1); + + policy_list.length (1); + policy_list[0] = + orb->create_policy (PortableInterceptor::PROCESSING_MODE_POLICY_TYPE, + server_proc_mode_as_any + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + info_3_1->add_server_request_interceptor_with_policy ( + server_interceptor.in (), + policy_list + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policy_list[0]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + policy_list[0] = CORBA::Policy::_nil (); + } + else + { + } +} + diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Echo_Collocated_ORBInitializer.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Echo_Collocated_ORBInitializer.h new file mode 100644 index 00000000000..70bc3ef1464 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Echo_Collocated_ORBInitializer.h @@ -0,0 +1,61 @@ +// -*- C++ -*- +// +// $Id$ + +#ifndef TAO_ECHO_CLIENT_ORB_INITIALIZER_H +#define TAO_ECHO_CLIENT_ORB_INITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "tao/orbconf.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/PI/ProcessingModePolicyC.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 */ + +/// Echo client ORB initializer. +class Echo_Collocated_ORBInitializer : + public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + Echo_Collocated_ORBInitializer + (PortableInterceptor::ProcessingMode server_proc_mode, + PortableInterceptor::ProcessingMode client_proc_mode); + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + + PortableInterceptor::ProcessingMode server_processing_mode_; + PortableInterceptor::ProcessingMode client_processing_mode_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + + +#include /**/ "ace/post.h" + +#endif /* TAO_ECHO_CLIENT_ORB_INITIALIZER_H */ diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/PI_ProcMode_Collocated.mpc b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/PI_ProcMode_Collocated.mpc new file mode 100644 index 00000000000..0e1f9788ad5 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/PI_ProcMode_Collocated.mpc @@ -0,0 +1,16 @@ +// -*- MPC -*- +// $Id$ + +project(*Collocated): taoserver, pi, pi_server, interceptors { + exename = PI_ProcMode_Collocated_Test + Source_Files { + testC.cpp + testS.cpp + test_i.cpp + interceptors.cpp + Echo_Collocated_ORBInitializer.cpp + Collocated_Test.cpp + Client_Task.cpp + Server_Task.cpp + } +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Server_Task.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Server_Task.cpp new file mode 100644 index 00000000000..5734a8f3df8 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Server_Task.cpp @@ -0,0 +1,112 @@ +// +// $Id$ +// +#include "Server_Task.h" +#include "test_i.h" +#include "interceptors.h" + +#include "ace/Manual_Event.h" + +ACE_RCSID(Collocated_Test, + Server_Task, + "$Id$") + + +Server_Task::Server_Task (const char *output, + CORBA::ORB_ptr sorb, + ACE_Manual_Event &me, + ACE_Thread_Manager *thr_mgr) + : ACE_Task_Base (thr_mgr) + , output_ (output) + , me_ (me) + , sorb_ (CORBA::ORB::_duplicate (sorb)) +{ +} + +int +Server_Task::svc (void) +{ + ACE_TRY_NEW_ENV + { + + CORBA::Object_var poa_object = + sorb_->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + 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_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + Visual_i * server_impl = 0; + ACE_NEW_RETURN (server_impl, Visual_i (sorb_.in ()), 1); + + PortableServer::ObjectId_var id = + root_poa->activate_object (server_impl + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var test_obj = + root_poa->id_to_reference (id.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Test_Interceptors::Visual_var server = + Test_Interceptors::Visual::_narrow (test_obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + this->sorb_->object_to_string (server.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Test_Interceptors::Visual: <%s>\n", ior.in ())); + + // If the ior_output_file exists, output the ior to it + if (output_ != 0) + { + FILE *output_file= ACE_OS::fopen (this->output_, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + this->output_), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + } + + // Signal the main thread before we call orb->run (); + this->me_.signal (); + + this->sorb_->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); + + root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + this->sorb_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught in server task:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Server_Task.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Server_Task.h new file mode 100644 index 00000000000..fe7e6b073d7 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/Server_Task.h @@ -0,0 +1,51 @@ +// -*- C++ -*- +// +// $Id$ + +#ifndef COLLOCATED_SERVER_TASK_H +#define COLLOCATED_SERVER_TASK_H + +#include /**/ "ace/pre.h" + +#include "ace/Task.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/ORB.h" + +class ACE_Manual_Event; + +/// Implement a Task to run the server in a single thread +class Server_Task : public ACE_Task_Base +{ +public: + /// Constructor + Server_Task (const char *output, + CORBA::ORB_ptr sorb, + ACE_Manual_Event &me, + ACE_Thread_Manager *thr_mgr); + + /// Thread entry point + int svc (void); + + /// The status of the svc loop + int status (void) const; + +private: + /// Output file for IOR + const char *output_; + + /// Manual event to wake up the main thread to create a client + /// thread. + ACE_Manual_Event &me_; + + CORBA::ORB_var sorb_; + + int status_; +}; + +#include /**/ "ace/post.h" + +#endif /* COLLOCATED_SERVER_TASK_H */ diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/interceptors.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/interceptors.cpp new file mode 100644 index 00000000000..a81e81a0e1b --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/interceptors.cpp @@ -0,0 +1,362 @@ +// $Id$ + +#include "interceptors.h" +#include "tao/PI/ClientRequestInfoC.h" +#include "tao/PI_Server/ServerRequestInfoC.h" +#include "tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h" +#include "tao/AnyTypeCode/DynamicC.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (Dynamic, + interceptors, + "$Id$") + +const char *request_msg = "The Echo_Request_Interceptor request message"; +const char *reply_msg = "The Echo_Request_Interceptor reply message"; +CORBA::ULong Echo_Client_Request_Interceptor::client_interceptor_check_ = 0; +CORBA::ULong Echo_Server_Request_Interceptor::server_interceptor_check_ = 0; + +Echo_Client_Request_Interceptor::Echo_Client_Request_Interceptor (void) + : myname_ ("Echo_Client_Interceptor") +{ +} + +Echo_Client_Request_Interceptor::~Echo_Client_Request_Interceptor () +{ +} + +char * +Echo_Client_Request_Interceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup (this->myname_); +} + +void +Echo_Client_Request_Interceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Echo_Client_Request_Interceptor::send_poll ( + PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED + ) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Do nothing +} + +void +Echo_Client_Request_Interceptor::send_request ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + client_interceptor_check_++; + + CORBA::String_var op = + ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Client_Request_Interceptor::send_request\n")); + + ACE_DEBUG ((LM_DEBUG, + "Echo_Client_Request_Interceptor::send_request from " + "\"%s\"\n", + op.in ())); + + if (ACE_OS::strcmp (op.in (), "normal") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i].argument >>= param; + + ACE_DEBUG ((LM_DEBUG, + "The arg is %d\n", + param)); + } +} + +void +Echo_Client_Request_Interceptor::receive_other ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + client_interceptor_check_++; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Client_Request_Interceptor::receive_other " + "from \"%s\"\n", + op.in ())); +} + +void +Echo_Client_Request_Interceptor::receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + client_interceptor_check_++; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Client_Request_Interceptor::receive_reply " + "from \"%s\"\n", + op.in ())); + + if (ACE_OS::strcmp (op.in (), "normal") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i].argument >>= param; + + } + else if (ACE_OS::strcmp (op.in (), "calculate") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param1, param2, result; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i++].argument >>= param1; + paramlist[i].argument >>= param2; + + CORBA::Any_var result_any = ri->result (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + (result_any.in ()) >>= result; + + ACE_DEBUG ((LM_DEBUG, + "The result of calculate is %d + %d = %d\n", + param1, + param2, + result)); + } +} + +void +Echo_Client_Request_Interceptor::receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + client_interceptor_check_++; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::String_var exception_id = + ri->received_exception_id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Client_Request_Interceptor::received_exception " + "from \"%s\"\n", + op.in ())); + + ACE_DEBUG ((LM_DEBUG, + "Exception ID = %s\n", + exception_id.in ())); +} + +Echo_Server_Request_Interceptor::Echo_Server_Request_Interceptor (void) + : myname_ ("Echo_Server_Interceptor") +{ +} + +Echo_Server_Request_Interceptor::~Echo_Server_Request_Interceptor () +{ +} + +char * +Echo_Server_Request_Interceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup (this->myname_); +} + +void +Echo_Server_Request_Interceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Echo_Server_Request_Interceptor::receive_request_service_contexts ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ +} + +void +Echo_Server_Request_Interceptor::receive_request ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + ++server_interceptor_check_; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + PortableInterceptor::ObjectId_var test_oid = + ri->object_id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Server_Request_Interceptor::receive_request from \"%s\"\n", + op.in ())); + + if (ACE_OS::strcmp (op.in (), "normal") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i].argument >>= param; + + ACE_DEBUG ((LM_DEBUG, + "The arg is %d\n", + param)); + + } + + CORBA::String_var tmdi = + ri->target_most_derived_interface (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Target most derived interface: %s\n", + tmdi.in ())); +} + +void +Echo_Server_Request_Interceptor::send_reply ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ++server_interceptor_check_; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Server_Request_Interceptor::send_reply from \"%s\"\n", + op.in ())); + + if (ACE_OS::strcmp (op.in (), "normal") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i].argument >>= param; + ACE_DEBUG ((LM_DEBUG, + "The arg is %d\n", + param)); + } + + if (ACE_OS::strcmp (op.in (), "calculate") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param1, param2, result = 0; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i++].argument >>= param1; + paramlist[i].argument >>= param2; + + CORBA::Any_var result_any = ri->result (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + (result_any.in ()) >>= result; + + ACE_DEBUG ((LM_DEBUG, + "The result of calculate is %d + %d = %d\n", + param1, + param2, + result)); + } +} + +void +Echo_Server_Request_Interceptor::send_exception ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + ++server_interceptor_check_; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Server_Request_Interceptor::send_exception " + "from \"%s\"\n", + op.in ())); + + + CORBA::Any_var any = + ri->sending_exception (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::TypeCode_var type = any->type (); + + const char *exception_id = type->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Exception ID = %s\n", + exception_id)); +} + +void +Echo_Server_Request_Interceptor::send_other ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + ++server_interceptor_check_; + + // Do Nothing +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/interceptors.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/interceptors.h new file mode 100644 index 00000000000..5b20f11e5c5 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/interceptors.h @@ -0,0 +1,140 @@ +// -*- C++ -*- +// +// $Id$ + +#ifndef TAO_INTERCEPTORS_H +#define TAO_INTERCEPTORS_H +#include /**/ "ace/pre.h" + +#include "tao/PI/PI.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI_Server/PI_Server.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 Echo_Client_Request_Interceptor + : public virtual PortableInterceptor::ClientRequestInterceptor, + public virtual TAO_Local_RefCounted_Object +{ + // = Client-side echo interceptor. For checking interceptor visually only. +public: + + Echo_Client_Request_Interceptor (void); + // ctor. + virtual ~Echo_Client_Request_Interceptor (); + // dtor. + + virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Canonical name of the interceptor. + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_poll ( + PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_request (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_other ( + PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + PortableInterceptor::ForwardRequest + )); + + virtual void receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + // Some identifiers that are used for error checking + static CORBA::ULong client_interceptor_check_; +private: + const char *myname_; +}; + +class Echo_Server_Request_Interceptor + : public PortableInterceptor::ServerRequestInterceptor, + public virtual TAO_Local_RefCounted_Object +{ + // = Server-side echo interceptor. For checking interceptor visually only. +public: + Echo_Server_Request_Interceptor (void); + // cotr. + ~Echo_Server_Request_Interceptor (); + // dotr. + + virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Canonical name of the interceptor. + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_request_service_contexts ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + CORBA::SystemException, + PortableInterceptor::ForwardRequest + )); + + virtual void receive_request (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_reply (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_exception (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_other ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + PortableInterceptor::ForwardRequest + )); + + // Some identifiers that are used for error checking + static CORBA::ULong server_interceptor_check_; + +private: + const char *myname_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /* TAO_INTERCEPTORS_H */ diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/run_test.pl b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/run_test.pl new file mode 100755 index 00000000000..e61783ae453 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/run_test.pl @@ -0,0 +1,125 @@ +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; + +sub get_test_modes +{ + my $testid = shift; + + my $client_mode = "LOCAL_AND_REMOTE"; + my $server_mode = "LOCAL_AND_REMOTE"; + + # There are Nine Permutations. + if ($testid == 1) + { + $client_mode = "LOCAL_AND_REMOTE"; + $server_mode = "LOCAL_AND_REMOTE"; + } + elsif ($testid == 2) + { + $client_mode = "LOCAL_AND_REMOTE"; + $server_mode = "LOCAL_ONLY"; + } + elsif ($testid == 3) + { + $client_mode = "LOCAL_AND_REMOTE"; + $server_mode = "REMOTE_ONLY"; + } + elsif ($testid == 4) + { + $client_mode = "LOCAL_ONLY"; + $server_mode = "LOCAL_AND_REMOTE"; + } + elsif ($testid == 5) + { + $client_mode = "LOCAL_ONLY"; + $server_mode = "LOCAL_ONLY"; + } + elsif ($testid == 6) + { + $client_mode = "LOCAL_ONLY"; + $server_mode = "REMOTE_ONLY"; + } + elsif ($testid == 7) + { + $client_mode = "REMOTE_ONLY"; + $server_mode = "LOCAL_AND_REMOTE"; + } + elsif ($testid == 8) + { + $client_mode = "REMOTE_ONLY"; + $server_mode = "LOCAL_ONLY"; + } + elsif ($testid == 9) + { + $client_mode = "REMOTE_ONLY"; + $server_mode = "REMOTE_ONLY"; + } + else + { + print STDERR "ERROR: invalid testid: $testid\n"; + exit 1; + } + + return ($client_mode, $server_mode); +} + +my $status = 0; +my $file = PerlACE::LocalFile ("test.ior"); + +my $testid; + +for ($testid = 1; $testid <= 9; ++$testid) +{ + unlink $file; + + my $client_mode; + my $server_mode; + + ($client_mode, $server_mode) = get_test_modes($testid); + + my $SV = new PerlACE::Process ("PI_ProcMode_Collocated_Test", + "-c $client_mode " . + "-s $server_mode " . + "-ORBobjrefstyle url"); + + print STDERR "\n\n==== Starting test variant #$testid\n\n"; + + $SV->Spawn (); + + if (PerlACE::waitforfile_timed ($file, 15) == -1) { + print STDERR "ERROR: cannot find file <$file>\n"; + $SV->Kill (); + exit 1; + } + + my $collocated = $SV->WaitKill (5); + + if ($collocated != 0) { + print STDERR "ERROR: PI_ProcMode_Collocated_Test returned $collocated\n"; + print STDERR "ERROR: For client-side mode [$client_mode],\n"; + print STDERR "ERROR: and server-side mode [$server_mode].\n"; + $status = 1; + print STDERR "\nTest variant #$testid of 9 failed!\n\n"; + } + else { + print STDERR "\nTest variant #$testid of 9 passed!\n\n"; + } +} + +unlink $file; + +if ($status == 0) { + print STDERR "\n==== All 9 test variants were successful!\n"; +} +else { + print STDERR "\n==== One or more of the 9 test variants failed!\n"; +} + +exit $status; diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test.idl b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test.idl new file mode 100644 index 00000000000..07ed4dee088 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test.idl @@ -0,0 +1,42 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Portable_Interceptors +// +// = FILENAME +// test.idl +// +// = DESCRIPTION +// Simple IDL file to test portable interceptor support. +// +// = AUTHORS +// Nanbor Wang <nanbor@cs.wustl.edu> +// +// ============================================================================ + +module Test_Interceptors +{ + exception Silly + {}; + + interface Visual + { + void normal (in long arg); + // Normal operation. + + long calculate (in long one, in long two); + // Normal operation with a return val. + + void user () + raises (Silly); + // throws a user exception. + + void system (); + // thows a system exception. + + oneway void shutdown (); + // shutdown the ORB + }; +}; diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test_i.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test_i.cpp new file mode 100644 index 00000000000..31585a94528 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test_i.cpp @@ -0,0 +1,60 @@ +// $Id$ + +#include "test_i.h" +#include "ace/OS_NS_unistd.h" + +ACE_RCSID(Dynamic, test_i, "$Id$") + +Visual_i::Visual_i (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + // ctor + +void +Visual_i::normal (CORBA::Long + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // ACE_DEBUG ((LM_DEBUG, "Visual::normal called with %d\n", arg)); +} + +CORBA::Long +Visual_i::calculate (CORBA::Long one, + CORBA::Long two + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // ACE_DEBUG ((LM_DEBUG, "Visual::calculate\n")); + return (one + two); +} + +void +Visual_i::user (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException,Test_Interceptors::Silly)) +{ + // ACE_DEBUG ((LM_DEBUG, "Visual::user, throwning Silly\n")); + ACE_THROW (Test_Interceptors::Silly ()); +} + +void +Visual_i::system (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // ACE_DEBUG ((LM_DEBUG, "Visual::user, throwing INV_OBJREF\n")); + ACE_THROW (CORBA::INV_OBJREF ()); +} + +void +Visual_i::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // Give the client thread time to return from the collocated + // call to this method before shutting down the ORB. We sleep + // to avoid BAD_INV_ORDER exceptions on fast dual processor machines. + ACE_OS::sleep(1); + this->orb_->shutdown (); +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test_i.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test_i.h new file mode 100644 index 00000000000..aed3c6f4ba9 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Collocated/test_i.h @@ -0,0 +1,55 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Portable_Interceptors/Dynamic +// +// = FILENAME +// test_i.h +// +// = AUTHOR +// Nanbor Wang +// +// ============================================================================ + +#ifndef TAO_INTERCEPTOR_TEST_I_H +#define TAO_INTERCEPTOR_TEST_I_H + +#include "testS.h" + +class Visual_i : public POA_Test_Interceptors::Visual, + public virtual PortableServer::RefCountServantBase +{ + // = DESCRIPTION + // Implements the Visual interface in test.idl + +public: + Visual_i (CORBA::ORB_ptr orb); + // ctor + + void normal (CORBA::Long arg + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + CORBA::Long calculate ( + CORBA::Long one, + CORBA::Long two + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void user (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException,Test_Interceptors::Silly)); + + void system (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + CORBA::ORB_var orb_; + // The ORB pointer (for shutdown.) +}; + +#endif /* TAO_INTERCEPTOR_TEST_I_H */ diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Client_Task.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Client_Task.cpp new file mode 100644 index 00000000000..0990fd47209 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Client_Task.cpp @@ -0,0 +1,98 @@ +// +// $Id$ +// + +#include "Client_Task.h" +#include "testC.h" +#include "client_interceptor.h" + +ACE_RCSID(Remote, Client_Task, "$Id$") + +Client_Task::Client_Task (const char *ior, + CORBA::ORB_ptr corb, + ACE_Thread_Manager *thr_mgr) + : ACE_Task_Base (thr_mgr) + , input_ (ior) + , corb_ (CORBA::ORB::_duplicate (corb)) + +{ +} + +int +Client_Task::svc (void) +{ + ACE_TRY_NEW_ENV + { + + CORBA::Object_var object = + corb_->string_to_object (input_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Test_Interceptors::Visual_var server = + Test_Interceptors::Visual::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (server.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Object reference <%s> is nil\n", + this->input_), + 1); + } + + run_test (server.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + server->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught in client task:"); + return 1; + } + ACE_ENDTRY; + + return 0; + +} + + +void +Client_Task::run_test (Test_Interceptors::Visual_ptr server + ACE_ENV_ARG_DECL) +{ + server->normal (10 ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long one = 1, two = 1; + (void) server->calculate (one, + two + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_TRY + { + (void) server->user (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (Test_Interceptors::Silly, userex) + { + ACE_DEBUG ((LM_DEBUG, "As expected, Caught Silly\n")); + } + ACE_ENDTRY; + ACE_CHECK; + + ACE_TRY_EX (SYS) + { + server->system (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK_EX (SYS); + } + ACE_CATCH (CORBA::INV_OBJREF, sysex) + { + ACE_DEBUG ((LM_DEBUG, "As expected, Caught CORBA::INV_OBJREF\n")); + } + ACE_ENDTRY; + ACE_CHECK; +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Client_Task.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Client_Task.h new file mode 100644 index 00000000000..3678e806775 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Client_Task.h @@ -0,0 +1,45 @@ +// +// $Id$ +// + +#ifndef TEST_CLIENT_TASK_H +#define TEST_CLIENT_TASK_H +#include /**/ "ace/pre.h" +#include "ace/Task.h" +#include "testS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "tao/ORB.h" + + +/// Implement a Task to run the client as a thread +class Client_Task : public ACE_Task_Base +{ +public: + + /// Constructor + Client_Task (const char *input, + CORBA::ORB_ptr corb, + ACE_Thread_Manager *thr_mgr); + + /// Thread entry point + int svc (void); + + void run_test (Test_Interceptors::Visual_ptr server + ACE_ENV_ARG_DECL); + + /// The status of the svc loop + int status (void) const; + +private: + const char *input_; + + CORBA::ORB_var corb_; + + int status_; +}; + +#include /**/ "ace/post.h" +#endif /* TEST_CLIENT_TASK_H */ diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Client_ORBInitializer.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Client_ORBInitializer.cpp new file mode 100644 index 00000000000..15751d6f087 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Client_ORBInitializer.cpp @@ -0,0 +1,90 @@ +// -*- C++ -*- +// +// $Id$ + +#include "Echo_Client_ORBInitializer.h" +#include "client_interceptor.h" +#include "tao/PI/ORBInitInfo.h" +#include "tao/ORB_Core.h" +#include "ace/OS_NS_string.h" + +Echo_Client_ORBInitializer::Echo_Client_ORBInitializer ( + PortableInterceptor::ProcessingMode proc_mode) + : processing_mode_(proc_mode) +{ +} + +void +Echo_Client_ORBInitializer::pre_init ( + PortableInterceptor::ORBInitInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Echo_Client_ORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // TAO-Specific way to get to the ORB Core (and thus, the ORB). + TAO_ORBInitInfo_var tao_info = + TAO_ORBInitInfo::_narrow (info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ORB_var orb = CORBA::ORB::_duplicate(tao_info->orb_core()->orb()); + + if (CORBA::is_nil(orb.in())) + { + ACE_THROW (CORBA::INTERNAL ()); + ACE_CHECK; + } + + PortableInterceptor::ORBInitInfo_3_1_var info_3_1 = + PortableInterceptor::ORBInitInfo_3_1::_narrow(info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil(info_3_1.in())) + { + ACE_THROW (CORBA::INTERNAL ()); + ACE_CHECK; + } + + PortableInterceptor::ClientRequestInterceptor_ptr interceptor = + PortableInterceptor::ClientRequestInterceptor::_nil (); + + // Install the Echo client request interceptor + ACE_NEW_THROW_EX (interceptor, + Echo_Client_Request_Interceptor, + CORBA::NO_MEMORY ()); + ACE_CHECK; + + PortableInterceptor::ClientRequestInterceptor_var + client_interceptor = interceptor; + + CORBA::Any client_proc_mode_as_any; + client_proc_mode_as_any <<= this->processing_mode_; + + CORBA::PolicyList policy_list (1); + + policy_list.length (1); + policy_list[0] = + orb->create_policy (PortableInterceptor::PROCESSING_MODE_POLICY_TYPE, + client_proc_mode_as_any + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + info_3_1->add_client_request_interceptor_with_policy ( + client_interceptor.in (), + policy_list + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policy_list[0]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + policy_list[0] = CORBA::Policy::_nil (); +} + diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Client_ORBInitializer.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Client_ORBInitializer.h new file mode 100644 index 00000000000..02dcc7fd9a4 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Client_ORBInitializer.h @@ -0,0 +1,60 @@ +// -*- C++ -*- +// +// $Id$ + +#ifndef TAO_ECHO_CLIENT_ORB_INITIALIZER_H +#define TAO_ECHO_CLIENT_ORB_INITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "tao/orbconf.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +#include "tao/PI/PI.h" +#include "tao/PI/ProcessingModePolicyC.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 */ + +/// Echo client ORB initializer. +class Echo_Client_ORBInitializer : + public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + Echo_Client_ORBInitializer + (PortableInterceptor::ProcessingMode proc_mode); + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + + PortableInterceptor::ProcessingMode processing_mode_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + + +#include /**/ "ace/post.h" + +#endif /* TAO_ECHO_CLIENT_ORB_INITIALIZER_H */ diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Server_ORBInitializer.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Server_ORBInitializer.cpp new file mode 100644 index 00000000000..9136e25e126 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Server_ORBInitializer.cpp @@ -0,0 +1,94 @@ +// -*- C++ -*- +// +// $Id$ + +#include "Echo_Server_ORBInitializer.h" +#include "server_interceptor.h" +#include "tao/PI/ORBInitInfo.h" +#include "tao/ORB_Core.h" +#include "ace/OS_NS_string.h" + +Echo_Server_ORBInitializer::Echo_Server_ORBInitializer ( + PortableInterceptor::ProcessingMode proc_mode) + : processing_mode_(proc_mode) +{ +} + +void +Echo_Server_ORBInitializer::pre_init ( + PortableInterceptor::ORBInitInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Echo_Server_ORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::String_var orb_id = + info->orb_id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // TAO-Specific way to get to the ORB Core (and thus, the ORB). + TAO_ORBInitInfo_var tao_info = + TAO_ORBInitInfo::_narrow (info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ORB_var orb = CORBA::ORB::_duplicate(tao_info->orb_core()->orb()); + + if (CORBA::is_nil(orb.in())) + { + ACE_THROW (CORBA::INTERNAL ()); + ACE_CHECK; + } + + PortableInterceptor::ORBInitInfo_3_1_var info_3_1 = + PortableInterceptor::ORBInitInfo_3_1::_narrow(info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil(info_3_1.in())) + { + ACE_THROW (CORBA::INTERNAL ()); + ACE_CHECK; + } + + PortableInterceptor::ServerRequestInterceptor_ptr interceptor = + PortableInterceptor::ServerRequestInterceptor::_nil (); + + // Install the Echo server request interceptor + ACE_NEW_THROW_EX (interceptor, + Echo_Server_Request_Interceptor, + CORBA::NO_MEMORY ()); + ACE_CHECK; + + PortableInterceptor::ServerRequestInterceptor_var + server_interceptor = interceptor; + + CORBA::Any proc_mode_as_any; + proc_mode_as_any <<= this->processing_mode_; + + CORBA::PolicyList policy_list (1); + + policy_list.length (1); + policy_list[0] = + orb->create_policy (PortableInterceptor::PROCESSING_MODE_POLICY_TYPE, + proc_mode_as_any + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + info_3_1->add_server_request_interceptor_with_policy ( + server_interceptor.in (), + policy_list + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policy_list[0]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + policy_list[0] = CORBA::Policy::_nil (); +} + diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Server_ORBInitializer.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Server_ORBInitializer.h new file mode 100644 index 00000000000..cb6d7109fb5 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Echo_Server_ORBInitializer.h @@ -0,0 +1,59 @@ +// -*- C++ -*- +// +// $Id$ + +#ifndef TAO_ECHO_SERVER_ORB_INITIALIZER_H +#define TAO_ECHO_SERVER_ORB_INITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "tao/orbconf.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/PI/ProcessingModePolicyC.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 */ + +/// Echo client ORB initializer. +class Echo_Server_ORBInitializer : + public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + Echo_Server_ORBInitializer + (PortableInterceptor::ProcessingMode proc_mode); + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + + PortableInterceptor::ProcessingMode processing_mode_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + + +#include /**/ "ace/post.h" + +#endif /* TAO_ECHO_SERVER_ORB_INITIALIZER_H */ diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/PI_ProcMode_Remote.mpc b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/PI_ProcMode_Remote.mpc new file mode 100644 index 00000000000..deab03af74f --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/PI_ProcMode_Remote.mpc @@ -0,0 +1,26 @@ +// -*- MPC -*- +// $Id$ + +project(*RemoteServer): taoserver, pi_server, interceptors { + exename = PI_ProcMode_Remote_TestServer + Source_Files { + testC.cpp + testS.cpp + test_i.cpp + server_interceptor.cpp + Echo_Server_ORBInitializer.cpp + server_main.cpp + Server_Task.cpp + } +} + +project(*RemoteClient): taoclient, portableserver, pi, interceptors { + exename = PI_ProcMode_Remote_TestClient + Source_Files { + testC.cpp + client_interceptor.cpp + Echo_Client_ORBInitializer.cpp + client_main.cpp + Client_Task.cpp + } +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Server_Task.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Server_Task.cpp new file mode 100644 index 00000000000..7fbab820892 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Server_Task.cpp @@ -0,0 +1,112 @@ +// +// $Id$ +// +#include "Server_Task.h" +#include "test_i.h" +#include "server_interceptor.h" + +#include "ace/Manual_Event.h" + +ACE_RCSID(Remote, + Server_Task, + "$Id$") + + +Server_Task::Server_Task (const char *output, + CORBA::ORB_ptr sorb, + ACE_Manual_Event &me, + ACE_Thread_Manager *thr_mgr) + : ACE_Task_Base (thr_mgr) + , output_ (output) + , me_ (me) + , sorb_ (CORBA::ORB::_duplicate (sorb)) +{ +} + +int +Server_Task::svc (void) +{ + ACE_TRY_NEW_ENV + { + + CORBA::Object_var poa_object = + sorb_->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + 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_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + Visual_i * server_impl = 0; + ACE_NEW_RETURN (server_impl, Visual_i (sorb_.in ()), 1); + + PortableServer::ObjectId_var id = + root_poa->activate_object (server_impl + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var test_obj = + root_poa->id_to_reference (id.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Test_Interceptors::Visual_var server = + Test_Interceptors::Visual::_narrow (test_obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + this->sorb_->object_to_string (server.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Test_Interceptors::Visual: <%s>\n", ior.in ())); + + // If the ior_output_file exists, output the ior to it + if (output_ != 0) + { + FILE *output_file= ACE_OS::fopen (this->output_, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + this->output_), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + } + + // Signal the main thread before we call orb->run (); + this->me_.signal (); + + this->sorb_->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); + + root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + this->sorb_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught in server task:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Server_Task.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Server_Task.h new file mode 100644 index 00000000000..5420647d490 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/Server_Task.h @@ -0,0 +1,51 @@ +// -*- C++ -*- +// +// $Id$ + +#ifndef TEST_SERVER_TASK_H +#define TEST_SERVER_TASK_H + +#include /**/ "ace/pre.h" + +#include "ace/Task.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/ORB.h" + +class ACE_Manual_Event; + +/// Implement a Task to run the server in a single thread +class Server_Task : public ACE_Task_Base +{ +public: + /// Constructor + Server_Task (const char *output, + CORBA::ORB_ptr sorb, + ACE_Manual_Event &me, + ACE_Thread_Manager *thr_mgr); + + /// Thread entry point + int svc (void); + + /// The status of the svc loop + int status (void) const; + +private: + /// Output file for IOR + const char *output_; + + /// Manual event to wake up the main thread to create a client + /// thread. + ACE_Manual_Event &me_; + + CORBA::ORB_var sorb_; + + int status_; +}; + +#include /**/ "ace/post.h" + +#endif /* COLLOCATED_SERVER_TASK_H */ diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_interceptor.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_interceptor.cpp new file mode 100644 index 00000000000..399025fa883 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_interceptor.cpp @@ -0,0 +1,184 @@ +// $Id$ + +#include "client_interceptor.h" +#include "tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h" +#include "tao/AnyTypeCode/DynamicC.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (Remote, + client_interceptor, + "$Id$") + +const char *request_msg = "The Echo_Client_Request_Interceptor request message"; +const char *reply_msg = "The Echo_Client_Request_Interceptor reply message"; +CORBA::ULong Echo_Client_Request_Interceptor::client_interceptor_check_ = 0; + +Echo_Client_Request_Interceptor::Echo_Client_Request_Interceptor (void) + : myname_ ("Echo_Client_Interceptor") +{ +} + +Echo_Client_Request_Interceptor::~Echo_Client_Request_Interceptor () +{ +} + +char * +Echo_Client_Request_Interceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup (this->myname_); +} + +void +Echo_Client_Request_Interceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Echo_Client_Request_Interceptor::send_poll ( + PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED + ) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Do nothing +} + +void +Echo_Client_Request_Interceptor::send_request ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + client_interceptor_check_++; + + CORBA::String_var op = + ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Client_Request_Interceptor::send_request\n")); + + ACE_DEBUG ((LM_DEBUG, + "Echo_Client_Request_Interceptor::send_request from " + "\"%s\"\n", + op.in ())); + + if (ACE_OS::strcmp (op.in (), "normal") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i].argument >>= param; + + ACE_DEBUG ((LM_DEBUG, + "The arg is %d\n", + param)); + } +} + +void +Echo_Client_Request_Interceptor::receive_other ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + client_interceptor_check_++; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Client_Request_Interceptor::receive_other " + "from \"%s\"\n", + op.in ())); +} + +void +Echo_Client_Request_Interceptor::receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + client_interceptor_check_++; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Client_Request_Interceptor::receive_reply " + "from \"%s\"\n", + op.in ())); + + if (ACE_OS::strcmp (op.in (), "normal") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i].argument >>= param; + + } + else if (ACE_OS::strcmp (op.in (), "calculate") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param1, param2, result; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i++].argument >>= param1; + paramlist[i].argument >>= param2; + + CORBA::Any_var result_any = ri->result (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + (result_any.in ()) >>= result; + + ACE_DEBUG ((LM_DEBUG, + "The result of calculate is %d + %d = %d\n", + param1, + param2, + result)); + } +} + +void +Echo_Client_Request_Interceptor::receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + client_interceptor_check_++; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::String_var exception_id = + ri->received_exception_id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Client_Request_Interceptor::received_exception " + "from \"%s\"\n", + op.in ())); + + ACE_DEBUG ((LM_DEBUG, + "Exception ID = %s\n", + exception_id.in ())); +} + diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_interceptor.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_interceptor.h new file mode 100644 index 00000000000..5e1f373f341 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_interceptor.h @@ -0,0 +1,83 @@ +// -*- C++ -*- +// +// $Id$ + +#ifndef TAO_CLIENT_INTERCEPTOR_H +#define TAO_CLIENT_INTERCEPTOR_H +#include /**/ "ace/pre.h" + +#include "tao/PI/PI.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#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 Echo_Client_Request_Interceptor + : public virtual PortableInterceptor::ClientRequestInterceptor, + public virtual TAO_Local_RefCounted_Object +{ + // = Client-side echo interceptor. For checking interceptor visually only. +public: + + Echo_Client_Request_Interceptor (void); + // ctor. + virtual ~Echo_Client_Request_Interceptor (); + // dtor. + + virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Canonical name of the interceptor. + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_poll ( + PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_request (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_other ( + PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + PortableInterceptor::ForwardRequest + )); + + virtual void receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + // Some identifiers that are used for error checking + static CORBA::ULong client_interceptor_check_; +private: + const char *myname_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /* TAO_CLIENT_INTERCEPTOR_H */ diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_main.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_main.cpp new file mode 100644 index 00000000000..78a62bdf25e --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/client_main.cpp @@ -0,0 +1,136 @@ +//$Id$ +#include "Client_Task.h" +#include "ace/Get_Opt.h" +#include "ace/Argv_Type_Converter.h" +#include "ace/SString.h" +#include "ace/Manual_Event.h" +#include "Echo_Client_ORBInitializer.h" +#include "tao/ORBInitializer_Registry.h" +#include "client_interceptor.h" + +const char *input = "file://test.ior"; + +ACE_CString proc_mode_str; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "p:k:"); + int c; + + proc_mode_str.set ("LOCAL_AND_REMOTE"); + + while ((c = get_opts ()) != -1) + { + switch (c) + { + case 'p': + proc_mode_str.set (get_opts.opt_arg ()); + break; + case 'k': + input = get_opts.opt_arg (); + break; + case '?': + default: + return 0; + } + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + if (parse_args (argc, + argv) == -1) + return -1; + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + PortableInterceptor::ORBInitializer_ptr temp_initializer = + PortableInterceptor::ORBInitializer::_nil (); + + // Set up our default expectations. + CORBA::ULong expected_interceptor_check = 12; + + PortableInterceptor::ProcessingMode proc_mode = + PortableInterceptor::LOCAL_AND_REMOTE; + + if (proc_mode_str == "LOCAL_ONLY") + { + proc_mode = PortableInterceptor::LOCAL_ONLY; + ACE_DEBUG((LM_DEBUG, + "Using LOCAL_ONLY for client-side ProcessingMode.\n")); + + // Since all of the calls are remote, setting the client-side + // ProcessingMode to LOCAL_ONLY will cause the client request + // interceptor to not fire. Thus, we expect 0 calls on the + // client interceptor. + expected_interceptor_check = 0; + } + else if (proc_mode_str == "REMOTE_ONLY") + { + proc_mode = PortableInterceptor::REMOTE_ONLY; + ACE_DEBUG((LM_DEBUG, + "Using REMOTE_ONLY for client-side ProcessingMode.\n")); + } + else + { + ACE_DEBUG((LM_DEBUG, + "Using LOCAL_AND_REMOTE for client-side ProcessingMode.\n")); + } + + ACE_NEW_RETURN (temp_initializer, + Echo_Client_ORBInitializer (proc_mode), + -1); // No exceptions yet! + PortableInterceptor::ORBInitializer_var orb_initializer = + temp_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_Argv_Type_Converter atc (argc, argv); + CORBA::ORB_var orb = + CORBA::ORB_init (atc.get_argc (), + atc.get_TCHAR_argv (), + "" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Client_Task client_task (input, + orb.in (), + ACE_Thread_Manager::instance ()); + + if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, + 1, + 1) == -1) + { + ACE_ERROR ((LM_ERROR, "Error activating client task\n")); + } + + ACE_Thread_Manager::instance ()->wait (); + + CORBA::ULong number_called = + Echo_Client_Request_Interceptor::client_interceptor_check_; + + if (number_called != expected_interceptor_check) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR:Client-Side Interceptors not called " + "properly, called %d times, expected %d.\n", + number_called, expected_interceptor_check)); + return 1; + } + } + ACE_CATCHANY + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR: Some exception was caught in main().\n")); + return 1; + } + ACE_ENDTRY; + return 0; +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/run_test.pl b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/run_test.pl new file mode 100755 index 00000000000..95abb3baad8 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/run_test.pl @@ -0,0 +1,140 @@ +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; + +sub get_test_modes +{ + my $testid = shift; + + my $client_mode = "LOCAL_AND_REMOTE"; + my $server_mode = "LOCAL_AND_REMOTE"; + + # There are Nine Permutations. + if ($testid == 1) + { + $client_mode = "LOCAL_AND_REMOTE"; + $server_mode = "LOCAL_AND_REMOTE"; + } + elsif ($testid == 2) + { + $client_mode = "LOCAL_AND_REMOTE"; + $server_mode = "LOCAL_ONLY"; + } + elsif ($testid == 3) + { + $client_mode = "LOCAL_AND_REMOTE"; + $server_mode = "REMOTE_ONLY"; + } + elsif ($testid == 4) + { + $client_mode = "LOCAL_ONLY"; + $server_mode = "LOCAL_AND_REMOTE"; + } + elsif ($testid == 5) + { + $client_mode = "LOCAL_ONLY"; + $server_mode = "LOCAL_ONLY"; + } + elsif ($testid == 6) + { + $client_mode = "LOCAL_ONLY"; + $server_mode = "REMOTE_ONLY"; + } + elsif ($testid == 7) + { + $client_mode = "REMOTE_ONLY"; + $server_mode = "LOCAL_AND_REMOTE"; + } + elsif ($testid == 8) + { + $client_mode = "REMOTE_ONLY"; + $server_mode = "LOCAL_ONLY"; + } + elsif ($testid == 9) + { + $client_mode = "REMOTE_ONLY"; + $server_mode = "REMOTE_ONLY"; + } + else + { + print STDERR "ERROR: invalid testid: $testid\n"; + exit 1; + } + + return ($client_mode, $server_mode); +} + +my $status = 0; +my $file = PerlACE::LocalFile ("test.ior"); + +my $testid; + +for ($testid = 1; $testid <= 9; ++$testid) +{ + unlink $file; + + my $client_mode; + my $server_mode; + + ($client_mode, $server_mode) = get_test_modes($testid); + + my $SV = new PerlACE::Process ("PI_ProcMode_Remote_TestServer", + "-p $server_mode " . + "-ORBobjrefstyle url"); + + print STDERR "\n\n==== Starting test variant #$testid\n\n"; + + $SV->Spawn (); + + if (PerlACE::waitforfile_timed ($file, 15) == -1) { + print STDERR "ERROR: cannot find file <$file>\n"; + $SV->Kill (); + exit 1; + } + + my $CLIENT = new PerlACE::Process ("PI_ProcMode_Remote_TestClient", + "-p $client_mode " . + "-ORBobjrefstyle url"); + + my $client_status = $CLIENT->SpawnWaitKill (5); + + if ($client_status != 0) { + print STDERR "ERROR: PI_ProcMode_TestClient returned $client_status\n"; + print STDERR "ERROR: For client-side mode [$client_mode],\n"; + print STDERR "ERROR: and server-side mode [$server_mode].\n"; + $status = 1; + } + + my $server_status = $SV->WaitKill (5); + + if ($server_status != 0) { + print STDERR "ERROR: PI_ProcMode_TestServer returned $server_status\n"; + print STDERR "ERROR: For client-side mode [$client_mode],\n"; + print STDERR "ERROR: and server-side mode [$server_mode].\n"; + $status = 1; + } + + if (($server_status == 0) && ($client_status == 0)) { + print STDERR "\n==== Test variant #$testid (of 9) passed!\n"; + } + else { + print STDERR "\n==== Test variant #$testid (of 9) failed!\n"; + } +} + +unlink $file; + +if ($status == 0) { + print STDERR "\n==== All 9 test variants were successful!\n"; +} +else { + print STDERR "\n==== One or more of the 9 test variants failed!\n"; +} + +exit $status; diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_interceptor.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_interceptor.cpp new file mode 100644 index 00000000000..a1928755bec --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_interceptor.cpp @@ -0,0 +1,192 @@ +// $Id$ + +#include "server_interceptor.h" +#include "tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h" +#include "tao/AnyTypeCode/DynamicC.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (Remote, + server_interceptor, + "$Id$") + +const char *request_msg = "The Echo_Server_Request_Interceptor request message"; +const char *reply_msg = "The Echo_Server_Request_Interceptor reply message"; +CORBA::ULong Echo_Server_Request_Interceptor::server_interceptor_check_ = 0; + +Echo_Server_Request_Interceptor::Echo_Server_Request_Interceptor (void) + : myname_ ("Echo_Server_Interceptor") +{ +} + +Echo_Server_Request_Interceptor::~Echo_Server_Request_Interceptor () +{ +} + +char * +Echo_Server_Request_Interceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup (this->myname_); +} + +void +Echo_Server_Request_Interceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +Echo_Server_Request_Interceptor::receive_request_service_contexts ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ +} + +void +Echo_Server_Request_Interceptor::receive_request ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + ++server_interceptor_check_; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + PortableInterceptor::ObjectId_var test_oid = + ri->object_id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Server_Request_Interceptor::receive_request from \"%s\"\n", + op.in ())); + + if (ACE_OS::strcmp (op.in (), "normal") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i].argument >>= param; + + ACE_DEBUG ((LM_DEBUG, + "The arg is %d\n", + param)); + + } + + CORBA::String_var tmdi = + ri->target_most_derived_interface (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Target most derived interface: %s\n", + tmdi.in ())); +} + +void +Echo_Server_Request_Interceptor::send_reply ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ++server_interceptor_check_; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Server_Request_Interceptor::send_reply from \"%s\"\n", + op.in ())); + + if (ACE_OS::strcmp (op.in (), "normal") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i].argument >>= param; + ACE_DEBUG ((LM_DEBUG, + "The arg is %d\n", + param)); + } + + if (ACE_OS::strcmp (op.in (), "calculate") == 0) + { + Dynamic::ParameterList_var paramlist = + ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long param1, param2, result = 0; + CORBA::ULong i = 0; // index -- explicitly used to avoid + // overloaded operator ambiguity. + paramlist[i++].argument >>= param1; + paramlist[i].argument >>= param2; + + CORBA::Any_var result_any = ri->result (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + (result_any.in ()) >>= result; + + ACE_DEBUG ((LM_DEBUG, + "The result of calculate is %d + %d = %d\n", + param1, + param2, + result)); + } +} + +void +Echo_Server_Request_Interceptor::send_exception ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + ++server_interceptor_check_; + + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Echo_Server_Request_Interceptor::send_exception " + "from \"%s\"\n", + op.in ())); + + + CORBA::Any_var any = + ri->sending_exception (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::TypeCode_var type = any->type (); + + const char *exception_id = type->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "Exception ID = %s\n", + exception_id)); +} + +void +Echo_Server_Request_Interceptor::send_other ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + ++server_interceptor_check_; + + // Do Nothing +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_interceptor.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_interceptor.h new file mode 100644 index 00000000000..94a57e62c2a --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_interceptor.h @@ -0,0 +1,86 @@ +// -*- C++ -*- +// +// $Id$ + +#ifndef TAO_SERVER_INTERCEPTOR_H +#define TAO_SERVER_INTERCEPTOR_H +#include /**/ "ace/pre.h" + +#include "tao/PI/PI.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI_Server/PI_Server.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 Echo_Server_Request_Interceptor + : public PortableInterceptor::ServerRequestInterceptor, + public virtual TAO_Local_RefCounted_Object +{ + // = Server-side echo interceptor. For checking interceptor visually only. +public: + Echo_Server_Request_Interceptor (void); + // cotr. + ~Echo_Server_Request_Interceptor (); + // dotr. + + virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Canonical name of the interceptor. + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_request_service_contexts ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + CORBA::SystemException, + PortableInterceptor::ForwardRequest + )); + + virtual void receive_request (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_reply (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_exception (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_other ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + PortableInterceptor::ForwardRequest + )); + + // Some identifiers that are used for error checking + static CORBA::ULong server_interceptor_check_; + +private: + const char *myname_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /* TAO_SERVER_INTERCEPTOR_H */ diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_main.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_main.cpp new file mode 100644 index 00000000000..720d51ab9ad --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/server_main.cpp @@ -0,0 +1,138 @@ +//$Id$ +#include "Server_Task.h" +#include "ace/Get_Opt.h" +#include "ace/Argv_Type_Converter.h" +#include "ace/SString.h" +#include "ace/Manual_Event.h" +#include "Echo_Server_ORBInitializer.h" +#include "tao/ORBInitializer_Registry.h" +#include "server_interceptor.h" + +const char *output = "test.ior"; + +ACE_CString proc_mode_str; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "p:o:"); + int c; + + proc_mode_str.set ("LOCAL_AND_REMOTE"); + + while ((c = get_opts ()) != -1) + { + switch (c) + { + case 'p': + proc_mode_str.set (get_opts.opt_arg ()); + break; + case 'o': + output = get_opts.opt_arg (); + break; + case '?': + default: + return 0; + } + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + if (parse_args (argc, + argv) == -1) + return -1; + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + PortableInterceptor::ORBInitializer_ptr temp_initializer = + PortableInterceptor::ORBInitializer::_nil (); + + // Set up our default expectations. + CORBA::ULong expected_interceptor_check = 12; + + PortableInterceptor::ProcessingMode proc_mode = + PortableInterceptor::LOCAL_AND_REMOTE; + + if (proc_mode_str == "LOCAL_ONLY") + { + proc_mode = PortableInterceptor::LOCAL_ONLY; + ACE_DEBUG((LM_DEBUG, + "Using LOCAL_ONLY for server-side ProcessingMode.\n")); + + // Since all of the calls are remote, setting the server-side + // ProcessingMode to LOCAL_ONLY will cause the server request + // interceptor to not fire. Thus, we expect 0 calls on the + // server interceptor. + expected_interceptor_check = 0; + } + else if (proc_mode_str == "REMOTE_ONLY") + { + proc_mode = PortableInterceptor::REMOTE_ONLY; + ACE_DEBUG((LM_DEBUG, + "Using REMOTE_ONLY for server-side ProcessingMode.\n")); + } + else + { + ACE_DEBUG((LM_DEBUG, + "Using LOCAL_AND_REMOTE for server-side ProcessingMode.\n")); + } + + ACE_NEW_RETURN (temp_initializer, + Echo_Server_ORBInitializer (proc_mode), + -1); // No exceptions yet! + PortableInterceptor::ORBInitializer_var orb_initializer = + temp_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_Argv_Type_Converter atc (argc, argv); + CORBA::ORB_var orb = + CORBA::ORB_init (atc.get_argc (), + atc.get_TCHAR_argv (), + "" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_Manual_Event me; + Server_Task server_task (output, + orb.in (), + me, + ACE_Thread_Manager::instance ()); + + if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, + 1, + 1) == -1) + { + ACE_ERROR ((LM_ERROR, "Error activating server task\n")); + } + + ACE_Thread_Manager::instance ()->wait (); + + CORBA::ULong number_called = + Echo_Server_Request_Interceptor::server_interceptor_check_; + + if (number_called != expected_interceptor_check) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR: Server-Side Interceptors not " + "called properly, called %d times, expected %d.\n", + number_called, expected_interceptor_check)); + return 1; + } + } + ACE_CATCHANY + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR: Some exception was caught in main().\n")); + return 1; + } + ACE_ENDTRY; + return 0; +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test.idl b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test.idl new file mode 100644 index 00000000000..07ed4dee088 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test.idl @@ -0,0 +1,42 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Portable_Interceptors +// +// = FILENAME +// test.idl +// +// = DESCRIPTION +// Simple IDL file to test portable interceptor support. +// +// = AUTHORS +// Nanbor Wang <nanbor@cs.wustl.edu> +// +// ============================================================================ + +module Test_Interceptors +{ + exception Silly + {}; + + interface Visual + { + void normal (in long arg); + // Normal operation. + + long calculate (in long one, in long two); + // Normal operation with a return val. + + void user () + raises (Silly); + // throws a user exception. + + void system (); + // thows a system exception. + + oneway void shutdown (); + // shutdown the ORB + }; +}; diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test_i.cpp b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test_i.cpp new file mode 100644 index 00000000000..bf5fe31c9f8 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test_i.cpp @@ -0,0 +1,55 @@ +// $Id$ + +#include "test_i.h" + +ACE_RCSID(Remote, test_i, "$Id$") + +Visual_i::Visual_i (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + // ctor + +void +Visual_i::normal (CORBA::Long + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // ACE_DEBUG ((LM_DEBUG, "Visual::normal called with %d\n", arg)); +} + +CORBA::Long +Visual_i::calculate (CORBA::Long one, + CORBA::Long two + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // ACE_DEBUG ((LM_DEBUG, "Visual::calculate\n")); + return (one + two); +} + +void +Visual_i::user (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException,Test_Interceptors::Silly)) +{ + // ACE_DEBUG ((LM_DEBUG, "Visual::user, throwning Silly\n")); + ACE_THROW (Test_Interceptors::Silly ()); +} + +void +Visual_i::system (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // ACE_DEBUG ((LM_DEBUG, "Visual::user, throwing INV_OBJREF\n")); + ACE_THROW (CORBA::INV_OBJREF ()); +} + +void +Visual_i::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->orb_->shutdown (); +} diff --git a/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test_i.h b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test_i.h new file mode 100644 index 00000000000..aed3c6f4ba9 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/test_i.h @@ -0,0 +1,55 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Portable_Interceptors/Dynamic +// +// = FILENAME +// test_i.h +// +// = AUTHOR +// Nanbor Wang +// +// ============================================================================ + +#ifndef TAO_INTERCEPTOR_TEST_I_H +#define TAO_INTERCEPTOR_TEST_I_H + +#include "testS.h" + +class Visual_i : public POA_Test_Interceptors::Visual, + public virtual PortableServer::RefCountServantBase +{ + // = DESCRIPTION + // Implements the Visual interface in test.idl + +public: + Visual_i (CORBA::ORB_ptr orb); + // ctor + + void normal (CORBA::Long arg + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + CORBA::Long calculate ( + CORBA::Long one, + CORBA::Long two + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void user (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException,Test_Interceptors::Silly)); + + void system (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + CORBA::ORB_var orb_; + // The ORB pointer (for shutdown.) +}; + +#endif /* TAO_INTERCEPTOR_TEST_I_H */ |