diff options
author | Phil Mesnier <mesnier_p@ociweb.com> | 2005-07-17 21:50:47 +0000 |
---|---|---|
committer | Phil Mesnier <mesnier_p@ociweb.com> | 2005-07-17 21:50:47 +0000 |
commit | 48528ef3476e797825ad7a6992b681361bcf5561 (patch) | |
tree | 9771799eecae9d7386c606cd5ee515461f04a50f /TAO | |
parent | bd2e7decec1b191b2db8673c20521635f83da645 (diff) | |
download | ATCD-48528ef3476e797825ad7a6992b681361bcf5561.tar.gz |
ChangeLog tag: Sun Jul 17 16:39:01 2005 Phil Mesnier <mesnier_p@ociweb.com>
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/ChangeLog | 76 | ||||
-rw-r--r-- | TAO/tao/Codeset/Codeset_Descriptor.cpp | 131 | ||||
-rw-r--r-- | TAO/tao/Codeset/Codeset_Descriptor.h | 61 | ||||
-rw-r--r-- | TAO/tao/Codeset/Codeset_Manager_Factory.cpp | 26 | ||||
-rw-r--r-- | TAO/tao/Codeset/Codeset_Manager_Factory.h | 2 | ||||
-rw-r--r-- | TAO/tao/Codeset/Codeset_Manager_i.cpp | 258 | ||||
-rw-r--r-- | TAO/tao/Codeset/Codeset_Manager_i.h | 102 | ||||
-rw-r--r-- | TAO/tao/Codeset/Codeset_Translator_Factory.cpp | 4 | ||||
-rw-r--r-- | TAO/tao/Codeset/UTF16_BOM_Translator.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/Codeset_Descriptor_Base.h | 45 | ||||
-rw-r--r-- | TAO/tao/Codeset_Manager.cpp | 8 | ||||
-rw-r--r-- | TAO/tao/Codeset_Manager.h | 6 | ||||
-rw-r--r-- | TAO/tao/Codeset_Manager_Factory_Base.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/Codeset_Manager_Factory_Base.h | 3 | ||||
-rw-r--r-- | TAO/tao/Makefile.am | 1 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.cpp | 74 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.h | 8 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.i | 9 | ||||
-rw-r--r-- | TAO/tao/Resource_Factory.cpp | 85 | ||||
-rw-r--r-- | TAO/tao/Resource_Factory.h | 35 | ||||
-rw-r--r-- | TAO/tao/default_resource.cpp | 121 | ||||
-rw-r--r-- | TAO/tao/default_resource.h | 20 | ||||
-rw-r--r-- | TAO/tao/tao.mpc | 1 |
23 files changed, 518 insertions, 562 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index d5924e4d986..fb01adc7cfb 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,49 @@ +Sun Jul 17 16:39:01 2005 Phil Mesnier <mesnier_p@ociweb.com> + + * tao/Codeset_Descriptor_Base.h: + * tao/Codeset_Manager.cpp: + * tao/Codeset_Manager.h: + * tao/Codeset_Manager_Factory_Base.cpp: + * tao/Codeset_Manager_Factory_Base.h: + * tao/Makefile.am: + * tao/ORB_Core.cpp: + * tao/ORB_Core.h: + * tao/ORB_Core.i: + * tao/Resource_Factory.cpp: + * tao/Resource_Factory.h: + * tao/default_resource.cpp: + * tao/default_resource.h: + * tao/tao.mpc: + * tao/Codeset/Codeset_Manager_Factory.cpp: + * tao/Codeset/Codeset_Manager_Factory.h: + * tao/Codeset/Codeset_Manager_i.cpp: + * tao/Codeset/Codeset_Manager_i.h: + * tao/Codeset/Codeset_Translator_Factory.cpp: + * tao/Codeset/UTF16_BOM_Translator.cpp: + * tao/Codeset/Codeset_Descriptor.cpp: + * tao/Codeset/Codeset_Descriptor.h: + + Moved the remaining codeset-specific details out of the ORB core + and into TAO_Codeset. This is accomplished by moving the codeset + descriptor interface out of the Resource_Factory.h and making it + accessible only through the Codeset_Manager interface. This + means that the codeset manager must be created earlier in + the start-up if the library is available. If one assumes that + specifying a native [w]char codeset, or translators in the + svc.conf file, one expects to use codeset negotiation, then this + earlier loading is not a problem. If no codeset configuration is + supplied and -ORBNegotiateCodesets 0 is supplied to ORB_init, + then the TAO_Codeset library will not be loaded. + + With static linked applications, if TAO_Codeset is not linked in + and tao/Codeset/Codeset.h is not included, then any codeset + specific configuration is ignored by the resource factory. + + This change requires regenerating makefiles for TAO and + TAO_Codeset. If rebuilding in an existing workspace, rebuilding + dependencies for these libraries is recommended. + + Sat Jul 16 18:01:26 2005 J.T. Conklin <jtc@acorntoolworks.com> * orbsvcs/orbsvcs/Log/Log_i.cpp: @@ -11,7 +57,7 @@ Sat Jul 16 17:48:15 2005 J.T. Conklin <jtc@acorntoolworks.com> * orbsvcs/orbsvcs/Log/BasicLogFactory_i.cpp * orbsvcs/orbsvcs/Log/Hash_LogStore.cpp * orbsvcs/orbsvcs/Log/LogMgr_i.cpp - + Remove stray ACE_DEBUGs. * orbsvcs/orbsvcs/Log/Log_i.cpp: @@ -40,14 +86,14 @@ Sat Jul 16 17:17:30 2005 J.T. Conklin <jtc@acorntoolworks.com> * orbsvcs/orbsvcs/Log/Hash_LogRecordStore.h * orbsvcs/orbsvcs/Log/LogRecordStore.h - Added flush method to ensure log records have been written + Added flush method to ensure log records have been written to persistent media. * orbsvcs/orbsvcs/Log/Log_i.h: Make remove_old_records public so it can be called by log compaction timer. - + * orbsvcs/orbsvcs/Log/Log_Compaction_Handler.cpp: Changed to invoke remove_old_records() on log now that @@ -89,7 +135,7 @@ Sat Jul 16 14:46:36 2005 J.T. Conklin <jtc@acorntoolworks.com> Sat Jul 16 16:12:04 2005 Douglas C. Schmidt <schmidt@cs.wustl.edu> - * orbsvcs/orbsvcs/PortableGroup/Portable_Group_Map.cpp (dispatch): + * orbsvcs/orbsvcs/PortableGroup/Portable_Group_Map.cpp (dispatch): Don't put the ACE_GUARDs in the TAO_GroupId*::operator() methods. Thanks to J.T. for noticing this. @@ -101,15 +147,15 @@ Sat Jul 16 18:20:12 UTC 2005 Johnny Willemsen <jwillemsen@remedy.nl> Sat Jul 16 10:24:36 2005 Douglas C. Schmidt <schmidt@cs.wustl.edu> - * orbsvcs/orbsvcs/PortableGroup/Portable_Group_Map.{cpp,h}: Added + * orbsvcs/orbsvcs/PortableGroup/Portable_Group_Map.{cpp,h}: Added a lock to prevent race conditions. Thanks to Frank Hunleth <frank@hunleth.com> and Felix Perez Alamillo - <fpalamillo@indra.es> for helping with this. - + <fpalamillo@indra.es> for helping with this. + Sat Jul 16 02:18:12 UTC 2005 Jeff Parsons <j.parsons@vanderbilt.edu> * TAO_IDL/be/be_visitor_valuebox/valuebox_ci.cpp: - + Changed code generation of the _boxed_out() method for boxed array types to return the type of the valuebox member's .out() method. The _boxed_out() method previously @@ -122,21 +168,21 @@ Fri Jul 15 17:01:34 2005 J.T. Conklin <jtc@acorntoolworks.com> * orbsvcs/orbsvcs/DsLogAdmin.mpc: - Added Hash_Persistence_Strategy.*, Hash_LogStore.*, and + Added Hash_Persistence_Strategy.*, Hash_LogStore.*, and Hash_LogRecordStore.* to DsLogAdmin_Serv project. * orbsvcs/orbsvcs/Log/LogMgr_i.cpp: * orbsvcs/orbsvcs/Log/LogMgr_i.h: - Use dynamically loaded persistence strategy to create + Use dynamically loaded persistence strategy to create LogStore. * orbsvcs/orbsvcs/Log/Log_Persistence_Strategy.h: * orbsvcs/orbsvcs/Log/Hash_Persistence_Strategy.cpp: * orbsvcs/orbsvcs/Log/Hash_Persistence_Strategy.h: - New TAO_Log_Persistence_Strategy abstract base class which - strategizes the log parameter and log record storage, with + New TAO_Log_Persistence_Strategy abstract base class which + strategizes the log parameter and log record storage, with concrete TAO_Hash_Persistence_Strategy.h implementation. * orbsvcs/orbsvcs/Log/LogMgr_i.cpp: @@ -153,7 +199,7 @@ Fri Jul 15 17:01:34 2005 J.T. Conklin <jtc@acorntoolworks.com> * orbsvcs/orbsvcs/Log/Hash_LogRecordStore.cpp: * orbsvcs/orbsvcs/Log/Hash_LogRecordStore.h: - Refactor TAO_LogRecordStore class into an abstract base class + Refactor TAO_LogRecordStore class into an abstract base class with a concrete TAO_Hash_LogRecordStore implementartion. * orbsvcs/orbsvcs/Log/Log_i.cpp (write_recordlist): @@ -187,9 +233,9 @@ Fri Jul 15 17:01:34 2005 J.T. Conklin <jtc@acorntoolworks.com> * orbsvcs/orbsvcs/Log/EventLogFactory_i.cpp: * orbsvcs/orbsvcs/Log/NotifyLogFactory_i.cpp: * orbsvcs/orbsvcs/Log/RTEventLogFactory_i.cpp: - + Update callers. - + * orbsvcs/orbsvcs/Log/NotifyLogFactory_i.cpp (object_creation): * orbsvcs/orbsvcs/Log/NotifyLogFactory_i.h: diff --git a/TAO/tao/Codeset/Codeset_Descriptor.cpp b/TAO/tao/Codeset/Codeset_Descriptor.cpp new file mode 100644 index 00000000000..239428d0bb3 --- /dev/null +++ b/TAO/tao/Codeset/Codeset_Descriptor.cpp @@ -0,0 +1,131 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tao/Codeset +// +// = FILENAME +// Codeset_Translator_Factory.cpp +// +// = DESCRIPTION +// The base for all the translator factories. Translator factories are +// responsible for supplying the proper translator on demand. +// +// = AUTHORS +// Phil Mesnier <mesnier_p@ociweb.com> +// +// ============================================================================ + +#include "Codeset_Descriptor.h" +#include "Codeset_Translator_Factory.h" + +#include "ace/Codeset_Registry.h" +#include "ace/Log_Msg.h" +#include "tao/debug.h" + +ACE_RCSID (Codeset, + Codeset_Manager_i, + "$Id$") + +TAO_Codeset_Descriptor::TAO_Codeset_Descriptor () + :ncs_ (0), + max_bytes_ (1), + num_translators_ (0), + trans_base_(0) +{ +} + +TAO_Codeset_Descriptor::~TAO_Codeset_Descriptor () +{ + Translator_Node *temp = trans_base_; + while (temp) + { + temp = trans_base_->next_; + // don't need to delete the associated translator factory, it is + // owned by the service registry + delete [] trans_base_->name_; + delete trans_base_; + trans_base_ = temp; + } +} + +void +TAO_Codeset_Descriptor::ncs (const ACE_TCHAR *name) +{ + ACE_CDR::ULong n = 0; + if (ACE_Codeset_Registry::locale_to_registry + (ACE_TEXT_ALWAYS_CHAR(name), n) == 0) + { + char **endPtr =0; + n = ACE_OS::strtoul(ACE_TEXT_ALWAYS_CHAR(name), + endPtr, 0); + } + this->ncs(n); +} + +void +TAO_Codeset_Descriptor::ncs (ACE_CDR::ULong n) +{ + this->ncs_ = n; + // Validate the CodesetId + this->max_bytes_ = ACE_Codeset_Registry::get_max_bytes(n); + if (this->max_bytes_ == 0) + { + if (TAO_debug_level > 0) + ACE_ERROR((LM_ERROR, + ACE_TEXT("(%P|%t) TAO_Codeset_Descriptor::ncs, ") + ACE_TEXT("unknown codeset id 0x%x\n"), + n)); + this->ncs_ = 0; + } +} + +ACE_CDR::ULong +TAO_Codeset_Descriptor::ncs (void) const +{ + return this->ncs_; +} + +int +TAO_Codeset_Descriptor::num_translators (void) const +{ + return this->num_translators_; +} + +int +TAO_Codeset_Descriptor::max_bytes (void) const +{ + return this->max_bytes_; +} + +void +TAO_Codeset_Descriptor::add_translator (const ACE_TCHAR *name) +{ + Translator_Node *temp = trans_base_; + if (this->trans_base_ == 0) + { + ACE_NEW (this->trans_base_, Translator_Node); + temp = trans_base_; + } + else + { + while (temp->next_ != 0) + temp = temp->next_; + ACE_NEW (temp->next_, Translator_Node); + temp = temp->next_; + } + if (temp) + { + this->num_translators_ ++; + temp->name_ = ACE_OS::strdup (name); + temp->translator_factory_ = 0; + temp->next_ = 0; + } +} + +TAO_Codeset_Descriptor::Translator_Node * +TAO_Codeset_Descriptor::translators (void) +{ + return this->trans_base_; +} diff --git a/TAO/tao/Codeset/Codeset_Descriptor.h b/TAO/tao/Codeset/Codeset_Descriptor.h new file mode 100644 index 00000000000..164db546916 --- /dev/null +++ b/TAO/tao/Codeset/Codeset_Descriptor.h @@ -0,0 +1,61 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Codeset_Descriptor.h + * + * $Id$ + * + * @author Phil Mesnier + */ +//============================================================================= + +#ifndef TAO_CODESET_DESCRIPTOR_H +#define TAO_CODESET_DESCRIPTOR_H + +#include /**/ "ace/pre.h" + +#include "codeset_export.h" +#include "ace/CDR_Base.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Codeset_Descriptor_Base.h" + +class TAO_Codeset_Translator_Factory; + +class TAO_Codeset_Export TAO_Codeset_Descriptor + : public TAO_Codeset_Descriptor_Base +{ +public: + TAO_Codeset_Descriptor (); + virtual ~TAO_Codeset_Descriptor (); + + struct Translator_Node + { + ACE_TCHAR *name_; + TAO_Codeset_Translator_Factory *translator_factory_; + Translator_Node *next_; + }; + + void ncs (ACE_CDR::ULong ncs); + void ncs (const ACE_TCHAR *name); + ACE_CDR::ULong ncs (void) const; + int max_bytes (void) const; + int num_translators (void) const; + + void add_translator (const ACE_TCHAR *name); + Translator_Node *translators (void); + +private: + ACE_CDR::ULong ncs_; + int max_bytes_; + int num_translators_; + Translator_Node *trans_base_; +}; + +#include /**/ "ace/post.h" + +#endif /* TAO_CODESET_DESCRIPTOR_H */ diff --git a/TAO/tao/Codeset/Codeset_Manager_Factory.cpp b/TAO/tao/Codeset/Codeset_Manager_Factory.cpp index 2c1f20f4501..46a4b8d5b7f 100644 --- a/TAO/tao/Codeset/Codeset_Manager_Factory.cpp +++ b/TAO/tao/Codeset/Codeset_Manager_Factory.cpp @@ -14,8 +14,6 @@ #include "Codeset_Manager_Factory.h" #include "ace/Service_Config.h" #include "Codeset_Manager_i.h" -#include "tao/Resource_Factory.h" -#include "tao/ORB_Core.h" ACE_RCSID (Codeset, Codeset_Manager_Factory, "$Id$") @@ -31,33 +29,11 @@ TAO_Codeset_Manager_Factory::is_default() const TAO_Codeset_Manager * -TAO_Codeset_Manager_Factory::create (TAO_ORB_Core *oc) +TAO_Codeset_Manager_Factory::create () { TAO_Codeset_Manager_i *csm = 0; ACE_NEW_RETURN (csm, TAO_Codeset_Manager_i, 0); - const TAO_Codeset_Descriptor *cd = - oc->resource_factory()->get_codeset_descriptor(0); // char - if (cd->ncs_set()) - csm->set_ncs_c(cd->ncs()); - const TAO_Codeset_Descriptor::Translator_Node *tlist = - cd->translators(); - while (tlist != 0) - { - csm->add_char_translator (tlist->name_); - tlist = tlist->next_; - } - - cd = oc->resource_factory()->get_codeset_descriptor(1); // wchar - if (cd->ncs_set()) - csm->set_ncs_w(cd->ncs(), cd->max_bytes()); - tlist = cd->translators(); - while (tlist != 0) - { - csm->add_wchar_translator (tlist->name_); - tlist = tlist->next_; - } - return csm; } diff --git a/TAO/tao/Codeset/Codeset_Manager_Factory.h b/TAO/tao/Codeset/Codeset_Manager_Factory.h index fd6cecb8ac6..103ba9b52f8 100644 --- a/TAO/tao/Codeset/Codeset_Manager_Factory.h +++ b/TAO/tao/Codeset/Codeset_Manager_Factory.h @@ -40,7 +40,7 @@ class TAO_Codeset_Export TAO_Codeset_Manager_Factory : { public: virtual ~TAO_Codeset_Manager_Factory (); - virtual TAO_Codeset_Manager *create(TAO_ORB_Core *orb_core); + virtual TAO_Codeset_Manager *create(void); virtual int is_default(void) const; }; diff --git a/TAO/tao/Codeset/Codeset_Manager_i.cpp b/TAO/tao/Codeset/Codeset_Manager_i.cpp index 39788478504..f01a4ba234b 100644 --- a/TAO/tao/Codeset/Codeset_Manager_i.cpp +++ b/TAO/tao/Codeset/Codeset_Manager_i.cpp @@ -8,8 +8,8 @@ #include "tao/debug.h" #include "tao/CDR.h" #include "tao/ORB_Core.h" -#include "tao/Resource_Factory.h" +#include "Codeset_Descriptor.h" #include "Codeset_Manager_i.h" #include "Codeset_Translator_Factory.h" #include "Codeset.h" @@ -20,7 +20,7 @@ #include "ace/Service_Config.h" -ACE_RCSID (tao, +ACE_RCSID (Codeset, Codeset_Manager_i, "$Id$") @@ -62,41 +62,30 @@ TAO_Codeset_Manager_i::default_wchar_codeset = TAO_DEFAULT_WCHAR_CODESET_ID; TAO_Codeset_Manager_i::TAO_Codeset_Manager_i () : codeset_info_ (), - char_factories_ (), - wchar_factories_ () + char_descriptor_ (), + wchar_descriptor_ () { - this->codeset_info_.ForCharData.native_code_set = - TAO_Codeset_Manager_i::default_char_codeset; - this->codeset_info_.ForWcharData.native_code_set = - TAO_Codeset_Manager_i::default_wchar_codeset; + char_descriptor_.ncs(TAO_Codeset_Manager_i::default_char_codeset); + char_descriptor_.add_translator ("UTF8_Latin1_Factory"); - this->add_char_translator ("UTF8_Latin1_Factory"); - this->add_wchar_translator ("UTF16_BOM_Factory"); + wchar_descriptor_.ncs(TAO_Codeset_Manager_i::default_wchar_codeset); + wchar_descriptor_.add_translator ("UTF16_BOM_Factory"); } TAO_Codeset_Manager_i::~TAO_Codeset_Manager_i () { - // Cleanup the character map - TAO_CodesetFactorySetItor cf_end = this->char_factories_.end (); - TAO_CodesetFactorySetItor cf_iter = this->char_factories_.begin (); - - for (; cf_iter != cf_end; ++cf_iter) - { - delete *cf_iter; - } - - this->char_factories_.reset (); - - // Cleanup the wide character map - cf_end = this->wchar_factories_.end (); - cf_iter = this->wchar_factories_.begin (); +} - for (;cf_iter != cf_end; ++cf_iter) - { - delete *cf_iter; - } +TAO_Codeset_Descriptor_Base * +TAO_Codeset_Manager_i::char_codeset_descriptor (void) +{ + return &this->char_descriptor_; +} - this->wchar_factories_.reset (); +TAO_Codeset_Descriptor_Base * +TAO_Codeset_Manager_i::wchar_codeset_descriptor (void) +{ + return &this->wchar_descriptor_; } void @@ -340,61 +329,9 @@ TAO_Codeset_Manager_i::computeTCS (CONV_FRAME::CodeSetComponent &remote, } void -TAO_Codeset_Manager_i::set_ncs_c (CONV_FRAME::CodeSetId ncs) -{ - this->codeset_info_.ForCharData.native_code_set = ncs; -} - -void -TAO_Codeset_Manager_i::set_ncs_w (CONV_FRAME::CodeSetId ncs,int mb) -{ - this->codeset_info_.ForWcharData.native_code_set = ncs; - ACE_OutputCDR::wchar_maxbytes(mb); -} - -int -TAO_Codeset_Manager_i::add_char_translator (const char *name) -{ - TAO_Codeset_Item *item = 0; - ACE_NEW_RETURN (item, TAO_Codeset_Item (name), -1); - - if (this->char_factories_.insert (item) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("TAO (%P|%t) - Codeset_Manager_i::") - ACE_TEXT ("add_char_translator, ") - ACE_TEXT ("Unable to add Codeset ") - ACE_TEXT ("factories for %s: %m\n"), - ACE_TEXT_CHAR_TO_TCHAR (name)), - -1); - } - - return 0; -} - -int -TAO_Codeset_Manager_i::add_wchar_translator (const char *name) -{ - TAO_Codeset_Item *item = 0; - ACE_NEW_RETURN (item, TAO_Codeset_Item (name), -1); - - if (this->wchar_factories_.insert (item) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("TAO (%P|%t) - Codeset_Manager_i::") - ACE_TEXT ("add_wchar_translator, ") - ACE_TEXT ("Unable to add Codeset ") - ACE_TEXT ("factories for %s: %m\n"), - ACE_TEXT_CHAR_TO_TCHAR (name)), - -1); - } - - return 0; -} - -void TAO_Codeset_Manager_i::open(void) { +#if 0 // These translators help comply with the CORBA 3.0.2 specifcation TAO_Codeset_Translator_Factory *fact = ACE_Dynamic_Service<TAO_Codeset_Translator_Factory>:: @@ -430,9 +367,17 @@ TAO_Codeset_Manager_i::open(void) ACE_TEXT("redundant load of UTF16_BOM_Factory\n") )); } +#endif + + // add in from the service configurator + this->codeset_info_.ForCharData.native_code_set = + this->char_descriptor_.ncs(); + this->codeset_info_.ForWcharData.native_code_set = + this->wchar_descriptor_.ncs(); + ACE_OutputCDR::wchar_maxbytes(this->wchar_descriptor_.max_bytes()); - if (init_codeset_factories_i (this->char_factories_, - this->codeset_info_.ForCharData) == -1) + if (init_ccs (this->char_descriptor_, + this->codeset_info_.ForCharData) == -1) { if (TAO_debug_level) ACE_ERROR ((LM_ERROR, @@ -441,8 +386,8 @@ TAO_Codeset_Manager_i::open(void) ACE_TEXT ("char codeset factories\n"))); } - if (init_codeset_factories_i (this->wchar_factories_, - this->codeset_info_.ForWcharData) == -1) + if (init_ccs (this->wchar_descriptor_, + this->codeset_info_.ForWcharData) == -1) { if (TAO_debug_level) ACE_ERROR ((LM_ERROR, @@ -450,59 +395,66 @@ TAO_Codeset_Manager_i::open(void) ACE_TEXT ("configure_codeset_factories, failed to init ") ACE_TEXT ("wchar codeset factories\n"))); } - - if (this->codeset_info_.ForWcharData.native_code_set == 0) - { - ACE_OutputCDR::wchar_maxbytes(0); // disallow wchar when no ncs_w set - } } + /// Initialise the specific type codeset factories int -TAO_Codeset_Manager_i::init_codeset_factories_i ( - TAO_CodesetFactorySet& factset, - CONV_FRAME::CodeSetComponent& cs_comp - ) +TAO_Codeset_Manager_i::init_ccs (TAO_Codeset_Descriptor& cd, + CONV_FRAME::CodeSetComponent& cs_comp) { - TAO_CodesetFactorySetItor end = factset.end (); - TAO_CodesetFactorySetItor iter = factset.begin (); + cs_comp.conversion_code_sets.length + (static_cast<CORBA::ULong> (cd.num_translators())); - CONV_FRAME::CodeSetId ncs = cs_comp.native_code_set; - cs_comp.conversion_code_sets.length ( - static_cast<CORBA::ULong> (factset.size())); CORBA::ULong index; + TAO_Codeset_Descriptor::Translator_Node *tlist = cd.translators(); - for (index = 0; iter != end; ++iter) + for (index = 0; tlist; tlist = tlist->next_) { - const char *name = (*iter)->codeset_name (); - TAO_Codeset_Translator_Factory *fact = - ACE_Dynamic_Service<TAO_Codeset_Translator_Factory>::instance (name); + tlist->translator_factory_ = + ACE_Dynamic_Service<TAO_Codeset_Translator_Factory>::instance + (ACE_TEXT_ALWAYS_CHAR (tlist->name_)); + + if (tlist->translator_factory_ == 0) + { + if (TAO_debug_level) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) - Codeset_Manager_i::") + ACE_TEXT ("init_ccs, Unable to load ") + ACE_TEXT ("code set translator <%s>, %m\n"), + tlist->name_)); + continue; + } - if (fact == 0) + if (tlist->translator_factory_->ncs() != cs_comp.native_code_set) { if (TAO_debug_level) ACE_ERROR ((LM_ERROR, ACE_TEXT ("TAO (%P|%t) - Codeset_Manager_i::") - ACE_TEXT ("init_codeset_factories_i, Unable to load ") - ACE_TEXT ("CodeSet <%s>, %m\n"), - ACE_TEXT_CHAR_TO_TCHAR(name))); + ACE_TEXT ("init_ccs, codeset translator <%s> ") + ACE_TEXT ("has wrong ncs (%d), %m\n"), + tlist->name_, + tlist->translator_factory_->ncs())); + tlist->translator_factory_ = 0; continue; } - if (fact->ncs() == ncs) + // this is a special case for the utf16 bom translator. + if (tlist->translator_factory_->tcs() == cs_comp.native_code_set) + continue; + + cs_comp.conversion_code_sets[index++] = + tlist->translator_factory_->tcs(); + if (TAO_debug_level > 2) { - (*iter)->factory (fact); - cs_comp.conversion_code_sets[index++] = fact->tcs(); - - if (TAO_debug_level > 2) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) - Codeset_Manager_i::") - ACE_TEXT ("init_codeset_factories_i, Loaded Codeset ") - ACE_TEXT ("<%s>, ncs = %08x tcs = %08x\n"), - ACE_TEXT_CHAR_TO_TCHAR(name), - fact->ncs(),fact->tcs())); - } + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) - Codeset_Manager_i::") + ACE_TEXT ("init_ccs, Loaded Codeset translator ") + ACE_TEXT ("<%s>, ncs = %08x tcs = %08x\n"), + tlist->name_, + tlist->translator_factory_->ncs(), + tlist->translator_factory_->tcs() + )); } } @@ -516,7 +468,7 @@ TAO_Codeset_Manager_i::get_char_trans (CONV_FRAME::CodeSetId tcs) { if (this->codeset_info_.ForCharData.native_code_set == tcs) return 0; - return this->get_translator_i (this->char_factories_,tcs); + return this->get_translator_i (this->char_descriptor_,tcs); } TAO_Codeset_Translator_Base * @@ -525,80 +477,30 @@ TAO_Codeset_Manager_i::get_wchar_trans (CONV_FRAME::CodeSetId tcs) if (tcs == this->codeset_info_.ForWcharData.native_code_set && tcs != ACE_CODESET_ID_ISO_UTF_16) return 0; - return this->get_translator_i (this->wchar_factories_,tcs); + return this->get_translator_i (this->wchar_descriptor_,tcs); } TAO_Codeset_Translator_Base * -TAO_Codeset_Manager_i::get_translator_i (TAO_CodesetFactorySet& factset, +TAO_Codeset_Manager_i::get_translator_i (TAO_Codeset_Descriptor& cd, CONV_FRAME::CodeSetId tcs) { - const TAO_CodesetFactorySetItor end = factset.end (); - - for (TAO_CodesetFactorySetItor iter = factset.begin (); iter != end; ++iter) + for (TAO_Codeset_Descriptor::Translator_Node *tlist = cd.translators(); + tlist; tlist = tlist->next_) { - TAO_Codeset_Translator_Factory *fact = (*iter)->factory (); - + TAO_Codeset_Translator_Factory *fact = tlist->translator_factory_; if (fact && tcs == fact->tcs ()) - { - return fact; - } + return fact; } - return 0; } -//--------------------------------------------------------------------- -// Codeset Item -TAO_Codeset_Item::TAO_Codeset_Item (const char *name) - : name_ (0), - factory_ (0) -{ - if (name) - { - name_ = ACE_OS::strdup(name); - } -} - -TAO_Codeset_Item::~TAO_Codeset_Item (void) -{ - ACE_OS::free (this->name_); -} - -const char * -TAO_Codeset_Item::codeset_name (void) -{ - return this->name_; -} - -TAO_Codeset_Translator_Factory * -TAO_Codeset_Item::factory (void) -{ - return this->factory_; -} - -void -TAO_Codeset_Item::factory (TAO_Codeset_Translator_Factory *factory) -{ - this->factory_ = factory; -} - -// End of Codeset Item Class - #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Dynamic_Service<TAO_Codeset_Translator_Factory>; -template class ACE_Node<TAO_Codeset_Item*>; -template class ACE_Unbounded_Set<TAO_Codeset_Item*>; -template class ACE_Unbounded_Set_Iterator<TAO_Codeset_Item*>; - #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate ACE_Dynamic_Service<TAO_Codeset_Translator_Factory> -#pragma instantiate ACE_Node<TAO_Codeset_Item*> -/// -#pragma instantiate ACE_Unbounded_Set<TAO_Codeset_Item*> -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Codeset_Item*> # endif diff --git a/TAO/tao/Codeset/Codeset_Manager_i.h b/TAO/tao/Codeset/Codeset_Manager_i.h index f582935b0e1..fe6f6b7b09c 100644 --- a/TAO/tao/Codeset/Codeset_Manager_i.h +++ b/TAO/tao/Codeset/Codeset_Manager_i.h @@ -18,6 +18,7 @@ #include /**/ "ace/pre.h" #include "tao/CONV_FRAMEC.h" +#include "tao/Codeset_Manager.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -25,9 +26,7 @@ #include "ace/Unbounded_Set.h" #include "codeset_export.h" -#include "tao/Codeset_Manager.h" - -class ACE_WChar_Codeset_Translator; +#include "Codeset_Descriptor.h" class TAO_Profile; class TAO_Transport; @@ -35,56 +34,7 @@ class TAO_Operation_Details; class TAO_ServerRequest; class TAO_Tagged_Components; -class TAO_Codeset_Translator_Factory; -class TAO_Codeset_Manager; - -// **************************************************************** - -/** - * @class TAO_Codeset_Item - * - * @brief A single element in the list of Codeset Translator Factories - * - * This class is used by the Codeset_Manager to store references to - * individual codeset factories. Only those translators that match the - * char or wchar native codeset will be kept in the list. - * - */ - -class TAO_Codeset_Item -{ -public: - friend class TAO_Codeset_Manager; - /// creator method, the codeset name can only be set when the - /// object is created. - TAO_Codeset_Item (const char *name); - - /// destructor that deallocates the factory object if the - /// CodeSet_Item retains ownership. - ~TAO_Codeset_Item (void); - - /// return a reference to the character representation of the codeset - /// factories name. - const char *codeset_name (void); - - /// return a pointer to the codeset factory. - TAO_Codeset_Translator_Factory *factory (void); - - /// set the factory pointer's value. - void factory (TAO_Codeset_Translator_Factory *factory); - -private: - // Prohibited - ACE_UNIMPLEMENTED_FUNC (TAO_Codeset_Item (const TAO_Codeset_Item&)) - ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Codeset_Item&)) - -private: - /// factory name. - char *name_; - - /// pointer to factory object. - TAO_Codeset_Translator_Factory *factory_; -}; +class TAO_Codeset_Descriptor; // **************************************************************** @@ -137,42 +87,16 @@ public: /// at this time Transport has the TCS for Char and WChar void generate_service_context (TAO_Operation_Details&, TAO_Transport & ); - - /// Called by the resource factory to set the native char codeset id - void set_ncs_c (CONV_FRAME::CodeSetId ncs); - - /// Called by the resource factory to set the native wchar codeset - /// id. The maxbytes value is used to communicate the width of - /// untranslated wide characters on the stream. This size may be - /// smaller than the size of a wchar_t. - void set_ncs_w (CONV_FRAME::CodeSetId ncs, int maxbytes = 0); - - /// Called by the resource factory to add a potential codeset - /// translator for char data. The actual factory will be added to - /// the list later, if its ncs matches that of the codeset manager. - int add_char_translator (const char *name); - - /// Called by the resource factory to add a potential codeset - /// translator for wchar data. The actual factory will be added to - /// the list later, if its ncs matches that of the codeset manager. - int add_wchar_translator (const char *name); - /// Called by the resource factory to signify the end of /// initialization. This will traverse the list of named codeset /// translator factories and add any of those that have a native /// codeset id matching the manager's native codeset id. void open(void); -private: - // typedefs for containers containing the list of codesets - // factories for character and wide character. - typedef ACE_Unbounded_Set<TAO_Codeset_Item*> - TAO_CodesetFactorySet; - - // Iterators - typedef ACE_Unbounded_Set_Iterator<TAO_Codeset_Item*> - TAO_CodesetFactorySetItor; + virtual TAO_Codeset_Descriptor_Base *char_codeset_descriptor (void); + virtual TAO_Codeset_Descriptor_Base *wchar_codeset_descriptor (void); +private: // Compute the TCS for Char/WChar asper the CORBA Specification CONV_FRAME::CodeSetId computeTCS (CONV_FRAME::CodeSetComponent &, CONV_FRAME::CodeSetComponent &); @@ -193,8 +117,8 @@ private: // conversion codeset values with the translated codeset id from // each factory that has a matching native codeset. Those factories // that do not have a matching codeset are not retained in the list. - int init_codeset_factories_i (TAO_CodesetFactorySet&, - CONV_FRAME::CodeSetComponent&); + int init_ccs (TAO_Codeset_Descriptor&, + CONV_FRAME::CodeSetComponent&); // get the translator between our ncs_c and the supplied tcs_c TAO_Codeset_Translator_Base * get_char_trans (CONV_FRAME::CodeSetId); @@ -202,18 +126,16 @@ private: // get the translator between our ncs_w and the supplied tcs_w TAO_Codeset_Translator_Base * get_wchar_trans (CONV_FRAME::CodeSetId); - TAO_Codeset_Translator_Base * - get_translator_i (TAO_CodesetFactorySet&, - CONV_FRAME::CodeSetId); + TAO_Codeset_Translator_Base * get_translator_i (TAO_Codeset_Descriptor&, + CONV_FRAME::CodeSetId); // The CodeSetComponentInfo struct contains all of the information // regarding the code sets this application recognizes. This is // where the native code set for both char and wchar are stored. CONV_FRAME::CodeSetComponentInfo codeset_info_; - // The lists of available translators for both chars and wchars. - TAO_CodesetFactorySet char_factories_; - TAO_CodesetFactorySet wchar_factories_; + TAO_Codeset_Descriptor char_descriptor_; + TAO_Codeset_Descriptor wchar_descriptor_; }; diff --git a/TAO/tao/Codeset/Codeset_Translator_Factory.cpp b/TAO/tao/Codeset/Codeset_Translator_Factory.cpp index 5abceffc601..affd4752199 100644 --- a/TAO/tao/Codeset/Codeset_Translator_Factory.cpp +++ b/TAO/tao/Codeset/Codeset_Translator_Factory.cpp @@ -3,7 +3,7 @@ // ============================================================================ // // = LIBRARY -// TAO/tao +// TAO/tao/Codeset // // = FILENAME // Codeset_Translator_Factory.cpp @@ -20,7 +20,7 @@ #include "Codeset_Translator_Factory.h" #include "tao/CDR.h" -ACE_RCSID (tao, +ACE_RCSID (Codeset, Codeset_Translator_Factory, "$Id$") diff --git a/TAO/tao/Codeset/UTF16_BOM_Translator.cpp b/TAO/tao/Codeset/UTF16_BOM_Translator.cpp index fdc20ecc76a..950968ca709 100644 --- a/TAO/tao/Codeset/UTF16_BOM_Translator.cpp +++ b/TAO/tao/Codeset/UTF16_BOM_Translator.cpp @@ -17,7 +17,7 @@ #include "tao/debug.h" #include "ace/Log_Msg.h" -ACE_RCSID (tao, +ACE_RCSID (Codeset, TAO_UTF16_BOM_Translator, "$Id$") diff --git a/TAO/tao/Codeset_Descriptor_Base.h b/TAO/tao/Codeset_Descriptor_Base.h new file mode 100644 index 00000000000..4d8b9a0a453 --- /dev/null +++ b/TAO/tao/Codeset_Descriptor_Base.h @@ -0,0 +1,45 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Codeset_Descriptor.h + * + * $Id$ + * + * @author Phil Mesnier + */ +//============================================================================= + +#ifndef TAO_CODESET_DESCRIPTOR_BASE_H +#define TAO_CODESET_DESCRIPTOR_BASE_H + +#include /**/ "ace/pre.h" + +#include "tao/TAO_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/* + * TAO_Codeset_Descriptor_Base describes the necessary interface for + * Objects within libTAO to be able to supply information to the codeset + * subsystem, as required. + * + * This class also serves as a default implementation when codeset support + * is not linked in. + */ + + +class TAO_Export TAO_Codeset_Descriptor_Base +{ +public: + virtual ~TAO_Codeset_Descriptor_Base (); + + virtual void ncs (const ACE_TCHAR *name) = 0; + virtual void add_translator (const ACE_TCHAR *name) = 0; +}; + +#include /**/ "ace/post.h" + +#endif /* TAO_CODESET_DESCRIPTOR_BASE_H */ diff --git a/TAO/tao/Codeset_Manager.cpp b/TAO/tao/Codeset_Manager.cpp index 6da7f490c30..9744abc08b7 100644 --- a/TAO/tao/Codeset_Manager.cpp +++ b/TAO/tao/Codeset_Manager.cpp @@ -1,6 +1,7 @@ // $Id$ #include "Codeset_Manager.h" +#include "Codeset_Descriptor_Base.h" ACE_RCSID (tao, Codeset_Manager, @@ -10,3 +11,10 @@ ACE_RCSID (tao, TAO_Codeset_Manager::~TAO_Codeset_Manager () { } + +// Add the default destructor for the codeset_descriptor_base here, because +// it is only ever used in conjunction with the codeset manager. + +TAO_Codeset_Descriptor_Base::~TAO_Codeset_Descriptor_Base () +{ +} diff --git a/TAO/tao/Codeset_Manager.h b/TAO/tao/Codeset_Manager.h index 4bb79a1e1c4..e0cdc9710cb 100644 --- a/TAO/tao/Codeset_Manager.h +++ b/TAO/tao/Codeset_Manager.h @@ -34,7 +34,8 @@ class TAO_Operation_Details; class TAO_ServerRequest; class TAO_Tagged_Components; class TAO_Codeset_Translator_Base; -class TAO_Codeset_Manager; +class TAO_Codeset_Descriptor_Base; + // **************************************************************** @@ -83,6 +84,9 @@ public: virtual void open (void) = 0; + virtual TAO_Codeset_Descriptor_Base *char_codeset_descriptor (void) = 0; + virtual TAO_Codeset_Descriptor_Base *wchar_codeset_descriptor (void) = 0; + }; #include /**/ "ace/post.h" diff --git a/TAO/tao/Codeset_Manager_Factory_Base.cpp b/TAO/tao/Codeset_Manager_Factory_Base.cpp index 37c3d544447..a4ed7de44d8 100644 --- a/TAO/tao/Codeset_Manager_Factory_Base.cpp +++ b/TAO/tao/Codeset_Manager_Factory_Base.cpp @@ -19,7 +19,7 @@ TAO_Codeset_Manager_Factory_Base::is_default() const } TAO_Codeset_Manager * -TAO_Codeset_Manager_Factory_Base::create (TAO_ORB_Core *) +TAO_Codeset_Manager_Factory_Base::create () { return 0; diff --git a/TAO/tao/Codeset_Manager_Factory_Base.h b/TAO/tao/Codeset_Manager_Factory_Base.h index 84bf95005dd..e69278db28c 100644 --- a/TAO/tao/Codeset_Manager_Factory_Base.h +++ b/TAO/tao/Codeset_Manager_Factory_Base.h @@ -25,7 +25,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -class TAO_ORB_Core; class TAO_Codeset_Manager; /** @@ -47,7 +46,7 @@ public: /// Create makes a new instance of the codeset manager for every /// call. This allows multiple ORBs to have their own (or none). /// This default implementation returns a null pointer only. - virtual TAO_Codeset_Manager *create(TAO_ORB_Core *orb_core); + virtual TAO_Codeset_Manager *create(void); /// Is_default is called by the ORB Core to determine if it needs /// to reload the factory with a dynamically linked libTAO_Codeset. diff --git a/TAO/tao/Makefile.am b/TAO/tao/Makefile.am index 6c399308737..aec197a33b8 100644 --- a/TAO/tao/Makefile.am +++ b/TAO/tao/Makefile.am @@ -426,6 +426,7 @@ nobase_include_HEADERS = \ ClientRequestInterceptor_Adapter.h \ ClientRequestInterceptor_Adapter_Factory.h \ Client_Strategy_Factory.h \ + Codeset_Descriptor_Base.h \ Codeset_Manager.h \ Codeset_Manager_Factory_Base.h \ Codeset_Translator_Base.h \ diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index ce889af66ff..4d2d0ec673e 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -36,7 +36,6 @@ #include "PolicyFactory_Registry_Factory.h" #include "ORBInitializer_Registry_Adapter.h" #include "Codeset_Manager.h" -#include "Codeset_Manager_Factory_Base.h" #if (TAO_HAS_CORBA_MESSAGING == 1) #include "Policy_Manager.h" @@ -271,8 +270,6 @@ TAO_ORB_Core::~TAO_ORB_Core (void) // Don't delete, is a process wide singleton shared by all orbs orbinitializer_registry_ = 0; - delete this->codeset_manager_; - CORBA::release (this->orb_); } @@ -1021,26 +1018,6 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) CORBA::COMPLETED_NO), -1); } -#if 0 - // @@Phil: Could we add a -ORB option to prevent creation of codeset - // manager. This adds to our runtime footprint. It would be awesome - // if we can do away with this if the user doesnt want to. Does that - // sound reasonable? Please let me know if this is not possible. - - this->codeset_manager_ = trf->get_codeset_manager(); - if (this->codeset_manager_ == 0) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) %p\n"), - ACE_TEXT ("ORB Core unable to initialize codeset_manager"))); - ACE_THROW_RETURN (CORBA::INITIALIZE ( - CORBA::SystemException::_tao_minor_code ( - TAO_ORB_CORE_INIT_LOCATION_CODE, - 0), - CORBA::COMPLETED_NO), - -1); - } -#endif // @@ ???? // Make sure the reactor is initialized... @@ -1171,6 +1148,14 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) this->orb_params ()->negotiate_codesets (negotiate_codesets); + if (this->codeset_manager()) + this->codeset_manager_->open(); + else + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("(%P|%t) ORB_Core: ") + ACE_TEXT("Codeset Manager not available\n"))); + // Set up the pluggable protocol infrastructure. First get a // pointer to the protocol factories set, then obtain pointers to // all factories loaded by the service configurator. @@ -2386,49 +2371,6 @@ TAO_ORB_Core::resolve_ior_table_i (ACE_ENV_SINGLE_ARG_DECL) } } -void -TAO_ORB_Core::load_codeset_manager () -{ - if (this->orb_params()->negotiate_codesets() == 0) - return; - - TAO_Codeset_Manager_Factory_Base *factory = - ACE_Dynamic_Service<TAO_Codeset_Manager_Factory_Base>::instance ("TAO_Codeset"); - if (factory == 0 || factory->is_default()) - { -#if !defined (TAO_AS_STATIC_LIBS) - // only for dynamic libs, check to see if default factory and if so, - // remove it - ACE_Service_Config::process_directive("remove TAO_Codeset"); - ACE_Service_Config::process_directive - (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Codeset", - "TAO_Codeset", - "_make_TAO_Codeset_Manager_Manager_Factory_Base", - "")); - factory = - ACE_Dynamic_Service<TAO_Codeset_Manager_Factory_Base>::instance ("TAO_Codeset"); -#endif - } - if (factory == 0) - { - if (TAO_debug_level > 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT("(%P|%t) ORB_Core: ") - ACE_TEXT("Unable to initialize Codeset Manager\n"))); - return; - } - - this->codeset_manager_ = factory->create (this); - if (this->codeset_manager_) - this->codeset_manager_->open(); - else - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("(%P|%t) ORB_Core: ") - ACE_TEXT("Codeset Manager not available\n"))); - -} - int TAO_ORB_Core::set_endpoint_helper (const ACE_CString &lane, const ACE_CString &endpoints diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 4a74cbc0edb..90b6cae4530 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -862,9 +862,8 @@ public: */ TAO_Flushing_Strategy *flushing_strategy (void); - /// Get/Set Code Set Manager + /// Get Code Set Manager TAO_Codeset_Manager *codeset_manager (void); - void codeset_manager (TAO_Codeset_Manager *); typedef ACE_Array_Map<ACE_CString, ACE_CString> InitRefMap; @@ -968,9 +967,6 @@ private: CORBA::Boolean is_collocation_enabled (TAO_ORB_Core *other_orb, const TAO_MProfile &mp); - /// Load the codeset manager, if the option is set and the library - /// is available. - void load_codeset_manager (); protected: @@ -1201,7 +1197,7 @@ protected: /// Hold the flushing strategy TAO_Flushing_Strategy *flushing_strategy_; - /// Code Set Manager + /// Code Set Manager - points to service object in the service repo TAO_Codeset_Manager *codeset_manager_; }; diff --git a/TAO/tao/ORB_Core.i b/TAO/tao/ORB_Core.i index a784a06f461..ee6173864a8 100644 --- a/TAO/tao/ORB_Core.i +++ b/TAO/tao/ORB_Core.i @@ -265,19 +265,14 @@ TAO_ORB_Core::codeset_manager() { // This causes a factory to be loaded which will call // the codeset_manager setter in this thread. - this->load_codeset_manager(); + this->codeset_manager_ = + this->resource_factory()->codeset_manager(); if (this->codeset_manager_ == 0) this->orb_params()->negotiate_codesets(false); } return this->codeset_manager_; } -ACE_INLINE void -TAO_ORB_Core::codeset_manager (TAO_Codeset_Manager *tcm) -{ - this->codeset_manager_ = tcm; -} - #define TAO_OC_RETRIEVE(member) \ ((this->member##_ == 0) \ ? (this->member##_ = this->resource_factory ()->get_##member ()) \ diff --git a/TAO/tao/Resource_Factory.cpp b/TAO/tao/Resource_Factory.cpp index d5aeebf9f4e..018db827411 100644 --- a/TAO/tao/Resource_Factory.cpp +++ b/TAO/tao/Resource_Factory.cpp @@ -50,79 +50,6 @@ TAO_Protocol_Item::factory (TAO_Protocol_Factory *factory, // ********************************************************************** -TAO_Codeset_Descriptor::TAO_Codeset_Descriptor () - :ncs_ (0), - max_bytes_ (1), - ncs_set_ (0), - trans_base_(0) -{ -} - -TAO_Codeset_Descriptor::~TAO_Codeset_Descriptor () -{ - Translator_Node *temp = trans_base_; - while (temp) - { - temp = trans_base_->next_; - delete [] trans_base_->name_; - delete trans_base_; - trans_base_ = temp; - } -} - -void -TAO_Codeset_Descriptor::ncs (ACE_CDR::ULong ncs, int mb) -{ - this->ncs_ = ncs; - this->max_bytes_ = mb; - this->ncs_set_ = 1; -} - -ACE_CDR::ULong -TAO_Codeset_Descriptor::ncs (void) const -{ - return this->ncs_; -} - -int -TAO_Codeset_Descriptor::max_bytes (void) const -{ - return this->max_bytes_; -} - -int -TAO_Codeset_Descriptor::ncs_set (void) const -{ - return this->ncs_set_; -} - -void -TAO_Codeset_Descriptor::add_translator (const char *name) -{ - Translator_Node *temp = trans_base_; - if (this->trans_base_ == 0) - { - this->trans_base_ = new Translator_Node; - temp = trans_base_; - } - else - { - while (temp->next_ != 0) - temp = temp->next_; - temp->next_ = new Translator_Node; - temp = temp->next_; - } - temp->name_ = new char[ACE_OS::strlen (name) + 1]; - ACE_OS::strcpy (temp->name_,name); - temp->next_ = 0; -} - -const TAO_Codeset_Descriptor::Translator_Node * -TAO_Codeset_Descriptor::translators (void) const -{ - return this->trans_base_; -} - // ******************************************************************** TAO_Resource_Factory::TAO_Resource_Factory (void) @@ -232,18 +159,18 @@ TAO_Resource_Factory::get_protocol_factories (void) return 0; } -const TAO_Codeset_Descriptor * -TAO_Resource_Factory::get_codeset_descriptor (int) const -{ - return 0; -} - int TAO_Resource_Factory::init_protocol_factories (void) { return -1; } +TAO_Codeset_Manager * +TAO_Resource_Factory::codeset_manager (void) +{ + return 0; +} + int TAO_Resource_Factory::cache_maximum (void) const { diff --git a/TAO/tao/Resource_Factory.h b/TAO/tao/Resource_Factory.h index 52f29c06cb1..65ec7222957 100644 --- a/TAO/tao/Resource_Factory.h +++ b/TAO/tao/Resource_Factory.h @@ -34,6 +34,7 @@ class TAO_Connector_Registry; class TAO_Flushing_Strategy; class TAO_Connection_Purging_Strategy; class TAO_LF_Strategy; +class TAO_Codeset_Manager; class ACE_Lock; @@ -86,34 +87,6 @@ typedef ACE_Unbounded_Set_Iterator<TAO_Protocol_Item*> // **************************************************************** -class TAO_Export TAO_Codeset_Descriptor -{ -public: - TAO_Codeset_Descriptor (); - ~TAO_Codeset_Descriptor (); - struct Translator_Node - { - char *name_; - Translator_Node *next_; - }; - void ncs (ACE_CDR::ULong ncs, int mb = 0); - ACE_CDR::ULong ncs (void) const; - int max_bytes (void) const; - - int ncs_set (void) const; - - void add_translator (const char *name); - const Translator_Node *translators (void) const; - -private: - ACE_CDR::ULong ncs_; - int max_bytes_; - int ncs_set_; - Translator_Node *trans_base_; -}; - -// **************************************************************** - /** * @class TAO_Resource_Factory * @@ -203,9 +176,6 @@ public: */ virtual TAO_ProtocolFactorySet *get_protocol_factories (void); - // Returns either the char or wchar codeset descriptor object. - virtual const TAO_Codeset_Descriptor *get_codeset_descriptor(int for_wchar=0) const; - /** * This method will loop through the protocol list and * using the protocol name field this method will @@ -216,6 +186,9 @@ public: */ virtual int init_protocol_factories (void); + /// Gets the codeset manager. + virtual TAO_Codeset_Manager* codeset_manager (void); + /// This denotes the maximum number of connections that can be cached. virtual int cache_maximum (void) const; diff --git a/TAO/tao/default_resource.cpp b/TAO/tao/default_resource.cpp index 4acaa884008..285df342808 100644 --- a/TAO/tao/default_resource.cpp +++ b/TAO/tao/default_resource.cpp @@ -11,11 +11,13 @@ #include "tao/Leader_Follower_Flushing_Strategy.h" #include "tao/LRU_Connection_Purging_Strategy.h" #include "tao/LF_Strategy_Complete.h" +#include "tao/Codeset_Descriptor_Base.h" +#include "tao/Codeset_Manager_Factory_Base.h" +#include "tao/Codeset_Manager.h" #include "ace/TP_Reactor.h" #include "ace/Dynamic_Service.h" #include "ace/Malloc.h" -#include "ace/Codeset_Registry.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_strings.h" #include "ace/Auto_Ptr.h" @@ -42,8 +44,9 @@ TAO_Default_Resource_Factory::TAO_Default_Resource_Factory (void) , object_key_table_lock_type_ (TAO_THREAD_LOCK) , corba_object_lock_type_ (TAO_THREAD_LOCK) , flushing_strategy_type_ (TAO_LEADER_FOLLOWER_FLUSHING) - , char_codeset_descriptor_ () - , wchar_codeset_descriptor_ () + , codeset_manager_ (0) + , char_codeset_descriptor_ (0) + , wchar_codeset_descriptor_ (0) , resource_usage_strategy_ (TAO_Resource_Factory::TAO_EAGER) , drop_replies_ (true) { @@ -160,51 +163,28 @@ TAO_Default_Resource_Factory::init (int argc, ACE_TCHAR *argv[]) /// CodeSet Translators else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-ORBNativeCharCodeSet")) == 0) - { + { ++curarg; - ACE_CDR::ULong ncs; - if (ACE_Codeset_Registry::locale_to_registry (ACE_TEXT_ALWAYS_CHAR(argv[curarg]), - ncs) == 0) - { - char **endPtr =0; - ncs = ACE_OS::strtoul(ACE_TEXT_ALWAYS_CHAR(argv[curarg]), - endPtr, 0); - } - // Validate the CodesetId - if (ACE_Codeset_Registry::get_max_bytes(ncs) == 0) + if (curarg < argc) { - if (TAO_debug_level > 0) - ACE_ERROR((LM_ERROR, - ACE_TEXT("(%P|%t) Invalid NativeCharCodeSet, %x\n"), - ncs)); - return -1; + if (this->char_codeset_descriptor_ == 0) + this->init_codeset_descriptors(); + if (this->char_codeset_descriptor_) + this->char_codeset_descriptor_->ncs (argv[curarg]); } - this->char_codeset_descriptor_.ncs (ncs); - } + } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-ORBNativeWCharCodeSet")) == 0) { ++curarg; - ACE_CDR::ULong ncs; - if (ACE_Codeset_Registry::locale_to_registry(ACE_TEXT_ALWAYS_CHAR(argv[curarg]), - ncs) == 0) - { - char **endPtr = 0; - ncs = ACE_OS::strtoul(ACE_TEXT_ALWAYS_CHAR(argv[curarg]), - endPtr, 0); - } - // Validate the CodesetId - int mb = ACE_Codeset_Registry::get_max_bytes(ncs); - if (mb == 0 || static_cast<size_t>(mb) > sizeof (ACE_CDR::WChar)) + if (curarg < argc) { - if (TAO_debug_level > 0) - ACE_ERROR((LM_ERROR, - ACE_TEXT("(%P|%t) Invalid NativeWCharCodeSet, %x\n"), - ncs)); - return -1; + if (this->wchar_codeset_descriptor_ == 0) + this->init_codeset_descriptors(); + if (this->wchar_codeset_descriptor_) + this->wchar_codeset_descriptor_->ncs (argv[curarg]); } - this->wchar_codeset_descriptor_.ncs (ncs, mb); } else if (ACE_OS::strcasecmp (argv[curarg], @@ -213,7 +193,10 @@ TAO_Default_Resource_Factory::init (int argc, ACE_TCHAR *argv[]) ++curarg; if (curarg < argc) { - this->char_codeset_descriptor_.add_translator (ACE_TEXT_ALWAYS_CHAR(argv[curarg])); + if (this->char_codeset_descriptor_ == 0) + this->init_codeset_descriptors(); + if (this->char_codeset_descriptor_) + this->char_codeset_descriptor_->add_translator (argv[curarg]); } } @@ -224,7 +207,10 @@ TAO_Default_Resource_Factory::init (int argc, ACE_TCHAR *argv[]) ++curarg; if (curarg < argc) { - this->wchar_codeset_descriptor_.add_translator (ACE_TEXT_ALWAYS_CHAR(argv[curarg])); + if (this->wchar_codeset_descriptor_ == 0) + this->init_codeset_descriptors(); + if (this->wchar_codeset_descriptor_) + this->wchar_codeset_descriptor_->add_translator (argv[curarg]); } } @@ -1015,12 +1001,57 @@ TAO_Default_Resource_Factory::disable_factory (void) } } -const TAO_Codeset_Descriptor * -TAO_Default_Resource_Factory::get_codeset_descriptor(int for_wchar) const +TAO_Codeset_Manager * +TAO_Default_Resource_Factory::codeset_manager(void) +{ + static int initialized = 0; + if (this->codeset_manager_ || initialized) + return this->codeset_manager_; + + initialized = 1; + TAO_Codeset_Manager_Factory_Base *factory = + ACE_Dynamic_Service<TAO_Codeset_Manager_Factory_Base>::instance ("TAO_Codeset"); + if (factory == 0 || factory->is_default()) + { +#if !defined (TAO_AS_STATIC_LIBS) + // only for dynamic libs, check to see if default factory and if so, + // remove it + ACE_Service_Config::process_directive("remove TAO_Codeset"); + ACE_Service_Config::process_directive + (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Codeset", + "TAO_Codeset", + "_make_TAO_Codeset_Manager_Factory", + "")); + factory = + ACE_Dynamic_Service<TAO_Codeset_Manager_Factory_Base>::instance ("TAO_Codeset"); +#endif + } + if (factory == 0) + { + if (TAO_debug_level > 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT("(%P|%t) ORB_Core: ") + ACE_TEXT("Unable to initialize Codeset Manager\n"))); + return 0; + } + + this->codeset_manager_ = factory->create (); + + return this->codeset_manager_; +} + +void +TAO_Default_Resource_Factory::init_codeset_descriptors(void) { - if (for_wchar) - return &this->wchar_codeset_descriptor_; - return &this->char_codeset_descriptor_; + if (this->char_codeset_descriptor_) + return; + if (this->codeset_manager() == 0) + return; + + this->char_codeset_descriptor_ = + this->codeset_manager_->char_codeset_descriptor(); + this->wchar_codeset_descriptor_ = + this->codeset_manager_->wchar_codeset_descriptor(); } TAO_Resource_Factory::Resource_Usage diff --git a/TAO/tao/default_resource.h b/TAO/tao/default_resource.h index c1721f78f23..8cbc1344a40 100644 --- a/TAO/tao/default_resource.h +++ b/TAO/tao/default_resource.h @@ -27,7 +27,7 @@ class TAO_Object_Adapter; class TAO_IOR_Parser; class TAO_LF_Strategy; - +class TAO_Codeset_Descriptor_Base; class ACE_Reactor_Impl; /** @@ -94,13 +94,6 @@ public: TAO_ALLOCATOR_THREAD_LOCK }; - /// Translator type - enum TRANSLATOR_TYPE - { - CHAR_TRANSLATOR, - WCHAR_TRANSLATOR - }; - /// Modify and get the source for the CDR allocators int cdr_allocator_source (void); @@ -121,10 +114,10 @@ public: virtual ACE_Allocator* ami_response_handler_allocator (void); virtual TAO_ProtocolFactorySet *get_protocol_factories (void); - virtual const TAO_Codeset_Descriptor *get_codeset_descriptor(int wchar=0) const; - virtual int init_protocol_factories (void); + virtual TAO_Codeset_Manager * codeset_manager (void); + virtual int cache_maximum (void) const; virtual int purge_percentage (void) const; virtual int max_muxed_connections (void) const; @@ -215,6 +208,8 @@ protected: int factory_disabled_; private: + void init_codeset_descriptors (void); + enum Lock_Type { TAO_NULL_LOCK, @@ -240,8 +235,9 @@ private: /// Type of flushing strategy configured Flushing_Strategy_Type flushing_strategy_type_; - TAO_Codeset_Descriptor char_codeset_descriptor_; - TAO_Codeset_Descriptor wchar_codeset_descriptor_; + TAO_Codeset_Manager *codeset_manager_; + TAO_Codeset_Descriptor_Base *char_codeset_descriptor_; + TAO_Codeset_Descriptor_Base * wchar_codeset_descriptor_; /// Resource usage strategy Resource_Usage resource_usage_strategy_; diff --git a/TAO/tao/tao.mpc b/TAO/tao/tao.mpc index d39583ab38f..7b2aa85f21b 100644 --- a/TAO/tao/tao.mpc +++ b/TAO/tao/tao.mpc @@ -349,6 +349,7 @@ project(TAO) : acelib, core, tao_output, taodefaults, pidl, extra_core { Cleanup_Func_Registry.h ClientRequestInterceptor_Adapter.h Client_Strategy_Factory.h + Codeset_Descriptor_Base.h Codeset_Manager.h Codeset_Manager_Factory_Base.h Codeset_Translator_Base.h |