diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2001-09-24 08:31:39 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2001-09-24 08:31:39 +0000 |
commit | 98bf6fd5944c42d6378d113a97887cf6c25ff616 (patch) | |
tree | b9674398df0afb2f1a2977634505a8cc23ea28c8 | |
parent | fa0cc67947b410a1ac3eb1502b5351a21e241d2b (diff) | |
download | ATCD-98bf6fd5944c42d6378d113a97887cf6c25ff616.tar.gz |
ChangeLogTag:Mon Sep 24 01:21:16 2001 Ossama Othman <ossama@uci.edu>
47 files changed, 2808 insertions, 63 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 7d445bbe521..d39ec37d917 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,139 @@ +Mon Sep 24 01:21:16 2001 Ossama Othman <ossama@uci.edu> + + * tao/PICurrent.h: + * tao/PICurrent.inl: + * tao/PICurrent.cpp: + + Implementation of the "PICurrent" object, i.e. the + PortableInterceptor::Current interface. + + * tao/PICurrent_ORBInitializer.h: + * tao/PICurrent_ORBInitializer.cpp: + + ORBInitializer that registers the PICurrent object with each + ORB. + + * tao/Makefile: + * tao/Makefile.bor: + * tao/TAO.dsp: + * tao/TAO_Static.dsp: + + Added new PICurrent source files to these Makefiles and project + files. + + * tao/ClientInterceptorAdapter.h: + * tao/PortableServer/ServerInterceptorAdapter.h: + + Updated list of authors. + + * tao/ClientRequestInfo.cpp (get_slot): + * tao/ORBInitInfo.cpp (allocated_slot_id): + + Implemented these methods. + + * tao/ORB.cpp (init_orb_globals): + + Register the PICurrent ORB initializer. + + * tao/ORB_Core.h: + + Added TSS portion of the PICurrent object to the ORB Core TSS + resources object. + + Cache the PICurrent object reference for speed/efficiency + reasons. + + * tao/ORB_Core.i (pi_current): + + New methods to set and get the cached thread-scope PICurrent + object reference. + + * tao/ORB_Core.cpp (TAO_ORB_Core): + + Initialize the pointer to the PICurrent object reference to + zero. + + * tao/PolicyFactory_Registry.cpp (~TAO_PolicyFactory_Registry): + + Close the factory map for the sake of completeness. + + * tao/TAO_Server_Request.h (TAO_ServerRequest): + + The "request scope" PICurrent object implementation for the + server side is now held in this class. + + * tao/TAO_Server_Request.i (rs_pi_current): + + Accessor for the request scope PICurrent object implementation. + + * tao/TAO_Server_Request.cpp (TAO_ServerRequest): + + Added request scope PICurrent attribute to the base member + initializer list. + + * tao/PortableServer/ServerInterceptorAdapter.cpp: + + Instantiate a "PICurrent" guard before invoking the + receive_request_service_contexts() interception point. Upon + leaving the scope, the request PICurrent will be logically + copied to the thread scope PICurrent. + + * tao/PortableServer/ServerRequestInfo.h: + * tao/PortableServer/ServerRequestInfo.inl (server_request): + + Added accessor to return a reference to the cached + TAO_ServerRequest object. + + * tao/PortableServer/ServerRequestInfo.cpp (get_server_policy): + + Implemented this method. However, see comments in the + implementation for important details. + + (get_slot, set_slot): + + Also implemented these methods. They are used to get and set + data in the "request scope" "PICurrent" object. + + * TAO_IDL/be/be_codegen.cpp (start_server_skeletons): + + Generate code to include the `tao/PICurrent.h' header. + + * TAO_IDL/be/be_visitor_operation/operation_ss.cpp + (visit_operation): + + Generate code that instantiates a "TAO_PICurrent_Guard" before + the code that invokes the receive_request() interception point + and the upcall. The thread scope PICurrent must be copied to + the request scope PICurrent object when the upcall is done. + + * tests/Portable_Interceptors/PICurrent/ServerORBInitializer.cpp: + * tests/Portable_Interceptors/PICurrent/ServerORBInitializer.h: + * tests/Portable_Interceptors/PICurrent/ServerRequestInterceptor.cpp: + * tests/Portable_Interceptors/PICurrent/ServerRequestInterceptor.h: + * tests/Portable_Interceptors/PICurrent/client.cpp: + * tests/Portable_Interceptors/PICurrent/server.cpp: + * tests/Portable_Interceptors/PICurrent/test.idl: + * tests/Portable_Interceptors/PICurrent/test_i.cpp: + * tests/Portable_Interceptors/PICurrent/test_i.h: + * tests/Portable_Interceptors/PICurrent/Makefile: + * tests/Portable_Interceptors/PICurrent/Makefile.bor: + * tests/Portable_Interceptors/PICurrent/client.bor: + * tests/Portable_Interceptors/PICurrent/server.bor: + * tests/Portable_Interceptors/PICurrent/PICurrent.dsw: + * tests/Portable_Interceptors/PICurrent/client.dsp: + * tests/Portable_Interceptors/PICurrent/server.dsp: + + Test that verifies PICurrent support is working properly. + + * tests/Portable_Interceptors/Makefile: + * tests/Portable_Interceptors/Makefile.bor: + + Added PICurrent test directory to the build list. + + * docs/interceptors.html: + + Updated PortableInterceptor release notes. + Sun Sep 23 20:34:23 2001 Ossama Othman <ossama@uci.edu> * tao/Typecode.cpp (BadKind, Bounds): diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp index 5d2607f8e0b..fd15982b62b 100644 --- a/TAO/TAO_IDL/be/be_codegen.cpp +++ b/TAO/TAO_IDL/be/be_codegen.cpp @@ -668,6 +668,8 @@ TAO_CodeGen::start_server_skeletons (const char *fname) this->gen_standard_include (this->server_skeletons_, "tao/RequestInfo_Util.h"); this->gen_standard_include (this->server_skeletons_, + "tao/PICurrent.h"); + this->gen_standard_include (this->server_skeletons_, "tao/PortableServer/ServerRequestInfo.h"); this->gen_standard_include (this->server_skeletons_, "tao/PortableServer/ServerInterceptorAdapter.h"); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp index 387ff91c5ee..ba43189ce15 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp @@ -272,7 +272,7 @@ be_visitor_operation_ss::visit_operation (be_operation *node) } } - *os << " ri (" << be_idt << be_idt_nl + *os << " _tao_ri (" << be_idt << be_idt_nl << "_tao_server_request," << be_nl << "_tao_upcall," << be_nl << "_tao_impl"; @@ -299,8 +299,21 @@ be_visitor_operation_ss::visit_operation (be_operation *node) *os << "ACE_TRY" << be_idt_nl << "{" << be_idt_nl; + // Create a new scope. The receive_request() interception point and + // the upcall will occur within this scope. + *os << "{" << be_idt_nl; + + // Copy the thread scope current (TSC) to the request scope current + // (RSC) upon leaving this scope, i.e. just after the upcall + // completes. A "guard" is used to make the copy also occur if an + // exception is thrown. + *os << "TAO_PICurrent_Guard _tao_pi_guard (_tao_ri.server_request ()," + << be_nl + << " 1 /* Copy TSC to RSC */);" + << be_nl << be_nl; + // Invoke the receive_request() interception point. - *os << "_tao_vfr.receive_request (&ri, ACE_TRY_ENV);" << be_nl + *os << "_tao_vfr.receive_request (&_tao_ri, ACE_TRY_ENV);" << be_nl << "ACE_TRY_CHECK;" << be_nl; *os << "\n#endif /* TAO_HAS_INTERCEPTORS */\n"; @@ -361,6 +374,9 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // check for exception. *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)" << be_nl; + *os << be_uidt + << "}" << be_nl << be_nl; + // Grab the right visitor to generate the return type accessor if // it's not void since we can't have a private member to be of void // type. @@ -397,27 +413,27 @@ be_visitor_operation_ss::visit_operation (be_operation *node) || bt->base_node_type () == AST_Decl::NT_array) { *os << " _tao_retval_info = _tao_retval._retn ();" << be_nl - << "ri.result (_tao_retval_info);" << be_nl + << "_tao_ri.result (_tao_retval_info);" << be_nl << "_tao_retval = _tao_retval_info;" << be_nl; } else { *os << " _tao_retval_info = _tao_retval;" << be_nl - << "ri.result (_tao_retval_info);" << be_nl; + << "_tao_ri.result (_tao_retval_info);" << be_nl; } } - *os << "ri.reply_status (PortableInterceptor::SUCCESSFUL);" << be_nl - << "_tao_vfr.send_reply (&ri, ACE_TRY_ENV);"<< be_nl + *os << "_tao_ri.reply_status (PortableInterceptor::SUCCESSFUL);" << be_nl + << "_tao_vfr.send_reply (&_tao_ri, ACE_TRY_ENV);"<< be_nl << "ACE_TRY_CHECK;" << be_uidt_nl; *os << "}" << be_uidt_nl << "ACE_CATCHANY" << be_idt_nl << "{" << be_idt_nl; // Update the ServerRequestInfo exception attribute. - *os << "ri.exception (&ACE_ANY_EXCEPTION);"<< be_nl + *os << "_tao_ri.exception (&ACE_ANY_EXCEPTION);"<< be_nl << "_tao_vfr.send_exception (" << be_idt << be_idt_nl - << "&ri," << be_nl + << "&_tao_ri," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl; @@ -427,7 +443,7 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // exception. *os << be_nl << "PortableInterceptor::ReplyStatus _tao_status =" << be_idt_nl - << "ri.reply_status (ACE_TRY_ENV);" << be_uidt_nl + << "_tao_ri.reply_status (ACE_TRY_ENV);" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl; *os << be_nl diff --git a/TAO/docs/interceptors.html b/TAO/docs/interceptors.html index 1012a6cdc01..a6d402fca85 100644 --- a/TAO/docs/interceptors.html +++ b/TAO/docs/interceptors.html @@ -388,6 +388,12 @@ module PortableInterceptor exception. Otherwise it will be propagated to the client. This change also has the added benefit of reducing the stub/skeleton footprint, particularly for IDL with many interfaces. + <li>Implemented <CODE>PortableInterceptor::Current</CODE> interface, + <CODE>ORBInitInfo::allocate_slot_id</CODE>, + <CODE>ClientRequestInfo::get_slot</CODE>, + <CODE>ServerRequestInfo::get_slot</CODE>, + <CODE>ServerRequestInfo::set_slot</CODE>, and + <CODE>ServerRequestInfo::get_server_policy</CODE> methods. </ul> <hr><P> @@ -397,8 +403,6 @@ module PortableInterceptor optimization to the interceptor chain; the <CODE>direct</CODE> collocation optimization will not go through the interceptor chain. - <li>Implement the <CODE>PortableInterceptor::Current</CODE> - interface. Useful for passing data between interceptors. <li>The <CODE>send_poll</CODE> request interception point implementation will most likely be deferred until TII is supported in TAO. diff --git a/TAO/tao/ClientInterceptorAdapter.h b/TAO/tao/ClientInterceptorAdapter.h index f0ab5039c6f..ae48fc9bb8e 100644 --- a/TAO/tao/ClientInterceptorAdapter.h +++ b/TAO/tao/ClientInterceptorAdapter.h @@ -10,8 +10,8 @@ * interceptors in tao_idl generated stubs. * * @author Nanbor Wang <nanbor@cs.wustl.edu> - * @author Kirthika Parameswaran <kirthika@cs.wustl.edu> * @author Ossama Othman <ossama@uci.edu> + * @author Kirthika Parameswaran <kirthika@cs.wustl.edu> */ //============================================================================= diff --git a/TAO/tao/ClientRequestInfo.cpp b/TAO/tao/ClientRequestInfo.cpp index 281ca1ed6a7..da2cbcd1412 100644 --- a/TAO/tao/ClientRequestInfo.cpp +++ b/TAO/tao/ClientRequestInfo.cpp @@ -470,17 +470,31 @@ TAO_ClientRequestInfo::forward_reference (CORBA::Environment &ACE_TRY_ENV) } CORBA::Any * -TAO_ClientRequestInfo::get_slot (PortableInterceptor::SlotId, +TAO_ClientRequestInfo::get_slot (PortableInterceptor::SlotId id, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, PortableInterceptor::InvalidSlot)) { - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT ( - CORBA::SystemException::_tao_minor_code ( - TAO_DEFAULT_MINOR_CODE, - ENOTSUP), - CORBA::COMPLETED_NO), - 0); + // @@ This implementation incurs a TSS access each time it is + // invoked. It need not do that. This method can be invoked by + // each client request interceptor multiple times. At some point + // we need to add the request scope current to the Invocation + // object or some other object that is tied to a given + // invocation. That way, only one TSS access would be + // introduced. + // -Ossama + + TAO_PICurrent *pi_current = + this->invocation_->orb_core ()->pi_current (); + + if (pi_current == 0) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + + // PICurrent is read-only during a request invocation on the client + // side. No copying is necessary. + return + pi_current->get_slot (id, + ACE_TRY_ENV); } IOP::ServiceContext * diff --git a/TAO/tao/Makefile b/TAO/tao/Makefile index 0937e07fc05..885fca8a9c6 100644 --- a/TAO/tao/Makefile +++ b/TAO/tao/Makefile @@ -190,6 +190,8 @@ ORB_CORE_FILES = \ RequestInfo_Util \ ClientInterceptorAdapter \ PortableInterceptorC \ + PICurrent \ + PICurrent_ORBInitializer \ DynamicC \ OctetSeqC \ StringSeqC \ diff --git a/TAO/tao/Makefile.bor b/TAO/tao/Makefile.bor index d88b8ceb1b1..b4c9b56fcb5 100644 --- a/TAO/tao/Makefile.bor +++ b/TAO/tao/Makefile.bor @@ -139,6 +139,8 @@ OBJFILES = \ $(OBJDIR)\Object_Ref_Table.obj \ $(OBJDIR)\OctetSeqC.obj \ $(OBJDIR)\Parser_Registry.obj \ + $(OBJDIR)\PICurrent.obj \ + $(OBJDIR)\PICurrent_ORBInitializer.obj \ $(OBJDIR)\Pluggable.obj \ $(OBJDIR)\Pluggable_Messaging.obj \ $(OBJDIR)\Pluggable_Messaging_Utils.obj \ diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp index 012e45ac584..5fe36455dbf 100644 --- a/TAO/tao/ORB.cpp +++ b/TAO/tao/ORB.cpp @@ -1,6 +1,11 @@ -// $Id$ +// -*- C++ -*- #include "ORB.h" + +ACE_RCSID (tao, + ORB, + "$Id$") + #include "ORB_Table.h" #include "Connector_Registry.h" #include "IOR_Parser.h" @@ -29,6 +34,10 @@ # include "Messaging_ORBInitializer.h" /* @@ This should go away! */ #endif /* TAO_HAS_CORBA_MESSAGING == 1 */ +#if TAO_HAS_INTERCEPTORS == 1 +# include "PICurrent_ORBInitializer.h" /* @@ This should go away! */ +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + #if defined (TAO_HAS_VALUETYPE) # include "ValueFactory_Map.h" #endif /* TAO_HAS_VALUETYPE */ @@ -65,8 +74,6 @@ using std::set_unexpected; # include "ORB.i" #endif /* ! __ACE_INLINE__ */ -ACE_RCSID(tao, ORB, "$Id$") - static const char ior_prefix [] = "IOR:"; // = Static initialization. @@ -1189,6 +1196,23 @@ CORBA_ORB::init_orb_globals (CORBA::Environment &ACE_TRY_ENV) ACE_CHECK; #endif /* TAO_HAS_CORBA_MESSAGING == 1 */ +#if TAO_HAS_INTERCEPTORS == 1 + + /// Register the PICurrent ORBInitializer. + ACE_NEW_THROW_EX (temp_orb_initializer, + TAO_PICurrent_ORBInitializer, + CORBA::NO_MEMORY ( + CORBA_SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + orb_initializer = temp_orb_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in (), + ACE_TRY_ENV); + ACE_CHECK; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ } void CORBA_ORB::_tao_unexpected_exception (void) diff --git a/TAO/tao/ORBInitInfo.cpp b/TAO/tao/ORBInitInfo.cpp index 71175728b8e..eed397c2587 100644 --- a/TAO/tao/ORBInitInfo.cpp +++ b/TAO/tao/ORBInitInfo.cpp @@ -7,6 +7,10 @@ #include "StringSeqC.h" #include "CodecFactory.h" +#if TAO_HAS_INTERCEPTORS == 1 +#include "PICurrent.h" +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + ACE_RCSID (TAO, ORBInitInfo, "$Id$") @@ -217,12 +221,16 @@ TAO_ORBInitInfo::allocate_slot_id (CORBA::Environment &ACE_TRY_ENV) this->check_validity (ACE_TRY_ENV); ACE_CHECK_RETURN (0); +#if TAO_HAS_INTERCEPTORS == 1 + return this->orb_core_->pi_current ()->allocate_slot_id (); +#else ACE_THROW_RETURN (CORBA::NO_IMPLEMENT ( CORBA_SystemException::_tao_minor_code ( TAO_DEFAULT_MINOR_CODE, ENOTSUP), CORBA::COMPLETED_NO), 0); +#endif /* TAO_HAS_INTERCEPTORS == 1 */ } void diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 27c233dfa41..7f71dcf3dd6 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -156,6 +156,7 @@ TAO_ORB_Core::TAO_ORB_Core (const char *orbid) refcount_ (1), policy_factory_registry_ (), #if (TAO_HAS_INTERCEPTORS == 1) + pi_current_ (0), client_request_interceptors_ (), server_request_interceptors_ (), #endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 5fafafb8263..47621ec8385 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -39,6 +39,7 @@ // Interceptor definitions. #include "PortableInterceptorC.h" #include "Interceptor_List.h" +#include "PICurrent.h" #include "Protocols_Hooks.h" @@ -157,6 +158,13 @@ public: /// cleanup functions for the TSS objects stored in the TSS object /// array in this class. TAO_ORB_Core *orb_core_; + +#if TAO_HAS_INTERCEPTORS == 1 + /// The thread-specific portion of the PICurrent object. + TAO_PICurrent_Impl pi_current_; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + + }; // **************************************************************** @@ -789,11 +797,18 @@ public: * @name Portable Interceptor Related Methods * * These are support methods for interceptor registration and - * interceptor set (an array) access. + * interceptor set (an array) access, in addition to PICurrent + * access. */ //@{ #if TAO_HAS_INTERCEPTORS == 1 + /// Return a pointer to the cached TAO_PICurrent object. + TAO_PICurrent *pi_current (void); + + /// Set the pointer to the cached TAO_PICurrent object. + void pi_current (TAO_PICurrent *current); + /// Register a client request interceptor. void add_interceptor ( PortableInterceptor::ClientRequestInterceptor_ptr interceptor, @@ -1179,8 +1194,19 @@ protected: TAO_PolicyFactory_Registry policy_factory_registry_; #if (TAO_HAS_INTERCEPTORS == 1) - /// Request interceptor registries. + /// Cached pointer/reference to the PICurrent object. + /** + * A pointer/reference to the PICurrent object is cached in the ORB + * Core since it is accessed in the critical path (i.e. the request + * invocation path). Caching it prevents additional overhead to due + * object resolution from occurring. + */ + TAO_PICurrent *pi_current_; + + /// Client request interceptor registry. TAO_ClientRequestInterceptor_List client_request_interceptors_; + + /// Server request interceptor registry. TAO_ServerRequestInterceptor_List server_request_interceptors_; #endif /* TAO_HAS_INTERCEPTORS */ @@ -1284,7 +1310,7 @@ public: void *poa_current_impl_; /// The default environment for the thread. - CORBA_Environment* default_environment_; + CORBA_Environment *default_environment_; /// If the user (or library) provides no environment the ORB_Core /// still holds one. diff --git a/TAO/tao/ORB_Core.i b/TAO/tao/ORB_Core.i index d78bfc23eb1..7b4e6ad56fe 100644 --- a/TAO/tao/ORB_Core.i +++ b/TAO/tao/ORB_Core.i @@ -566,6 +566,24 @@ TAO_ORB_Core::resolve_rt_current (CORBA::Environment &ACE_TRY_ENV) } #if (TAO_HAS_INTERCEPTORS == 1) +ACE_INLINE TAO_PICurrent * +TAO_ORB_Core::pi_current (void) +{ + // A pointer/reference to PICurrent is cached in the ORB Core since + // it is accessed in the critical path (i.e. the request invocation + // path). Caching it prevents additional overhead to due object + // resolution from occurring. + return this->pi_current_; +} + +ACE_INLINE void +TAO_ORB_Core::pi_current (TAO_PICurrent *current) +{ + // Not duplicated since the ORB Core's "object_ref_table" already + // contains a duplicate of the PICurrent object. + this->pi_current_ = current; +} + ACE_INLINE void TAO_ORB_Core::add_interceptor ( PortableInterceptor::ClientRequestInterceptor_ptr interceptor, diff --git a/TAO/tao/PICurrent.cpp b/TAO/tao/PICurrent.cpp new file mode 100644 index 00000000000..d41839d8f54 --- /dev/null +++ b/TAO/tao/PICurrent.cpp @@ -0,0 +1,348 @@ +// -*- C++ -*- + +#include "PICurrent.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +ACE_RCSID (tao, + PICurrent, + "$Id$") + + +#if !defined (__ACE_INLINE__) +# include "PICurrent.inl" +#endif /* __ACE_INLINE__ */ + + +#include "ORB_Core.h" +#include "Stub.h" +#include "TAO_Server_Request.h" + + +TAO_PICurrent::TAO_PICurrent (TAO_ORB_Core *orb_core) + : orb_core_ (orb_core), + slot_count_ (0) +{ +} + +TAO_PICurrent::~TAO_PICurrent (void) +{ +} + +CORBA::Any * +TAO_PICurrent::get_slot (PortableInterceptor::SlotId id, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::InvalidSlot)) +{ + this->check_validity (id, ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + TAO_PICurrent_Impl *impl = this->tsc (); + + if (impl == 0) + { + ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (TAO_OMG_VMCID | 14, + CORBA::COMPLETED_NO), + 0); + } + + return impl->get_slot (id, ACE_TRY_ENV); +} + +void +TAO_PICurrent::set_slot (PortableInterceptor::SlotId id, + const CORBA::Any & data, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::InvalidSlot)) +{ + this->check_validity (id, ACE_TRY_ENV); + ACE_CHECK; + + TAO_PICurrent_Impl *impl = this->tsc (); + + if (impl == 0) + { + ACE_THROW (CORBA::BAD_INV_ORDER (TAO_OMG_VMCID | 14, + CORBA::COMPLETED_NO)); + } + + impl->set_slot (id, data, ACE_TRY_ENV); + ACE_CHECK; +} + +PortableInterceptor::SlotId +TAO_PICurrent::allocate_slot_id (void) +{ + // No need to acquire a lock. This only gets called during ORB + // initialization. ORB initialization is already atomic. + return this->slot_count_++; +} + +TAO_PICurrent_Impl * +TAO_PICurrent::tsc (void) +{ + TAO_ORB_Core_TSS_Resources *tss = + this->orb_core_->get_tss_resources (); + + return &tss->pi_current_; +} + +// ------------------------------------------------------------------ + +TAO_PICurrent_Impl::TAO_PICurrent_Impl (void) + : pi_peer_ (0), + slot_table_ (), + lc_slot_table_ (0), + dirty_ (0) +{ +} + +TAO_PICurrent_Impl::~TAO_PICurrent_Impl (void) +{ + size_t len = this->slot_table_.size (); + for (size_t i = 0; i < len; ++i) + delete ACE_static_cast (CORBA::Any *, this->slot_table_[i]); +} + +CORBA::Any * +TAO_PICurrent_Impl::get_slot (PortableInterceptor::SlotId id, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::InvalidSlot)) +{ + // No need to check validity of SlotId. It is validated before this + // method is invoked. + + TAO_PICurrent_Impl::Table &table = + this->lc_slot_table_ == 0 ? this->slot_table_ : *this->lc_slot_table_; + + CORBA::Any * any = 0; + + if (id >= table.size () || table[id] == 0) + { + // In accordance with the Portable Interceptor specification, + // return an Any with a TCKind of tk_null. A default + // constructed Any has that TCKind. + ACE_NEW_THROW_EX (any, + CORBA::Any, + CORBA::NO_MEMORY ( + CORBA_SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (0); + + return any; + } + + const CORBA::Any *data = + ACE_static_cast (CORBA::Any *, table[id]); + + ACE_NEW_THROW_EX (any, + CORBA::Any (*data), // Make a copy. + CORBA::NO_MEMORY ( + CORBA_SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (0); + + return any; +} + +void +TAO_PICurrent_Impl::set_slot (PortableInterceptor::SlotId id, + const CORBA::Any & data, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::InvalidSlot)) +{ + // No need to check validity of SlotId. It is validated before this + // method is invoked. + + // Copy the contents of the logically copied slot table before + // modifying our own slot table. + if (this->lc_slot_table_ != 0) + { + // Deep copy + + Table &table = *this->lc_slot_table_; + + size_t new_size = table.size (); + this->slot_table_.size (new_size); + + for (size_t i = 0; i < new_size; ++i) + { + if (i == id) + continue; // Avoid copying data twice. + + const CORBA::Any *lc_data = + ACE_static_cast (CORBA::Any *, table[i]); + + CORBA::Any *any = 0; + ACE_NEW_THROW_EX (any, + CORBA::Any (*lc_data), // Make a copy. + CORBA::NO_MEMORY ( + CORBA_SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + this->slot_table_[i] = any; + } + + // Break all ties with the logically copied slot table. + this->lc_slot_table_ = 0; + } + + // If the slot table array isn't large enough, then increase its + // size. We're guaranteed not to exceed the number of allocated + // slots for the reason stated above. + size_t old_size = this->slot_table_.size (); + size_t new_size = id + 1; + if (id >= old_size && this->slot_table_.size (new_size) != 0) + ACE_THROW (CORBA::INTERNAL ()); + + // Initialize intermediate array elements to zero, since they + // haven't been initialized yet. This ensures that garbage is not + // returned when accessing any of those elements at a later point in + // time. + for (size_t i = old_size; i < id; ++i) + this->slot_table_[i] = 0; + + // Now copy the data into the slot table. + CORBA::Any * any = 0; + ACE_NEW_THROW_EX (any, + CORBA::Any (data), // Make a copy. + CORBA::NO_MEMORY ( + CORBA_SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + this->slot_table_[id] = any; + + // Mark the table as being modified. + this->dirty_ = 1; +} + +void +TAO_PICurrent_Impl::copy (TAO_PICurrent_Impl &rhs, CORBA::Boolean deep_copy) +{ + if (rhs.dirty () && deep_copy) + { + size_t new_size = rhs.slot_table ().size (); + + this->slot_table_.size (new_size); + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + for (size_t i = 0; i < new_size; ++i) + { + this->slot_table_[i] = + rhs.get_slot (i, ACE_TRY_ENV); // Deep copy + ACE_TRY_CHECK; + } + } + ACE_CATCHANY + { + if (TAO_debug_level > 0) + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "(%P|%t) Error during PICurrent " + "slot table copy."); + } + ACE_ENDTRY; + + rhs.dirty (0); + + rhs.pi_peer (0); // Break all ties with the PICurrent peer. + } + else + { + this->lc_slot_table_ = &rhs.slot_table (); // Shallow copy + + this->pi_peer_ = &rhs; + } +} + +// ------------------------------------------------------------------ + +TAO_PICurrent_Guard::TAO_PICurrent_Guard (TAO_Stub *stub, + TAO_PICurrent_Impl &rsc) + : src_ (0), + dest_ (0) +{ + // This constructor is used on the client side. + + // Retrieve the thread scope current (no TSS access incurred yet). + TAO_PICurrent *pi_current = stub->orb_core ()->pi_current (); + + // If the slot count is zero, then there is nothing to copy. + // Prevent any copying (and hence TSS accesses) from occurring. + if (pi_current->slot_count () != 0) + { + // Retrieve the thread scope current. + TAO_PICurrent_Impl *tsc = pi_current->tsc (); + + // Copy the TSC to the RSC. + rsc.copy (*tsc, 0); // Shallow copy + } + + // Notice that a TAO_PICurrent_Guard instantiated with this + // constructor will basically have a no-op destructor. +} + +TAO_PICurrent_Guard::TAO_PICurrent_Guard (TAO_ServerRequest &server_request, + CORBA::Boolean tsc_to_rsc) + : src_ (0), + dest_ (0) +{ + // This constructor is used on the server side. + + // Retrieve the thread scope current (no TSS access incurred yet). + TAO_PICurrent *pi_current = server_request.orb_core ()->pi_current (); + + // If the slot count is zero, then there is nothing to copy. + // Prevent any copying (and hence TSS accesses) from occurring. + if (pi_current->slot_count () != 0) + { + // Retrieve the request scope current. + TAO_PICurrent_Impl *rsc = &server_request.rs_pi_current (); + + // Retrieve the thread scope current. + TAO_PICurrent_Impl *tsc = pi_current->tsc (); + + if (tsc_to_rsc) + { + // TSC to RSC copy. + // Occurs after receive_request() interception point and + // upcall. + this->src_ = tsc; + this->dest_ = rsc; + } + else + { + // RSC to TSC copy. + // Occurs after receive_request_service_contexts() + // interception point. + this->src_ = rsc; + this->dest_ = tsc; + } + } +} + +TAO_PICurrent_Guard::~TAO_PICurrent_Guard (void) +{ + if (this->src_ != 0 && this->dest_ != 0) + { + // This copy better be exception-safe! + this->dest_->copy (*this->src_, 0); // Logical copy + } +} + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/TAO/tao/PICurrent.h b/TAO/tao/PICurrent.h new file mode 100644 index 00000000000..40cf7afab63 --- /dev/null +++ b/TAO/tao/PICurrent.h @@ -0,0 +1,311 @@ +// -*- C++ -*- + +// =================================================================== +/** + * @file PICurrent.h + * + * $Id$ + * + * @author Ossama Othman <ossama@uci.edu> + */ +// =================================================================== + +#ifndef TAO_PI_CURRENT_H +#define TAO_PI_CURRENT_H + +#include "ace/pre.h" + +#include "tao/corbafwd.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "ace/Array_Base.h" + +#include "PortableInterceptorC.h" +#include "LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/// Forward declarations. +class TAO_ORB_Core; +class TAO_PICurrent_Impl; + +/** + * @class TAO_PICurrent + * + * @brief Implementation of the PortableInterceptor::Current + * interface. + * + * PortableInterceptor::Current is useful for passing data between + * request interceptors, in addition to passing data from an + * interceptor to the calling thread. + */ +class TAO_Export TAO_PICurrent : + public virtual PortableInterceptor::Current, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /// Constructor. + TAO_PICurrent (TAO_ORB_Core *orb_core); + + /** + * @name PortableInterceptor::Current Methods + * + * These are methods exposed by the PortableInterceptor::Current + * interface. + */ + //@{ + /// Retrieve information stored in the slot table at the given + /// SlotId. + virtual CORBA::Any * get_slot (PortableInterceptor::SlotId id, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::InvalidSlot)); + + /// Set information in the slot table at the given SlotId. + virtual void set_slot (PortableInterceptor::SlotId id, + const CORBA::Any & data, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::InvalidSlot)); + //@} + + /// Allocate a new SlotId. + /* This reserves a slot in the data array. This method is only + * invoked by TAO_ORBInitInfo::allocate_slot_id(), which is why it + * is protected. + */ + PortableInterceptor::SlotId allocate_slot_id (void); + + /// Number of slots allocated in the slot table. + PortableInterceptor::SlotId slot_count (void) const; + + /// Retrieve the PICurrent implementation from TSS, i.e. the thread + /// scope current (TSC). + TAO_PICurrent_Impl * tsc (void); + + /// Verify the validity of the given SlotId. + void check_validity (const PortableInterceptor::SlotId &id, + CORBA::Environment &ACE_TRY_ENV); + +protected: + + /// Destructor + /** + * Protected destructor to enforce the fact this class is reference + * counted, and should not be destroyed using delete() by anything + * other than the reference counting mechanism. + */ + ~TAO_PICurrent (void); + +private: + + /// Prevent copying through the copy constructor and the assignment + /// operator. + //@{ + ACE_UNIMPLEMENTED_FUNC (TAO_PICurrent (const TAO_PICurrent &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_PICurrent &)) + //@} + +private: + + /// Pointer to the orb core. + TAO_ORB_Core *orb_core_; + + /// The number of allocated slots. + PortableInterceptor::SlotId slot_count_; + +}; + +// ------------------------------------------------------------------ + +/** + * @class TAO_PICurrent_Impl + * + * @brief Implementation of the PortableInterceptor::Current + * interface. + * + * This class implements both the "request scope current" and the + * "thread scope current" objects as required by Portable + * Interceptors. + */ +class TAO_Export TAO_PICurrent_Impl +{ +public: + + /// Typedef for the underyling "slot table." + /** + * @note The slot table is implemented as an array of pointers to + * void to simply avoid increasing the footprint of the ORB. + * A template instance of ACE_Array_Base<void*> is + * already used by TAO_ORB_Core_TSS_Resources. Thus, no + * increase in footprint will occur due to this template + * instance. + */ + typedef ACE_Array_Base<void *> Table; + + /// Constructor + TAO_PICurrent_Impl (void); + + /// Destructor + ~TAO_PICurrent_Impl (void); + + /// Retrieve information stored in the slot table at the given + /// SlotId. + CORBA::Any * get_slot (PortableInterceptor::SlotId id, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::InvalidSlot)); + + /// Set information in the slot table at the given SlotId. + void set_slot (PortableInterceptor::SlotId id, + const CORBA::Any & data, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::InvalidSlot)); + + + /// Get the PICurrent peer associated with this PICurrent + /// implementation. + TAO_PICurrent_Impl *pi_peer (void); + + /// Set the PICurrent peer associated with this PICurrent + /// implementation. + void pi_peer (TAO_PICurrent_Impl *peer); + + /// Return a reference to the underlying slot table. + Table &slot_table (void); + + /// Mark the slot table as being clean or dirty. The slot table is + /// dirty if it has been modified since the last time it was + /// copied. + void dirty (CORBA::Boolean dirty); + + /// Flag that specifies if the underlying slot table has been + /// modified since last copy. + CORBA::Boolean dirty (void) const; + + /// Copy the contents of the given PICurrent. + void copy (TAO_PICurrent_Impl &rhs, CORBA::Boolean deep_copy); + +private: + + /// Prevent copying through the copy constructor and the assignment + //operator. + //@{ + ACE_UNIMPLEMENTED_FUNC ( + TAO_PICurrent_Impl (const TAO_PICurrent_Impl &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_PICurrent_Impl &)) + //@} + +private: + + /// The PICurrent implementation with which this implementation's + /// slot table interacts. + TAO_PICurrent_Impl *pi_peer_; + + /// Array of CORBA::Anys that is the underlying "slot table." + Table slot_table_; + + /// Table that was logically copied from a PICurrent in another + /// scope, i.e. either the request scope or the thread scope. + Table *lc_slot_table_; + + /// Flag that specifies if the underlying slot table has been + /// modified since last copy. + /** + * @note This flag is only used when copying between a request scope + * current and a thread scope current. + */ + CORBA::Boolean dirty_; + +}; + +// ------------------------------------------------------------------ + +/** + * @class TAO_PICurrent_Guard + * + * @brief Class used to make copying between request scope current and + * thread scope current exception-safe. + * + * Since copies between the request scope current and thread scope + * current must also occur if an exception is thrown, e.g. made + * available to the receive_exception() and send_exception() + * interception points, the "guard" idiom is used to make this action + * exception-safe. + */ +class TAO_Export TAO_PICurrent_Guard +{ +public: + + /// Constructor + /** + * This constructor copies data held in a given PICurrent when + * transitioning from one PICurrent scope to another immediately + * before any starting interception points are invoked (e.g. on the + * client side just before send_request() is invoked). + */ + TAO_PICurrent_Guard (TAO_Stub *stub, TAO_PICurrent_Impl &rsc); + + /// Constructor + /** + * This constructor sets up this guard to copy the data held in a + * given PICurrent when transitioning from that PICurrent's scope to + * another scope (e.g. request scope to thread scope transition + * immediately following receive_request_service_contexts() on + * server side). + */ + TAO_PICurrent_Guard (TAO_ServerRequest &server_request, + CORBA::Boolean tsc_to_rsc); + + /// Destructor + /** + * The destructor copies (a logical copy whenever possible) data + * held in a given PICurrent when transitioning from one PICurrent + * scope to another immediately before any ending interception + * points are invoked, and after the sending and intermediate (if + * any) interception points are invoked. + */ + ~TAO_PICurrent_Guard (void); + +private: + + /// The PICurrent implementation whose slot table will copied. + TAO_PICurrent_Impl *src_; + + /// The PICurrent implementation whose slot table will filled with + /// the contents of another PICurrent's slot table. + TAO_PICurrent_Impl *dest_; + +}; + + +#if defined (__ACE_INLINE__) +# include "PICurrent.inl" +#endif /* __ACE_INLINE__ */ + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + +#include "ace/post.h" + +#endif /* TAO_PI_CURRENT_H */ + diff --git a/TAO/tao/PICurrent.inl b/TAO/tao/PICurrent.inl new file mode 100644 index 00000000000..a48e98038f8 --- /dev/null +++ b/TAO/tao/PICurrent.inl @@ -0,0 +1,51 @@ +// -*- C++ -*- +// +// $Id$ + +ACE_INLINE PortableInterceptor::SlotId +TAO_PICurrent::slot_count (void) const +{ + return this->slot_count_; +} + +ACE_INLINE void +TAO_PICurrent::check_validity (const PortableInterceptor::SlotId &id, + CORBA::Environment &ACE_TRY_ENV) +{ + // No need to acquire a lock for this check. At this point, these + // attributes are read only. + if (id >= this->slot_count_) + ACE_THROW (PortableInterceptor::InvalidSlot ()); +} + +// ------------------------------------------------------------------ + +ACE_INLINE TAO_PICurrent_Impl * +TAO_PICurrent_Impl::pi_peer (void) +{ + return this->pi_peer_; +} + +ACE_INLINE void +TAO_PICurrent_Impl::pi_peer (TAO_PICurrent_Impl *peer) +{ + this->pi_peer_ = peer; +} + +ACE_INLINE TAO_PICurrent_Impl::Table & +TAO_PICurrent_Impl::slot_table (void) +{ + return this->slot_table_; +} + +ACE_INLINE void +TAO_PICurrent_Impl::dirty (CORBA::Boolean d) +{ + this->dirty_ = d; +} + +ACE_INLINE CORBA::Boolean +TAO_PICurrent_Impl::dirty (void) const +{ + return this->dirty_; +} diff --git a/TAO/tao/PICurrent_ORBInitializer.cpp b/TAO/tao/PICurrent_ORBInitializer.cpp new file mode 100644 index 00000000000..8866bcdea77 --- /dev/null +++ b/TAO/tao/PICurrent_ORBInitializer.cpp @@ -0,0 +1,57 @@ +// -*- C++ -*- + +#include "PICurrent_ORBInitializer.h" + +#include "ORB_Core.h" + +#include "PICurrent.h" +#include "ORBInitInfo.h" + +ACE_RCSID (TAO, + PICurrent_ORBInitializer, + "$Id$") + +void +TAO_PICurrent_ORBInitializer::pre_init ( + PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_ENV_ARG_DEFN; + + TAO_ORBInitInfo_var tao_info = + TAO_ORBInitInfo::_narrow (info, ACE_TRY_ENV); + ACE_CHECK; + + TAO_ORB_Core *orb_core = tao_info->orb_core (); + + TAO_PICurrent *tao_pi_current = 0; + ACE_NEW_THROW_EX (tao_pi_current, + TAO_PICurrent (orb_core), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + PortableInterceptor::Current_var current = tao_pi_current; + + // The PICurrent is stateless and reentrant, so share a single + // instance between all ORBs. + info->register_initial_reference ("PICurrent", + current.in (), + ACE_TRY_ENV); + ACE_CHECK; + + // Cache the downcasted pointer in the ORB Core. + orb_core->pi_current (tao_pi_current); +} + +void +TAO_PICurrent_ORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} diff --git a/TAO/tao/PICurrent_ORBInitializer.h b/TAO/tao/PICurrent_ORBInitializer.h new file mode 100644 index 00000000000..7c6e7f58f17 --- /dev/null +++ b/TAO/tao/PICurrent_ORBInitializer.h @@ -0,0 +1,77 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file PICurrent_ORBInitializer.h + * + * $Id$ + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + + +#ifndef TAO_PI_CURRENT_ORB_INITIALIZER_H +#define TAO_PI_CURRENT_ORB_INITIALIZER_H + +#include "ace/pre.h" + +#include "TAO_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "PortableInterceptorC.h" +#include "LocalObject.h" +#include "PICurrent.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 */ + + +/** + * @class TAO_PICurrent_ORBInitializer + * + * @brief ORBInitializer for the PICurrent support. + * + * This class simply registers the PICurrent object with the ORB + * resolve_initial_references() mechanism. + */ +class TAO_Export TAO_PICurrent_ORBInitializer + : public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /** + * @name PortableInterceptor::ORBInitializer Methods + * + * Methods required by the PortableInterceptor::ORBInitializer + * interface. + */ + //@{ + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + //@} + +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include "ace/post.h" + +#endif /* TAO_PI_CURRENT_ORB_INITIALIZER_H */ diff --git a/TAO/tao/PolicyFactory_Registry.cpp b/TAO/tao/PolicyFactory_Registry.cpp index 814f6e0d1c4..22066d1bcd7 100644 --- a/TAO/tao/PolicyFactory_Registry.cpp +++ b/TAO/tao/PolicyFactory_Registry.cpp @@ -19,6 +19,8 @@ TAO_PolicyFactory_Registry::~TAO_PolicyFactory_Registry (void) for (TABLE::ITERATOR i = this->factories_.begin (); i != end; ++i) CORBA::release ((*i).int_id_); + + this->factories_.close (); } void diff --git a/TAO/tao/PortableServer/ServerInterceptorAdapter.cpp b/TAO/tao/PortableServer/ServerInterceptorAdapter.cpp index 160726d7c00..1a7509c7991 100644 --- a/TAO/tao/PortableServer/ServerInterceptorAdapter.cpp +++ b/TAO/tao/PortableServer/ServerInterceptorAdapter.cpp @@ -32,14 +32,12 @@ receive_request_service_contexts ( ACE_TRY { -#if 0 // Copy the request scope current (RSC) to the thread scope // current (TSC) upon leaving this scope, i.e. just after the // receive_request_service_contexts() completes. A "guard" is // used to make the copy also occur if an exception is thrown. TAO_PICurrent_Guard pi_guard (ri->server_request (), 0 /* Copy RSC to TSC */); -#endif /* 0 */ for (size_t i = 0 ; i < this->len_; ++i) { diff --git a/TAO/tao/PortableServer/ServerInterceptorAdapter.h b/TAO/tao/PortableServer/ServerInterceptorAdapter.h index 28f92f13b89..cb3ec64bfd5 100644 --- a/TAO/tao/PortableServer/ServerInterceptorAdapter.h +++ b/TAO/tao/PortableServer/ServerInterceptorAdapter.h @@ -10,8 +10,8 @@ * interceptors in tao_idl generated skeletons. * * @author Nanbor Wang <nanbor@cs.wustl.edu> - * @author Kirthika Parameswaran <kirthika@cs.wustl.edu> * @author Ossama Othman <ossama@uci.edu> + * @author Kirthika Parameswaran <kirthika@cs.wustl.edu> */ //============================================================================= diff --git a/TAO/tao/PortableServer/ServerRequestInfo.cpp b/TAO/tao/PortableServer/ServerRequestInfo.cpp index a9a17300ca2..80702882dd1 100644 --- a/TAO/tao/PortableServer/ServerRequestInfo.cpp +++ b/TAO/tao/PortableServer/ServerRequestInfo.cpp @@ -4,9 +4,12 @@ #include "ServerRequestInfo.h" #include "POA.h" +#include "POA_Policy_Set.h" #include "tao/TAO_Server_Request.h" #include "tao/PolicyC.h" +#include "tao/ORB_Core.h" + ACE_RCSID (TAO_PortableServer, ServerRequestInfo, @@ -172,17 +175,27 @@ TAO_ServerRequestInfo::forward_reference (CORBA::Environment &ACE_TRY_ENV) } CORBA::Any * -TAO_ServerRequestInfo::get_slot (PortableInterceptor::SlotId, +TAO_ServerRequestInfo::get_slot (PortableInterceptor::SlotId id, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, PortableInterceptor::InvalidSlot)) { - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT ( - CORBA::SystemException::_tao_minor_code ( - TAO_DEFAULT_MINOR_CODE, - ENOTSUP), - CORBA::COMPLETED_NO), - 0); + // Retrieve the total number of assigned slots from the PICurrent. + // No TSS access is incurred. + TAO_PICurrent *pi_current = + this->server_request_.orb_core ()->pi_current (); + + if (pi_current == 0) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + + pi_current->check_validity (id, ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + // Retrieve the request scope PICurrent object. + TAO_PICurrent_Impl &rsc = this->server_request_.rs_pi_current (); + + return rsc.get_slot (id, ACE_TRY_ENV); + } IOP::ServiceContext * @@ -305,9 +318,9 @@ TAO_ServerRequestInfo::object_id (CORBA::Environment &ACE_TRY_ENV) const PortableServer::ObjectId &id = this->servant_upcall_->user_id (); - CORBA::OctetSeq *obj_id = 0; + CORBA::OctetSeq *tmp = 0; - ACE_NEW_THROW_EX (obj_id, + ACE_NEW_THROW_EX (tmp, CORBA::OctetSeq, CORBA::NO_MEMORY ( CORBA::SystemException::_tao_minor_code ( @@ -316,6 +329,8 @@ TAO_ServerRequestInfo::object_id (CORBA::Environment &ACE_TRY_ENV) CORBA::COMPLETED_NO)); ACE_CHECK_RETURN (0); + CORBA::OctetSeq_var obj_id = tmp; + // @@ It would be nice to avoid this copy. However, we can't be // sure if the octet sequence will out live the POA from // which the object ID is ultimately obtained. In the event @@ -329,7 +344,7 @@ TAO_ServerRequestInfo::object_id (CORBA::Environment &ACE_TRY_ENV) CORBA::Octet *buffer = obj_id->get_buffer (); ACE_OS_String::memcpy (buffer, id.get_buffer (), len); - return obj_id; + return obj_id._retn (); } ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (TAO_OMG_VMCID | 14, @@ -354,34 +369,88 @@ TAO_ServerRequestInfo::target_most_derived_interface ( CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { + // Implemented in the generated skeleton. + ACE_THROW_RETURN (CORBA::NO_RESOURCES (1, CORBA::COMPLETED_NO), 0); } CORBA::Policy_ptr -TAO_ServerRequestInfo::get_server_policy (CORBA::PolicyType, +TAO_ServerRequestInfo::get_server_policy (CORBA::PolicyType type, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT ( - CORBA::SystemException::_tao_minor_code ( - TAO_DEFAULT_MINOR_CODE, - ENOTSUP), - CORBA::COMPLETED_NO), + // @@ Currently, it is only possible to retrieve the server policy + // only during and after the receive_request() interception + // point, i.e. within the skeleton. + if (this->servant_upcall_ != 0) + { + TAO_POA_Policy_Set &policies = + this->servant_upcall_->poa ().policies (); + + // @@ This brain damaged implementation exists due to the fact + // neither TAO_POA nor TAO_POA_Policy_Set exposes any methods + // useful for retrieving a given Policy in the POA's + // PolicyList. So, I use the lame interfaces for now. + // -Ossama + const CORBA::ULong num_policies = policies.num_policies (); + for (CORBA::ULong i = 0; i < num_policies; ++i) + { + // @@ This incurs at least two locks per loop iteration due + // to the reference counting found within the policy + // object reference!!! + CORBA::Policy_var policy = policies.get_policy_by_index (i); + + CORBA::PolicyType ptype = policy->policy_type (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + if (ptype == type) + return policy._retn (); + } + + // No policy matching the given PolicyType was found. + ACE_THROW_RETURN (CORBA::INV_POLICY (TAO_OMG_VMCID | 3, + CORBA::COMPLETED_NO), + CORBA::Policy::_nil ()); + } + + // @@ Technically, we shouldn't be throwing this exception since + // this method should be valid in all server side request + // interception points. + ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (TAO_OMG_VMCID | 14, + CORBA::COMPLETED_NO), CORBA::Policy::_nil ()); } void -TAO_ServerRequestInfo::set_slot (PortableInterceptor::SlotId, - const CORBA::Any &, +TAO_ServerRequestInfo::set_slot (PortableInterceptor::SlotId id, + const CORBA::Any &data, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, PortableInterceptor::InvalidSlot)) { - ACE_THROW (CORBA::NO_IMPLEMENT ( - CORBA::SystemException::_tao_minor_code ( - TAO_DEFAULT_MINOR_CODE, - ENOTSUP), - CORBA::COMPLETED_NO)); + // Retrieve the total number of assigned slots from the PICurrent + // object. No TSS access is incurred. + TAO_PICurrent *pi_current = + this->server_request_.orb_core ()->pi_current (); + + if (pi_current == 0) + ACE_THROW (CORBA::INTERNAL ()); + + pi_current->check_validity (id, ACE_TRY_ENV); + ACE_CHECK; + + // Retrieve the "request scope current" (RSC). + TAO_PICurrent_Impl &rsc = this->server_request_.rs_pi_current (); + + // If the RSC was logically copied to the TSC, then deep copy the + // contents of the RSC to the TSC before modifying the RSC. The TSC + // should not be altered by modifications to the RSC. + TAO_PICurrent_Impl *tsc = rsc.pi_peer (); + if (tsc != 0) + tsc->copy (rsc, 1); // Deep copy + + rsc.set_slot (id, data, ACE_TRY_ENV); + ACE_CHECK; } CORBA::Boolean @@ -389,6 +458,8 @@ TAO_ServerRequestInfo::target_is_a (const char * /* id */, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { + // Implemented in the generated skeleton. + ACE_THROW_RETURN (CORBA::NO_RESOURCES (TAO_OMG_VMCID | 1, CORBA::COMPLETED_NO), 0); } diff --git a/TAO/tao/PortableServer/ServerRequestInfo.h b/TAO/tao/PortableServer/ServerRequestInfo.h index 800fa901bf7..3d0c8a11266 100644 --- a/TAO/tao/PortableServer/ServerRequestInfo.h +++ b/TAO/tao/PortableServer/ServerRequestInfo.h @@ -128,6 +128,7 @@ public: CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException)) ; + /// Retrieve data from the "request scope" PICurrent object. virtual CORBA::Any * get_slot ( PortableInterceptor::SlotId id, CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) @@ -188,6 +189,7 @@ public: CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException)); + /// Insert data into the "request scope" PICurrent object. virtual void set_slot ( PortableInterceptor::SlotId id, const CORBA::Any & data, @@ -236,6 +238,9 @@ public: //@} + /// Return a reference to the underlying TAO_ServerRequest object. + TAO_ServerRequest &server_request (void); + protected: /// Helper method to get the request and response service contexts. diff --git a/TAO/tao/PortableServer/ServerRequestInfo.inl b/TAO/tao/PortableServer/ServerRequestInfo.inl index b0bc239247f..c3a98809fd1 100644 --- a/TAO/tao/PortableServer/ServerRequestInfo.inl +++ b/TAO/tao/PortableServer/ServerRequestInfo.inl @@ -45,3 +45,9 @@ TAO_ServerRequestInfo::forward_reference (CORBA::Object_ptr obj) // Store the forward reference in the TAO_ServerRequest object. this->server_request_.forward_location (obj); } + +ACE_INLINE TAO_ServerRequest & +TAO_ServerRequestInfo::server_request (void) +{ + return this->server_request_; +} diff --git a/TAO/tao/TAO.dsp b/TAO/tao/TAO.dsp index 936cfa71814..d2942ae74e6 100644 --- a/TAO/tao/TAO.dsp +++ b/TAO/tao/TAO.dsp @@ -667,6 +667,14 @@ SOURCE=.\Parser_Registry.cpp # End Source File
# Begin Source File
+SOURCE=.\PICurrent.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PICurrent_ORBInitializer.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\Pluggable.cpp
# End Source File
# Begin Source File
@@ -1443,6 +1451,14 @@ SOURCE=.\Parser_Registry.h # End Source File
# Begin Source File
+SOURCE=.\PICurrent.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\PICurrent_ORBInitializer.h
+# End Source File
+# Begin Source File
+
SOURCE=.\Pluggable.h
# End Source File
# Begin Source File
@@ -2079,6 +2095,10 @@ SOURCE=.\Parser_Registry.i # End Source File
# Begin Source File
+SOURCE=.\PICurrent.inl
+# End Source File
+# Begin Source File
+
SOURCE=.\Pluggable.i
# End Source File
# Begin Source File
diff --git a/TAO/tao/TAO_Server_Request.cpp b/TAO/tao/TAO_Server_Request.cpp index bf1b278f813..a5453a07401 100644 --- a/TAO/tao/TAO_Server_Request.cpp +++ b/TAO/tao/TAO_Server_Request.cpp @@ -71,7 +71,8 @@ TAO_ServerRequest::TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base, dsi_nvlist_align_ (0), argument_flag_ (1) #if TAO_HAS_INTERCEPTORS == 1 - , interceptor_count_ (0) + , interceptor_count_ (0) + , rs_pi_current_ () #endif /* TAO_HAS_INTERCEPTORS == 1 */ { ACE_FUNCTION_TIMEPROBE (TAO_SERVER_REQUEST_START); @@ -106,7 +107,8 @@ TAO_ServerRequest::TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base, dsi_nvlist_align_ (0), argument_flag_ (1) #if TAO_HAS_INTERCEPTORS == 1 - , interceptor_count_ (0) + , interceptor_count_ (0) + , rs_pi_current_ () #endif /* TAO_HAS_INTERCEPTORS == 1 */ { profile_.object_key (object_key); diff --git a/TAO/tao/TAO_Server_Request.h b/TAO/tao/TAO_Server_Request.h index 8d30ee17f2d..9fa314068e0 100644 --- a/TAO/tao/TAO_Server_Request.h +++ b/TAO/tao/TAO_Server_Request.h @@ -34,6 +34,10 @@ #include "Service_Context.h" #include "Object.h" +#if TAO_HAS_INTERCEPTORS == 1 +#include "PICurrent.h" +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + class TAO_Pluggable_Messaging; class TAO_Transport; @@ -189,11 +193,16 @@ public: #if TAO_HAS_INTERCEPTORS == 1 /// Return a reference to the number of interceptors pushed on to - /// the current interceptor flow stack. It is a reference since the - /// Portable Interceptor flow stack code must be able to modify this - /// value and use that value at a later time without being forced to - /// use TSS. + /// the current interceptor flow stack. + /** + * @note It is a reference since the Portable Interceptor flow stack + * code must be able to modify this value and use that value + * at a later time without being forced to use TSS. + */ size_t &interceptor_count (void); + + /// Return a reference to the "request scope" PICurrent object. + TAO_PICurrent_Impl &rs_pi_current (void); #endif /* TAO_HAS_INTERCEPTORS == 1 */ private: @@ -269,6 +278,10 @@ private: /// The number of interceptors pushed on to the current interceptor /// flow stack. size_t interceptor_count_; + + /// The "Request Scope Current" (RSC) object, as required by + /// Portable Interceptors. + TAO_PICurrent_Impl rs_pi_current_; #endif /* TAO_HAS_INTERCEPTORS == 1 */ }; diff --git a/TAO/tao/TAO_Server_Request.i b/TAO/tao/TAO_Server_Request.i index c79064a782c..91f6ba97433 100644 --- a/TAO/tao/TAO_Server_Request.i +++ b/TAO/tao/TAO_Server_Request.i @@ -194,4 +194,10 @@ TAO_ServerRequest::interceptor_count (void) { return this->interceptor_count_; } + +ACE_INLINE TAO_PICurrent_Impl & +TAO_ServerRequest::rs_pi_current (void) +{ + return this->rs_pi_current_; +} #endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/TAO/tao/TAO_Static.dsp b/TAO/tao/TAO_Static.dsp index 90b2cc33153..12d4dbae945 100644 --- a/TAO/tao/TAO_Static.dsp +++ b/TAO/tao/TAO_Static.dsp @@ -40,8 +40,8 @@ RSC=rc.exe # PROP Output_Dir ""
# PROP Intermediate_Dir "LIB\Release"
# PROP Target_Dir ""
-MTL=midl.exe
LINK32=link.exe -lib
+MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "../../" /I "../" /D "_WINDOWS" /D "_CONSOLE" /D "NDEBUG" /D "WIN32" /D "TAO_AS_STATIC_LIBS" /D "ACE_AS_STATIC_LIBS" /FD /c
# SUBTRACT CPP /YX
@@ -66,8 +66,8 @@ LIB32=link.exe -lib # PROP Output_Dir ""
# PROP Intermediate_Dir "LIB\Debug"
# PROP Target_Dir ""
-MTL=midl.exe
LINK32=link.exe -lib
+MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "../../" /I "../" /D "_WINDOWS" /D "_CONSOLE" /D "_DEBUG" /D "WIN32" /D "ACE_AS_STATIC_LIBS" /D "TAO_AS_STATIC_LIBS" /FD /c
# SUBTRACT CPP /YX
@@ -599,6 +599,14 @@ SOURCE=.\Parser_Registry.cpp # End Source File
# Begin Source File
+SOURCE=.\PICurrent.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PICurrent_ORBInitializer.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\Pluggable.cpp
# End Source File
# Begin Source File
@@ -840,7 +848,7 @@ SOURCE=.\WrongTransactionC.cpp # End Group
# Begin Group "Header Files"
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
+# PROP Default_Filter "h;hpp;hxx;hm;fi;fd"
# Begin Source File
SOURCE=.\Abstract_Servant_Base.h
@@ -1415,6 +1423,14 @@ SOURCE=.\Parser_Registry.h # End Source File
# Begin Source File
+SOURCE=.\PICurrent.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\PICurrent_ORBInitializer.h
+# End Source File
+# Begin Source File
+
SOURCE=.\Pluggable.h
# End Source File
# Begin Source File
@@ -1684,7 +1700,7 @@ SOURCE=.\WrongTransactionC.h # End Group
# Begin Group "Inline Files"
-# PROP Default_Filter "i"
+# PROP Default_Filter "i;inl"
# Begin Source File
SOURCE=.\Acceptor_Filter.i
@@ -2023,6 +2039,10 @@ SOURCE=.\Parser_Registry.i # End Source File
# Begin Source File
+SOURCE=.\PICurrent.inl
+# End Source File
+# Begin Source File
+
SOURCE=.\Pluggable.i
# End Source File
# Begin Source File
diff --git a/TAO/tests/Portable_Interceptors/Makefile b/TAO/tests/Portable_Interceptors/Makefile index a90e8b50afb..5491b3f9676 100644 --- a/TAO/tests/Portable_Interceptors/Makefile +++ b/TAO/tests/Portable_Interceptors/Makefile @@ -16,7 +16,8 @@ DIRS = \ Service_Context_Manipulation \ IORInterceptor \ ForwardRequest \ - Request_Interceptor_Flow + Request_Interceptor_Flow \ + PICurrent ifndef TAO_ROOT TAO_ROOT = $(ACE_ROOT)/TAO diff --git a/TAO/tests/Portable_Interceptors/Makefile.bor b/TAO/tests/Portable_Interceptors/Makefile.bor index af9961da3e9..8ff05d49ba3 100644 --- a/TAO/tests/Portable_Interceptors/Makefile.bor +++ b/TAO/tests/Portable_Interceptors/Makefile.bor @@ -8,6 +8,7 @@ DIRS = \ Service_Context_Manipulation \ IORInterceptor \ ForwardRequest \ - Request_Interceptor_Flow + Request_Interceptor_Flow \ + PICurrent !include <$(ACE_ROOT)\include\makeinclude\recurse.bor> diff --git a/TAO/tests/Portable_Interceptors/PICurrent/Makefile b/TAO/tests/Portable_Interceptors/PICurrent/Makefile new file mode 100644 index 00000000000..917365b9a00 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/Makefile @@ -0,0 +1,67 @@ +#---------------------------------------------------------------------------- +# +# $Id$ +# +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif # ! TAO_ROOT + +IDL_FILES = test +IDL_SRC = \ + testC.cpp \ + testS.cpp +BIN_UNCHECKED = client server + +SRC = $(addsuffix .cpp, $(BIN_UNCHECKED) test_i ServerORBInitializer ServerRequestInterceptor) $(IDL_SRC) + +CLIENT_OBJS = \ + client.o \ + testC.o + +SERVER_OBJS = \ + server.o \ + test_i.o \ + ServerORBInitializer.o \ + ServerRequestInterceptor.o \ + $(IDL_SRC:.cpp=.o) + +TAO_IDLFLAGS += -Ge 1 + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(TAO_ROOT)/rules.tao.GNU + +ifeq ($(interceptors), 1) +BIN = $(BIN_UNCHECKED) +endif # interceptors + +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +.PRECIOUS: $(foreach ext, $(IDL_EXT), test$(ext)) + +server: $(addprefix $(VDIR),$(SERVER_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(TAO_SRVR_LIBS) $(POSTLINK) + +client: $(addprefix $(VDIR),$(CLIENT_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(TAO_CLNT_LIBS) $(POSTLINK) + +realclean: clean + -$(RM) $(foreach ext, $(IDL_EXT), test$(ext)) + diff --git a/TAO/tests/Portable_Interceptors/PICurrent/Makefile.bor b/TAO/tests/Portable_Interceptors/PICurrent/Makefile.bor new file mode 100644 index 00000000000..f13abcc72c1 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/Makefile.bor @@ -0,0 +1,7 @@ +# +# Makefile for building the PICurrent test executables +# + +MAKEFILES = server.bor client.bor + +!include <$(ACE_ROOT)\include\makeinclude\recurse.bor> diff --git a/TAO/tests/Portable_Interceptors/PICurrent/PICurrent.dsw b/TAO/tests/Portable_Interceptors/PICurrent/PICurrent.dsw new file mode 100644 index 00000000000..56d0b7e7407 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/PICurrent.dsw @@ -0,0 +1,41 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "PICurrent Client"=.\client.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "PICurrent Server"=.\server.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/TAO/tests/Portable_Interceptors/PICurrent/ServerORBInitializer.cpp b/TAO/tests/Portable_Interceptors/PICurrent/ServerORBInitializer.cpp new file mode 100644 index 00000000000..7f747dc9947 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/ServerORBInitializer.cpp @@ -0,0 +1,46 @@ +// -*- C++ -*- + +#include "ServerORBInitializer.h" +#include "ServerRequestInterceptor.h" + +ACE_RCSID (PICurrent, + ServerORBInitializer, + "$Id$") + +PortableInterceptor::SlotId slot_id = 2093843221; + +void +ServerORBInitializer::pre_init ( + PortableInterceptor::ORBInitInfo_ptr /* info */ + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +ServerORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_ENV_ARG_DEFN; + + ::slot_id = info->allocate_slot_id (ACE_TRY_ENV); + ACE_CHECK; + + PortableInterceptor::ServerRequestInterceptor_ptr tmp; + ACE_NEW_THROW_EX (tmp, + ServerRequestInterceptor (slot_id), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + PortableInterceptor::ServerRequestInterceptor_var interceptor = tmp; + + info->add_server_request_interceptor (interceptor.in (), + ACE_TRY_ENV); + ACE_CHECK; +} diff --git a/TAO/tests/Portable_Interceptors/PICurrent/ServerORBInitializer.h b/TAO/tests/Portable_Interceptors/PICurrent/ServerORBInitializer.h new file mode 100644 index 00000000000..b8b1ed06ec4 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/ServerORBInitializer.h @@ -0,0 +1,84 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ServerORBInitializer.h + * + * $Id$ + * + * Implementation header for the PICurrentTest server-side ORB + * initializer. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +#ifndef SERVER_ORB_INITIALIZER_H +#define SERVER_ORB_INITIALIZER_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +// Test's SlotId made global for ease of implementation. +// It is initialized to a large number to make it obvious when the +// SlotId is invalid. +// +// Don't do this if you have more than one ORB in your application or +// if thread-safety is an issue!!! +extern PortableInterceptor::SlotId slot_id; + +/** + * @class ServerORBInitializer + * + * @brief Simple concrete ORB initializer. + * + * This is a test ORB initializer that registers an IORInterceptor for + * this test. + */ +class ServerORBInitializer : + public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /** + * @name Methods Required by the ORBInitializer Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all ORB initializers. + */ + //@{ + /// The pre-initialization hook. + virtual void pre_init ( + PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// The post-initialization hook. + virtual void post_init ( + PortableInterceptor::ORBInitInfo_ptr info + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + //@} + +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* SERVER_ORB_INITIALIZER_H */ diff --git a/TAO/tests/Portable_Interceptors/PICurrent/ServerRequestInterceptor.cpp b/TAO/tests/Portable_Interceptors/PICurrent/ServerRequestInterceptor.cpp new file mode 100644 index 00000000000..be970a885c6 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/ServerRequestInterceptor.cpp @@ -0,0 +1,162 @@ +// -*- C++ -*- + +#include "ServerRequestInterceptor.h" + +#include "tao/CORBA_String.h" + +ACE_RCSID (PICurrent, + ServerRequestInterceptor, + "$Id$") + +ServerRequestInterceptor::ServerRequestInterceptor ( + PortableInterceptor::SlotId id) + : slot_id_ (id) +{ +} + +char * +ServerRequestInterceptor::name (TAO_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup ("ServerRequestInterceptor"); +} + +void +ServerRequestInterceptor::destroy (TAO_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +ServerRequestInterceptor::receive_request_service_contexts ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + TAO_ENV_ARG_DEFN; + + CORBA::String_var op = ri->operation (ACE_TRY_ENV); + ACE_CHECK; + + if (ACE_OS::strcmp (op.in (), "invoke_me") != 0) + return; // Don't mess with PICurrent if not invoking test method. + + // Insert data into the RSC (request scope current). + + CORBA::Long number = 62; + + CORBA::Any data; + data <<= number; + + ACE_TRY + { + ri->set_slot (this->slot_id_, data, ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCH (PortableInterceptor::InvalidSlot, ex) + { + ACE_PRINT_EXCEPTION (ex, + "Exception thrown in " + "receive_request_service_contexts()\n"); + + ACE_DEBUG ((LM_DEBUG, + "Invalid slot: %u\n", + this->slot_id_)); + + ACE_TRY_THROW (CORBA::INTERNAL ()); + } + ACE_ENDTRY; + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Inserted number <%d> into RSC.\n", + number)); +} + +void +ServerRequestInterceptor::receive_request ( + PortableInterceptor::ServerRequestInfo_ptr + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ +} + +void +ServerRequestInterceptor::send_reply ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_ENV_ARG_DEFN; + + CORBA::String_var op = ri->operation (ACE_TRY_ENV); + ACE_CHECK; + + if (ACE_OS::strcmp (op.in (), "invoke_me") != 0) + return; // Don't mess with PICurrent if not invoking test method. + + CORBA::Any_var data; + + ACE_TRY + { + // Retrieve the data stored in the RSC. This data should be + // different from the original data stored into the RSC by the + // receive_request_service_contexts() interception point. + data = ri->get_slot (this->slot_id_, ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCH (PortableInterceptor::InvalidSlot, ex) + { + ACE_PRINT_EXCEPTION (ex, + "Exception thrown in " + "send_reply()\n"); + + ACE_DEBUG ((LM_DEBUG, + "Invalid slot: %u\n", + this->slot_id_)); + + ACE_TRY_THROW (CORBA::INTERNAL ()); + } + ACE_ENDTRY; + ACE_CHECK; + + // The original data in the RSC was of type CORBA::Long. If the + // following extraction from the CORBA::Any fails, then the original + // data in the RSC was not replaced with the data in the TSC after + // the test method completed. + const char *str = 0; + if (data.in () >>= str) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Retrieved \"%s\" from the RSC.\n", + str)); + } + else + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Unable to extract data (a string) " + "from the RSC.\n")); + + ACE_THROW ((CORBA::INTERNAL ())); + } +} + +void +ServerRequestInterceptor::send_exception ( + PortableInterceptor::ServerRequestInfo_ptr + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ +} + +void +ServerRequestInterceptor::send_other ( + PortableInterceptor::ServerRequestInfo_ptr + TAO_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ +} diff --git a/TAO/tests/Portable_Interceptors/PICurrent/ServerRequestInterceptor.h b/TAO/tests/Portable_Interceptors/PICurrent/ServerRequestInterceptor.h new file mode 100644 index 00000000000..d261109238e --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/ServerRequestInterceptor.h @@ -0,0 +1,109 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ServerRequestInterceptor.h + * + * $Id$ + * + * Implementation header for the server request interceptor for the + * PortableInterceptor::Current test. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +#ifndef SERVER_REQUEST_INTERCEPTOR_H +#define SERVER_REQUEST_INTERCEPTOR_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class ServerRequestInterceptor + * + * @brief Simple concrete server request interceptor. + * + * This server request interceptor + */ +class ServerRequestInterceptor + : public virtual PortableInterceptor::ServerRequestInterceptor, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /// Constructor. + ServerRequestInterceptor (PortableInterceptor::SlotId id); + + /** + * @name Methods Required by the Server Request Interceptor + * Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all server request interceptors. + */ + //@{ + /// Return the name of this ServerRequestinterceptor. + virtual char * name (TAO_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void destroy (TAO_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_request_service_contexts ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_request ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_reply ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_exception ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_other ( + PortableInterceptor::ServerRequestInfo_ptr ri + TAO_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + //@} + +private: + + // The PICurrent slot ID allocated to this application during ORB + // initialization. + PortableInterceptor::SlotId slot_id_; + +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* SERVER_REQUEST_INTERCEPTOR_H */ diff --git a/TAO/tests/Portable_Interceptors/PICurrent/client.bor b/TAO/tests/Portable_Interceptors/PICurrent/client.bor new file mode 100644 index 00000000000..b8b8d824c1d --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/client.bor @@ -0,0 +1,37 @@ +# +# $Id$ +# +# Makefile for building the PICurrent test client +# + +NAME = client + +TAO_IDL = $(CORE_BINDIR)\tao_idl -g $(CORE_BINDIR)\gperf.exe -Ge 1 + +OBJFILES = \ + $(OBJDIR)\testC.obj \ + $(OBJDIR)\client.obj + +CFLAGS = \ + $(ACE_CFLAGS) \ + $(TAO_CFLAGS) + +LIBFILES = \ + $(ACE_LIB) \ + $(TAO_LIB) + +IDLFILES = \ + $(IDLDIR)\test.idl + +CPPDIR = . + +IDLDIR = . + +!include <$(ACE_ROOT)\include\makeinclude\build_exe.bor> + +# +# IDL Build rules +# + +$(IDLDIR)\testS.cpp $(IDLDIR)\testC.cpp: $(IDLDIR)\test.idl + $(TAO_IDL) $** diff --git a/TAO/tests/Portable_Interceptors/PICurrent/client.cpp b/TAO/tests/Portable_Interceptors/PICurrent/client.cpp new file mode 100644 index 00000000000..e2638125471 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/client.cpp @@ -0,0 +1,96 @@ +// -*- C++ -*- + +#include "ace/Get_Opt.h" + +#include "testC.h" +//#include "ClientORBInitializer.h" + +ACE_RCSID (PICurrent, + client, + "$Id$") + +const char *ior = "file://test.ior"; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "k:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.optarg; + break; + default: + ACE_ERROR_RETURN ((LM_ERROR, + "Usage: %s " + "-k IOR " + "\n", + argv[0]), + -1); + } + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { +#if 0 + PortableInterceptor::ORBInitializer_ptr temp_initializer = + PortableInterceptor::ORBInitializer::_nil (); + + ACE_NEW_RETURN (temp_initializer, + ClientORBInitializer, + -1); // No exceptions yet! + PortableInterceptor::ORBInitializer_var orb_initializer = + temp_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; +#endif /* 0 */ + + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "client_orb", ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var obj = + orb->string_to_object (ior, ACE_TRY_ENV); + ACE_TRY_CHECK; + + PICurrentTest::test_var server = + PICurrentTest::test::_narrow (obj.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (CORBA::is_nil (server.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Object reference <%s> is nil.\n", + ior), + 1); + } + + server->invoke_me (ACE_TRY_ENV); + ACE_TRY_CHECK; + + server->shutdown (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "PICurrent test (client-side):"); + return -1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/tests/Portable_Interceptors/PICurrent/client.dsp b/TAO/tests/Portable_Interceptors/PICurrent/client.dsp new file mode 100644 index 00000000000..1049c673dcb --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/client.dsp @@ -0,0 +1,204 @@ +# Microsoft Developer Studio Project File - Name="PICurrent Client" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=PICurrent Client - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "client.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "client.mak" CFG="PICurrent Client - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "PICurrent Client - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "PICurrent Client - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "PICurrent Client - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../../.." /I "../../.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 tao.lib ace.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao"
+
+!ELSEIF "$(CFG)" == "PICurrent Client - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../../../.." /I "../../.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 taod.lib aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao"
+
+!ENDIF
+
+# Begin Target
+
+# Name "PICurrent Client - Win32 Release"
+# Name "PICurrent Client - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter ".cpp"
+# Begin Source File
+
+SOURCE=.\client.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\testC.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h"
+# Begin Source File
+
+SOURCE=.\testC.h
+# End Source File
+# End Group
+# Begin Group "IDL Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\test.idl
+
+!IF "$(CFG)" == "PICurrent Client - Win32 Release"
+
+# PROP Ignore_Default_Tool 1
+USERDEP__TEST_="..\..\..\..\bin\Release\tao_idl.exe"
+# Begin Custom Build - Invoking TAO_IDL Compiler
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\Release\tao_idl -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "PICurrent Client - Win32 Debug"
+
+USERDEP__TEST_="..\..\..\..\bin\tao_idl.exe"
+# Begin Custom Build - Invoking TAO_IDL Compiler
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\tao_idl -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Group "Inline Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\testC.i
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/TAO/tests/Portable_Interceptors/PICurrent/server.bor b/TAO/tests/Portable_Interceptors/PICurrent/server.bor new file mode 100644 index 00000000000..24a24f2513e --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/server.bor @@ -0,0 +1,44 @@ +# +# $Id$ +# +# Makefile for building the PICurrent test client +# + +NAME = server + +TAO_IDL = $(CORE_BINDIR)\tao_idl -g $(CORE_BINDIR)\gperf.exe -Ge 1 + +OBJFILES = \ + $(OBJDIR)\testC.obj \ + $(OBJDIR)\testS.obj \ + $(OBJDIR)\server.obj \ + $(OBJDIR)\test_i.obj \ + $(OBJDIR)\ServerRequestInterceptor.obj \ + $(OBJDIR)\ServerORBInitializer.obj + +CFLAGS = \ + $(ACE_CFLAGS) \ + $(TAO_CFLAGS) \ + $(TAO_PORTABLESERVER_CFLAGS) + +LIBFILES = \ + $(ACE_LIB) \ + $(TAO_LIB) \ + $(TAO_PORTABLESERVER_LIB) + +IDLFILES = \ + $(IDLDIR)\test.idl + +CPPDIR = . + +IDLDIR = . + +!include <$(ACE_ROOT)\include\makeinclude\build_exe.bor> + +# +# IDL Build rules +# + +$(IDLDIR)\testS.cpp $(IDLDIR)\testC.cpp: $(IDLDIR)\test.idl + $(TAO_IDL) $** + diff --git a/TAO/tests/Portable_Interceptors/PICurrent/server.cpp b/TAO/tests/Portable_Interceptors/PICurrent/server.cpp new file mode 100644 index 00000000000..32568337887 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/server.cpp @@ -0,0 +1,155 @@ +// -*- C++ -*- + +#include "ace/Get_Opt.h" + +#include "test_i.h" +#include "ServerORBInitializer.h" + +ACE_RCSID (PICurrent, + server, + "$Id$") + +const char *ior_output_file = 0; + +extern PortableInterceptor::SlotId slot_id; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "o:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + ior_output_file = get_opts.optarg; + break; + default: + ACE_ERROR_RETURN ((LM_ERROR, + "Usage: %s " + "-o <iorfile>" + "\n", + argv[0]), + -1); + } + + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + PortableInterceptor::ORBInitializer_ptr temp_initializer = + PortableInterceptor::ORBInitializer::_nil (); + + ACE_NEW_RETURN (temp_initializer, + ServerORBInitializer, + -1); // No CORBA exceptions yet! + PortableInterceptor::ORBInitializer_var orb_initializer = + temp_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::ORB_var orb = CORBA::ORB_init (argc, + argv, + "test_orb", + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::Object_var obj = + orb->resolve_initial_references ("RootPOA", + ACE_TRY_ENV); + ACE_TRY_CHECK; + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (obj.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (CORBA::is_nil (root_poa.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to obtain RootPOA reference.\n"), + -1); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_TRY_ENV); + ACE_TRY_CHECK; + + poa_manager->activate (ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return -1; + + obj = orb->resolve_initial_references ("PICurrent", ACE_TRY_ENV); + ACE_TRY_CHECK; + + PortableInterceptor::Current_var pi_current = + PortableInterceptor::Current::_narrow (obj.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (CORBA::is_nil (pi_current.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to obtain PICurrent reference.\n"), + -1); + + test_i server_impl (pi_current.in (), + ::slot_id, + orb.in ()); + + obj = server_impl._this (ACE_TRY_ENV); + ACE_TRY_CHECK; + + PICurrentTest::test_var server = + PICurrentTest::test::_narrow (obj.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (CORBA::is_nil (server.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to obtain reference to " + "PICurrentTest::test object.\n"), + -1); + + CORBA::String_var ior = + orb->object_to_string (server.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_INFO, "PICurrentTest::test: <%s>\n", ior.in ())); + + // If the ior_output_file exists, output the IOR to it. + if (ior_output_file != 0) + { + FILE *output_file = ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing " + "IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + } + + orb->run (ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_INFO, "Event loop finished.\n")); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "PICurrent test (server-side):"); + + return -1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/tests/Portable_Interceptors/PICurrent/server.dsp b/TAO/tests/Portable_Interceptors/PICurrent/server.dsp new file mode 100644 index 00000000000..d0ba46383d2 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/server.dsp @@ -0,0 +1,240 @@ +# Microsoft Developer Studio Project File - Name="PICurrent Server" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=PICurrent Server - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "server.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "server.mak" CFG="PICurrent Server - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "PICurrent Server - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "PICurrent Server - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "PICurrent Server - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../../.." /I "../../.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib TAO.lib TAO_PortableServer.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\tao\PortableServer"
+
+!ELSEIF "$(CFG)" == "PICurrent Server - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../../../.." /I "../../.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib TAOd.lib TAO_PortableServerd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\tao\PortableServer"
+
+!ENDIF
+
+# Begin Target
+
+# Name "PICurrent Server - Win32 Release"
+# Name "PICurrent Server - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter ".cpp"
+# Begin Source File
+
+SOURCE=.\server.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ServerORBInitializer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ServerRequestInterceptor.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_i.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\testC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\testS.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter ".h"
+# Begin Source File
+
+SOURCE=.\ServerORBInitializer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ServerRequestInterceptor.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_i.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\testC.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\testS.h
+# End Source File
+# End Group
+# Begin Group "IDL Files"
+
+# PROP Default_Filter ".idl"
+# Begin Source File
+
+SOURCE=.\test.idl
+
+!IF "$(CFG)" == "PICurrent Server - Win32 Release"
+
+# PROP Ignore_Default_Tool 1
+USERDEP__TEST_="..\..\..\..\bin\Release\tao_idl.exe"
+# Begin Custom Build - Invoking TAO_IDL Compiler
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\Release\tao_idl -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "PICurrent Server - Win32 Debug"
+
+USERDEP__TEST_="..\..\..\..\bin\tao_idl.exe"
+# Begin Custom Build - Invoking TAO_IDL Compiler
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\tao_idl -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Group "Inline Files"
+
+# PROP Default_Filter ".i"
+# Begin Source File
+
+SOURCE=.\testC.i
+# End Source File
+# Begin Source File
+
+SOURCE=.\testS.i
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/TAO/tests/Portable_Interceptors/PICurrent/test.idl b/TAO/tests/Portable_Interceptors/PICurrent/test.idl new file mode 100644 index 00000000000..95fbdb084ea --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/test.idl @@ -0,0 +1,26 @@ +// -*- IDL -*- + +//============================================================================= +/** + * @file test.idl + * + * $Id$ + * + * Simple IDL file to test PortableInterceptor::Current + * support. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +module PICurrentTest +{ + + interface test + { + void invoke_me (); + + oneway void shutdown (); + }; + +}; diff --git a/TAO/tests/Portable_Interceptors/PICurrent/test_i.cpp b/TAO/tests/Portable_Interceptors/PICurrent/test_i.cpp new file mode 100644 index 00000000000..2dab4c97561 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/test_i.cpp @@ -0,0 +1,122 @@ +// -*- C++ -*- + +#include "test_i.h" + +ACE_RCSID (PICurrent, + test_i, + "$Id$") + +test_i::test_i (PortableInterceptor::Current_ptr current, + PortableInterceptor::SlotId id, + CORBA::ORB_ptr orb) + : current_ (PortableInterceptor::Current::_duplicate (current)), + slot_id_ (id), + orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +test_i::~test_i (void) +{ +} + +void +test_i::invoke_me (CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, + "Test method invoked.\n")); + + // @note "TSC" is "thread scope current" + // "RSC" is "request scope current" + + // ---------------------------------------------------- + + CORBA::Any_var retrieved_any; + + ACE_TRY + { + // Retrieve data placed into RSC PICurrent by the + // receive_request_service_contexts() interception point, and + // then copied into the TSC current. + retrieved_any = + this->current_->get_slot (this->slot_id_, ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCH (PortableInterceptor::InvalidSlot, ex) + { + ACE_PRINT_EXCEPTION (ex, + "Exception thrown in " + "test_i::invoke_me() when calling " + "Current::get_slot\n"); + + ACE_DEBUG ((LM_DEBUG, + "Invalid slot: %u\n", + this->slot_id_)); + + ACE_TRY_THROW (CORBA::INTERNAL ()); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Unexpected exception\n"); + } + ACE_ENDTRY; + ACE_CHECK; + + CORBA::Long retrieved; + if (retrieved_any.in() >>= retrieved) + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Retrieved number <%d> from TSC.\n", + retrieved)); + else + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Problem extracting data from " + "CORBA::Any retrieved from TSC.\n")); + + ACE_THROW ((CORBA::INTERNAL ())); + } + // ---------------------------------------------------- + + // Insert some data into the TSC PICurrent object. + const char str[] = "Drink milk!"; + + CORBA::Any data; + + data <<= str; + + ACE_TRY + { + this->current_->set_slot (this->slot_id_, data, ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCH (PortableInterceptor::InvalidSlot, ex) + { + ACE_PRINT_EXCEPTION (ex, + "Exception thrown in " + "test_i::invoke_me() when calling " + "Current::set_slot\n"); + + ACE_DEBUG ((LM_DEBUG, + "Invalid slot: %u\n", + this->slot_id_)); + + ACE_TRY_THROW (CORBA::INTERNAL ()); + } + ACE_ENDTRY; + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) String \"%s\" inserted into TSC.\n", + str)); +} + +void +test_i::shutdown (CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Server is shutting down.\n")); + + this->orb_->shutdown (0, ACE_TRY_ENV); +} diff --git a/TAO/tests/Portable_Interceptors/PICurrent/test_i.h b/TAO/tests/Portable_Interceptors/PICurrent/test_i.h new file mode 100644 index 00000000000..598bdfba9a8 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/PICurrent/test_i.h @@ -0,0 +1,63 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file test_i.h + * + * $Id$ + * + * Implementation header for the "test" IDL interface for the + * PortableInterceptor::Current test. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +#ifndef TEST_I_H +#define TEST_I_H + +#include "testS.h" + +/** + * @class test_i + * + * @brief Simple test class. + * + * This class implements the "test" interface used in this test. + */ +class test_i : public virtual POA_PICurrentTest::test +{ +public: + + /// Constructor. + test_i (PortableInterceptor::Current_ptr current, + PortableInterceptor::SlotId id, + CORBA::ORB_ptr orb); + + /// Destructor. + ~test_i (void); + + /// Return the number assigned to this object. + virtual void invoke_me (CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Shutdown the ORB. + virtual void shutdown (CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + + /// Reference to the PICurrent object. + PortableInterceptor::Current_var current_; + + /// SlotId in the PICurrent object assigned to this test. + PortableInterceptor::SlotId slot_id_; + + /// Pseudo-reference to the ORB. + CORBA::ORB_var orb_; + +}; + +#endif /* TEST_I_H */ |