diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2008-07-22 11:34:18 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2008-07-22 11:34:18 +0000 |
commit | 402b3a1ec291d92dd436c0248c9bb0f3ce62c82b (patch) | |
tree | 3cacdd80884731dd236f6a4711f0337ea9b0d50e /TAO | |
parent | ac6c3a80af06ab93c8a20023a2543da0c71100d0 (diff) | |
download | ATCD-402b3a1ec291d92dd436c0248c9bb0f3ce62c82b.tar.gz |
Tue Jul 22 11:31:28 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'TAO')
80 files changed, 3122 insertions, 360 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 28ed016e83e..435e9f927e4 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,168 @@ +Tue Jul 22 11:31:28 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl> + + Major commit to add ZIOP to the core of TAO. This adds the capability + to compress the data on the wire. This is a proof of concept implementation + that we try to get standardized within the CORBA spec. Interoperability + with other ORBs and different TAO versions isn't guaranteed until ZIOP + has been formally adopted by the OMG. If you want to experiment with ZIOP + add TAO_HAS_ZIOP 1 as define to your config.h file. This prototype will need + some more work to support ZIOP for the full request/reply chain, in some + cases the reply isn't compressed at this moment. For this we need to rework + the full policy support in the ORB for which we search funding. + + * MPC/config/ziop.mpb: + New base project for anyone using ZIOP + + * tao/BiDir_GIOP/BiDir_Service_Context_Handler.cpp: + * tao/BiDir_GIOP/BiDir_Service_Context_Handler.h: + Updated this class to the new service context handler API which is more + generic + + * tao/CDR.cpp: + * tao/CDR.h: + * tao/CDR.inl: + Added a compressed flag to the input and output stream which indicated + whether this stream contains compressed data + + * tao/GIOP_Message_Base.cpp: + Decompress the data when it is compressed + + * tao/GIOP_Message_Generator_Parser_12.cpp: + Use new service context handler api + + * tao/GIOP_Message_State.{h,cpp,inl}: + Added compressed flag + + * tao/IIOP_Transport.cpp: + * tao/Strategies/DIOP_Transport.cpp: + * tao/Strategies/SCIOP_Transport.cpp: + * tao/Strategies/SHMIOP_Transport.cpp: + * tao/Strategies/UIOP_Transport.cpp: + + Made messaging_object_ private, derived classes should use + messaging_object() + + * tao/Invocation_Base.{h,cpp,inl}: + Removed cached orb_core, can easily get this from the stub when we need + it + + * tao/Messaging/Asynch_Invocation.cpp: + Set compressed to false again + + * tao/ORB_Core.{h,cpp,inl}: + Added ziop_adapter + + * tao/orbconf.h: + Disabled ZIOP by default, added cached values for ZIOP policies + + * tao/PI/ClientRequestInfo.cpp: + Get the core from the stub + + * tao/PolicyC.h: + Use false instead of 0 + + * tao/PortableServer/POA_Policy_Set.cpp: + Use prefix increment and use ! operator + + * tao/PortableServer/Upcall_Wrapper.{h,cpp}: + Use ZIOP + + * tao/Profile.cpp: + Client exposed policies are not really related to CORBA messaging anymore, do + handle them each time. Fixed a bug which could lead to a crash when a + not supported policy was found in the object reference + + * tao/Remote_Invocation.cpp: + Use ziop + + * tao/RTCORBA/RT_Endpoint_Utils.{h,cpp}: + Use Policy_ptr + + * tao/RTCORBA/RT_ORBInitializer.cpp: + Fixed some comments + + * tao/RTCORBA/RT_Policy_i.{h,cpp}: + Layout changes, const changes, use ! operator + + * tao/RTCORBA/RT_PolicyFactory.cpp: + * tao/RTCORBA/RT_PolicyFactory.h: + Layout changes and use switch instead of a lot of if checks + + * tao/RTCORBA/RT_Protocols_Hooks.cpp: + Use _nil() instead of 0 + + * tao/RTCORBA/RT_Stub.cpp: + * tao/RTCORBA/RT_Stub.h: + Use dynamic_cast, use switch, not dependent on messaging + + * tao/Service_Context_Handler.h: + Made the api more generic + + * tao/Service_Context_Handler_Registry.cpp: + * tao/Service_Context_Handler_Registry.h: + Updated the api and fixed a possible bug when a handler is + requested but which is not there. This fixes bugzilla 3354 + Thanks to Russ Noseworthy <j dot russell dot noseworthy at saic dot com> + for reporting this + + * tao/Stub.cpp: + * tao/Stub.h: + Make policies independent of messaging + + * tao/Synch_Invocation.cpp: + Use operator! + + * tao/Synch_Reply_Dispatcher.cpp: + Call service context handler registry + + * tao/Tagged_Components.cpp + * tao/Tagged_Components.h + * tao/Tagged_Components.inl + Use operator! and use bool + + * tao/TAO_Internal.cpp: + Use ZIOP + + * tao/TAO_Server_Request.cpp: + Set compressed to false + + * tao/Transport.cpp + * tao/Transport.h + * tao/Transport.inl + Use bool, layout changes, use ACE_ERROR for errors + + * tao/ZIOP.mpc: + New file + + * tao/ZIOP/TAO_ZIOP.pc.in + * tao/ZIOP/ZIOP.cpp + * tao/ZIOP/ZIOP.h + * tao/ZIOP/ZIOP.pidl + * tao/ZIOP/ziop_export.h + * tao/ZIOP/ZIOP_ORBInitializer.cpp + * tao/ZIOP/ZIOP_ORBInitializer.h + * tao/ZIOP/ZIOP_Policy_i.cpp + * tao/ZIOP/ZIOP_Policy_i.h + * tao/ZIOP/ZIOP_Policy_Validator.cpp + * tao/ZIOP/ZIOP_Policy_Validator.h + * tao/ZIOP/ZIOP_PolicyFactory.cpp + * tao/ZIOP/ZIOP_PolicyFactory.h + * tao/ZIOP/ZIOP_Stub.cpp + * tao/ZIOP/ZIOP_Stub.h + * tao/ZIOP/ZIOP_Stub_Factory.cpp + * tao/ZIOP/ZIOP_Stub_Factory.h + New ZIOP library implementation + + * tao/catior/catior.cpp: + Recognize TIDC++ orb, handle policy values correctly, added support + for ZIOP + + * tao/catior/catior.mpc: + Added ziop as base + + * tao/Unbounded_Octet_Sequence_T.h: + Documentation change + Tue Jul 22 10:02:28 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl> * tao/Bzip2Compressor.mpc: diff --git a/TAO/MPC/config/ziop.mpb b/TAO/MPC/config/ziop.mpb new file mode 100644 index 00000000000..0f7a5155a92 --- /dev/null +++ b/TAO/MPC/config/ziop.mpb @@ -0,0 +1,7 @@ +// -*- MPC -*- +// $Id$ + +project : taolib, compression { + after += ZIOP + libs += TAO_ZIOP +} diff --git a/TAO/tao/BiDir_GIOP/BiDir_Service_Context_Handler.cpp b/TAO/tao/BiDir_GIOP/BiDir_Service_Context_Handler.cpp index 7f78d6da748..e92ef8ee7e3 100644 --- a/TAO/tao/BiDir_GIOP/BiDir_Service_Context_Handler.cpp +++ b/TAO/tao/BiDir_GIOP/BiDir_Service_Context_Handler.cpp @@ -13,13 +13,13 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL int TAO_BiDIR_Service_Context_Handler::process_service_context ( - TAO_ServerRequest& server_request, + TAO_Transport& transport, const IOP::ServiceContext& context) { TAO_InputCDR cdr (reinterpret_cast<const char*> ( context.context_data.get_buffer ()), context.context_data.length ()); - return server_request.transport()->tear_listen_point_list (cdr); + return transport.tear_listen_point_list (cdr); } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/BiDir_GIOP/BiDir_Service_Context_Handler.h b/TAO/tao/BiDir_GIOP/BiDir_Service_Context_Handler.h index 04689ed4eb4..fe81d85889e 100644 --- a/TAO/tao/BiDir_GIOP/BiDir_Service_Context_Handler.h +++ b/TAO/tao/BiDir_GIOP/BiDir_Service_Context_Handler.h @@ -26,7 +26,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL class TAO_BiDIR_Service_Context_Handler : public TAO_Service_Context_Handler { - virtual int process_service_context (TAO_ServerRequest& server_request, + virtual int process_service_context (TAO_Transport& transport, const IOP::ServiceContext& context); }; diff --git a/TAO/tao/CDR.cpp b/TAO/tao/CDR.cpp index 60917fd0f99..afcefaae16e 100644 --- a/TAO/tao/CDR.cpp +++ b/TAO/tao/CDR.cpp @@ -76,6 +76,9 @@ TAO_OutputCDR::TAO_OutputCDR (size_t size, , stub_ (0) , message_semantics_ (TAO_Transport::TAO_TWOWAY_REQUEST) , timeout_ (0) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR1_ENTER); @@ -112,6 +115,9 @@ TAO_OutputCDR::TAO_OutputCDR (char *data, , stub_ (0) , message_semantics_ (TAO_Transport::TAO_TWOWAY_REQUEST) , timeout_ (0) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR2_ENTER); } @@ -141,6 +147,9 @@ TAO_OutputCDR::TAO_OutputCDR (char *data, , stub_ (0) , message_semantics_ (TAO_Transport::TAO_TWOWAY_REQUEST) , timeout_ (0) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR3_ENTER); } @@ -161,6 +170,9 @@ TAO_OutputCDR::TAO_OutputCDR (ACE_Message_Block *data, , stub_ (0) , message_semantics_ (TAO_Transport::TAO_TWOWAY_REQUEST) , timeout_ (0) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR4_ENTER); } @@ -184,6 +196,9 @@ TAO_OutputCDR::TAO_OutputCDR (ACE_Data_Block *data_block, , stub_ (0) , message_semantics_ (TAO_Transport::TAO_TWOWAY_REQUEST) , timeout_ (0) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR5_ENTER); } @@ -277,6 +292,9 @@ TAO_InputCDR::TAO_InputCDR (const TAO_OutputCDR& rhs, : (orb_core ? orb_core->output_cdr_msgblock_allocator () : 0)), orb_core_ (orb_core) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } diff --git a/TAO/tao/CDR.h b/TAO/tao/CDR.h index 1123d618b14..00b49e305f5 100644 --- a/TAO/tao/CDR.h +++ b/TAO/tao/CDR.h @@ -180,11 +180,20 @@ public: /// Specify whether there are more data fragments to come. void more_fragments (bool more); +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + /// Are we containing compressed data? + bool compressed (void) const; + + /// Specify whether we have compressed data. + void compressed (bool compressed); +#endif + /// Set fragmented message attributes. void message_attributes (CORBA::ULong request_id, TAO_Stub * stub, TAO_Transport::TAO_Message_Semantics message_semantics, - ACE_Time_Value * timeout); + ACE_Time_Value * timeout, + bool compressed); /// Fragmented message request ID. CORBA::ULong request_id (void) const; @@ -235,8 +244,12 @@ private: /// Request/reply send timeout. ACE_Time_Value * timeout_; - //@} +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + /// Do we contain compressed data + bool compressed_; +#endif + //@} }; /** @@ -367,9 +380,21 @@ public: static void throw_stub_exception (int error_num); static void throw_skel_exception (int error_num); +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + /// Are we containing compressed data? + bool compressed (void) const; + + /// Specify whether we have compressed data. + void compressed (bool compressed); +#endif + private: /// The ORB_Core, required to extract object references. TAO_ORB_Core* orb_core_; + +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + CORBA::Boolean compressed_; +#endif }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/CDR.inl b/TAO/tao/CDR.inl index 5f4f73bbd53..034797671e9 100644 --- a/TAO/tao/CDR.inl +++ b/TAO/tao/CDR.inl @@ -21,16 +21,36 @@ TAO_OutputCDR::more_fragments (bool more) this->more_fragments_ = more; } +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 +ACE_INLINE bool +TAO_OutputCDR::compressed (void) const +{ + return this->compressed_; +} + +ACE_INLINE void +TAO_OutputCDR::compressed (bool compressed) +{ + this->compressed_ = compressed; +} +#endif + ACE_INLINE void TAO_OutputCDR::message_attributes (CORBA::ULong request_id, TAO_Stub * stub, TAO_Transport::TAO_Message_Semantics message_semantics, - ACE_Time_Value * timeout) + ACE_Time_Value * timeout, + bool compressed) { this->request_id_ = request_id; this->stub_ = stub; this->message_semantics_ = message_semantics; this->timeout_ = timeout; +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + this->compressed_ = compressed; +#else + ACE_UNUSED_ARG (compressed); +#endif } ACE_INLINE CORBA::ULong @@ -78,6 +98,9 @@ TAO_InputCDR::TAO_InputCDR (const char *buf, major_version, minor_version), orb_core_ (orb_core) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } @@ -92,6 +115,9 @@ TAO_InputCDR::TAO_InputCDR (size_t bufsiz, major_version, minor_version), orb_core_ (orb_core) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } @@ -106,6 +132,9 @@ TAO_InputCDR::TAO_InputCDR (const ACE_Message_Block *data, major_version, minor_version), orb_core_ (orb_core) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } @@ -122,6 +151,9 @@ TAO_InputCDR::TAO_InputCDR (const ACE_Message_Block *data, minor_version, lock), orb_core_ (orb_core) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } @@ -138,6 +170,9 @@ TAO_InputCDR::TAO_InputCDR (ACE_Data_Block *data, major_version, minor_version), orb_core_ (orb_core) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } @@ -159,6 +194,9 @@ TAO_InputCDR::TAO_InputCDR (ACE_Data_Block *data, major_version, minor_version), orb_core_ (orb_core) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } @@ -171,6 +209,9 @@ TAO_InputCDR::TAO_InputCDR (const TAO_InputCDR& rhs, size, offset), orb_core_ (rhs.orb_core_) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } @@ -180,6 +221,9 @@ TAO_InputCDR::TAO_InputCDR (const TAO_InputCDR& rhs, : ACE_InputCDR (rhs, size), orb_core_ (rhs.orb_core_) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } @@ -187,6 +231,9 @@ ACE_INLINE TAO_InputCDR::TAO_InputCDR (const TAO_InputCDR& rhs) : ACE_InputCDR (rhs), orb_core_ (rhs.orb_core_) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } @@ -195,6 +242,9 @@ TAO_InputCDR::TAO_InputCDR (ACE_InputCDR::Transfer_Contents rhs, TAO_ORB_Core* orb_core) : ACE_InputCDR (rhs), orb_core_ (orb_core) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } @@ -209,6 +259,20 @@ TAO_InputCDR::orb_core (void) const return this->orb_core_; } +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 +ACE_INLINE bool +TAO_InputCDR::compressed (void) const +{ + return this->compressed_; +} + +ACE_INLINE void +TAO_InputCDR::compressed (bool compressed) +{ + this->compressed_ = compressed; +} +#endif + // **************************************************************** ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os, diff --git a/TAO/tao/GIOP_Message_Base.cpp b/TAO/tao/GIOP_Message_Base.cpp index 1b718f10441..a002f9a9591 100644 --- a/TAO/tao/GIOP_Message_Base.cpp +++ b/TAO/tao/GIOP_Message_Base.cpp @@ -12,6 +12,7 @@ #include "tao/Request_Dispatcher.h" #include "tao/Codeset_Manager.h" #include "tao/SystemException.h" +#include "tao/ZIOP_Adapter.h" #include "ace/Min_Max.h" /* @@ -648,6 +649,10 @@ TAO_GIOP_Message_Base::process_request_message (TAO_Transport *transport, qd->giop_version ().minor_version (), this->orb_core_); +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + input_cdr.compressed_ = qd->state().compressed (); +#endif + transport->assign_translators(&input_cdr,&output); // We know we have some request message. Check whether it is a @@ -864,6 +869,26 @@ TAO_GIOP_Message_Base::process_request ( CORBA::Object_var forward_to; +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + if (cdr.compressed_) + { + TAO_ZIOP_Adapter* adapter = this->orb_core_->ziop_adapter (); + if (adapter) + { + adapter->decompress (request); + } + else + { + if (TAO_debug_level > 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) ERROR: Unable to decompress ") + ACE_TEXT ("data.\n"))); + + return -1; + } + } +#endif + /* * Hook to specialize request processing within TAO * This hook will be replaced by specialized request @@ -902,7 +927,8 @@ TAO_GIOP_Message_Base::process_request ( output.message_attributes (request_id, 0, TAO_Transport::TAO_REPLY, - 0); + 0, + false); // Make the GIOP header and Reply header this->generate_reply_header (output, reply_params); @@ -919,9 +945,9 @@ TAO_GIOP_Message_Base::process_request ( output.more_fragments (false); - int result = transport->send_message (output, - 0, - TAO_Transport::TAO_REPLY); + int const result = transport->send_message (output, + 0, + TAO_Transport::TAO_REPLY); if (result == -1) { if (TAO_debug_level > 0) @@ -1439,6 +1465,7 @@ TAO_GIOP_Message_Base::dump_msg (const char *label, // Byte order. int byte_order = ptr[TAO_GIOP_MESSAGE_FLAGS_OFFSET] & 0x01; + int compressed = ptr[TAO_GIOP_MESSAGE_FLAGS_OFFSET] & 0x04; // Get the version info CORBA::Octet major = ptr[TAO_GIOP_VERSION_MAJOR_OFFSET]; @@ -1480,14 +1507,15 @@ TAO_GIOP_Message_Base::dump_msg (const char *label, // Print. ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - GIOP_Message_Base::dump_msg, " - "%s GIOP v%c.%c msg, %d data bytes, %s endian, " - "Type %s[%u]\n", - ACE_TEXT_CHAR_TO_TCHAR (label), + "%C GIOP v%c.%c msg, %d data bytes, %s endian, " + "%s compressed, Type %C[%u]\n", + label, digits[ptr[TAO_GIOP_VERSION_MAJOR_OFFSET]], digits[ptr[TAO_GIOP_VERSION_MINOR_OFFSET]], len - TAO_GIOP_MESSAGE_HEADER_LEN , (byte_order == TAO_ENCAP_BYTE_ORDER) ? ACE_TEXT("my") : ACE_TEXT("other"), - ACE_TEXT_CHAR_TO_TCHAR(message_name), + (compressed == 0) ? ACE_TEXT("not") : ACE_TEXT("is"), + message_name, *id)); if (TAO_debug_level >= 10) @@ -1920,6 +1948,11 @@ TAO_GIOP_Message_Base::set_giop_flags (TAO_OutputCDR & msg) const // Only supported in GIOP 1.1 or better. if (!(major <= 1 && minor == 0)) ACE_SET_BITS (flags, msg.more_fragments () << 1); + +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + if (!(major <= 1 && minor < 2)) + ACE_SET_BITS (flags, msg.compressed () << 2); +#endif } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/GIOP_Message_Generator_Parser_12.cpp b/TAO/tao/GIOP_Message_Generator_Parser_12.cpp index 1448ff7b111..6c7fc8e9285 100644 --- a/TAO/tao/GIOP_Message_Generator_Parser_12.cpp +++ b/TAO/tao/GIOP_Message_Generator_Parser_12.cpp @@ -288,7 +288,7 @@ TAO_GIOP_Message_Generator_Parser_12::parse_request_header ( if (req_service_info.length() > 0) { request.orb_core ()->service_context_registry (). - process_service_contexts (request); + process_service_contexts (req_service_info, *(request.transport ())); } if (input.length () > 0) diff --git a/TAO/tao/GIOP_Message_State.cpp b/TAO/tao/GIOP_Message_State.cpp index 8a843895ace..74eedd39cf7 100644 --- a/TAO/tao/GIOP_Message_State.cpp +++ b/TAO/tao/GIOP_Message_State.cpp @@ -154,14 +154,12 @@ TAO_GIOP_Message_State::get_byte_order_info (char *buf) } // Let us be specific that this is for 1.0 - if (this->giop_version_.minor == 0 && - this->giop_version_.major == 1) + if (this->giop_version_.minor == 0 && this->giop_version_.major == 1) { this->byte_order_ = buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]; - if (this->byte_order_ != 0 && - this->byte_order_ != 1) + if (this->byte_order_ != 0 && this->byte_order_ != 1) { if (TAO_debug_level > 2) { @@ -181,21 +179,13 @@ TAO_GIOP_Message_State::get_byte_order_info (char *buf) // Read the fragment bit this->more_fragments_ = - (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x02); + ((buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x02) == 2); - if ((buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET] & ~0x3) != 0) - { - if (TAO_debug_level > 2) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) - invalid flags for <%d> ") - ACE_TEXT ("for version <%d %d> \n"), - buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET], - this->giop_version_.major, - this->giop_version_.minor)); - } - return -1; - } +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + // Read the compressed flag + this->compressed_ = + ((buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x04) == 4); +#endif } return 0; diff --git a/TAO/tao/GIOP_Message_State.h b/TAO/tao/GIOP_Message_State.h index 208b7f7b2b1..5815b1b0afe 100644 --- a/TAO/tao/GIOP_Message_State.h +++ b/TAO/tao/GIOP_Message_State.h @@ -72,6 +72,11 @@ public: /// Get the GIOP version TAO_GIOP_Message_Version const &giop_version (void) const; +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + /// Return the compressed information + CORBA::Boolean compressed (void) const; +#endif + private: /// Parse the message header. int parse_message_header_i (ACE_Message_Block &incoming); @@ -115,6 +120,11 @@ private: /// fragments. A value of non-zero indicates that it does have /// fragments. CORBA::Boolean more_fragments_; + +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + /// Compressed + CORBA::Boolean compressed_; +#endif }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/GIOP_Message_State.inl b/TAO/tao/GIOP_Message_State.inl index 49bcc0e5083..bec93790aad 100644 --- a/TAO/tao/GIOP_Message_State.inl +++ b/TAO/tao/GIOP_Message_State.inl @@ -12,6 +12,9 @@ TAO_GIOP_Message_State::TAO_GIOP_Message_State (void) message_type_ (GIOP::Request), payload_size_ (0), more_fragments_ (false) +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + , compressed_ (false) +#endif { } @@ -57,4 +60,12 @@ TAO_GIOP_Message_State::giop_version (void) const return this->giop_version_; } +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 +ACE_INLINE CORBA::Boolean +TAO_GIOP_Message_State::compressed (void) const +{ + return this->compressed_; +} +#endif + TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/IIOP_Transport.cpp b/TAO/tao/IIOP_Transport.cpp index 063cb391369..b39a4960c51 100644 --- a/TAO/tao/IIOP_Transport.cpp +++ b/TAO/tao/IIOP_Transport.cpp @@ -231,7 +231,7 @@ TAO_IIOP_Transport::send_message (TAO_OutputCDR &stream, ACE_Time_Value *max_wait_time) { // Format the message in the stream first - if (this->messaging_object_->format_message (stream) != 0) + if (this->messaging_object ()->format_message (stream) != 0) return -1; // This guarantees to send all data (bytes) or return an error. @@ -267,7 +267,7 @@ TAO_IIOP_Transport::generate_request_header (TAO_Operation_Details &opdetails, // and also make sure that we have not recd. or sent any information // regarding this before... if (this->orb_core ()->bidir_giop_policy () && - this->messaging_object_->is_ready_for_bidirectional (msg) && + this->messaging_object ()->is_ready_for_bidirectional (msg) && this->bidirectional_flag () < 0) { this->set_bidir_context_info (opdetails); @@ -315,7 +315,7 @@ TAO_IIOP_Transport::set_bidir_context_info (TAO_Operation_Details &opdetails) IIOP::ListenPointList listen_point_list; - const TAO_AcceptorSetIterator end = ar.end (); + TAO_AcceptorSetIterator const end = ar.end (); for (TAO_AcceptorSetIterator acceptor = ar.begin (); acceptor != end; diff --git a/TAO/tao/Invocation_Base.cpp b/TAO/tao/Invocation_Base.cpp index d8127890713..916a1247e79 100644 --- a/TAO/tao/Invocation_Base.cpp +++ b/TAO/tao/Invocation_Base.cpp @@ -45,10 +45,9 @@ namespace TAO , reply_status_ (GIOP::NO_EXCEPTION) , otarget_ (ot) , target_ (t) - , orb_core_ (stub->orb_core ()) , stub_ (stub) #if TAO_HAS_INTERCEPTORS == 1 - , adapter_ (orb_core_->clientrequestinterceptor_adapter ()) + , adapter_ (stub->orb_core ()->clientrequestinterceptor_adapter ()) , stack_size_ (0) , invoke_status_ (TAO_INVOKE_START) , caught_exception_ (0) diff --git a/TAO/tao/Invocation_Base.h b/TAO/tao/Invocation_Base.h index 115a3fac224..6b6fc935b80 100644 --- a/TAO/tao/Invocation_Base.h +++ b/TAO/tao/Invocation_Base.h @@ -63,8 +63,6 @@ namespace TAO /// Accessor and mutator methods //@{ - TAO_ORB_Core *orb_core (void) const; - TAO_Stub *stub (void) const; /// Accessor and mutator methods for forwarded object @@ -101,8 +99,10 @@ namespace TAO /// Does this invocation return a response? CORBA::Boolean response_expected (void) const; - /// Accessor and mutator of reply_status of the invocation. + /// Accessor of reply_status of the invocation. GIOP::ReplyStatusType reply_status (void) const; + + /// Mutator of reply_status of the invocation. void reply_status (GIOP::ReplyStatusType s); /// The operaton details of the invocation @@ -160,12 +160,9 @@ namespace TAO /// The effective target on which the invocation is on. CORBA::Object_ptr target_; - - /// Cache the ORB_Core - TAO_ORB_Core *orb_core_; + //@} TAO_Stub *stub_; - //@} /// Operations invoked by the /// PortableInterceptor::ClientRequestInfo object to get details diff --git a/TAO/tao/Invocation_Base.inl b/TAO/tao/Invocation_Base.inl index 621a6748bf1..6a7e65ae3f7 100644 --- a/TAO/tao/Invocation_Base.inl +++ b/TAO/tao/Invocation_Base.inl @@ -6,12 +6,6 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { - ACE_INLINE TAO_ORB_Core * - Invocation_Base::orb_core (void) const - { - return this->orb_core_; - } - ACE_INLINE TAO_Stub * Invocation_Base::stub (void) const { diff --git a/TAO/tao/Messaging/Asynch_Invocation.cpp b/TAO/tao/Messaging/Asynch_Invocation.cpp index 43f8e3fdee1..cc9df631e1c 100644 --- a/TAO/tao/Messaging/Asynch_Invocation.cpp +++ b/TAO/tao/Messaging/Asynch_Invocation.cpp @@ -73,7 +73,8 @@ namespace TAO cdr.message_attributes (this->details_.request_id (), this->resolver_.stub (), TAO_Transport::TAO_ONEWAY_REQUEST, - max_wait_time); + max_wait_time, + false); this->write_header (cdr); diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 863e4ba9dfd..941c9c2e2e3 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -15,6 +15,7 @@ #include "tao/Object_Loader.h" #include "tao/ObjectIdListC.h" #include "tao/BiDir_Adapter.h" +#include "tao/ZIOP_Adapter.h" #include "tao/Collocation_Resolver.h" #include "tao/Flushing_Strategy.h" #include "tao/Request_Dispatcher.h" @@ -259,6 +260,8 @@ TAO_ORB_Core::TAO_ORB_Core (const char *orbid, parser_registry_ (), bidir_adapter_ (0), bidir_giop_policy_ (0), + ziop_adapter_ (0), + ziop_enabled_ (false), flushing_strategy_ (0), codeset_manager_ (0), config_ (gestalt), @@ -1583,6 +1586,21 @@ TAO_ORB_Core::policy_factory_registry_i (void) return this->policy_factory_registry_; } +TAO_ZIOP_Adapter * +TAO_ORB_Core::ziop_adapter_i (void) +{ + // Check if there is a cached reference. + if (this->ziop_adapter_ != 0) + return this->ziop_adapter_; + + this->ziop_adapter_ = + ACE_Dynamic_Service<TAO_ZIOP_Adapter>::instance + (this->configuration (), + ACE_TEXT ("ZIOP_Loader")); + + return this->ziop_adapter_; +} + TAO::ORBInitializer_Registry_Adapter * TAO_ORB_Core::orbinitializer_registry_i (void) { @@ -1714,7 +1732,6 @@ TAO_ORB_Core::service_context_list ( TAO_Service_Context &service_context, CORBA::Boolean restart) { - // @NOTE: Can use Interceptors instead.. if (this->protocols_hooks_ != 0) { this->protocols_hooks_->rt_service_context (stub, service_context, restart); @@ -1893,7 +1910,15 @@ TAO_ORB_Core::load_policy_validators (TAO_Policy_Validator &validator) // Call the BiDir library if it has been loaded if (this->bidir_adapter_) - this->bidir_adapter_->load_policy_validators (validator); + { + this->bidir_adapter_->load_policy_validators (validator); + } + + // Call the ZIOP library if it has been loaded + if (this->ziop_adapter_) + { + this->ziop_adapter_->load_policy_validators (validator); + } } CORBA::Object_ptr @@ -3429,15 +3454,11 @@ TAO_ORB_Core::collocation_strategy (CORBA::Object_ptr object) if (!CORBA::is_nil (stub->servant_orb_var ().in ()) && stub->servant_orb_var ()->orb_core () != 0) { - TAO_ORB_Core *orb_core = - stub->servant_orb_var ()->orb_core (); - - const int collocated = - orb_core->collocation_resolver ().is_collocated (object); + TAO_ORB_Core *orb_core = stub->servant_orb_var ()->orb_core (); - if (collocated) + if (orb_core->collocation_resolver ().is_collocated (object)) { - switch (stub->servant_orb_var ()->orb_core ()->get_collocation_strategy ()) + switch (orb_core->get_collocation_strategy ()) { case THRU_POA: return TAO::TAO_CS_THRU_POA_STRATEGY; diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 1c3ea97a6f1..7378b8d4aa6 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -82,6 +82,7 @@ class TAO_Message_State_Factory; class TAO_Protocols_Hooks; class TAO_Network_Priority_Protocols_Hooks; class TAO_BiDir_Adapter; +class TAO_ZIOP_Adapter; class TAO_Flushing_Strategy; @@ -201,6 +202,12 @@ public: /// yet TAO::ORBInitializer_Registry_Adapter *orbinitializer_registry (void); + TAO_ZIOP_Adapter *ziop_adapter () const; + void ziop_adapter (TAO_ZIOP_Adapter *adapter); + + CORBA::Boolean ziop_enabled () const; + void ziop_enabled (CORBA::Boolean value); + TAO_Service_Context_Registry &service_context_registry (void); /// Get the protocol factories @@ -581,7 +588,7 @@ public: /// Check if ORB has shutdown. If it has, throw an exception. void check_shutdown (void); - /// Returns the <timeout> value used by the server threads to poll + /// Returns the @a timeout value used by the server threads to poll /// the shutdown flag. If the return value is zero then the server /// threads block forever. int thread_per_connection_timeout (ACE_Time_Value &timeout) const; @@ -656,6 +663,8 @@ public: /// Resolve the IOR Manipulation reference for this ORB. CORBA::Object_ptr resolve_ior_manipulation (void); + TAO_ZIOP_Adapter* ziop_adapter_i (void); + /// Resolve the IOR Table reference for this ORB. CORBA::Object_ptr resolve_ior_table (void); @@ -1232,6 +1241,12 @@ protected: /// Bir Dir GIOP policy value CORBA::Boolean bidir_giop_policy_; + /// ZIOP Adapter + TAO_ZIOP_Adapter *ziop_adapter_; + + /// ZIOP enabled or not + CORBA::Boolean ziop_enabled_; + /// Hold the flushing strategy TAO_Flushing_Strategy *flushing_strategy_; diff --git a/TAO/tao/ORB_Core.inl b/TAO/tao/ORB_Core.inl index 82d1dc15173..7c44fee7c25 100644 --- a/TAO/tao/ORB_Core.inl +++ b/TAO/tao/ORB_Core.inl @@ -436,6 +436,30 @@ TAO_ORB_Core::codeset_manager() return this->codeset_manager_; } +ACE_INLINE TAO_ZIOP_Adapter * +TAO_ORB_Core::ziop_adapter () const +{ + return this->ziop_adapter_; +} + +ACE_INLINE void +TAO_ORB_Core::ziop_adapter (TAO_ZIOP_Adapter *adapter) +{ + this->ziop_adapter_ = adapter; +} + +ACE_INLINE CORBA::Boolean +TAO_ORB_Core::ziop_enabled () const +{ + return this->ziop_enabled_; +} + +ACE_INLINE void +TAO_ORB_Core::ziop_enabled (CORBA::Boolean value) +{ + this->ziop_enabled_ = value; +} + ACE_INLINE TAO::ORBInitializer_Registry_Adapter * TAO_ORB_Core::orbinitializer_registry () { diff --git a/TAO/tao/PI/ClientRequestInfo.cpp b/TAO/tao/PI/ClientRequestInfo.cpp index fce3aa2aae2..ed51f4b2d34 100644 --- a/TAO/tao/PI/ClientRequestInfo.cpp +++ b/TAO/tao/PI/ClientRequestInfo.cpp @@ -41,7 +41,7 @@ TAO_ClientRequestInfo::setup_picurrent (void) { // Retrieve the thread scope current (no TSS access incurred yet). CORBA::Object_ptr pi_current_obj = - this->invocation_->orb_core ()->pi_current (); + this->invocation_->stub ()->orb_core ()->pi_current (); TAO::PICurrent *pi_current = dynamic_cast <TAO::PICurrent*> (pi_current_obj); diff --git a/TAO/tao/PolicyC.h b/TAO/tao/PolicyC.h index 66bdbd06022..51c89308b35 100644 --- a/TAO/tao/PolicyC.h +++ b/TAO/tao/PolicyC.h @@ -338,7 +338,7 @@ namespace CORBA // Non-local interface only. Policy ( TAO_Stub *objref, - CORBA::Boolean _tao_collocated = 0, + CORBA::Boolean _tao_collocated = false, TAO_Abstract_ServantBase *servant = 0, TAO_ORB_Core *orb_core = 0 ); diff --git a/TAO/tao/PortableServer/POA_Policy_Set.cpp b/TAO/tao/PortableServer/POA_Policy_Set.cpp index 084ce2cb75f..d4bc8d261bd 100644 --- a/TAO/tao/PortableServer/POA_Policy_Set.cpp +++ b/TAO/tao/PortableServer/POA_Policy_Set.cpp @@ -49,7 +49,7 @@ TAO_POA_Policy_Set::add_client_exposed_fixed_policies ( { client_exposed_policies->length (cep_index + 1); (*client_exposed_policies)[cep_index] = policy->copy (); - cep_index++; + ++cep_index; } } } @@ -75,7 +75,7 @@ TAO_POA_Policy_Set::validate_policies (TAO_Policy_Validator &validator, CORBA::PolicyType type = policy->policy_type (); - if (validator.legal_policy (type) == 0) + if (!(validator.legal_policy (type))) { #if !defined (CORBA_E_MICRO) // An invalid policy was specified. Let the user know about diff --git a/TAO/tao/PortableServer/Upcall_Wrapper.cpp b/TAO/tao/PortableServer/Upcall_Wrapper.cpp index fe00d465c16..9e7ce66d489 100644 --- a/TAO/tao/PortableServer/Upcall_Wrapper.cpp +++ b/TAO/tao/PortableServer/Upcall_Wrapper.cpp @@ -4,6 +4,7 @@ #include "tao/PortableServer/Upcall_Command.h" #include "tao/PortableServer/Collocated_Arguments_Converter.h" #include "tao/SystemException.h" +#include "tao/ZIOP_Adapter.h" #if TAO_HAS_INTERCEPTORS == 1 # include "tao/ServerRequestInterceptor_Adapter.h" @@ -205,7 +206,7 @@ TAO::Upcall_Wrapper::upcall (TAO_ServerRequest & server_request, { if (server_request.outgoing ()) { - this->post_upcall (*server_request.outgoing (), args, nargs); + this->post_upcall (server_request, args, nargs); } } @@ -241,26 +242,37 @@ TAO::Upcall_Wrapper::pre_upcall (TAO_InputCDR & cdr, } void -TAO::Upcall_Wrapper::post_upcall (TAO_OutputCDR & cdr, +TAO::Upcall_Wrapper::post_upcall (TAO_ServerRequest& server_request, TAO::Argument * const * args, size_t nargs) { +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 // Marshal the operation "inout" and "out" arguments and return // value, if any. + TAO_ZIOP_Adapter* ziop_adapter = server_request.orb_core ()->ziop_adapter (); - TAO::Argument * const * const begin = args; - TAO::Argument * const * const end = args + nargs; - - for (TAO::Argument * const * i = begin; i != end; ++i) + if (ziop_adapter) + { + ziop_adapter->marshal_reply_data (server_request, args, nargs); + } + else +#endif { - if (!(*i)->marshal (cdr)) + TAO_OutputCDR & cdr = (*server_request.outgoing ()); + TAO::Argument * const * const begin = args; + TAO::Argument * const * const end = args + nargs; + + for (TAO::Argument * const * i = begin; i != end; ++i) { - TAO_OutputCDR::throw_skel_exception (errno); + if (!(*i)->marshal (cdr)) + { + TAO_OutputCDR::throw_skel_exception (errno); + } } - } - // Reply body marshaling completed. No other fragments to send. - cdr.more_fragments (false); + // Reply body marshaling completed. No other fragments to send. + cdr.more_fragments (false); + } } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/PortableServer/Upcall_Wrapper.h b/TAO/tao/PortableServer/Upcall_Wrapper.h index 5040cbee594..13bcadd1970 100644 --- a/TAO/tao/PortableServer/Upcall_Wrapper.h +++ b/TAO/tao/PortableServer/Upcall_Wrapper.h @@ -104,10 +104,9 @@ namespace TAO * Perform post-upcall operations, including operation @c INOUT * and @c OUT argument marshaling. */ - void post_upcall (TAO_OutputCDR & cdr, + void post_upcall (TAO_ServerRequest& server_request, TAO::Argument * const * args, size_t nargs); - }; } // End namespace TAO diff --git a/TAO/tao/Profile.cpp b/TAO/tao/Profile.cpp index fa3cbbc1c30..1a116fb1c4e 100644 --- a/TAO/tao/Profile.cpp +++ b/TAO/tao/Profile.cpp @@ -202,8 +202,7 @@ TAO_Profile::decode (TAO_InputCDR& cdr) TAO::ObjectKey ok; // ... and object key. - if (TAO::ObjectKey::demarshal_key (ok, - cdr) == 0) + if (TAO::ObjectKey::demarshal_key (ok, cdr) == 0) { return -1; } @@ -217,8 +216,7 @@ TAO_Profile::decode (TAO_InputCDR& cdr) // Tagged Components *only* exist after version 1.0! // For GIOP 1.2, IIOP and GIOP have same version numbers! - if (this->version_.major > 1 - || this->version_.minor > 0) + if (this->version_.major > 1 || this->version_.minor > 0) { if (this->tagged_components_.decode (cdr) == 0) { @@ -337,8 +335,6 @@ TAO_Profile::set_tagged_components (TAO_OutputCDR &out_cdr) void TAO_Profile::policies (CORBA::PolicyList *policy_list) { -#if (TAO_HAS_CORBA_MESSAGING == 1) - if (policy_list == 0) { if (TAO_debug_level) @@ -354,20 +350,19 @@ TAO_Profile::policies (CORBA::PolicyList *policy_list) Messaging::PolicyValue pv; Messaging::PolicyValueSeq policy_value_seq; - size_t length; + size_t length = 0; CORBA::Octet *buf = 0; - policy_value_seq.length (policy_list->length ()); - // This loop iterates through CORBA::PolicyList to convert // each CORBA::Policy into a CORBA::PolicyValue - const size_t plen = policy_list->length (); + size_t const plen = policy_list->length (); + + policy_value_seq.length (plen); for (CORBA::ULong i = 0; i < plen; ++i) { TAO_OutputCDR out_CDR; - policy_value_seq[i].ptype = - (*policy_list)[i]->policy_type (); + policy_value_seq[i].ptype = (*policy_list)[i]->policy_type (); out_CDR << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER); (*policy_list)[i]->_tao_encode (out_CDR); @@ -417,12 +412,6 @@ TAO_Profile::policies (CORBA::PolicyList *policy_list) // member variable. tagged_components_.set_component (tagged_component); this->are_policies_parsed_ = true; - -#else /* TAO_HAS_CORBA_MESSAGING == 1 */ - - ACE_UNUSED_ARG (policy_list); - -#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ } @@ -430,8 +419,6 @@ TAO_Profile::policies (CORBA::PolicyList *policy_list) void TAO_Profile::get_policies (CORBA::PolicyList& pl) { -#if (TAO_HAS_CORBA_MESSAGING == 1) && !defined (CORBA_E_MICRO) - if (!this->are_policies_parsed_) // None has already parsed the policies. { @@ -451,7 +438,7 @@ TAO_Profile::get_policies (CORBA::PolicyList& pl) // Extract the Byte Order CORBA::Boolean byte_order; - if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) + if (!(in_cdr >> ACE_InputCDR::to_boolean (byte_order))) { return ; } @@ -469,18 +456,13 @@ TAO_Profile::get_policies (CORBA::PolicyList& pl) // Here we extract the Messaging::PolicyValue out of the sequence // and we convert those into the proper CORBA::Policy - - CORBA::Policy_var policy; CORBA::ULong const length = policy_value_seq.length (); - // Set the policy list length. - pl.length (length); - for (CORBA::ULong i = 0; i < length; ++i) { try { - policy = + CORBA::Policy_var policy = this->orb_core_->orb ()->_create_policy ( policy_value_seq[i].ptype); @@ -497,7 +479,13 @@ TAO_Profile::get_policies (CORBA::PolicyList& pl) in_cdr.reset_byte_order (static_cast <int> (byte_order)); - policy->_tao_decode (in_cdr); + if (!policy->_tao_decode (in_cdr)) + throw ::CORBA::INV_OBJREF (); + + // Increase the policy length with 1 when we know we support + // this policy, this way we don't get nil values in the list + pl.length (pl.length () + 1); + pl[i] = policy._retn (); } else @@ -507,7 +495,6 @@ TAO_Profile::get_policies (CORBA::PolicyList& pl) // so as specified by the RT-CORBA // spec. ptc/99-05-03 we just ignore these // un-understood policies. - if (TAO_debug_level >= 5) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("The IOR contains unsupported ") @@ -529,14 +516,8 @@ TAO_Profile::get_policies (CORBA::PolicyList& pl) } } } - -#else - ACE_UNUSED_ARG (pl); -#endif /* (TAO_HAS_CORBA_MESSAGING == 1) */ - } - void TAO_Profile::verify_orb_configuration (void) { @@ -832,7 +813,7 @@ TAO_Unknown_Profile::to_string (void) int TAO_Unknown_Profile::decode (TAO_InputCDR& cdr) { - if ((cdr >> this->body_) == 0) + if (!(cdr >> this->body_)) { return -1; } @@ -890,8 +871,7 @@ TAO_Unknown_Profile::is_equivalent_hook (const TAO_Profile * /* other */) } CORBA::ULong -TAO_Unknown_Profile::hash (CORBA::ULong max - ) +TAO_Unknown_Profile::hash (CORBA::ULong max) { return (ACE::hash_pjw (reinterpret_cast <const char*> (this->body_.get_buffer ()), diff --git a/TAO/tao/RTCORBA/RT_Endpoint_Utils.cpp b/TAO/tao/RTCORBA/RT_Endpoint_Utils.cpp index 94904eeb443..611a7cc3ea7 100644 --- a/TAO/tao/RTCORBA/RT_Endpoint_Utils.cpp +++ b/TAO/tao/RTCORBA/RT_Endpoint_Utils.cpp @@ -18,11 +18,11 @@ ACE_RCSID (RTCORBA, TAO_BEGIN_VERSIONED_NAMESPACE_DECL -CORBA::Policy * +CORBA::Policy_ptr TAO_RT_Endpoint_Utils::policy (TAO_Cached_Policy_Type type, TAO::Profile_Transport_Resolver &r) { - CORBA::Policy *policy = CORBA::Policy::_nil (); + CORBA::Policy_ptr policy = CORBA::Policy::_nil (); TAO_RT_Stub * const rt_stub = dynamic_cast<TAO_RT_Stub *> (r.stub ()); @@ -32,8 +32,7 @@ TAO_RT_Endpoint_Utils::policy (TAO_Cached_Policy_Type type, try { - policy = - rt_stub->get_cached_policy (type); + policy = rt_stub->get_cached_policy (type); } catch (const ::CORBA::INV_POLICY&) { diff --git a/TAO/tao/RTCORBA/RT_Endpoint_Utils.h b/TAO/tao/RTCORBA/RT_Endpoint_Utils.h index 22b71e8a727..3398516fe1a 100644 --- a/TAO/tao/RTCORBA/RT_Endpoint_Utils.h +++ b/TAO/tao/RTCORBA/RT_Endpoint_Utils.h @@ -44,9 +44,8 @@ class TAO_RTCORBA_Export TAO_RT_Endpoint_Utils { public: static - CORBA::Policy *policy (TAO_Cached_Policy_Type type, - TAO::Profile_Transport_Resolver &r - ); + CORBA::Policy_ptr policy (TAO_Cached_Policy_Type type, + TAO::Profile_Transport_Resolver &r); private: /// ctor. diff --git a/TAO/tao/RTCORBA/RT_ORBInitializer.cpp b/TAO/tao/RTCORBA/RT_ORBInitializer.cpp index 96f21a8e5e9..f5b01d149d9 100644 --- a/TAO/tao/RTCORBA/RT_ORBInitializer.cpp +++ b/TAO/tao/RTCORBA/RT_ORBInitializer.cpp @@ -94,7 +94,7 @@ TAO_RT_ORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr info) tao_info->orb_core ()->orb_params ()->stub_factory_name ("RT_Stub_Factory"); ACE_Service_Config::process_directive (ace_svc_desc_TAO_RT_Stub_Factory); - // Set the name of the stub factory to be RT_Stub_Factory. + // Set the name of the endpoint selector factory to be RT_Endpoint_Selector_Factory. tao_info->orb_core ()->orb_params ()->endpoint_selector_factory_name ("RT_Endpoint_Selector_Factory"); ACE_Service_Config::process_directive (ace_svc_desc_RT_Endpoint_Selector_Factory); diff --git a/TAO/tao/RTCORBA/RT_PolicyFactory.cpp b/TAO/tao/RTCORBA/RT_PolicyFactory.cpp index 5257e6eaa82..9539b13cf22 100644 --- a/TAO/tao/RTCORBA/RT_PolicyFactory.cpp +++ b/TAO/tao/RTCORBA/RT_PolicyFactory.cpp @@ -18,23 +18,21 @@ TAO_RT_PolicyFactory::create_policy ( CORBA::PolicyType type, const CORBA::Any &value) { - if (type == RTCORBA::PRIORITY_MODEL_POLICY_TYPE) - return TAO_PriorityModelPolicy::create (value); - - if (type == RTCORBA::THREADPOOL_POLICY_TYPE) - return TAO_ThreadpoolPolicy::create (value); - - if (type == RTCORBA::SERVER_PROTOCOL_POLICY_TYPE) - return TAO_ServerProtocolPolicy::create (value); - - if (type == RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE) - return TAO_ClientProtocolPolicy::create (value); - - if (type == RTCORBA::PRIVATE_CONNECTION_POLICY_TYPE) - return TAO_PrivateConnectionPolicy::create (value); - - if (type == RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE) - return TAO_PriorityBandedConnectionPolicy::create (value); + switch (type) + { + case RTCORBA::PRIORITY_MODEL_POLICY_TYPE : + return TAO_PriorityModelPolicy::create (value); + case RTCORBA::THREADPOOL_POLICY_TYPE : + return TAO_ThreadpoolPolicy::create (value); + case RTCORBA::SERVER_PROTOCOL_POLICY_TYPE : + return TAO_ServerProtocolPolicy::create (value); + case RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE : + return TAO_ClientProtocolPolicy::create (value); + case RTCORBA::PRIVATE_CONNECTION_POLICY_TYPE : + return TAO_PrivateConnectionPolicy::create (value); + case RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE : + return TAO_PriorityBandedConnectionPolicy::create (value); + } throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE); } @@ -44,7 +42,9 @@ TAO_RT_PolicyFactory::_create_policy (CORBA::PolicyType type) { CORBA::Policy_ptr policy = CORBA::Policy_ptr (); - if (type == RTCORBA::PRIORITY_MODEL_POLICY_TYPE) + switch (type) + { + case RTCORBA::PRIORITY_MODEL_POLICY_TYPE : { ACE_NEW_THROW_EX (policy, TAO_PriorityModelPolicy, @@ -56,8 +56,8 @@ TAO_RT_PolicyFactory::_create_policy (CORBA::PolicyType type) return policy; } - - if (type == RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE) + break; + case RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE : { ACE_NEW_THROW_EX (policy, TAO_PriorityBandedConnectionPolicy, @@ -69,8 +69,8 @@ TAO_RT_PolicyFactory::_create_policy (CORBA::PolicyType type) return policy; } - - if (type == RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE) + break; + case RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE : { ACE_NEW_THROW_EX (policy, TAO_ClientProtocolPolicy, @@ -82,6 +82,8 @@ TAO_RT_PolicyFactory::_create_policy (CORBA::PolicyType type) return policy; } + break; + } throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE); } diff --git a/TAO/tao/RTCORBA/RT_PolicyFactory.h b/TAO/tao/RTCORBA/RT_PolicyFactory.h index 13544f517a3..6aef83ef536 100644 --- a/TAO/tao/RTCORBA/RT_PolicyFactory.h +++ b/TAO/tao/RTCORBA/RT_PolicyFactory.h @@ -45,13 +45,10 @@ class TAO_RT_PolicyFactory public virtual ::CORBA::LocalObject { public: + virtual CORBA::Policy_ptr create_policy (CORBA::PolicyType type, + const CORBA::Any &value); - CORBA::Policy_ptr create_policy (CORBA::PolicyType type, - const CORBA::Any &value - ); - - CORBA::Policy_ptr _create_policy (CORBA::PolicyType type - ); + virtual CORBA::Policy_ptr _create_policy (CORBA::PolicyType type); }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/RTCORBA/RT_Policy_i.cpp b/TAO/tao/RTCORBA/RT_Policy_i.cpp index cc2a4bdc94f..3371caad46c 100644 --- a/TAO/tao/RTCORBA/RT_Policy_i.cpp +++ b/TAO/tao/RTCORBA/RT_Policy_i.cpp @@ -167,7 +167,7 @@ CORBA::Policy_ptr TAO_ThreadpoolPolicy::create (const CORBA::Any &val) { RTCORBA::ThreadpoolId value; - if ((val >>= value) == 0) + if (!(val >>= value)) throw ::CORBA::PolicyError (CORBA::BAD_POLICY_VALUE); TAO_ThreadpoolPolicy *tmp = 0; @@ -324,7 +324,7 @@ CORBA::Policy_ptr TAO_PriorityBandedConnectionPolicy::create (const CORBA::Any &val) { RTCORBA::PriorityBands *value = 0; - if ((val >>= value) == 0) + if (!(val >>= value)) throw ::CORBA::PolicyError (CORBA::BAD_POLICY_VALUE); TAO_PriorityBandedConnectionPolicy *tmp = 0; @@ -339,7 +339,7 @@ TAO_PriorityBandedConnectionPolicy::create (const CORBA::Any &val) RTCORBA::PriorityBands * TAO_PriorityBandedConnectionPolicy::priority_bands (void) { - RTCORBA::PriorityBands *tmp; + RTCORBA::PriorityBands *tmp = 0; ACE_NEW_THROW_EX (tmp, RTCORBA::PriorityBands (this->priority_bands_), CORBA::NO_MEMORY (TAO::VMCID, @@ -374,13 +374,13 @@ TAO_PriorityBandedConnectionPolicy::destroy (void) CORBA::Boolean TAO_PriorityBandedConnectionPolicy::_tao_encode (TAO_OutputCDR &out_cdr) { - return out_cdr << priority_bands_; + return out_cdr << this->priority_bands_; } CORBA::Boolean TAO_PriorityBandedConnectionPolicy::_tao_decode (TAO_InputCDR &in_cdr) { - return in_cdr >> priority_bands_; + return in_cdr >> this->priority_bands_; } TAO_Cached_Policy_Type @@ -399,7 +399,7 @@ TAO_PriorityBandedConnectionPolicy::_tao_scope (void) const RTCORBA::PriorityBands & TAO_PriorityBandedConnectionPolicy::priority_bands_rep (void) { - return priority_bands_; + return this->priority_bands_; } // **************************************************************** @@ -430,7 +430,7 @@ CORBA::Policy_ptr TAO_ServerProtocolPolicy::create (const CORBA::Any &val) { RTCORBA::ProtocolList *value = 0; - if ((val >>= value) == 0) + if (!(val >>= value)) throw ::CORBA::PolicyError (CORBA::BAD_POLICY_VALUE); TAO_ServerProtocolPolicy *tmp = 0; @@ -529,7 +529,7 @@ CORBA::Policy_ptr TAO_ClientProtocolPolicy::create (const CORBA::Any &val) { RTCORBA::ProtocolList *value = 0; - if ((val >>= value) == 0) + if (!(val >>= value)) throw ::CORBA::PolicyError (CORBA::BAD_POLICY_VALUE); TAO_ClientProtocolPolicy *tmp = 0; @@ -1242,8 +1242,8 @@ TAO_Protocol_Properties_Factory::create_transport_protocol_property (IOP::Profil else if (id == TAO_TAG_UIOP_PROFILE) { - int send_buffer_size = orb_core ? orb_core->orb_params ()->sock_sndbuf_size () : 0; - int recv_buffer_size = orb_core ? orb_core->orb_params ()->sock_rcvbuf_size () : 0; + int const send_buffer_size = orb_core ? orb_core->orb_params ()->sock_sndbuf_size () : 0; + int const recv_buffer_size = orb_core ? orb_core->orb_params ()->sock_rcvbuf_size () : 0; ACE_NEW_RETURN (property, TAO_UnixDomain_Protocol_Properties (send_buffer_size, @@ -1253,8 +1253,8 @@ TAO_Protocol_Properties_Factory::create_transport_protocol_property (IOP::Profil else if (id == TAO_TAG_DIOP_PROFILE) { - int send_buffer_size = orb_core ? orb_core->orb_params ()->sock_sndbuf_size () : 0; - int recv_buffer_size = orb_core ? orb_core->orb_params ()->sock_rcvbuf_size () : 0; + int const send_buffer_size = orb_core ? orb_core->orb_params ()->sock_sndbuf_size () : 0; + int const recv_buffer_size = orb_core ? orb_core->orb_params ()->sock_rcvbuf_size () : 0; CORBA::Boolean enable_network_priority = false; ACE_NEW_RETURN (property, diff --git a/TAO/tao/RTCORBA/RT_Policy_i.h b/TAO/tao/RTCORBA/RT_Policy_i.h index 2b2d27b8d38..dd3c59b0b4a 100644 --- a/TAO/tao/RTCORBA/RT_Policy_i.h +++ b/TAO/tao/RTCORBA/RT_Policy_i.h @@ -305,8 +305,7 @@ public: */ RTCORBA::ProtocolList & protocols_rep (void); - RTCORBA::ProtocolList *protocols - (void); + RTCORBA::ProtocolList *protocols (void); CORBA::PolicyType policy_type (void); @@ -364,8 +363,7 @@ public: */ RTCORBA::ProtocolList & protocols_rep (void); - RTCORBA::ProtocolList *protocols - (void); + RTCORBA::ProtocolList *protocols (void); CORBA::PolicyType policy_type (void); diff --git a/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp b/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp index 925a0265228..a3c9e9da4cf 100644 --- a/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp +++ b/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp @@ -74,19 +74,19 @@ TAO_RT_Protocols_Hooks::server_protocol_properties (IOP::ProfileId protocol_tag, CORBA::Policy_ptr policy) { if (CORBA::is_nil (policy)) - return 0; + return RTCORBA::ProtocolProperties::_nil (); RTCORBA::ServerProtocolPolicy_var server_protocol_policy = RTCORBA::ServerProtocolPolicy::_narrow (policy); if (CORBA::is_nil (server_protocol_policy.in ())) - return 0; + return RTCORBA::ProtocolProperties::_nil (); TAO_ServerProtocolPolicy *server_protocols = dynamic_cast<TAO_ServerProtocolPolicy *> (server_protocol_policy.in ()); if (server_protocols == 0) - return 0; + return RTCORBA::ProtocolProperties::_nil (); // TAO_ServerProtocolPolicy RTCORBA::ProtocolList &protocols = @@ -101,7 +101,7 @@ TAO_RT_Protocols_Hooks::server_protocol_properties (IOP::ProfileId protocol_tag, } } - return 0; + return RTCORBA::ProtocolProperties::_nil (); } RTCORBA::ProtocolProperties_ptr @@ -109,19 +109,19 @@ TAO_RT_Protocols_Hooks::client_protocol_properties (IOP::ProfileId protocol_tag, CORBA::Policy_ptr policy) { if (CORBA::is_nil (policy)) - return 0; + return RTCORBA::ProtocolProperties::_nil (); RTCORBA::ClientProtocolPolicy_var client_protocol_policy = RTCORBA::ClientProtocolPolicy::_narrow (policy); if (CORBA::is_nil (client_protocol_policy.in ())) - return 0; + return RTCORBA::ProtocolProperties::_nil (); TAO_ClientProtocolPolicy *client_protocols = dynamic_cast<TAO_ClientProtocolPolicy *> (client_protocol_policy.in ()); if (client_protocols == 0) - return 0; + return RTCORBA::ProtocolProperties::_nil (); // TAO_ClientProtocolPolicy RTCORBA::ProtocolList &protocols = @@ -136,7 +136,7 @@ TAO_RT_Protocols_Hooks::client_protocol_properties (IOP::ProfileId protocol_tag, } } - return 0; + return RTCORBA::ProtocolProperties::_nil (); } RTCORBA::ProtocolProperties_ptr @@ -504,9 +504,7 @@ void TAO_RT_Protocols_Hooks::add_rt_service_context_hook ( TAO_Service_Context &service_context, CORBA::Policy *model_policy, - CORBA::Short &client_priority - - ) + CORBA::Short &client_priority) { RTCORBA::PriorityModelPolicy_var model_policy_ptr = RTCORBA::PriorityModelPolicy::_narrow (model_policy); diff --git a/TAO/tao/RTCORBA/RT_Stub.cpp b/TAO/tao/RTCORBA/RT_Stub.cpp index ee410570711..7d524757165 100644 --- a/TAO/tao/RTCORBA/RT_Stub.cpp +++ b/TAO/tao/RTCORBA/RT_Stub.cpp @@ -1,9 +1,6 @@ // $Id$ #include "tao/RTCORBA/RT_Stub.h" - -#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 - #include "tao/RTCORBA/RT_Policy_i.h" #include "tao/ORB_Core.h" #include "tao/Policy_Set.h" @@ -53,17 +50,23 @@ TAO_RT_Stub::parse_policies (void) // Cache away the policies that we'll need later. for (CORBA::ULong i = 0; i < length; ++i) { - if (policy_list[i]->policy_type () == - RTCORBA::PRIORITY_MODEL_POLICY_TYPE) - this->exposed_priority_model (policy_list[i]); - - else if (policy_list[i]->policy_type () == - RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE) - this->exposed_priority_banded_connection (policy_list[i]); - - else if (policy_list[i]->policy_type () == - RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE) - this->exposed_client_protocol (policy_list[i]); + switch (policy_list[i]->policy_type ()) + { + case RTCORBA::PRIORITY_MODEL_POLICY_TYPE: + { + this->exposed_priority_model (policy_list[i]); } + break; + case RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE : + { + this->exposed_priority_banded_connection (policy_list[i]); + } + break; + case RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE : + { + this->exposed_client_protocol (policy_list[i]); + } + break; + } } this->are_policies_parsed_ = true; @@ -120,21 +123,26 @@ TAO_RT_Stub::exposed_client_protocol (CORBA::Policy_ptr policy) this->client_protocol_policy_ = CORBA::Policy::_duplicate (policy); } -#if (TAO_HAS_CORBA_MESSAGING == 1) - CORBA::Policy_ptr TAO_RT_Stub::get_policy (CORBA::PolicyType type) { // If we are dealing with a client exposed policy, check if any // value came in the IOR/reconcile IOR value and overrides. - if (type == RTCORBA::PRIORITY_MODEL_POLICY_TYPE) - return this->exposed_priority_model (); - - if (type == RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE) - return this->effective_priority_banded_connection (); - - if (type == RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE) - return this->effective_client_protocol (); + switch (type) + { + case RTCORBA::PRIORITY_MODEL_POLICY_TYPE: + { + return this->exposed_priority_model (); + } + case RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE : + { + return this->effective_priority_banded_connection (); + } + case RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE : + { + return this->effective_client_protocol (); + } + } return this->TAO_Stub::get_policy (type); } @@ -144,14 +152,21 @@ TAO_RT_Stub::get_cached_policy (TAO_Cached_Policy_Type type) { // If we are dealing with a client exposed policy, check if any // value came in the IOR/reconcile IOR value and overrides. - if (type == TAO_CACHED_POLICY_PRIORITY_MODEL) - return this->exposed_priority_model (); - - if (type == TAO_CACHED_POLICY_RT_PRIORITY_BANDED_CONNECTION) - return this->effective_priority_banded_connection (); - - if (type == TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL) - return this->effective_client_protocol (); + switch (type) + { + case TAO_CACHED_POLICY_PRIORITY_MODEL: + { + return this->exposed_priority_model (); + } + case TAO_CACHED_POLICY_RT_PRIORITY_BANDED_CONNECTION : + { + return this->effective_priority_banded_connection (); + } + case TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL : + { + return this->effective_client_protocol (); + } + } return this->TAO_Stub::get_cached_policy (type); } @@ -182,9 +197,7 @@ TAO_RT_Stub::set_policy_overrides (const CORBA::PolicyList & policies, return this->TAO_Stub::set_policy_overrides(policies, set_add); } -#endif /* TAO_HAS_CORBA_MESSAGING */ - -CORBA::Policy * +CORBA::Policy_ptr TAO_RT_Stub::effective_priority_banded_connection (void) { // Get effective override. @@ -206,13 +219,18 @@ TAO_RT_Stub::effective_priority_banded_connection (void) RTCORBA::PriorityBandedConnectionPolicy::_narrow (override.in ()); TAO_PriorityBandedConnectionPolicy *override_policy = - static_cast<TAO_PriorityBandedConnectionPolicy *> (override_policy_var.in ()); + dynamic_cast<TAO_PriorityBandedConnectionPolicy *> (override_policy_var.in ()); RTCORBA::PriorityBandedConnectionPolicy_var exposed_policy_var = RTCORBA::PriorityBandedConnectionPolicy::_narrow (exposed.in ()); TAO_PriorityBandedConnectionPolicy *exposed_policy = - static_cast<TAO_PriorityBandedConnectionPolicy *> (exposed_policy_var.in ()); + dynamic_cast<TAO_PriorityBandedConnectionPolicy *> (exposed_policy_var.in ()); + + if (!override_policy || !exposed_policy) + { + throw ::CORBA::INV_POLICY (); + } // Both override and exposed have been set. // See if either of them has empty priority bands. @@ -227,7 +245,7 @@ TAO_RT_Stub::effective_priority_banded_connection (void) throw ::CORBA::INV_POLICY (); } -CORBA::Policy * +CORBA::Policy_ptr TAO_RT_Stub::effective_client_protocol (void) { // Get effective override. @@ -249,13 +267,18 @@ TAO_RT_Stub::effective_client_protocol (void) RTCORBA::ClientProtocolPolicy::_narrow (override.in ()); TAO_ClientProtocolPolicy *override_policy = - static_cast<TAO_ClientProtocolPolicy *> (override_policy_var.in ()); + dynamic_cast<TAO_ClientProtocolPolicy *> (override_policy_var.in ()); RTCORBA::ClientProtocolPolicy_var exposed_policy_var = RTCORBA::ClientProtocolPolicy::_narrow (exposed.in ()); TAO_ClientProtocolPolicy *exposed_policy = - static_cast<TAO_ClientProtocolPolicy *> (exposed_policy_var.in ()); + dynamic_cast<TAO_ClientProtocolPolicy *> (exposed_policy_var.in ()); + + if (!override_policy || !exposed_policy) + { + throw ::CORBA::INV_POLICY (); + } // Both override and exposed have been set. // See if either of them has empty priority bands. @@ -275,4 +298,3 @@ TAO_RT_Stub::effective_client_protocol (void) TAO_END_VERSIONED_NAMESPACE_DECL -#endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */ diff --git a/TAO/tao/RTCORBA/RT_Stub.h b/TAO/tao/RTCORBA/RT_Stub.h index cdc16fd9a81..230abf70920 100644 --- a/TAO/tao/RTCORBA/RT_Stub.h +++ b/TAO/tao/RTCORBA/RT_Stub.h @@ -59,7 +59,7 @@ public: #if (TAO_HAS_CORBA_MESSAGING == 1) /** - * Returns the effective policy if <type> is a known client-exposed + * Returns the effective policy if @a type is a known client-exposed * policy type. Returns the effective override for all other policy * types. */ @@ -105,8 +105,8 @@ private: // override for a given policy type, and then reconciling it with // the policy value exported in the Object's IOR. - CORBA::Policy *effective_priority_banded_connection (void); - CORBA::Policy *effective_client_protocol (void); + CORBA::Policy_ptr effective_priority_banded_connection (void); + CORBA::Policy_ptr effective_client_protocol (void); // The following attribute are used to cache // the different kind of policies and avoid to @@ -119,7 +119,7 @@ private: CORBA::Policy_var client_protocol_policy_; - CORBA::Boolean are_policies_parsed_; + bool are_policies_parsed_; private: // = Disallow copying and assignment. diff --git a/TAO/tao/Remote_Invocation.cpp b/TAO/tao/Remote_Invocation.cpp index a0b0b7434a2..1cbfb6bae3b 100644 --- a/TAO/tao/Remote_Invocation.cpp +++ b/TAO/tao/Remote_Invocation.cpp @@ -11,6 +11,7 @@ #include "tao/Network_Priority_Protocols_Hooks.h" #include "tao/debug.h" #include "tao/SystemException.h" +#include "tao/ZIOP_Adapter.h" ACE_RCSID (tao, Remote_Invocation, @@ -40,8 +41,8 @@ namespace TAO { /** * Mega hack for RTCORBA start. I don't think that - * PortableInterceptor would work here esp. for RTCORBA. PI needs - * to be improved to help our cause. + * PortableInterceptor would work here esp. for RTCORBA. PI needs + * to be improved to help our cause. */ this->resolver_.stub ()->orb_core ()->service_context_list ( this->resolver_.stub (), @@ -118,10 +119,22 @@ namespace TAO void Remote_Invocation::marshal_data (TAO_OutputCDR &out_stream) - { - if (this->details_.marshal_args (out_stream) == false) + { +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP ==1 + TAO_ZIOP_Adapter* ziop_adapter = this->stub()->orb_core()->ziop_adapter (); + + if (ziop_adapter) { - throw ::CORBA::MARSHAL (); + ziop_adapter->marshal_data (this->details_, out_stream, this->resolver_); + } + else +#endif + { + // Marshal application data + if (this->details_.marshal_args (out_stream) == false) + { + throw ::CORBA::MARSHAL (); + } } } diff --git a/TAO/tao/Service_Context_Handler.h b/TAO/tao/Service_Context_Handler.h index 1d1ab48c257..390fbd43d57 100644 --- a/TAO/tao/Service_Context_Handler.h +++ b/TAO/tao/Service_Context_Handler.h @@ -23,7 +23,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL -class TAO_ServerRequest; +class TAO_Transport; /** * This is the base of handler classes that each can process a certain @@ -35,7 +35,7 @@ class TAO_Export TAO_Service_Context_Handler { public: TAO_Service_Context_Handler (void); - virtual int process_service_context (TAO_ServerRequest& server_request, + virtual int process_service_context (TAO_Transport& transport, const IOP::ServiceContext& context) = 0; virtual ~TAO_Service_Context_Handler (void); }; diff --git a/TAO/tao/Service_Context_Handler_Registry.cpp b/TAO/tao/Service_Context_Handler_Registry.cpp index a39281416e6..5fd8a69cf67 100644 --- a/TAO/tao/Service_Context_Handler_Registry.cpp +++ b/TAO/tao/Service_Context_Handler_Registry.cpp @@ -13,19 +13,20 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL int TAO_Service_Context_Registry::process_service_contexts ( - TAO_ServerRequest& server_request) + IOP::ServiceContextList &sc, + TAO_Transport& transport) { - IOP::ServiceContextList &service_info = - server_request.request_service_context ().service_info (); for (CORBA::ULong index = 0; - index != service_info.length (); + index != sc.length (); ++index) { - IOP::ServiceContext const & context = service_info[index]; - TAO_Service_Context_Handler* const handler = registry_[context.context_id]; - if (handler) + IOP::ServiceContext const & context = sc[index]; + + iterator handler_iter = this->registry_.find (context.context_id); + + if (handler_iter != registry_.end ()) { - return handler->process_service_context (server_request, context); + return handler_iter->second->process_service_context (transport, context); } } return 0; diff --git a/TAO/tao/Service_Context_Handler_Registry.h b/TAO/tao/Service_Context_Handler_Registry.h index ea48bbd4b18..071d5a62c31 100644 --- a/TAO/tao/Service_Context_Handler_Registry.h +++ b/TAO/tao/Service_Context_Handler_Registry.h @@ -25,7 +25,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL -class TAO_ServerRequest; +class TAO_Transport; class TAO_Service_Context_Handler; class TAO_Export TAO_Service_Context_Registry @@ -45,7 +45,7 @@ class TAO_Export TAO_Service_Context_Registry */ TAO_Service_Context_Handler* operator[] (IOP::ServiceId id); - int process_service_contexts (TAO_ServerRequest& server_request); + int process_service_contexts (IOP::ServiceContextList &sc, TAO_Transport& transport); private: typedef ACE_Array_Map<IOP::ServiceId, diff --git a/TAO/tao/Strategies/DIOP_Transport.cpp b/TAO/tao/Strategies/DIOP_Transport.cpp index e8e504c9e4f..7d7cee491d8 100644 --- a/TAO/tao/Strategies/DIOP_Transport.cpp +++ b/TAO/tao/Strategies/DIOP_Transport.cpp @@ -251,7 +251,7 @@ TAO_DIOP_Transport::send_message (TAO_OutputCDR &stream, ACE_Time_Value *max_wait_time) { // Format the message in the stream first - if (this->messaging_object_->format_message (stream) != 0) + if (this->messaging_object ()->format_message (stream) != 0) return -1; // Strictly speaking, should not need to loop here because the diff --git a/TAO/tao/Strategies/SCIOP_Transport.cpp b/TAO/tao/Strategies/SCIOP_Transport.cpp index 0d0e9f1024b..727e1db17af 100644 --- a/TAO/tao/Strategies/SCIOP_Transport.cpp +++ b/TAO/tao/Strategies/SCIOP_Transport.cpp @@ -137,7 +137,7 @@ TAO_SCIOP_Transport::send_message (TAO_OutputCDR &stream, ACE_Time_Value *max_wait_time) { // Format the message in the stream first - if (this->messaging_object_->format_message (stream) != 0) + if (this->messaging_object ()->format_message (stream) != 0) return -1; // This guarantees to send all data (bytes) or return an error. diff --git a/TAO/tao/Strategies/SHMIOP_Transport.cpp b/TAO/tao/Strategies/SHMIOP_Transport.cpp index bd8d5f60170..8d84e052f38 100644 --- a/TAO/tao/Strategies/SHMIOP_Transport.cpp +++ b/TAO/tao/Strategies/SHMIOP_Transport.cpp @@ -298,7 +298,7 @@ TAO_SHMIOP_Transport::send_message (TAO_OutputCDR &stream, ACE_Time_Value *max_wait_time) { // Format the message in the stream first - if (this->messaging_object_->format_message (stream) != 0) + if (this->messaging_object ()->format_message (stream) != 0) return -1; // Strictly speaking, should not need to loop here because the diff --git a/TAO/tao/Strategies/UIOP_Transport.cpp b/TAO/tao/Strategies/UIOP_Transport.cpp index 3327173b771..2fc09a6765f 100644 --- a/TAO/tao/Strategies/UIOP_Transport.cpp +++ b/TAO/tao/Strategies/UIOP_Transport.cpp @@ -123,7 +123,7 @@ TAO_UIOP_Transport::send_message (TAO_OutputCDR &stream, ACE_Time_Value *max_wait_time) { // Format the message in the stream first - if (this->messaging_object_->format_message (stream) != 0) + if (this->messaging_object ()->format_message (stream) != 0) return -1; // Strictly speaking, should not need to loop here because the diff --git a/TAO/tao/Stub.cpp b/TAO/tao/Stub.cpp index f0d66a60446..c6218565384 100644 --- a/TAO/tao/Stub.cpp +++ b/TAO/tao/Stub.cpp @@ -50,9 +50,7 @@ TAO_Stub::TAO_Stub (const char *repository_id, , profile_lock_ptr_ (0) , profile_success_ (false) , refcount_ (1) -#if (TAO_HAS_CORBA_MESSAGING == 1) , policies_ (0) -#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ , ior_info_ (0) , forwarded_ior_info_ (0) , collocation_opt_ (orb_core->optimize_collocation_objects ()) @@ -102,12 +100,8 @@ TAO_Stub::~TAO_Stub (void) delete this->profile_lock_ptr_; -#if (TAO_HAS_CORBA_MESSAGING == 1) - delete this->policies_; -#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ - if (this->ior_info_) delete this->ior_info_; @@ -385,8 +379,6 @@ TAO_Stub::forward_back_one (void) // // **************************************************************** -#if (TAO_HAS_CORBA_MESSAGING == 1) - // Some policies can only be set locally on the client, while others // can only be exported in the IOR by the server, and yet others can // be set by both by client and server. Furthermore, reconciliation @@ -493,8 +485,6 @@ TAO_Stub::get_policy_overrides (const CORBA::PolicyTypeSeq &types) } } -#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ - CORBA::Boolean TAO_Stub::marshal (TAO_OutputCDR &cdr) { diff --git a/TAO/tao/Stub.h b/TAO/tao/Stub.h index 8a68c039636..9c278f83b7f 100644 --- a/TAO/tao/Stub.h +++ b/TAO/tao/Stub.h @@ -69,8 +69,6 @@ namespace IOP class TAO_Export TAO_Stub { public: -#if (TAO_HAS_CORBA_MESSAGING == 1) - /** * Returns the effective policy if @a type is a known client-exposed * policy type. Returns the effective override for all other policy @@ -86,8 +84,6 @@ public: virtual CORBA::PolicyList *get_policy_overrides ( const CORBA::PolicyTypeSeq & types); -#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ - /// Return the queueing strategy to be used in by the transport. /// Selection will be based on the SyncScope policies. TAO::Transport_Queueing_Strategy *transport_queueing_strategy (void); @@ -122,7 +118,7 @@ public: /// profiles need to be edited. ACE_Lock *profile_lock (void) const; - // Manage the base (non-forwarded) profiles. + /// Manage the base (non-forwarded) profiles. /// Returns a pointer to the profile_in_use object. This object /// retains ownership of this profile. TAO_Profile *profile_in_use (void); @@ -161,20 +157,20 @@ public: /** * THREAD SAFE - * this method will reset the base profile list to reference the first + * This method will reset the base profile list to reference the first * profile and if there are anmy existing forward profiles they are * reset. */ void reset_profiles (void); - /// Returns 1 if a forward profile has successfully been used. + /// Returns true if a forward profile has successfully been used. /// profile_success_ && forward_profiles_ CORBA::Boolean valid_forward_profile (void); - /// NON-THREAD-SAFE. Will set profile_success_ to 0. + /// NON-THREAD-SAFE. Will set profile_success_ to true. void set_valid_profile (void); - /// Returns TRUE if a connection was successful with at least + /// Returns true if a connection was successful with at least /// one profile. CORBA::Boolean valid_profile (void) const; @@ -353,7 +349,6 @@ protected: */ TAO::Object_Proxy_Broker *object_proxy_broker_; - /// Ordered list of profiles for this object. TAO_MProfile base_profiles_; diff --git a/TAO/tao/Synch_Invocation.cpp b/TAO/tao/Synch_Invocation.cpp index d5a089a2523..b94a200205f 100644 --- a/TAO/tao/Synch_Invocation.cpp +++ b/TAO/tao/Synch_Invocation.cpp @@ -88,7 +88,8 @@ namespace TAO cdr.message_attributes (this->details_.request_id (), this->resolver_.stub (), TAO_Transport::TAO_TWOWAY_REQUEST, - max_wait_time); + max_wait_time, + false); this->write_header (cdr); @@ -305,7 +306,7 @@ namespace TAO try { return - this->orb_core ()->service_raise_comm_failure ( + this->stub()->orb_core ()->service_raise_comm_failure ( this->details_.request_service_context ().service_info (), this->resolver_.profile ()); @@ -367,7 +368,7 @@ namespace TAO { // de-marshalling of permanent object reference was successfull CORBA::Boolean const permanent_forward_condition = - this->orb_core ()->is_permanent_forward_condition + this->stub ()->orb_core ()->is_permanent_forward_condition (this->forwarded_to_.in (), this->request_service_context ()); @@ -435,7 +436,7 @@ namespace TAO CORBA::Object_var fwd; - if ((inp_stream >> fwd) == 0) + if (!(inp_stream >> fwd)) { throw ::CORBA::MARSHAL ( CORBA::SystemException::_tao_minor_code ( @@ -465,7 +466,7 @@ namespace TAO // Pull the exception from the stream. CORBA::String_var buf; - if ((cdr >> buf.inout ()) == 0) + if (!(cdr >> buf.inout ())) { // Could not demarshal the exception id, raise an local // CORBA::MARSHAL @@ -510,7 +511,7 @@ namespace TAO CORBA::String_var type_id; - if ((cdr >> type_id.inout ()) == 0) + if (!(cdr >> type_id.inout ())) { // Could not demarshal the exception id, raise an local // CORBA::MARSHAL @@ -546,7 +547,7 @@ namespace TAO * forcing us into this. */ Invocation_Status const s = - this->orb_core ()->service_raise_transient_failure ( + this->stub ()->orb_core ()->service_raise_transient_failure ( this->details_.request_service_context ().service_info (), this->resolver_.profile ()); @@ -656,7 +657,8 @@ namespace TAO cdr.message_attributes (this->details_.request_id (), this->resolver_.stub (), TAO_Transport::TAO_ONEWAY_REQUEST, - max_wait_time); + max_wait_time, + false); this->write_header (cdr); diff --git a/TAO/tao/Synch_Reply_Dispatcher.cpp b/TAO/tao/Synch_Reply_Dispatcher.cpp index aec04954877..571239f2e05 100644 --- a/TAO/tao/Synch_Reply_Dispatcher.cpp +++ b/TAO/tao/Synch_Reply_Dispatcher.cpp @@ -62,8 +62,14 @@ TAO_Synch_Reply_Dispatcher::dispatch_reply ( // this data. CORBA::ULong const max = params.svc_ctx_.maximum (); CORBA::ULong const len = params.svc_ctx_.length (); - IOP::ServiceContext* context_list = params.svc_ctx_.get_buffer (1); - this->reply_service_info_.replace (max, len, context_list, 1); + IOP::ServiceContext* context_list = params.svc_ctx_.get_buffer (true); + this->reply_service_info_.replace (max, len, context_list, true); + + if (this->reply_service_info_.length() > 0) + { + orb_core_->service_context_registry (). + process_service_contexts (this->reply_service_info_, *(params.transport_)); + } // Must reset the message state, it is possible that the same reply // dispatcher is used because the request must be re-sent. diff --git a/TAO/tao/TAO_Internal.cpp b/TAO/tao/TAO_Internal.cpp index 31246941890..5c41411ca06 100644 --- a/TAO/tao/TAO_Internal.cpp +++ b/TAO/tao/TAO_Internal.cpp @@ -247,13 +247,13 @@ TAO::ORB::open_global_services (int argc, // (global) Service Configurator instance. // Be certain to copy the program name so that service configurator // has something to skip! - ACE_ARGV global_svc_config_argv (true); // only this ctor allows + ACE_ARGV global_svc_config_argv (true); // only this ctor allows // subsequent use of add()! - global_svc_config_argv.add ((argc <= 0 || argv == 0) ? + global_svc_config_argv.add ((argc <= 0 || argv == 0) ? ACE_TEXT ("") : argv[0]); // Will expand the environment variables, if any were used. - // Is this a good thing? I guess it provides greater flexibility + // Is this a good thing? I guess it provides greater flexibility // for deployment,so let's leave it. Will also quote arguments. ACE_ARGV copyargv (argc, argv, true, true); @@ -287,11 +287,11 @@ TAO::ORB::open_global_services (int argc, return -1; // register_global_services_i depends on the parsing of at least the - // -ORBNegotiateCodesets option, and must be invoked after all the + // -ORBNegotiateCodesets option, and must be invoked after all the // parsing methods, but still must preceed the opening of other services. register_global_services_i (theone); - + // Perform the open magic (unless SC::open() has been called already) int global_svc_config_argc = global_svc_config_argv.argc (); int status = open_private_services_i (theone, @@ -407,7 +407,7 @@ TAO::ORB::open_services (ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> pcfg, // Parse any globally applicable arguments, but do not make them effective. // We are effectively purging the command line from them without affecting - // the global state - after all, it may be a private (local) configuration + // the global state - after all, it may be a private (local) configuration // context. int status = parse_global_args_i(argc, argv, global_svc_config_argv, false); @@ -651,6 +651,18 @@ namespace bidir_loader->init (0, 0); } +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP == 1 + ACE_Service_Object * const ziop_loader = + ACE_Dynamic_Service<ACE_Service_Object>::instance ( + pcfg, + "ZIOP_Loader"); + + if (ziop_loader != 0) + { + ziop_loader->init (0, 0); + } +#endif + ACE_Service_Object * const messaging_loader = ACE_Dynamic_Service<ACE_Service_Object>::instance ( pcfg, diff --git a/TAO/tao/TAO_Server_Request.cpp b/TAO/tao/TAO_Server_Request.cpp index 893d416f762..69358c20e18 100644 --- a/TAO/tao/TAO_Server_Request.cpp +++ b/TAO/tao/TAO_Server_Request.cpp @@ -270,7 +270,8 @@ TAO_ServerRequest::init_reply (void) this->outgoing_->message_attributes (this->request_id_, 0, TAO_Transport::TAO_REPLY, - 0); + 0, + false); // Construct a REPLY header. this->mesg_base_->generate_reply_header (*this->outgoing_, reply_params); @@ -317,7 +318,8 @@ TAO_ServerRequest::send_no_exception_reply (void) this->outgoing_->message_attributes (this->request_id_, 0, TAO_Transport::TAO_REPLY, - 0); + 0, + false); // Construct a REPLY header. this->mesg_base_->generate_reply_header (*this->outgoing_, reply_params); @@ -352,9 +354,9 @@ TAO_ServerRequest::tao_send_reply (void) this->outgoing_->more_fragments (false); - int result = this->transport_->send_message (*this->outgoing_, - 0, - TAO_Transport::TAO_REPLY); + int const result = this->transport_->send_message (*this->outgoing_, + 0, + TAO_Transport::TAO_REPLY); if (result == -1) { if (TAO_debug_level > 0) @@ -509,7 +511,8 @@ TAO_ServerRequest::send_cached_reply (CORBA::OctetSeq &s) this->outgoing_->message_attributes (this->request_id_, 0, TAO_Transport::TAO_REPLY, - 0); + 0, + false); // Make the reply message if (this->mesg_base_->generate_reply_header (*this->outgoing_, @@ -527,9 +530,11 @@ TAO_ServerRequest::send_cached_reply (CORBA::OctetSeq &s) s.length ()); if (!this->outgoing_->good_bit ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("TAO (%P|%t) - ServerRequest::send_cached_reply, ") - ACE_TEXT ("could not marshal reply\n"))); + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) - ServerRequest::send_cached_reply, ") + ACE_TEXT ("could not marshal reply\n"))); + } this->outgoing_->more_fragments (false); diff --git a/TAO/tao/Tagged_Components.cpp b/TAO/tao/Tagged_Components.cpp index 7580d2a3b28..28d22ce41ed 100644 --- a/TAO/tao/Tagged_Components.cpp +++ b/TAO/tao/Tagged_Components.cpp @@ -63,10 +63,10 @@ TAO_Tagged_Components::set_code_sets_i ( CONV_FRAME::CodeSetComponent &rhs) { lhs.native_code_set = rhs.native_code_set; - CORBA::ULong max = rhs.conversion_code_sets.maximum (); - CORBA::ULong len = rhs.conversion_code_sets.length (); - CONV_FRAME::CodeSetId *buffer = rhs.conversion_code_sets.get_buffer (1); - lhs.conversion_code_sets.replace (max, len, buffer, 1); + CORBA::ULong const max = rhs.conversion_code_sets.maximum (); + CORBA::ULong const len = rhs.conversion_code_sets.length (); + CONV_FRAME::CodeSetId *buffer = rhs.conversion_code_sets.get_buffer (true); + lhs.conversion_code_sets.replace (max, len, buffer, true); } // **************************************************************** @@ -140,7 +140,7 @@ TAO_Tagged_Components::set_known_component_i ( CORBA::Boolean byte_order; - if ((cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) + if (!(cdr >> ACE_InputCDR::to_boolean (byte_order))) { return; } @@ -151,7 +151,7 @@ TAO_Tagged_Components::set_known_component_i ( { CORBA::ULong orb_type; - if ((cdr >> orb_type) == 0) + if (!(cdr >> orb_type)) { return; } @@ -163,7 +163,7 @@ TAO_Tagged_Components::set_known_component_i ( { CONV_FRAME::CodeSetComponentInfo ci; - if ((cdr >> ci) == 0) + if (!(cdr >> ci)) { return; } @@ -315,7 +315,7 @@ TAO_Tagged_Components::decode (TAO_InputCDR& cdr) this->orb_type_set_ = 0; this->code_sets_set_ = 0; - if ((cdr >> this->components_) == 0) + if (!(cdr >> this->components_)) { return 0; } diff --git a/TAO/tao/Tagged_Components.h b/TAO/tao/Tagged_Components.h index 92d78043e55..90c74e3dae3 100644 --- a/TAO/tao/Tagged_Components.h +++ b/TAO/tao/Tagged_Components.h @@ -139,10 +139,10 @@ private: int get_component_i (IOP::TaggedComponent& component) const; /// Is @a tag a well-known component? - int known_tag (IOP::ComponentId tag) const; + bool known_tag (IOP::ComponentId tag) const; /// Does @a tag show up only once? - int unique_tag (IOP::ComponentId tag) const; + bool unique_tag (IOP::ComponentId tag) const; private: /// The ORB_TYPE component value diff --git a/TAO/tao/Tagged_Components.inl b/TAO/tao/Tagged_Components.inl index cb61b5235b4..e19251e5acd 100644 --- a/TAO/tao/Tagged_Components.inl +++ b/TAO/tao/Tagged_Components.inl @@ -47,7 +47,7 @@ TAO_Tagged_Components::get_code_sets ( return this->code_sets_set_; } -ACE_INLINE int +ACE_INLINE bool TAO_Tagged_Components::known_tag (IOP::ComponentId tag) const { return (tag == IOP::TAG_ORB_TYPE @@ -55,7 +55,7 @@ TAO_Tagged_Components::known_tag (IOP::ComponentId tag) const } -ACE_INLINE int +ACE_INLINE bool TAO_Tagged_Components::unique_tag (IOP::ComponentId tag) const { return (tag == IOP::TAG_ORB_TYPE diff --git a/TAO/tao/Transport.cpp b/TAO/tao/Transport.cpp index 818fa94ba00..7ee91375464 100644 --- a/TAO/tao/Transport.cpp +++ b/TAO/tao/Transport.cpp @@ -23,6 +23,7 @@ #include "tao/ORB_Core.h" #include "tao/MMAP_Allocator.h" #include "tao/SystemException.h" +#include "tao/operation_details.h" #include "ace/OS_NS_sys_time.h" #include "ace/OS_NS_stdio.h" @@ -148,7 +149,7 @@ TAO_Transport::TAO_Transport (CORBA::ULong tag, , char_translator_ (0) , wchar_translator_ (0) , tcs_set_ (0) - , first_request_ (1) + , first_request_ (true) , partial_message_ (0) #if TAO_HAS_SENDFILE == 1 // The ORB has been configured to use the MMAP allocator, meaning @@ -421,7 +422,7 @@ TAO_Transport::generate_locate_request ( { if (TAO_debug_level > 0) { - ACE_DEBUG ((LM_DEBUG, + ACE_ERROR ((LM_ERROR, ACE_TEXT ("TAO (%P|%t) - Transport[%d]::generate_locate_request, ") ACE_TEXT ("error while marshalling the LocateRequest header\n"), this->id ())); @@ -445,7 +446,7 @@ TAO_Transport::generate_request_header ( { TAO_Codeset_Manager * const csm = this->orb_core ()->codeset_manager (); if (csm) - csm->generate_service_context (opdetails,*this); + csm->generate_service_context (opdetails, *this); } if (this->messaging_object ()->generate_request_header (opdetails, @@ -454,9 +455,9 @@ TAO_Transport::generate_request_header ( { if (TAO_debug_level > 0) { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) - Transport[%d]::generate_request_header, ") - ACE_TEXT ("error while marshalling the Request header\n"), + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) - Transport[%d]::generate_request_header, ") + ACE_TEXT ("error while marshalling the Request header\n"), this->id())); } @@ -783,12 +784,6 @@ TAO_Transport::send_synch_message_helper_i (TAO_Synch_Queued_Message &synch_mess return 0; } -bool -TAO_Transport::queue_is_empty_i (void) -{ - return (this->head_ == 0); -} - int TAO_Transport::schedule_output_i (void) { @@ -1889,9 +1884,9 @@ TAO_Transport::handle_input_missing_data (TAO_Resume_Handle &rh, int -TAO_Transport::handle_input_parse_extra_messages (ACE_Message_Block &message_block) +TAO_Transport::handle_input_parse_extra_messages ( + ACE_Message_Block &message_block) { - // store buffer status of last extraction: -1 parse error, 0 // incomplete message header in buffer, 1 complete messages header // parsed @@ -1935,7 +1930,6 @@ int TAO_Transport::handle_input_parse_data (TAO_Resume_Handle &rh, ACE_Time_Value * max_wait_time) { - if (TAO_debug_level > 3) { ACE_DEBUG ((LM_DEBUG, @@ -1944,7 +1938,6 @@ TAO_Transport::handle_input_parse_data (TAO_Resume_Handle &rh, this->id ())); } - // The buffer on the stack which will be used to hold the input // messages, ACE_CDR::MAX_ALIGNMENT compensates the // memory-alignment. This improves performance with SUN-Java-ORB-1.4 @@ -2067,7 +2060,7 @@ TAO_Transport::handle_input_parse_data (TAO_Resume_Handle &rh, // invocation context to get meaningful information. this->recv_buffer_size_ = recv_size; - // Read the message into the message block that we have created on + // Read the message into the message block that we have created on // the stack. ssize_t const n = this->recv (message_block.wr_ptr (), recv_size, @@ -2164,8 +2157,7 @@ TAO_Transport::handle_input_parse_data (TAO_Resume_Handle &rh, size_t mesg_length = 0; - if (this->messaging_object ()->parse_next_message (qd, - mesg_length) == -1 + if (this->messaging_object ()->parse_next_message (qd, mesg_length) == -1 || (qd.missing_data () == 0 && mesg_length > message_block.length ()) ) { @@ -2232,8 +2224,7 @@ TAO_Transport::handle_input_parse_data (TAO_Resume_Handle &rh, } } - TAO_Queued_Data *nqd = - TAO_Queued_Data::duplicate (qd); + TAO_Queued_Data *nqd = TAO_Queued_Data::duplicate (qd); if (nqd == 0) { @@ -2303,7 +2294,7 @@ TAO_Transport::handle_input_parse_data (TAO_Resume_Handle &rh, } - const int retval = this->notify_reactor (); + int const retval = this->notify_reactor (); if (retval == 1) { @@ -2322,8 +2313,7 @@ TAO_Transport::handle_input_parse_data (TAO_Resume_Handle &rh, } // PRE: incoming_message_queue is empty - if (this->process_parsed_messages (&qd, - rh) == -1) + if (this->process_parsed_messages (&qd, rh) == -1) { return -1; } @@ -2381,10 +2371,12 @@ TAO_Transport::process_parsed_messages (TAO_Queued_Data *qd, case GIOP::CloseConnection: { if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) - Transport[%d]::process_parsed_messages, ") - ACE_TEXT ("received CloseConnection message - %m\n"), - this->id())); + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) - Transport[%d]::process_parsed_messages, ") + ACE_TEXT ("received CloseConnection message - %m\n"), + this->id())); + } // Return a "-1" so that the next stage can take care of // closing connection and the necessary memory management. @@ -2398,9 +2390,7 @@ TAO_Transport::process_parsed_messages (TAO_Queued_Data *qd, // request. This will open up the handle for other threads. rh.resume_handle (); - if (this->messaging_object ()->process_request_message ( - this, - qd) == -1) + if (this->messaging_object ()->process_request_message (this, qd) == -1) { // Return a "-1" so that the next stage can take care of // closing connection and the necessary memory management. @@ -2418,10 +2408,12 @@ TAO_Transport::process_parsed_messages (TAO_Queued_Data *qd, if (this->messaging_object ()->process_reply_message (params, qd) == -1) { if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) - Transport[%d]::process_parsed_messages, ") - ACE_TEXT ("error in process_reply_message - %m\n"), - this->id ())); + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) - Transport[%d]::process_parsed_messages, ") + ACE_TEXT ("error in process_reply_message - %m\n"), + this->id ())); + } return -1; } diff --git a/TAO/tao/Transport.h b/TAO/tao/Transport.h index 5570a7fbc19..120f1b60019 100644 --- a/TAO/tao/Transport.h +++ b/TAO/tao/Transport.h @@ -772,9 +772,12 @@ public: /// Return true if the tcs has been set CORBA::Boolean is_tcs_set() const; - /// Set the state of the first_request_ flag to 0 + /// Set the state of the first_request_ flag to false void first_request_sent(); + /// Get the first request flag + bool first_request () const; + /// Notify all the components inside a Transport when the underlying /// connection is closed. void send_connection_closed_notifications (void); @@ -807,7 +810,7 @@ private: * * @return true if the queue is empty */ - bool queue_is_empty_i (void); + bool queue_is_empty_i (void) const; /// A helper routine used in drain_queue_i() int drain_queue_helper (int &iovcnt, iovec iov[], ACE_Time_Value *max_wait_time); @@ -1031,11 +1034,11 @@ protected: /// buffer the requests in this transport until the connection is ready bool is_connected_; +private: + /// Our messaging object. TAO_GIOP_Message_Base *messaging_object_; -private: - /// @@Phil, I think it would be nice if we could think of a way to /// do the following. /// We have been trying to use the transport for marking about @@ -1061,7 +1064,7 @@ private: /// is necessary since codeset context information is necessary only on the /// first request. After that, the translators are fixed for the life of the /// connection. - CORBA::Boolean first_request_; + bool first_request_; /// Holds the partial GIOP message (if there is one) ACE_Message_Block* partial_message_; diff --git a/TAO/tao/Transport.inl b/TAO/tao/Transport.inl index 458c8dbbfb9..f0d411b2928 100644 --- a/TAO/tao/Transport.inl +++ b/TAO/tao/Transport.inl @@ -4,6 +4,12 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL +ACE_INLINE bool +TAO_Transport::queue_is_empty_i (void) const +{ + return (this->head_ == 0); +} + ACE_INLINE CORBA::ULong TAO_Transport::tag (void) const { @@ -163,7 +169,13 @@ TAO_Transport::is_tcs_set(void) const ACE_INLINE void TAO_Transport::first_request_sent (void) { - this->first_request_ = 0; + this->first_request_ = false; +} + +ACE_INLINE bool +TAO_Transport::first_request (void) const +{ + return this->first_request_; } ACE_INLINE bool diff --git a/TAO/tao/Unbounded_Octet_Sequence_T.h b/TAO/tao/Unbounded_Octet_Sequence_T.h index dbe1f4a604a..8f9a960b45c 100644 --- a/TAO/tao/Unbounded_Octet_Sequence_T.h +++ b/TAO/tao/Unbounded_Octet_Sequence_T.h @@ -77,7 +77,7 @@ public: freebuf(buffer_); } /// Create a sequence of octets from a single message block (i.e. it - /// ignores any chaining in the meesage block). + /// ignores any chaining in the message block). inline unbounded_value_sequence<CORBA::Octet> (CORBA::ULong length, const ACE_Message_Block* mb) : maximum_ (length) diff --git a/TAO/tao/ZIOP.mpc b/TAO/tao/ZIOP.mpc new file mode 100644 index 00000000000..d7aa0e4b7fb --- /dev/null +++ b/TAO/tao/ZIOP.mpc @@ -0,0 +1,45 @@ +//$Id$ + +project(ZIOP) : tao_output, install, taolib, compression, pi, tao_versioning_idl_defaults { + sharedname = TAO_ZIOP + dynamicflags = TAO_ZIOP_BUILD_DLL + + Source_Files { + ZIOP + } + + Header_Files { + ZIOP + } + + Inline_Files { + ZIOP + } + + Template_Files { + ZIOP + } + + Resource_Files { + ZIOP + } + + PIDL_Files { + ZIOP + } + + IDL_Files { + idlflags -= -Sa -St + idlflags += -Gp -Gd -Sci -SS -Sorb \ + -Wb,export_macro=TAO_ZIOP_Export \ + -Wb,export_include=tao/ZIOP/ziop_export.h \ + -Wb,include_guard=TAO_ZIOP_SAFE_INCLUDE \ + -Wb,safe_include=tao/ZIOP/ZIOP.h \ + -o ZIOP + ZIOP/ZIOP.pidl + } + + Pkgconfig_Files { + ZIOP/TAO_ZIOP.pc.in + } +} diff --git a/TAO/tao/ZIOP/TAO_ZIOP.pc.in b/TAO/tao/ZIOP/TAO_ZIOP.pc.in new file mode 100644 index 00000000000..0acb01b9d9f --- /dev/null +++ b/TAO/tao/ZIOP/TAO_ZIOP.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: TAO_ZIOP +Description: TAO ZIOP Library +Requires: TAO_PI, TAO_CodecFactory, TAO_AnyTypeCode, TAO +Version: @VERSION@ +Libs: -L${libdir} -lTAO_ZIOP +Cflags: -I${includedir} diff --git a/TAO/tao/ZIOP/ZIOP.cpp b/TAO/tao/ZIOP/ZIOP.cpp new file mode 100644 index 00000000000..9590435cc2f --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP.cpp @@ -0,0 +1,446 @@ +#include "tao/ZIOP/ZIOP_ORBInitializer.h" +#include "tao/ZIOP/ZIOP_Policy_Validator.h" +#include "tao/ZIOP/ZIOP.h" +#include "tao/ORB_Core.h" +#include "tao/debug.h" +#include "tao/ORBInitializer_Registry.h" +#include "tao/operation_details.h" +#include "tao/Stub.h" + +ACE_RCSID (ZIOP, + ZIOP, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// Set the flag to zero to start with +bool TAO_ZIOP_Loader::is_activated_ = false; + +TAO_ZIOP_Loader::TAO_ZIOP_Loader (void) +{ +} + +TAO_ZIOP_Loader::~TAO_ZIOP_Loader (void) +{ +} + +int +TAO_ZIOP_Loader::init (int, ACE_TCHAR* []) +{ + if (TAO_ZIOP_Loader::is_activated_ == false && TAO_DEF_GIOP_MINOR >= 2) + { + PortableInterceptor::ORBInitializer_ptr tmp_orb_initializer = + PortableInterceptor::ORBInitializer::_nil (); + PortableInterceptor::ORBInitializer_var ziop_orb_initializer; + + try + { + /// Register the BiDir ORBInitializer. + ACE_NEW_THROW_EX (tmp_orb_initializer, + TAO_ZIOP_ORBInitializer (this), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + ziop_orb_initializer = tmp_orb_initializer; + + PortableInterceptor::register_orb_initializer ( + ziop_orb_initializer.in ()); + + TAO_ZIOP_Loader::is_activated_ = true; + } + catch (const ::CORBA::Exception& ex) + { + if (TAO_debug_level > 0) + { + ex._tao_print_exception ("Caught exception:"); + } + return -1; + } + } + + return 0; +} + +void +TAO_ZIOP_Loader::load_policy_validators (TAO_Policy_Validator &val) +{ + // Is this true? Does the GIOP protocol version matter here? + if (TAO_DEF_GIOP_MINOR < 2) + return; + + TAO_ZIOPPolicy_Validator *validator = 0; + ACE_NEW_THROW_EX (validator, + TAO_ZIOPPolicy_Validator (val.orb_core ()), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + // We may be adding another TAO_BiDirPolicy_Validator instance for + // the same ORB (different POA). In cases where huge numbers of + // bi-directional POA instances are created, having a validator + // instance per POA may introduce additional delays in policy + // validation and hence, the overal policy creation time. Since this + // is out of the critical invocation processing path, I plan to keep + // the design simple and not try to avoid an ineficiency of such + // small proportions. + val.add_validator (validator); +} + +int +TAO_ZIOP_Loader::Initializer (void) +{ + return ACE_Service_Config::process_directive (ace_svc_desc_TAO_ZIOP_Loader); +} + +bool +TAO_ZIOP_Loader::decompress (TAO_ServerRequest& server_request) +{ + CORBA::Object_var compression_manager = + server_request.orb_core()->resolve_compression_manager(); + + Compression::CompressionManager_var manager = + Compression::CompressionManager::_narrow (compression_manager.in ()); + + if (!CORBA::is_nil(manager.in ())) + { + ZIOP::CompressedData data; + if (!(*(server_request.incoming()) >> data)) + return false; + + Compression::Compressor_var compressor = manager->get_compressor (data.compressorid, 6); + CORBA::OctetSeq myout; + myout.length (data.original_length); + + compressor->decompress (data.data, myout); + TAO_InputCDR* newstream = new TAO_InputCDR ((char*)myout.get_buffer(true), (size_t)data.original_length); + server_request.incoming()->steal_from (*newstream); + } + else + { + return false; + } + + return true; +} + +CORBA::ULong +TAO_ZIOP_Loader::compression_low_value (TAO::Profile_Transport_Resolver &resolver) const +{ + CORBA::ULong result = 0; + CORBA::Policy_var policy = CORBA::Policy::_nil (); + + if (resolver.stub () == 0) + { + policy = + resolver.stub()->orb_core()->get_cached_policy_including_current (TAO_CACHED_COMPRESSION_LOW_VALUE_POLICY); + } + else + { + policy = resolver.stub ()->get_cached_policy (TAO_CACHED_COMPRESSION_LOW_VALUE_POLICY); + } + + if (!CORBA::is_nil (policy.in ())) + { + ZIOP::CompressionLowValuePolicy_var srp = + ZIOP::CompressionLowValuePolicy::_narrow (policy.in ()); + + if (!CORBA::is_nil (srp.in ())) + { + result = srp->low_value (); + } + } + + return result; +} + +bool +TAO_ZIOP_Loader::compress (Compression::Compressor_ptr compressor, + const ::Compression::Buffer &source, + ::Compression::Buffer &target) +{ + try + { + compressor->compress (source, target); + } + catch (...) + { + return false; + } + + return true; +} + +bool +TAO_ZIOP_Loader::check_min_ratio (CORBA::ULong /* original_data_length */, CORBA::ULong /*compressed_length*/) const +{ +/* CORBA::ULong ratio = 100 - (compressed_length /original_length) * 100; + if (resolver.stub () == 0) + { + policy = + resolver.stub()->orb_core()->get_cached_policy_including_current (TAO_CACHED_COMPRESSION_ENABLING_POLICY); + } + else + { + policy = resolver.stub ()->get_cached_policy (TAO_CACHED_COMPRESSION_ENABLING_POLICY); + }*/ + return true; +} + +bool +TAO_ZIOP_Loader::marshal_data (TAO_Operation_Details &details, TAO_OutputCDR &stream, TAO::Profile_Transport_Resolver &resolver) +{ +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP == 0 + ACE_UNUSED_ARG (details); + ACE_UNUSED_ARG (stream); + ACE_UNUSED_ARG (resolver); +#else + CORBA::Boolean use_ziop = false; + Compression::CompressorId compressor_id = Compression::COMPRESSORID_ZLIB; + Compression::CompressionLevel compression_level = 0; + + CORBA::Policy_var policy = resolver.stub ()->get_cached_policy (TAO_CACHED_COMPRESSION_ENABLING_POLICY); + + if (!CORBA::is_nil (policy.in ())) + { + ZIOP::CompressionEnablingPolicy_var srp = + ZIOP::CompressionEnablingPolicy::_narrow (policy.in ()); + + if (!CORBA::is_nil (srp.in ())) + { + use_ziop = srp->compression_enabled (); + } + } + + if (use_ziop) + { + policy = resolver.stub ()->get_cached_policy (TAO_CACHED_COMPRESSION_ID_LEVEL_LIST_POLICY); + + if (!CORBA::is_nil (policy.in ())) + { + ZIOP::CompressorIdLevelListPolicy_var srp = + ZIOP::CompressorIdLevelListPolicy::_narrow (policy.in ()); + + if (!CORBA::is_nil (srp.in ())) + { + ::Compression::CompressorIdLevelList* list = srp->compressor_ids (); + if (list) + { + compressor_id = (*list)[0].compressor_id; + compression_level = (*list)[0].compression_level; + } + else + { + // No compatible compressor found + use_ziop = false; + } + } + } + } + + ACE_Message_Block* current = const_cast <ACE_Message_Block*> (stream.current ()); + + if (use_ziop) + { + // Set the read pointer to the point where the application data starts + current->rd_ptr (current->wr_ptr()); + } + + // Marshal application data + if (!details.marshal_args (stream)) + { + throw ::CORBA::MARSHAL (); + } + + current = const_cast <ACE_Message_Block*> (stream.current()); + CORBA::ULong const original_data_length =(CORBA::ULong)(current->wr_ptr() - current->rd_ptr()); + + if (use_ziop && original_data_length > 0) + { + // We can only compress one message block, so when compression is enabled first do + // a consolidate. + stream.consolidate (); + + CORBA::Object_var compression_manager = + resolver.stub()->orb_core()->resolve_compression_manager(); + + Compression::CompressionManager_var manager = + Compression::CompressionManager::_narrow (compression_manager.in ()); + + if (!CORBA::is_nil(manager.in ())) + { + Compression::Compressor_var compressor = manager->get_compressor (compressor_id, compression_level); + + if (original_data_length > this->compression_low_value (resolver)) + { + CORBA::OctetSeq myout; + CORBA::OctetSeq input (original_data_length, current); + myout.length (original_data_length); + + bool compressed = this->compress (compressor.in (), input, myout); + + if (compressed && (myout.length () < original_data_length) && (this->check_min_ratio (original_data_length, myout.length()))) + { + stream.compressed (true); + current->wr_ptr (current->rd_ptr ()); + stream.current_alignment (current->wr_ptr() - current->base ()); + ZIOP::CompressedData data; + data.compressorid = compressor_id; + data.original_length = input.length(); + data.data = myout; + stream << data; + } + } + } + } + + // Set the read pointer back to the starting point + current->rd_ptr (current->base ()); +#endif + + return true; +} + +bool +TAO_ZIOP_Loader::marshal_reply_data (TAO_ServerRequest& server_request, + TAO::Argument * const * args, + size_t nargs) +{ +#if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP == 0 + ACE_UNUSED_ARG (server_request); + ACE_UNUSED_ARG (args); + ACE_UNUSED_ARG (nargs); +#else + CORBA::Boolean use_ziop = false; + Compression::CompressorId compressor_id = Compression::COMPRESSORID_ZLIB; + Compression::CompressionLevel compression_level = 0; + TAO_Transport& transport = *server_request.transport (); + + CORBA::Policy_var policy = transport.orb_core()->get_cached_policy_including_current (TAO_CACHED_COMPRESSION_ENABLING_POLICY); + + if (!CORBA::is_nil (policy.in ())) + { + ZIOP::CompressionEnablingPolicy_var srp = + ZIOP::CompressionEnablingPolicy::_narrow (policy.in ()); + + if (!CORBA::is_nil (srp.in ())) + { + use_ziop = srp->compression_enabled (); + } + } + + if (use_ziop) + { + policy = transport.orb_core()->get_cached_policy_including_current (TAO_CACHED_COMPRESSION_ID_LEVEL_LIST_POLICY); + + if (!CORBA::is_nil (policy.in ())) + { + ZIOP::CompressorIdLevelListPolicy_var srp = + ZIOP::CompressorIdLevelListPolicy::_narrow (policy.in ()); + + if (!CORBA::is_nil (srp.in ())) + { + ::Compression::CompressorIdLevelList* list = srp->compressor_ids (); + if (list) + { + compressor_id = (*list)[0].compressor_id; + compression_level = (*list)[0].compression_level; + } + else + { + // No compatible compressor found + use_ziop = false; + } + } + } + } + + TAO_OutputCDR & stream = (*server_request.outgoing ()); + ACE_Message_Block* current = const_cast <ACE_Message_Block*> (stream.current ()); + + if (use_ziop) + { + // Set the read pointer to the point where the application data starts + current->rd_ptr (current->wr_ptr()); + } + + // Marshal application data + TAO::Argument * const * const begin = args; + TAO::Argument * const * const end = args + nargs; + + for (TAO::Argument * const * i = begin; i != end; ++i) + { + if (!(*i)->marshal (stream)) + { + TAO_OutputCDR::throw_skel_exception (errno); + } + } + + // Reply body marshaling completed. No other fragments to send. + stream.more_fragments (false); + + current = const_cast <ACE_Message_Block*> (stream.current()); + CORBA::ULong const original_data_length =(CORBA::ULong)(current->wr_ptr() - current->rd_ptr()); + + if (use_ziop && original_data_length > 0) + { + // We can only compress one message block, so when compression is enabled first do + // a consolidate. + stream.consolidate (); + + CORBA::Object_var compression_manager = + server_request.transport ()->orb_core()->resolve_compression_manager(); + + Compression::CompressionManager_var manager = + Compression::CompressionManager::_narrow (compression_manager.in ()); + + if (!CORBA::is_nil(manager.in ())) + { + Compression::Compressor_var compressor = manager->get_compressor (compressor_id, compression_level); + +// if (original_data_length > this->compression_low_value (resolver) + if (1) + { + CORBA::OctetSeq myout; + CORBA::OctetSeq input (original_data_length, current); + myout.length (original_data_length); + + bool compressed = this->compress (compressor.in (), input, myout); + + if (compressed && (myout.length () < original_data_length)) // && (this->check_min_ratio (original_data_length, myout.length()))) + { + stream.compressed (true); + current->wr_ptr (current->rd_ptr ()); + stream.current_alignment (current->wr_ptr() - current->base ()); + ZIOP::CompressedData data; + data.compressorid = compressor_id; + data.original_length = input.length(); + data.data = myout; + stream << data; + } + } + } + } + + // Set the read pointer back to the starting point + current->rd_ptr (current->base ()); +#endif + + return true; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DEFINE (TAO_ZIOP_Loader, + ACE_TEXT ("ZIOP_Loader"), + ACE_SVC_OBJ_T, + &ACE_SVC_NAME (TAO_ZIOP_Loader), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, + 0) + +ACE_FACTORY_DEFINE (TAO_ZIOP, TAO_ZIOP_Loader) + diff --git a/TAO/tao/ZIOP/ZIOP.h b/TAO/tao/ZIOP/ZIOP.h new file mode 100644 index 00000000000..8d4f0fd5acf --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP.h @@ -0,0 +1,99 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ZIOP.h + * + * $Id$ + * + * Dynamic loader object for the ZIOP library + * + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +//============================================================================= + +#ifndef TAO_ZIOP_H +#define TAO_ZIOP_H +#include /**/ "ace/pre.h" + +#include "tao/ZIOP/ziop_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/ZIOP_Adapter.h" +#include "tao/Compression/Compression.h" +#include "tao/Policy_Validator.h" +#include "ace/Service_Config.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class TAO_ZIOP_Loader + * + * @brief Class that loads the BiDir library. + */ + +class TAO_ZIOP_Export TAO_ZIOP_Loader : public TAO_ZIOP_Adapter +{ +public: + + /// Constructor + TAO_ZIOP_Loader (void); + + /// Destructor + virtual ~TAO_ZIOP_Loader (void); + + virtual bool decompress (TAO_ServerRequest& server_request); + + // Compress the @a stream. Starting point of the compression is rd_ptr() + virtual bool marshal_data (TAO_Operation_Details &details, TAO_OutputCDR &stream, TAO::Profile_Transport_Resolver &resolver); + + /// Initialize the BiDIR loader hooks. + virtual int init (int argc, ACE_TCHAR* []); + + virtual void load_policy_validators (TAO_Policy_Validator &validator); + + /// Used to force the initialization of the ORB code. + static int Initializer (void); + + bool marshal_reply_data (TAO_ServerRequest& server_request, + TAO::Argument * const * args, + size_t nargs); + +private: + + /// Flag to indicate whether the ZIOP library has been + /// activated. + static bool is_activated_; + + /// Get the compression low value, returns 0 when it is not set + CORBA::ULong compression_low_value (TAO::Profile_Transport_Resolver &resolver) const; + + bool compress (Compression::Compressor_ptr compressor, + const ::Compression::Buffer &source, + ::Compression::Buffer &target); + + bool check_min_ratio (CORBA::ULong original_data_length, CORBA::ULong compressed_length) const; +}; + +static int +TAO_Requires_ZIOP_Initializer = TAO_ZIOP_Loader::Initializer (); + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DECLARE (TAO_ZIOP_Loader) +ACE_FACTORY_DECLARE (TAO_ZIOP, TAO_ZIOP_Loader) + + +#define TAO_ZIOP_SAFE_INCLUDE +#include "tao/ZIOP/ZIOPC.h" +#undef TAO_ZIOP_SAFE_INCLUDE + +#include /**/ "ace/post.h" +#endif /* TAO_ZIOP_H */ + + diff --git a/TAO/tao/ZIOP/ZIOP.pidl b/TAO/tao/ZIOP/ZIOP.pidl new file mode 100644 index 00000000000..3cd17e32702 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP.pidl @@ -0,0 +1,60 @@ +// $Id$ + +#include "tao/Policy.pidl" +#include "tao/IOP.pidl" +#include "tao/Compression/Compression_include.pidl" + +module ZIOP +{ + struct CompressedData { + Compression::CompressorId compressorid; + unsigned long original_length; + Compression::Buffer data; + }; + + // + // ORB Policies for ZIOP + // + + /** + * Tag Id for CompressionEnablingPolicy + */ + const CORBA::PolicyType COMPRESSION_ENABLING_POLICY_ID = 5555; + + /** + * The ZIOP CompressionEnablingPolicy. Has an boolean attribute indicating + * if compression is enabled or not. + */ + local interface CompressionEnablingPolicy : CORBA::Policy + { + readonly attribute boolean compression_enabled; + }; + + /** + * Tag Id for CompressorIdPolicy + */ + const CORBA::PolicyType COMPRESSOR_ID_LEVEL_LIST_POLICY_ID = 5556; + + /** + * The ZIOP CompressorIdListPolicy. Has an CompressorId attribute indicating + * the compression algorithm to be used. + */ + local interface CompressorIdLevelListPolicy : CORBA::Policy + { + readonly attribute Compression::CompressorIdLevelList compressor_ids; + }; + + const CORBA::PolicyType COMPRESSION_LOW_VALUE_POLICY_ID = 5557; + + local interface CompressionLowValuePolicy : CORBA::Policy + { + readonly attribute unsigned long low_value; + }; + + const CORBA::PolicyType COMPRESSION_MIN_RATIO_POLICY_ID = 5558; + + local interface CompressionMinRatioPolicy : CORBA::Policy + { + readonly attribute unsigned long ratio; + }; +}; diff --git a/TAO/tao/ZIOP/ZIOP_ORBInitializer.cpp b/TAO/tao/ZIOP/ZIOP_ORBInitializer.cpp new file mode 100644 index 00000000000..61b3eefcf93 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_ORBInitializer.cpp @@ -0,0 +1,104 @@ +// $Id$ + +#include "tao/ZIOP/ZIOP_ORBInitializer.h" + +#include "tao/ZIOP/ZIOP.h" +#include "tao/ZIOP/ZIOP_Stub_Factory.h" +#include "tao/ZIOP/ZIOP_PolicyFactory.h" +#include "tao/ORB_Core.h" +#include "tao/PI/ORBInitInfo.h" + +ACE_RCSID (ZIOP, + ZIOP_ORBInitializer, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_ZIOP_ORBInitializer::TAO_ZIOP_ORBInitializer (TAO_ZIOP_Loader* loader) : loader_ (loader) +{ +} + +void +TAO_ZIOP_ORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr info) +{ + // Narrow to a TAO_ORBInitInfo object to get access to the + // orb_core() TAO extension. + TAO_ORBInitInfo_var tao_info = TAO_ORBInitInfo::_narrow (info); + + if (CORBA::is_nil (tao_info.in ())) + { + if (TAO_debug_level > 0) + ACE_ERROR ((LM_ERROR, + "(%P|%t) TAO_ZIOP_ORBInitializer::pre_init:\n" + "(%P|%t) Unable to narrow " + "\"PortableInterceptor::ORBInitInfo_ptr\" to\n" + "(%P|%t) \"TAO_ORBInitInfo *.\"\n")); + + throw ::CORBA::INTERNAL (); + } + + tao_info->orb_core ()->ziop_adapter (this->loader_); + // Set the name of the stub factory to be ZIOP_Stub_Factory. + tao_info->orb_core ()->orb_params ()->stub_factory_name ("ZIOP_Stub_Factory"); + ACE_Service_Config::process_directive (ace_svc_desc_TAO_ZIOP_Stub_Factory); +} + +void +TAO_ZIOP_ORBInitializer::post_init (PortableInterceptor::ORBInitInfo_ptr info) +{ + this->register_policy_factories (info); +} + +void +TAO_ZIOP_ORBInitializer::register_policy_factories ( + PortableInterceptor::ORBInitInfo_ptr info) +{ + // Register the ZIOP policy factories. + PortableInterceptor::PolicyFactory_ptr policy_factory_ptr; + ACE_NEW_THROW_EX (policy_factory_ptr, + TAO_ZIOP_PolicyFactory, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + + PortableInterceptor::PolicyFactory_var policy_factory = + policy_factory_ptr; + + try + { + info->register_policy_factory (ZIOP::COMPRESSION_ENABLING_POLICY_ID, + policy_factory.in ()); + + info->register_policy_factory (ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID, + policy_factory.in ()); + + info->register_policy_factory (ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID, + policy_factory.in ()); + + info->register_policy_factory (ZIOP::COMPRESSION_MIN_RATIO_POLICY_ID, + policy_factory.in ()); + } + catch (const CORBA::BAD_INV_ORDER& ex) + { + if (ex.minor () == (CORBA::OMGVMCID | 16)) + { + // The factory is already there, it happens because the + // magic initializer in Messaging.cpp registers with the + // ORB multiple times. This is an indication that we + // should do no more work in this ORBInitializer. + return; + } + throw; + } + catch (...) + { + // Rethrow any other exceptions... + throw; + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + diff --git a/TAO/tao/ZIOP/ZIOP_ORBInitializer.h b/TAO/tao/ZIOP/ZIOP_ORBInitializer.h new file mode 100644 index 00000000000..ff170b69b32 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_ORBInitializer.h @@ -0,0 +1,76 @@ +// -*- C -*- + +//============================================================================= +/** + * @file ZIOP_ORBInitializer.h + * + * $Id$ + * +* @author Johnny Willemsen + */ +//============================================================================= + + +#ifndef TAO_ZIOP_ORB_INITIALIZER_H +#define TAO_ZIOP_ORB_INITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "tao/ZIOP/ziop_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +class TAO_ZIOP_Loader; + +/// ZIOP ORB initializer. +class TAO_ZIOP_ORBInitializer + : public virtual PortableInterceptor::ORBInitializer, + public virtual ::CORBA::LocalObject +{ +public: + TAO_ZIOP_ORBInitializer (TAO_ZIOP_Loader* loader); + + /** + * @name PortableInterceptor::ORBInitializer Methods + * + * The following methods are required by the + * PortableInterceptor::ORBInitializer interface. + */ + //@{ + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info); + //@} + +private: + + /// Register policy factories. + void register_policy_factories (PortableInterceptor::ORBInitInfo_ptr info); + + TAO_ZIOP_Loader* loader_; +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" + +#endif /* TAO_ZIOP_ORB_INITIALIZER_H */ + diff --git a/TAO/tao/ZIOP/ZIOP_PolicyFactory.cpp b/TAO/tao/ZIOP/ZIOP_PolicyFactory.cpp new file mode 100644 index 00000000000..14b86a17383 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_PolicyFactory.cpp @@ -0,0 +1,148 @@ +#include "tao/ZIOP/ZIOP_PolicyFactory.h" +#include "tao/ZIOP/ZIOP.h" +#include "tao/ZIOP/ZIOP_Policy_i.h" + +#include "tao/ORB_Constants.h" +#include "tao/AnyTypeCode/Any.h" + +ACE_RCSID (ZIOP_GIOP, + ZIOP_PolicyFactory, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +CORBA::Policy_ptr +TAO_ZIOP_PolicyFactory::create_policy ( + CORBA::PolicyType type, + const CORBA::Any &value) +{ + CORBA::Policy_ptr policy = CORBA::Policy::_nil (); + + switch (type) + { + case ZIOP::COMPRESSION_ENABLING_POLICY_ID: + { + ::CORBA::Boolean val; + + // Extract the value from the any. + + if (!(value >>= CORBA::Any::to_boolean (val))) + { + throw CORBA::PolicyError (CORBA::BAD_POLICY_VALUE); + } + + ACE_NEW_THROW_EX (policy, + TAO::CompressionEnablingPolicy (val), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + return policy; + } + case ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID : + { + ::Compression::CompressorIdLevelList* val = 0; + + // Extract the value from the any. + if (!(value >>= val)) + { + throw CORBA::PolicyError (CORBA::BAD_POLICY_VALUE); + } + + ACE_NEW_THROW_EX (policy, + TAO::CompressorIdLevelListPolicy (*val), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + return policy; + } + case ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID: + { + ::CORBA::ULong val; + + // Extract the value from the any. + + if (!(value >>= val)) + { + throw CORBA::PolicyError (CORBA::BAD_POLICY_VALUE); + } + + ACE_NEW_THROW_EX (policy, + TAO::CompressionLowValuePolicy (val), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + return policy; + } + case ZIOP::COMPRESSION_MIN_RATIO_POLICY_ID: + { + ::CORBA::ULong val; + + // Extract the value from the any. + + if (!(value >>= val)) + { + throw CORBA::PolicyError (CORBA::BAD_POLICY_VALUE); + } + + ACE_NEW_THROW_EX (policy, + TAO::CompressionMinRatioPolicy (val), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + return policy; + } + } + + throw CORBA::PolicyError (CORBA::BAD_POLICY_TYPE); +} + +CORBA::Policy_ptr +TAO_ZIOP_PolicyFactory::_create_policy (CORBA::PolicyType type) +{ + CORBA::Policy_ptr policy = CORBA::Policy_ptr (); + + switch (type) + { + case ZIOP::COMPRESSION_ENABLING_POLICY_ID: + { + ACE_NEW_THROW_EX (policy, + TAO::CompressionEnablingPolicy, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + return policy; + } + case ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID: + { + ACE_NEW_THROW_EX (policy, + TAO::CompressorIdLevelListPolicy, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + return policy; + } + } + throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE); +} + + +TAO_END_VERSIONED_NAMESPACE_DECL + diff --git a/TAO/tao/ZIOP/ZIOP_PolicyFactory.h b/TAO/tao/ZIOP/ZIOP_PolicyFactory.h new file mode 100644 index 00000000000..b9ae1161bb0 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_PolicyFactory.h @@ -0,0 +1,56 @@ +// -*- C -*- +// +// =================================================================== +/** + * @file ZIOP_PolicyFactory.h + * + * $Id$ + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +// =================================================================== +#ifndef TAO_ZIOP_POLICY_FACTORY_H +#define TAO_ZIOP_POLICY_FACTORY_H + +#include /**/ "ace/pre.h" + +#include "tao/ZIOP/ziop_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable:4250) +#endif /* _MSC_VER */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/// Policy factory for all Messaging related policies. +class TAO_ZIOP_PolicyFactory + : public PortableInterceptor::PolicyFactory + , public ::CORBA::LocalObject +{ +public: + virtual CORBA::Policy_ptr create_policy (CORBA::PolicyType type, + const CORBA::Any & value); + + virtual CORBA::Policy_ptr _create_policy (CORBA::PolicyType type); +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" + +#endif /* TAO_ZIOP_POLICY_FACTORY_H */ + diff --git a/TAO/tao/ZIOP/ZIOP_Policy_Validator.cpp b/TAO/tao/ZIOP/ZIOP_Policy_Validator.cpp new file mode 100644 index 00000000000..4690d2a39ce --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_Policy_Validator.cpp @@ -0,0 +1,104 @@ +#include "tao/ZIOP/ZIOP_Policy_Validator.h" +#include "tao/ZIOP/ZIOP_Policy_i.h" +#include "tao/Policy_Set.h" +#include "tao/ORB_Core.h" + +ACE_RCSID (ZIOP_GIOP, + ZIOPPolicy_Validator, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_ZIOPPolicy_Validator::TAO_ZIOPPolicy_Validator (TAO_ORB_Core &orb_core) + : TAO_Policy_Validator (orb_core) +{ +} + + +void +TAO_ZIOPPolicy_Validator::validate_impl (TAO_Policy_Set &policies) +{ + CORBA::Policy_var policy = + policies.get_cached_policy (TAO_CACHED_COMPRESSION_ENABLING_POLICY); + + if (policy.in () == 0) + return; + + ZIOP::CompressionEnablingPolicy_var srp = + ZIOP::CompressionEnablingPolicy::_narrow (policy.in ()); + + if (srp.in () == 0) + return; + + // Set the flag in the ORB_Core + orb_core_.ziop_enabled (srp->compression_enabled ()); +} + +void +TAO_ZIOPPolicy_Validator::merge_policies_impl (TAO_Policy_Set &policies) +{ + // Check if the user has specified the priority model policy. + CORBA::Policy_var priority_model = + policies.get_cached_policy (TAO_CACHED_COMPRESSION_ENABLING_POLICY); + + if (CORBA::is_nil (priority_model.in ())) + { + // If not, check if the priority model policy has been specified + // at the ORB level. + priority_model = + this->orb_core_.get_cached_policy (TAO_CACHED_COMPRESSION_ENABLING_POLICY); + + if (!CORBA::is_nil (priority_model.in ())) + { + // If so, we'll use that policy. + policies.set_policy (priority_model.in ()); + } + } + + // Check if the user has specified the server protocol policy. + CORBA::Policy_var server_protocol = + policies.get_cached_policy (TAO_CACHED_COMPRESSION_LOW_VALUE_POLICY); + + if (CORBA::is_nil (server_protocol.in ())) + { + // If not, check if the server protocol policy has been + // specified at the ORB level. + server_protocol = + this->orb_core_.get_cached_policy (TAO_CACHED_COMPRESSION_LOW_VALUE_POLICY); + + if (!CORBA::is_nil (server_protocol.in ())) + { + // If so, we'll use that policy. + policies.set_policy (server_protocol.in ()); + } + } + + // Check if the user has specified the server protocol policy. + CORBA::Policy_var x = + policies.get_cached_policy (TAO_CACHED_COMPRESSION_ID_LEVEL_LIST_POLICY); + + if (CORBA::is_nil (x.in ())) + { + // If not, check if the server protocol policy has been + // specified at the ORB level. + x = + this->orb_core_.get_cached_policy (TAO_CACHED_COMPRESSION_ID_LEVEL_LIST_POLICY); + + if (!CORBA::is_nil (x.in ())) + { + // If so, we'll use that policy. + policies.set_policy (x.in ()); + } + } +} + +CORBA::Boolean +TAO_ZIOPPolicy_Validator::legal_policy_impl (CORBA::PolicyType type) +{ + return (type == ZIOP::COMPRESSION_ENABLING_POLICY_ID || + type == ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID || + type == ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + diff --git a/TAO/tao/ZIOP/ZIOP_Policy_Validator.h b/TAO/tao/ZIOP/ZIOP_Policy_Validator.h new file mode 100644 index 00000000000..59c98c67547 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_Policy_Validator.h @@ -0,0 +1,56 @@ +// -*- C -*- + +//============================================================================= +/** + * @file ZIOP_Policy_Validator.h + * + * $Id$ + * + * This file contains the declaration for the ZIOP policy validator + * interface. + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +//============================================================================= + +#ifndef TAO_ZIOP_POLICY_VALIDATOR_H_ +#define TAO_ZIOP_POLICY_VALIDATOR_H_ + +#include /**/ "ace/pre.h" +#include "tao/ZIOP/ZIOP_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "tao/Policy_Validator.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +class TAO_Policy_Set; +class TAO_ORB_Core; + +/** + * @class TAO_ZIOPPolicy_Validator + * + * @brief Policy Validator for ZIOP policies + * + */ +class TAO_ZIOP_Export TAO_ZIOPPolicy_Validator : public TAO_Policy_Validator +{ +public: + + TAO_ZIOPPolicy_Validator (TAO_ORB_Core &orb_core); + + virtual void validate_impl (TAO_Policy_Set &policies); + + virtual void merge_policies_impl (TAO_Policy_Set &policies); + + virtual CORBA::Boolean legal_policy_impl (CORBA::PolicyType type); +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* TAO_ZIOP_POLICY_VALIDATOR_H_ */ + + diff --git a/TAO/tao/ZIOP/ZIOP_Policy_i.cpp b/TAO/tao/ZIOP/ZIOP_Policy_i.cpp new file mode 100644 index 00000000000..05bef28edd1 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_Policy_i.cpp @@ -0,0 +1,358 @@ +// $Id$ + +#include "tao/ZIOP/ZIOP_Policy_i.h" + +#include "tao/CDR.h" +#include "tao/Stub.h" +#include "tao/debug.h" +#include "tao/ORB_Constants.h" + +ACE_RCSID (ZIOP, + ZIOP_Policy_i, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ +CompressorIdLevelListPolicy::CompressorIdLevelListPolicy ( + const ::Compression::CompressorIdLevelList& val) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::ZIOP::CompressorIdLevelListPolicy () + , ::CORBA::LocalObject () + , value_ (val) +{ +} + +CompressorIdLevelListPolicy::CompressorIdLevelListPolicy (void) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::ZIOP::CompressorIdLevelListPolicy () + , ::CORBA::LocalObject () + , value_ (0) +{ +} + +CompressorIdLevelListPolicy::CompressorIdLevelListPolicy (const CompressorIdLevelListPolicy &rhs) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::ZIOP::CompressorIdLevelListPolicy () + , ::CORBA::LocalObject () + , value_ (rhs.value_) +{ +} + +CORBA::PolicyType +CompressorIdLevelListPolicy::policy_type (void) +{ + // Future policy implementors: notice how this minimizes the + // footprint of the class. + return ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID; +} + + +CompressorIdLevelListPolicy * +CompressorIdLevelListPolicy::clone (void) const +{ + CompressorIdLevelListPolicy *copy = 0; + ACE_NEW_RETURN (copy, + CompressorIdLevelListPolicy (*this), + 0); + return copy; +} + +CORBA::Policy_ptr +CompressorIdLevelListPolicy::copy (void) +{ + CompressorIdLevelListPolicy* tmp = 0; + ACE_NEW_THROW_EX (tmp, CompressorIdLevelListPolicy (*this), + CORBA::NO_MEMORY (TAO::VMCID, + CORBA::COMPLETED_NO)); + + return tmp; +} + +void +CompressorIdLevelListPolicy::destroy (void) +{ +} + +::Compression::CompressorIdLevelList * +CompressorIdLevelListPolicy::compressor_ids (void) +{ + ::Compression::CompressorIdLevelList *tmp = 0; + ACE_NEW_THROW_EX (tmp, + ::Compression::CompressorIdLevelList (this->value_), + CORBA::NO_MEMORY (TAO::VMCID, + CORBA::COMPLETED_NO)); + + return tmp; +} + +TAO_Cached_Policy_Type +CompressorIdLevelListPolicy::_tao_cached_type (void) const +{ + return TAO_CACHED_COMPRESSION_ID_LEVEL_LIST_POLICY; +} + +TAO_Policy_Scope +CompressorIdLevelListPolicy::_tao_scope (void) const +{ + return static_cast<TAO_Policy_Scope> (TAO_POLICY_DEFAULT_SCOPE | + TAO_POLICY_CLIENT_EXPOSED); +} + +CORBA::Boolean +CompressorIdLevelListPolicy::_tao_encode (TAO_OutputCDR &out_cdr) +{ + return out_cdr << this->value_; +} + +CORBA::Boolean +CompressorIdLevelListPolicy::_tao_decode (TAO_InputCDR &in_cdr) +{ + return in_cdr >> this->value_; +} + +CompressionEnablingPolicy::CompressionEnablingPolicy ( + const ::CORBA::Boolean val) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::ZIOP::CompressionEnablingPolicy () + , ::CORBA::LocalObject () + , value_ (val) +{ +} + +CompressionEnablingPolicy::CompressionEnablingPolicy (void) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::ZIOP::CompressionEnablingPolicy () + , ::CORBA::LocalObject () + , value_ (false) +{ +} + +CompressionEnablingPolicy::CompressionEnablingPolicy (const CompressionEnablingPolicy &rhs) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::ZIOP::CompressionEnablingPolicy () + , ::CORBA::LocalObject () + , value_ (rhs.value_) +{ +} + +CORBA::PolicyType +CompressionEnablingPolicy::policy_type (void) +{ + // Future policy implementors: notice how this minimizes the + // footprint of the class. + return ZIOP::COMPRESSION_ENABLING_POLICY_ID; +} + + +CompressionEnablingPolicy * +CompressionEnablingPolicy::clone (void) const +{ + CompressionEnablingPolicy *copy = 0; + ACE_NEW_RETURN (copy, + CompressionEnablingPolicy (*this), + 0); + return copy; +} + +CORBA::Policy_ptr +CompressionEnablingPolicy::copy (void) +{ + // Future policy implementors: notice how the following code is + // exception safe! + + CompressionEnablingPolicy* tmp = 0; + ACE_NEW_THROW_EX (tmp, CompressionEnablingPolicy (*this), + CORBA::NO_MEMORY (TAO::VMCID, + CORBA::COMPLETED_NO)); + + return tmp; +} + +void +CompressionEnablingPolicy::destroy (void) +{ +} + +::CORBA::Boolean +CompressionEnablingPolicy::compression_enabled (void) +{ + return this->value_; +} + + +TAO_Cached_Policy_Type +CompressionEnablingPolicy::_tao_cached_type (void) const +{ + return TAO_CACHED_COMPRESSION_ENABLING_POLICY; +} + +TAO_Policy_Scope +CompressionEnablingPolicy::_tao_scope (void) const +{ + return static_cast<TAO_Policy_Scope> (TAO_POLICY_DEFAULT_SCOPE | + TAO_POLICY_CLIENT_EXPOSED); +} + +CORBA::Boolean +CompressionEnablingPolicy::_tao_encode (TAO_OutputCDR &out_cdr) +{ + return out_cdr << ACE_OutputCDR::from_boolean (this->value_); +} + +CORBA::Boolean +CompressionEnablingPolicy::_tao_decode (TAO_InputCDR &in_cdr) +{ + return in_cdr >> ACE_InputCDR::to_boolean (this->value_); +} + +CompressionLowValuePolicy::CompressionLowValuePolicy ( + const ::CORBA::ULong val) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::ZIOP::CompressionLowValuePolicy () + , ::CORBA::LocalObject () + , value_ (val) +{ +} + +CompressionLowValuePolicy::CompressionLowValuePolicy (const CompressionLowValuePolicy &rhs) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::ZIOP::CompressionLowValuePolicy () + , ::CORBA::LocalObject () + , value_ (rhs.value_) +{ +} + +CORBA::PolicyType +CompressionLowValuePolicy::policy_type (void) +{ + // Future policy implementors: notice how this minimizes the + // footprint of the class. + return ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID; +} + + +CompressionLowValuePolicy * +CompressionLowValuePolicy::clone (void) const +{ + CompressionLowValuePolicy *copy = 0; + ACE_NEW_RETURN (copy, + CompressionLowValuePolicy (*this), + 0); + return copy; +} + +CORBA::Policy_ptr +CompressionLowValuePolicy::copy (void) +{ + // Future policy implementors: notice how the following code is + // exception safe! + + CompressionLowValuePolicy* tmp = 0; + ACE_NEW_THROW_EX (tmp, CompressionLowValuePolicy (*this), + CORBA::NO_MEMORY (TAO::VMCID, + CORBA::COMPLETED_NO)); + + return tmp; +} + +void +CompressionLowValuePolicy::destroy (void) +{ +} + +::CORBA::ULong +CompressionLowValuePolicy::low_value (void) +{ + return this->value_; +} + + +TAO_Cached_Policy_Type +CompressionLowValuePolicy::_tao_cached_type (void) const +{ + return TAO_CACHED_COMPRESSION_LOW_VALUE_POLICY; +} + +CompressionMinRatioPolicy::CompressionMinRatioPolicy ( + const ::CORBA::ULong val) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::ZIOP::CompressionMinRatioPolicy () + , ::CORBA::LocalObject () + , value_ (val) +{ +} + +CompressionMinRatioPolicy::CompressionMinRatioPolicy (const CompressionMinRatioPolicy &rhs) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::ZIOP::CompressionMinRatioPolicy () + , ::CORBA::LocalObject () + , value_ (rhs.value_) +{ +} + +CORBA::PolicyType +CompressionMinRatioPolicy::policy_type (void) +{ + // Future policy implementors: notice how this minimizes the + // footprint of the class. + return ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID; +} + + +CompressionMinRatioPolicy * +CompressionMinRatioPolicy::clone (void) const +{ + CompressionMinRatioPolicy *copy = 0; + ACE_NEW_RETURN (copy, + CompressionMinRatioPolicy (*this), + 0); + return copy; +} + +CORBA::Policy_ptr +CompressionMinRatioPolicy::copy (void) +{ + // Future policy implementors: notice how the following code is + // exception safe! + + CompressionMinRatioPolicy* tmp = 0; + ACE_NEW_THROW_EX (tmp, CompressionMinRatioPolicy (*this), + CORBA::NO_MEMORY (TAO::VMCID, + CORBA::COMPLETED_NO)); + + return tmp; +} + +void +CompressionMinRatioPolicy::destroy (void) +{ +} + +::CORBA::ULong +CompressionMinRatioPolicy::ratio (void) +{ + return this->value_; +} + + +TAO_Cached_Policy_Type +CompressionMinRatioPolicy::_tao_cached_type (void) const +{ + return TAO_CACHED_POLICY_UNCACHED; +} + +} +TAO_END_VERSIONED_NAMESPACE_DECL + diff --git a/TAO/tao/ZIOP/ZIOP_Policy_i.h b/TAO/tao/ZIOP/ZIOP_Policy_i.h new file mode 100644 index 00000000000..fb0476b0a77 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_Policy_i.h @@ -0,0 +1,210 @@ +// -*- C -*- + +// =================================================================== +/** + * @file ZIOP_Policy_i.h + * + * $Id$ + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +// =================================================================== + +#ifndef TAO_ZIOP_POLICY_I_H +#define TAO_ZIOP_POLICY_I_H +#include /**/ "ace/pre.h" +#include "tao/ZIOP/ziop_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/ZIOP/ZIOP.h" +#include "tao/LocalObject.h" + +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable:4250) +#endif /* _MSC_VER */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ +/** + * @class CompressorIdPolicy + * + * @brief Implementation of the ZIOP::CompressorIdPolicy + */ +class CompressorIdLevelListPolicy + : public virtual ::ZIOP::CompressorIdLevelListPolicy + , public virtual ::CORBA::LocalObject +{ +public: + CompressorIdLevelListPolicy (void); + + /// Constructor. + CompressorIdLevelListPolicy (const ::Compression::CompressorIdLevelList& val); + + /// Copy constructor. + CompressorIdLevelListPolicy (const CompressorIdLevelListPolicy &rhs); + + /// Returns a copy of <this>. + virtual CompressorIdLevelListPolicy *clone (void) const; + + virtual ::Compression::CompressorIdLevelList * compressor_ids (); + + virtual CORBA::PolicyType policy_type (void); + + virtual CORBA::Policy_ptr copy (void); + + virtual void destroy (void); + + virtual TAO_Cached_Policy_Type _tao_cached_type (void) const; + + // Returns the scope at which this policy can be applied. See orbconf.h. + TAO_Policy_Scope _tao_scope (void) const; + + /// This method writes a CDR representation of the current object. + CORBA::Boolean _tao_encode (TAO_OutputCDR &out_cdr); + + /// This method reads the object state from a CDR representation. + CORBA::Boolean _tao_decode (TAO_InputCDR &in_cdr); + +private: + /// The attribute + ::Compression::CompressorIdLevelList value_; +}; + +/** + * @class CompressionEnablingPolicy + * + * @brief Implementation of the ZIOP::CompressionEnablingPolicy + */ +class CompressionEnablingPolicy + : public virtual ::ZIOP::CompressionEnablingPolicy + , public virtual ::CORBA::LocalObject +{ +public: + CompressionEnablingPolicy (void); + + /// Constructor. + CompressionEnablingPolicy (const ::CORBA::Boolean val); + + /// Copy constructor. + CompressionEnablingPolicy (const CompressionEnablingPolicy &rhs); + + /// Returns a copy of <this>. + virtual CompressionEnablingPolicy *clone (void) const; + + /// = The ZIOP::BidirectionalPolicy methods + virtual ::CORBA::Boolean compression_enabled (void); + + virtual CORBA::PolicyType policy_type (void); + + virtual CORBA::Policy_ptr copy (void); + + virtual void destroy (void); + + virtual TAO_Cached_Policy_Type _tao_cached_type (void) const; + + // Returns the scope at which this policy can be applied. See orbconf.h. + TAO_Policy_Scope _tao_scope (void) const; + + /// This method writes a CDR representation of the current object. + CORBA::Boolean _tao_encode (TAO_OutputCDR &out_cdr); + + /// This method reads the object state from a CDR representation. + CORBA::Boolean _tao_decode (TAO_InputCDR &in_cdr); + +private: + + /// The attribute + ::CORBA::Boolean value_; +}; + +/** + * @class CompressionLowValuePolicy + * + * @brief Implementation of the ZIOP::CompressionLowValuePolicy + */ +class CompressionLowValuePolicy + : public virtual ::ZIOP::CompressionLowValuePolicy + , public virtual ::CORBA::LocalObject +{ +public: + + /// Constructor. + CompressionLowValuePolicy (const ::CORBA::ULong val); + + /// Copy constructor. + CompressionLowValuePolicy (const CompressionLowValuePolicy &rhs); + + /// Returns a copy of <this>. + virtual CompressionLowValuePolicy *clone (void) const; + + /// = The ZIOP::BidirectionalPolicy methods + virtual ::CORBA::ULong low_value (void); + + virtual CORBA::PolicyType policy_type (void); + + virtual CORBA::Policy_ptr copy (void); + + virtual void destroy (void); + + virtual TAO_Cached_Policy_Type _tao_cached_type (void) const; + +private: + + /// The attribute + ::CORBA::ULong value_; +}; + +/** + * @class CompressionLowValuePolicy + * + * @brief Implementation of the ZIOP::CompressionLowValuePolicy + */ +class CompressionMinRatioPolicy + : public virtual ::ZIOP::CompressionMinRatioPolicy + , public virtual ::CORBA::LocalObject +{ +public: + + /// Constructor. + CompressionMinRatioPolicy (const ::CORBA::ULong val); + + /// Copy constructor. + CompressionMinRatioPolicy (const CompressionMinRatioPolicy &rhs); + + /// Returns a copy of <this>. + virtual CompressionMinRatioPolicy *clone (void) const; + + /// = The ZIOP::BidirectionalPolicy methods + virtual ::CORBA::ULong ratio (void); + + virtual CORBA::PolicyType policy_type (void); + + virtual CORBA::Policy_ptr copy (void); + + virtual void destroy (void); + + virtual TAO_Cached_Policy_Type _tao_cached_type (void) const; + +private: + + /// The attribute + ::CORBA::ULong value_; +}; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /* TAO_BIDIR_POLICY_I_H */ + + diff --git a/TAO/tao/ZIOP/ZIOP_Service_Context_Handler.cpp b/TAO/tao/ZIOP/ZIOP_Service_Context_Handler.cpp new file mode 100644 index 00000000000..3a6d206a9be --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_Service_Context_Handler.cpp @@ -0,0 +1,44 @@ +// $Id$ + +#include "tao/ZIOP/ZIOP_Service_Context_Handler.h" + +ACE_RCSID (ZIOP, + ZIOP_Service_Context_Handler, + "$Id$") + +#include "tao/Compression/Compression.h" +#include "tao/CDR.h" +#include "tao/TAO_Server_Request.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +int +TAO_ZIOP_Service_Context_Handler::process_service_context ( + TAO_Transport& transport, + const IOP::ServiceContext& context) +{ + TAO_InputCDR cdr (reinterpret_cast<const char*> ( + context.context_data.get_buffer ()), + context.context_data.length ()); + + CORBA::Boolean byte_order; + if (!(cdr >> ACE_InputCDR::to_boolean (byte_order))) + return -1; + + cdr.reset_byte_order (static_cast<int> (byte_order)); + + // @TODO use real typedef + Compression::CompressorId compressorid; + if (!(cdr >> compressorid)) + return -1; + +// request.original_message_length_ = message_length; +ACE_DEBUG ((LM_DEBUG, "Received compressor %d\n", compressorid)); +//+ request.compressed_ = true; +//+ request.original_message_length_ = message_length; +//+ + + return 0; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/ZIOP/ZIOP_Service_Context_Handler.h b/TAO/tao/ZIOP/ZIOP_Service_Context_Handler.h new file mode 100644 index 00000000000..75ad1d72ab2 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_Service_Context_Handler.h @@ -0,0 +1,36 @@ +// -*- C++ -*- + +// =================================================================== +/** + * @file ZIOP_Service_Context_Handler.h + * + * $Id$ + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +// =================================================================== + +#ifndef TAO_ZIOP_SERVICE_CONTEXT_HANDLER_H +#define TAO_ZIOP_SERVICE_CONTEXT_HANDLER_H +#include /**/ "ace/pre.h" +#include "tao/ZIOP/ziop_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Service_Context_Handler.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +class TAO_ZIOP_Service_Context_Handler : + public TAO_Service_Context_Handler +{ + virtual int process_service_context (TAO_Transport& transport, + const IOP::ServiceContext& context); +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* TAO_ZIOP_SERVICE_CONTEXT_HANDLER_H */ diff --git a/TAO/tao/ZIOP/ZIOP_Stub.cpp b/TAO/tao/ZIOP/ZIOP_Stub.cpp new file mode 100644 index 00000000000..f34189a1dc3 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_Stub.cpp @@ -0,0 +1,204 @@ +// $Id$ + +#include "tao/ZIOP/ZIOP_Stub.h" +#include "tao/ZIOP/ZIOP_Policy_i.h" +#include "tao/ORB_Core.h" +#include "tao/Policy_Set.h" +#include "tao/Policy_Manager.h" +#include "tao/SystemException.h" + +ACE_RCSID (ZIOP, + ZIOP_Stub, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_ZIOP_Stub::TAO_ZIOP_Stub (const char *repository_id, + const TAO_MProfile &profiles, + TAO_ORB_Core *orb_core) + : TAO_Stub (repository_id, + profiles, + orb_core), + are_policies_parsed_ (false) +{ +} + +TAO_ZIOP_Stub::~TAO_ZIOP_Stub (void) +{ + if (!CORBA::is_nil (this->compression_enabling_policy_.in ())) + this->compression_enabling_policy_->destroy (); + + if (!CORBA::is_nil (this->compression_id_list_policy_.in ())) + this->compression_id_list_policy_->destroy (); +} + +void +TAO_ZIOP_Stub::parse_policies (void) +{ + CORBA::PolicyList_var policy_list + = this->base_profiles_.policy_list (); + + CORBA::ULong const length = policy_list->length (); + + // Cache away the policies that we'll need later. + for (CORBA::ULong i = 0; i < length; ++i) + { + switch (policy_list[i]->policy_type ()) + { + case ZIOP::COMPRESSION_ENABLING_POLICY_ID: + { + this->exposed_compression_enabling_policy (policy_list[i]); + } + break; + case ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID: + { + this->exposed_compression_id_list_policy (policy_list[i]); + } + break; + } + + } + + this->are_policies_parsed_ = true; +} + +CORBA::Policy * +TAO_ZIOP_Stub::exposed_compression_id_list_policy (void) +{ + if (!this->are_policies_parsed_) + { + this->parse_policies (); + } + + return CORBA::Policy::_duplicate (this->compression_id_list_policy_.in ()); +} + +void +TAO_ZIOP_Stub::exposed_compression_id_list_policy (CORBA::Policy_ptr policy) +{ + this->compression_id_list_policy_ = CORBA::Policy::_duplicate (policy); +} + +CORBA::Policy * +TAO_ZIOP_Stub::exposed_compression_enabling_policy (void) +{ + if (!this->are_policies_parsed_) + { + this->parse_policies (); + } + + return CORBA::Policy::_duplicate (this->compression_enabling_policy_.in ()); +} + +void +TAO_ZIOP_Stub::exposed_compression_enabling_policy (CORBA::Policy_ptr policy) +{ + this->compression_enabling_policy_ = CORBA::Policy::_duplicate (policy); +} + +CORBA::Policy_ptr +TAO_ZIOP_Stub::get_policy (CORBA::PolicyType type) +{ + // If we are dealing with a client exposed policy, check if any + // value came in the IOR/reconcile IOR value and overrides. + switch (type) + { + case ZIOP::COMPRESSION_ENABLING_POLICY_ID : + { + return this->effective_compression_enabling_policy (); + } + case ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID : + { + return this->effective_compression_id_list_policy (); + } + } + + return this->TAO_Stub::get_policy (type); +} + +CORBA::Policy_ptr +TAO_ZIOP_Stub::get_cached_policy (TAO_Cached_Policy_Type type) +{ + // If we are dealing with a client exposed policy, check if any + // value came in the IOR/reconcile IOR value and overrides. + switch (type) + { + case TAO_CACHED_COMPRESSION_ENABLING_POLICY: + { + return this->effective_compression_enabling_policy (); + } + case TAO_CACHED_COMPRESSION_ID_LEVEL_LIST_POLICY: + { + return this->effective_compression_id_list_policy (); + } + } + + return this->TAO_Stub::get_cached_policy (type); +} + +CORBA::Policy * +TAO_ZIOP_Stub::effective_compression_enabling_policy (void) +{ + // Get effective override. + CORBA::Policy_var override = + this->TAO_Stub::get_cached_policy ( + TAO_CACHED_COMPRESSION_ENABLING_POLICY); + + // Get the value from the ior. + CORBA::Policy_var exposed = this->exposed_compression_enabling_policy (); + + // Reconcile client-exposed and locally set values. + if (CORBA::is_nil (exposed.in ())) + return override._retn (); + + if (CORBA::is_nil (override.in ())) + return exposed._retn (); + + ZIOP::CompressionEnablingPolicy_var override_policy_var = + ZIOP::CompressionEnablingPolicy::_narrow (override.in ()); + + ZIOP::CompressionEnablingPolicy_var exposed_policy_var = + ZIOP::CompressionEnablingPolicy::_narrow (exposed.in ()); + + // Both override and exposed have been set. + // See if either of them has empty priority bands. + if (override_policy_var->compression_enabled () && exposed_policy_var->compression_enabled ()) + return override._retn (); + + if (!override_policy_var->compression_enabled ()) + return override._retn (); + + return exposed._retn (); +} + +CORBA::Policy * +TAO_ZIOP_Stub::effective_compression_id_list_policy (void) +{ + // Get effective override. + CORBA::Policy_var override = + this->TAO_Stub::get_cached_policy (TAO_CACHED_COMPRESSION_ID_LEVEL_LIST_POLICY); + + // Get the value from the ior. + CORBA::Policy_var exposed = + this->exposed_compression_id_list_policy (); + + // Reconcile client-exposed and locally set values. + if (CORBA::is_nil (exposed.in ())) + return override._retn (); + + if (CORBA::is_nil (override.in ())) + return exposed._retn (); + + ZIOP::CompressorIdLevelListPolicy_var override_policy_var = + ZIOP::CompressorIdLevelListPolicy::_narrow (override.in ()); + + ZIOP::CompressorIdLevelListPolicy_var exposed_policy_var = + ZIOP::CompressorIdLevelListPolicy::_narrow (exposed.in ()); + + // Check which compressor id we should use and which level + + return exposed._retn (); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + diff --git a/TAO/tao/ZIOP/ZIOP_Stub.h b/TAO/tao/ZIOP/ZIOP_Stub.h new file mode 100644 index 00000000000..7bd90f2806b --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_Stub.h @@ -0,0 +1,102 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ZIOP_Stub.h + * + * $Id$ + * + * This file contains the declaration for the ZIOP Stub. + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +//============================================================================= + +#ifndef TAO_ZIOP_STUB_H_ +#define TAO_ZIOP_STUB_H_ + +#include /**/ "ace/pre.h" + +#include "tao/orbconf.h" + +#include "tao/ZIOP/ziop_export.h" + +#include "tao/Stub.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward references. +namespace TAO +{ + class CompressorIdListPolicy; + class CompressionEnablingPolicy; +} + +/** + * @class TAO_ZIOP_Stub + * + * This class represent a stub with extended functionality, which are needed + * for ZIOPCORBA. + */ +class TAO_ZIOP_Export TAO_ZIOP_Stub : public TAO_Stub +{ +public: + + TAO_ZIOP_Stub (const char *repository_id, + const TAO_MProfile &profiles, + TAO_ORB_Core *orb_core); + + virtual ~TAO_ZIOP_Stub (void); + + /** + * Returns the effective policy if @a type is a known client-exposed + * policy type. Returns the effective override for all other policy + * types. + */ + CORBA::Policy_ptr get_policy (CORBA::PolicyType type); + + CORBA::Policy_ptr get_cached_policy (TAO_Cached_Policy_Type type); + +private: + + /// Helper method used to parse the policies. + void parse_policies (void); + + void exposed_compression_enabling_policy (CORBA::Policy_ptr policy); + + void exposed_compression_id_list_policy (CORBA::Policy_ptr policy); + + CORBA::Policy_ptr exposed_compression_enabling_policy (void); + + CORBA::Policy_ptr exposed_compression_id_list_policy (void); + + CORBA::Policy *effective_compression_enabling_policy (void); + CORBA::Policy *effective_compression_id_list_policy (void); + + // The following attribute are used to cache + // the different kind of policies and avoid to + // parse the MProfile's policy list each time we + // are asked about a given policy. + + CORBA::Policy_var compression_enabling_policy_; + + CORBA::Policy_var compression_id_list_policy_; + + CORBA::Boolean are_policies_parsed_; + +private: + // = Disallow copying and assignment. + TAO_ZIOP_Stub (const TAO_ZIOP_Stub &); + TAO_ZIOP_Stub &operator = (const TAO_ZIOP_Stub &); + +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_ZIOP_STUB_FACTORY_H_ */ diff --git a/TAO/tao/ZIOP/ZIOP_Stub_Factory.cpp b/TAO/tao/ZIOP/ZIOP_Stub_Factory.cpp new file mode 100644 index 00000000000..4db30972711 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_Stub_Factory.cpp @@ -0,0 +1,47 @@ +// $Id$ +#include "tao/ZIOP/ZIOP_Stub_Factory.h" + +#include "tao/ZIOP/ZIOP_Stub.h" + +#include "tao/ORB_Constants.h" +#include "tao/SystemException.h" + +#include "ace/Log_Msg.h" + +ACE_RCSID (ZIOP, + ZIOP_Stub_Factory, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_ZIOP_Stub_Factory::~TAO_ZIOP_Stub_Factory (void) +{ +} + +TAO_Stub * +TAO_ZIOP_Stub_Factory::create_stub (const char *repository_id, + const TAO_MProfile &profiles, + TAO_ORB_Core *orb_core) +{ + TAO_Stub *retval = 0; + + ACE_NEW_THROW_EX (retval, + TAO_ZIOP_Stub (repository_id, profiles, orb_core), + CORBA::NO_MEMORY (TAO::VMCID, + CORBA::COMPLETED_MAYBE)); + + return retval; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +// **************************************************************** + +ACE_STATIC_SVC_DEFINE (TAO_ZIOP_Stub_Factory, + ACE_TEXT ("ZIOP_Stub_Factory"), + ACE_SVC_OBJ_T, + &ACE_SVC_NAME (TAO_ZIOP_Stub_Factory), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, + 0) +ACE_FACTORY_DEFINE (TAO_ZIOP, TAO_ZIOP_Stub_Factory) + diff --git a/TAO/tao/ZIOP/ZIOP_Stub_Factory.h b/TAO/tao/ZIOP/ZIOP_Stub_Factory.h new file mode 100644 index 00000000000..cc129ce6ce3 --- /dev/null +++ b/TAO/tao/ZIOP/ZIOP_Stub_Factory.h @@ -0,0 +1,62 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ZIOP_Stub_Factory.h + * + * $Id$ + * + * Defines the a factory interface for creating Stubs. + * This class creates the ZIOP stub, that is used in + * the ZIOP library + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +//============================================================================= + +#ifndef TAO_ZIOP_STUB_FACTORY_H_ +#define TAO_ZIOP_STUB_FACTORY_H_ + +#include /**/ "ace/pre.h" + +#include "tao/orbconf.h" + +#include "tao/ZIOP/ziop_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Stub_Factory.h" + +#include "ace/Service_Config.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class TAO_ZIOP_Stub_Factory + * + * This class is a factory whose product is the TAO_ZIOP_Stub used by + * TAO. This factory, or one of its subclasses is dynamically + * plugged into the ORB_Core, and is used by the ORB_Core to create + * Stub Objects. + */ +class TAO_ZIOP_Export TAO_ZIOP_Stub_Factory : public TAO_Stub_Factory +{ +public: + // -- Ctor/Dtor -- + virtual ~TAO_ZIOP_Stub_Factory (void); + + /// Creates a Stub Object. + virtual TAO_Stub *create_stub (const char *repository_id, + const TAO_MProfile &profiles, + TAO_ORB_Core *orb_core); +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DECLARE_EXPORT (TAO_ZIOP, TAO_ZIOP_Stub_Factory) +ACE_FACTORY_DECLARE (TAO_ZIOP, TAO_ZIOP_Stub_Factory) + +#include /**/ "ace/post.h" +#endif /* TAO_ZIOP_STUB_FACTORY_H_ */ diff --git a/TAO/tao/ZIOP/ziop_export.h b/TAO/tao/ZIOP/ziop_export.h new file mode 100644 index 00000000000..f865c230b9b --- /dev/null +++ b/TAO/tao/ZIOP/ziop_export.h @@ -0,0 +1,40 @@ +// -*- C -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl +// ------------------------------ +#ifndef TAO_ZIOP_EXPORT_H +#define TAO_ZIOP_EXPORT_H + +#include "ace/config-all.h" + +#if defined (TAO_AS_STATIC_LIBS) +# if !defined (TAO_ZIOP_HAS_DLL) +# define TAO_ZIOP_HAS_DLL 0 +# endif /* ! TAO_ZIOP_HAS_DLL */ +#else +# if !defined (TAO_ZIOP_HAS_DLL) +# define TAO_ZIOP_HAS_DLL 1 +# endif /* ! TAO_ZIOP_HAS_DLL */ +#endif + +#if defined (TAO_ZIOP_HAS_DLL) && (TAO_ZIOP_HAS_DLL == 1) +# if defined (TAO_ZIOP_BUILD_DLL) +# define TAO_ZIOP_Export ACE_Proper_Export_Flag +# define TAO_ZIOP_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TAO_ZIOP_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TAO_ZIOP_BUILD_DLL */ +# define TAO_ZIOP_Export ACE_Proper_Import_Flag +# define TAO_ZIOP_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TAO_ZIOP_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TAO_ZIOP_BUILD_DLL */ +#else /* TAO_ZIOP_HAS_DLL == 1 */ +# define TAO_ZIOP_Export +# define TAO_ZIOP_SINGLETON_DECLARATION(T) +# define TAO_ZIOP_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TAO_ZIOP_HAS_DLL == 1 */ + +#endif /* TAO_ZIOP_EXPORT_H */ + +// End of auto generated file. + diff --git a/TAO/tao/orbconf.h b/TAO/tao/orbconf.h index bd5af7829f0..15df99a8f9e 100644 --- a/TAO/tao/orbconf.h +++ b/TAO/tao/orbconf.h @@ -246,6 +246,10 @@ const size_t TAO_DEFAULT_VALUE_FACTORY_TABLE_SIZE = 128; # define TAO_HAS_MONITOR_POINTS ACE_HAS_MONITOR_POINTS #endif +#if !defined (TAO_HAS_ZIOP) +# define TAO_HAS_ZIOP 0 +#endif + // Avoid namespace pollution that's common on older UNIXes... #if defined (minor) #undef minor @@ -765,6 +769,12 @@ enum TAO_Cached_Policy_Type TAO_CACHED_POLICY_ENDPOINT, + TAO_CACHED_COMPRESSION_ENABLING_POLICY, + + TAO_CACHED_COMPRESSION_LOW_VALUE_POLICY, + + TAO_CACHED_COMPRESSION_ID_LEVEL_LIST_POLICY, + /// NOTE: The "TAO_CACHED_POLICY_MAX_CACHED" should always be the last. /// This value is used as the cached_policies_ array size in TAO_Policy_Set, /// Any policy type defined after "TAO_CACHED_POLICY_MAX_CACHED" will cause diff --git a/TAO/utils/catior/catior.cpp b/TAO/utils/catior/catior.cpp index 6718ac70865..55ea34aca39 100644 --- a/TAO/utils/catior/catior.cpp +++ b/TAO/utils/catior/catior.cpp @@ -20,6 +20,7 @@ #include "tao/Messaging_PolicyValueC.h" #include "tao/Messaging/Messaging_TypesC.h" +#include "tao/ZIOP/ZIOP.h" #include "tao/RTCORBA/RTCORBA.h" #include "tao/AnyTypeCode/Marshal.h" #include "tao/IIOP_Profile.h" @@ -996,18 +997,30 @@ cat_tag_orb_type (TAO_InputCDR& stream) { if (!(stream2 >> orbtype)) return false; - if (orbtype == TAO_ORB_TYPE) + switch (orbtype) + { + case TAO_ORB_TYPE: { ACE_DEBUG ((LM_DEBUG, "%I ORB Type: 0x%x (TAO)\n", orbtype)); + break; } - else + case 0x29A: + { + ACE_DEBUG ((LM_DEBUG, + "%I ORB Type: 0x%x (TIDorbC++)\n", + orbtype)); + break; + } + default: { ACE_DEBUG ((LM_DEBUG, "%I ORB Type: 0x%x\n", orbtype)); } + break; + } return true; } @@ -1114,18 +1127,17 @@ cat_tag_policies (TAO_InputCDR& stream) { for (unsigned int iter=0; iter < policies.length() ; iter++) { // Create new stream for pvalue contents - char *pmbuf = new char [policies[iter].pvalue.length()]; + const CORBA::Octet *pmbuf = policies[iter].pvalue.get_buffer (); - for (unsigned int biter=0 ; - biter < policies[iter].pvalue.length() - sizeof(int) ; - biter++) { - pmbuf[biter] = policies[iter].pvalue[biter + sizeof(int)]; - } + TAO_InputCDR stream3 ( + reinterpret_cast <const char*> (pmbuf), + policies[iter].pvalue.length ()); + + CORBA::Boolean byte_order; + if (!(stream3 >> ACE_InputCDR::to_boolean (byte_order))) + return 1; - int byteOrder = policies[iter].pvalue[0]; - TAO_InputCDR stream3 (pmbuf, - policies[iter].pvalue.length(), - static_cast<int> (byteOrder)); + stream3.reset_byte_order (static_cast <int> (byte_order)); if (policies[iter].ptype == RTCORBA::PRIORITY_MODEL_POLICY_TYPE) { ACE_DEBUG ((LM_DEBUG, @@ -1225,13 +1237,34 @@ cat_tag_policies (TAO_InputCDR& stream) { "%I Policy #%d Type: %d (QUEUE_ORDER_POLICY_TYPE)\n", iter+1, policies[iter].ptype)); + } else if (policies[iter].ptype == ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID) { + ACE_DEBUG ((LM_DEBUG, + "%I Policy #%d Type: %d (COMPRESSOR_ID_LEVEL_LIST_POLICY_ID)\n", + iter+1, + policies[iter].ptype)); + ::Compression::CompressorIdLevelList idlist; + if (!(stream3 >> idlist)) + return 1; + CORBA::ULong index = 0; + for (index; index < idlist.length(); index++) + { + ACE_DEBUG ((LM_DEBUG,"%I\t CompressorId: %d Level: %d\n", + idlist[index].compressor_id, idlist[index].compression_level)); + } + } else if (policies[iter].ptype == ZIOP::COMPRESSION_ENABLING_POLICY_ID) { + ACE_DEBUG ((LM_DEBUG, + "%I Policy #%d Type: %d (COMPRESSION_ENABLING_POLICY_ID)\n", + iter+1, + policies[iter].ptype)); + CORBA::Boolean status; + stream3 >> ACE_InputCDR::to_boolean (status); + ACE_DEBUG ((LM_DEBUG,"%I\t Enabled: %d\n", + status)); } else { ACE_DEBUG ((LM_DEBUG, "%I Policy #%d Type: %d (UNKNOWN)\n", iter+1, policies[iter].ptype)); } - - delete [] pmbuf; } return 1; diff --git a/TAO/utils/catior/catior.mpc b/TAO/utils/catior/catior.mpc index 15f52f53376..fc334fa11ed 100644 --- a/TAO/utils/catior/catior.mpc +++ b/TAO/utils/catior/catior.mpc @@ -1,6 +1,6 @@ // $Id$ -project : namingexe, rtcorba, install, messaging { +project : namingexe, rtcorba, install, messaging, ziop { exename = catior install = $(ACE_ROOT)/bin } |