diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-07 06:02:05 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-07 06:02:05 +0000 |
commit | ad3d8280b949de51d9fdf0846466643b0149c05d (patch) | |
tree | 0f0899b92e0f33ad73e55f865f89f2a5e3739bbd | |
parent | 154ce55fb56b20b553f65250b8a8fa887f7a43d3 (diff) | |
download | ATCD-ad3d8280b949de51d9fdf0846466643b0149c05d.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/examples/TAO_Examples.dsw | 3 | ||||
-rw-r--r-- | TAO/tao/Object_Adapter.cpp | 28 | ||||
-rw-r--r-- | TAO/tao/Object_Adapter.h | 2 | ||||
-rw-r--r-- | TAO/tao/POA.cpp | 245 | ||||
-rw-r--r-- | TAO/tao/POA.h | 17 | ||||
-rw-r--r-- | TAO/tao/POA.i | 34 |
6 files changed, 238 insertions, 91 deletions
diff --git a/TAO/examples/TAO_Examples.dsw b/TAO/examples/TAO_Examples.dsw index a081f08c9b4..152956be94d 100644 --- a/TAO/examples/TAO_Examples.dsw +++ b/TAO/examples/TAO_Examples.dsw @@ -11,6 +11,9 @@ Package=<5> Package=<4>
{{{
+ Begin Project Dependency
+ Project_Dep_Name POA Generic Servant DLL
+ End Project Dependency
}}}
###############################################################################
diff --git a/TAO/tao/Object_Adapter.cpp b/TAO/tao/Object_Adapter.cpp index 46ec3517349..5e1106007e0 100644 --- a/TAO/tao/Object_Adapter.cpp +++ b/TAO/tao/Object_Adapter.cpp @@ -286,20 +286,22 @@ TAO_Object_Adapter::dispatch_servant_i (const TAO_ObjectKey &key, void TAO_Object_Adapter::locate_poa (const TAO_ObjectKey &key, - PortableServer::ObjectId &id, + PortableServer::ObjectId &system_id, TAO_POA *&poa, CORBA_Environment &ACE_TRY_ENV) { TAO_Object_Adapter::poa_name poa_system_name; - CORBA::Boolean persistent = 0; - CORBA::Boolean system_id = 0; + CORBA::Boolean is_root = 0; + CORBA::Boolean is_persistent = 0; + CORBA::Boolean is_system_id = 0; TAO_Temporary_Creation_Time poa_creation_time; int result = TAO_POA::parse_key (key, poa_system_name, - id, - persistent, system_id, + is_root, + is_persistent, + is_system_id, poa_creation_time); if (result != 0) { @@ -307,7 +309,8 @@ TAO_Object_Adapter::locate_poa (const TAO_ObjectKey &key, } result = this->find_poa (poa_system_name, - persistent, + is_persistent, + is_root, poa_creation_time, poa, ACE_TRY_ENV); @@ -321,6 +324,7 @@ TAO_Object_Adapter::locate_poa (const TAO_ObjectKey &key, int TAO_Object_Adapter::find_poa (const poa_name &system_name, CORBA::Boolean activate_it, + CORBA::Boolean root, const TAO_Temporary_Creation_Time &poa_creation_time, TAO_POA *&poa, CORBA_Environment &ACE_TRY_ENV) @@ -334,6 +338,7 @@ TAO_Object_Adapter::find_poa (const poa_name &system_name, else { return this->find_transient_poa (system_name, + root, poa_creation_time, poa); } @@ -341,11 +346,20 @@ TAO_Object_Adapter::find_poa (const poa_name &system_name, int TAO_Object_Adapter::find_transient_poa (const poa_name &system_name, + CORBA::Boolean root, const TAO_Temporary_Creation_Time &poa_creation_time, TAO_POA *&poa) { - int result = this->transient_poa_map_->find (system_name, + int result = 0; + if (root) + { + poa = this->orb_core_.root_poa (); + } + else + { + result = this->transient_poa_map_->find (system_name, poa); + } if (result == 0) { diff --git a/TAO/tao/Object_Adapter.h b/TAO/tao/Object_Adapter.h index c5ef0844d7b..3024bc64b44 100644 --- a/TAO/tao/Object_Adapter.h +++ b/TAO/tao/Object_Adapter.h @@ -63,6 +63,7 @@ public: int find_poa (const poa_name &system_name, CORBA::Boolean activate_it, + CORBA::Boolean root, const TAO_Temporary_Creation_Time &poa_creation_time, TAO_POA *&poa, CORBA_Environment &ACE_TRY_ENV); @@ -102,6 +103,7 @@ protected: CORBA_Environment &ACE_TRY_ENV); int find_transient_poa (const poa_name &system_name, + CORBA::Boolean root, const TAO_Temporary_Creation_Time &poa_creation_time, TAO_POA *&poa); diff --git a/TAO/tao/POA.cpp b/TAO/tao/POA.cpp index b5a40065df2..4f2d7ded228 100644 --- a/TAO/tao/POA.cpp +++ b/TAO/tao/POA.cpp @@ -1756,6 +1756,7 @@ TAO_POA::reference_to_servant (CORBA::Object_ptr reference, // WrongAdapter exception is raised. PortableServer::ObjectId system_id; TAO_Object_Adapter::poa_name poa_system_name; + CORBA::Boolean is_root = 0; CORBA::Boolean is_persistent = 0; CORBA::Boolean is_system_id = 0; TAO_Temporary_Creation_Time poa_creation_time; @@ -1763,15 +1764,17 @@ TAO_POA::reference_to_servant (CORBA::Object_ptr reference, int result = this->parse_key (key.in (), poa_system_name, system_id, + is_root, is_persistent, is_system_id, poa_creation_time); - if (result != 0 - || poa_system_name != this->system_name () - || is_persistent != this->persistent () - || is_system_id != this->system_id () - || !this->persistent () - && poa_creation_time != this->creation_time_) + if (result != 0 || + poa_system_name != this->system_name () || + is_root != this->root () || + is_persistent != this->persistent () || + is_system_id != this->system_id () || + !this->persistent () && + poa_creation_time != this->creation_time_) { ACE_THROW_RETURN (PortableServer::POA::WrongAdapter (), 0); @@ -1844,23 +1847,27 @@ TAO_POA::reference_to_id (CORBA::Object_ptr reference, TAO_ObjectKey_var key = reference->_key (ACE_TRY_ENV); ACE_CHECK_RETURN (0); - PortableServer::ObjectId id; + PortableServer::ObjectId system_id; TAO_Object_Adapter::poa_name poa_system_name; - CORBA::Boolean persistent = 0; - CORBA::Boolean system_id = 0; + CORBA::Boolean is_root = 0; + CORBA::Boolean is_persistent = 0; + CORBA::Boolean is_system_id = 0; TAO_Temporary_Creation_Time poa_creation_time; int result = this->parse_key (key.in (), poa_system_name, - id, - persistent, system_id, + is_root, + is_persistent, + is_system_id, poa_creation_time); if (result != 0 || poa_system_name != this->system_name () || - persistent != this->persistent () || - system_id != this->system_id () || - !this->persistent () && poa_creation_time != this->creation_time_) + is_root != this->root () || + is_persistent != this->persistent () || + is_system_id != this->system_id () || + !this->persistent () && + poa_creation_time != this->creation_time_) { ACE_THROW_RETURN (PortableServer::POA::WrongAdapter (), 0); @@ -1872,7 +1879,7 @@ TAO_POA::reference_to_id (CORBA::Object_ptr reference, // The object denoted by the reference does not have to be active // for this operation to succeed. PortableServer::ObjectId_var user_id; - if (this->active_object_map ().find_user_id_using_system_id (id, + if (this->active_object_map ().find_user_id_using_system_id (system_id, user_id.out ()) == -1) { ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), @@ -2229,53 +2236,89 @@ TAO_POA::locate_servant_i (const char *operation, int TAO_POA::parse_key (const TAO_ObjectKey &key, TAO_Object_Adapter::poa_name &poa_system_name, - PortableServer::ObjectId &id, - CORBA::Boolean &persistent, - CORBA::Boolean &system_id, + PortableServer::ObjectId &system_id, + CORBA::Boolean &is_root, + CORBA::Boolean &is_persistent, + CORBA::Boolean &is_system_id, TAO_Temporary_Creation_Time &poa_creation_time) { ACE_FUNCTION_TIMEPROBE (TAO_POA_PARSE_KEY_START); + // Start at zero. CORBA::ULong starting_at = 0; + + // Get the object key octets. const CORBA::Octet *key_data = key.get_buffer (); #if !defined (TAO_NO_IOR_TABLE) - // Skip the TAO Object Key Prefix. + // Skip the object key prefix since we have already checked for + // this. starting_at += TAO_OBJECTKEY_PREFIX_SIZE; -#endif +#endif /* TAO_NO_IOR_TABLE */ - // Check the system id indicator + // Check the root indicator. + char root_key_type = key_data[starting_at]; + if (root_key_type == TAO_POA::root_key_char ()) + { + is_root = 1; + } + else if (root_key_type == TAO_POA::non_root_key_char ()) + { + is_root = 0; + } + else + { + // Incorrect key + return -1; + } + + // Skip past the system id indicator + starting_at += TAO_POA::root_key_type_length (); + + // Check the system id indicator. char system_id_key_type = key_data[starting_at]; if (system_id_key_type == TAO_POA::system_id_key_char ()) - system_id = 1; + { + is_system_id = 1; + } else if (system_id_key_type == TAO_POA::user_id_key_char ()) - system_id = 0; + { + is_system_id = 0; + } else - // Incorrect key - return -1; + { + // Incorrect key + return -1; + } // Skip past the system id indicator starting_at += TAO_POA::system_id_key_type_length (); // Assume persistent key when the POA_NO_TIMESTAMP is enabled. - persistent = 1; + is_persistent = 1; #if !defined (POA_NO_TIMESTAMP) - // Check the persistence indicator char persistent_key_type = key_data[starting_at]; if (persistent_key_type == TAO_POA::persistent_key_char ()) - persistent = 1; + { + is_persistent = 1; + } else if (persistent_key_type == TAO_POA::transient_key_char ()) - persistent = 0; + { + is_persistent = 0; + } else - // Incorrect key - return -1; + { + // Incorrect key + return -1; + } // Skip past the persistent indicator starting_at += TAO_POA::persistent_key_type_length (); - if (!persistent) + // Grab the timestamp for transient POAs. + if (!is_persistent) { // Take the creation time for the timestamp poa_creation_time.creation_time (key_data + starting_at); @@ -2283,41 +2326,50 @@ TAO_POA::parse_key (const TAO_ObjectKey &key, // Skip past the timestamp starting_at += TAO_Creation_Time::creation_time_length (); } - #endif /* POA_NO_TIMESTAMP */ + // Calculate the size of the POA name. CORBA::ULong poa_name_size = 0; - if (!persistent) + if (!is_persistent) { + // Transient POAs have fixed size. poa_name_size = TAO_Object_Adapter::transient_poa_name_size (); } - else if (system_id) + else if (is_system_id) { + // System ids have fixed size. poa_name_size = key.length () - starting_at - TAO_Active_Object_Map::system_id_size (); } else { + // Get the size from the object key. ACE_OS::memcpy (&poa_name_size, key_data + starting_at, sizeof (poa_name_size)); poa_name_size = ACE_NTOHL (poa_name_size); + starting_at += sizeof (poa_name_size); } - poa_system_name.replace (poa_name_size, - poa_name_size, - (CORBA::Octet *) key_data + starting_at, - 0); + // For non-root POAs, grab their name. + if (!is_root) + { + poa_system_name.replace (poa_name_size, + poa_name_size, + (CORBA::Octet *) key_data + starting_at, + 0); - starting_at += poa_name_size; + starting_at += poa_name_size; + } - CORBA::ULong id_size = key.length () - starting_at; + // The rest is the system id. + CORBA::ULong system_id_size = key.length () - starting_at; - // Reset the Id - id.replace (id_size, - id_size, - (CORBA::Octet *) key_data + starting_at, - 0); + // Reset <system_id>. + system_id.replace (system_id_size, + system_id_size, + (CORBA::Octet *) key_data + starting_at, + 0); // Success return 0; @@ -2326,71 +2378,99 @@ TAO_POA::parse_key (const TAO_ObjectKey &key, TAO_ObjectKey * TAO_POA::create_object_key (const PortableServer::ObjectId &id) { + // Calculate the prefix size. + CORBA::ULong prefix_size = 0; +#if !defined (TAO_NO_IOR_TABLE) + prefix_size += TAO_OBJECTKEY_PREFIX_SIZE; +#endif /* TAO_NO_IOR_TABLE */ + + // If we are dealing with a persistent POA and user ids are being + // used, then we need to add the POA name length field to the object + // key. Otherwise, the POA name length can be calculated by looking + // at the remainder after extracting other parts of the key. + int add_poa_name_length = + this->persistent_ && + !this->system_id_; + + // Size required by the POA name. + CORBA::ULong poa_name = 0; + + // Calculate the space required for the POA name. + CORBA::ULong poa_name_length = this->system_name_->length (); + if (!this->root ()) + { + poa_name += poa_name_length; + } + + // Check if we need to added the length of the POA name. + if (add_poa_name_length) + { + poa_name += sizeof (poa_name_length); + } + + // Calculate the space required for the timestamp and the persistent + // byte. + CORBA::ULong creation_time = 0; #if !defined (POA_NO_TIMESTAMP) - CORBA::ULong creation_time_length = 0; + // Calculate the space required for the timestamp. + CORBA::ULong creation_time_length = TAO_Creation_Time::creation_time_length (); if (!this->persistent_) { - creation_time_length = TAO_Creation_Time::creation_time_length (); + creation_time = creation_time_length; } -#endif /* POA_NO_TIMESTAMP */ - CORBA::ULong poa_name_length = this->system_name_->length (); + creation_time += this->persistent_key_type_length (); +#endif /* POA_NO_TIMESTAMP */ - // Calculate the space required for the key - int buffer_size = -#if !defined (TAO_NO_IOR_TABLE) - TAO_OBJECTKEY_PREFIX_SIZE + -#endif + // Calculate the space required for the key. + CORBA::ULong buffer_size = + prefix_size + + this->root_key_type_length () + this->system_id_key_type_length () + -#if !defined (POA_NO_TIMESTAMP) - this->persistent_key_type_length () + - creation_time_length + -#endif /* POA_NO_TIMESTAMP */ - poa_name_length + + creation_time + + poa_name + id.length (); - if (this->persistent_ && - !this->system_id_) - { - buffer_size += sizeof (poa_name_length); - } - - // Create the buffer for the key + // Create the buffer for the key. CORBA::Octet *buffer = TAO_ObjectKey::allocbuf (buffer_size); - // Keeps track of where the next infomation goes; start at 0 byte + // Keeps track of where the next infomation goes; start at 0 byte. CORBA::ULong starting_at = 0; #if !defined (TAO_NO_IOR_TABLE) + // Add the object key prefix. ACE_OS::memcpy (&buffer[starting_at], &objectkey_prefix[0], TAO_OBJECTKEY_PREFIX_SIZE); starting_at += TAO_OBJECTKEY_PREFIX_SIZE; -#endif +#endif /* TAO_NO_IOR_TABLE */ + + // Copy the root byte. + buffer[starting_at] = (CORBA::Octet) this->root_key_type (); + starting_at += this->root_key_type_length (); - // Copy the system id bit + // Copy the system id byte. buffer[starting_at] = (CORBA::Octet) this->system_id_key_type (); starting_at += this->system_id_key_type_length (); #if !defined (POA_NO_TIMESTAMP) - // Copy the persistence bit + // Copy the persistence byte. buffer[starting_at] = (CORBA::Octet) this->persistent_key_type (); starting_at += this->persistent_key_type_length (); + // Then copy the timestamp for transient POAs. if (!this->persistent ()) { - // Then copy the timestamp ACE_OS::memcpy (&buffer[starting_at], this->creation_time_.creation_time (), creation_time_length); starting_at += creation_time_length; } - #endif /* POA_NO_TIMESTAMP */ - if (this->persistent_ && - !this->system_id_) + // Check if we need to added the length of the POA name. + if (add_poa_name_length) { poa_name_length = ACE_HTONL (poa_name_length); ACE_OS::memcpy (&buffer[starting_at], @@ -2399,13 +2479,16 @@ TAO_POA::create_object_key (const PortableServer::ObjectId &id) starting_at += sizeof (poa_name_length); } - // Put the POA name into the buffer - ACE_OS::memcpy (&buffer[starting_at], - this->system_name_->get_buffer (), - this->system_name_->length ()); - starting_at += this->system_name_->length (); + // Put the POA name into the key (for non-root POAs). + if (!this->root ()) + { + ACE_OS::memcpy (&buffer[starting_at], + this->system_name_->get_buffer (), + this->system_name_->length ()); + starting_at += this->system_name_->length (); + } - // Then copy the ID into the key + // Then copy the object id into the key. ACE_OS::memcpy (&buffer[starting_at], id.get_buffer (), id.length ()); diff --git a/TAO/tao/POA.h b/TAO/tao/POA.h index 28875a11722..758e573f45a 100644 --- a/TAO/tao/POA.h +++ b/TAO/tao/POA.h @@ -599,9 +599,10 @@ protected: static int parse_key (const TAO_ObjectKey &key, TAO_Object_Adapter::poa_name &poa_system_name, - PortableServer::ObjectId &id, - CORBA::Boolean &persistent, - CORBA::Boolean &system_id, + PortableServer::ObjectId &system_id, + CORBA::Boolean &is_root, + CORBA::Boolean &is_persistent, + CORBA::Boolean &is_system_id, TAO_Temporary_Creation_Time &poa_creation_time); // Should really be protected, but some compilers complain @@ -646,6 +647,16 @@ protected: static CORBA::ULong system_id_key_type_length (void); + virtual CORBA::Boolean root (void); + + virtual char root_key_type (void); + + static char root_key_char (void); + + static char non_root_key_char (void); + + static CORBA::ULong root_key_type_length (void); + String name_; TAO_Object_Adapter::poa_name folded_name_; diff --git a/TAO/tao/POA.i b/TAO/tao/POA.i index 95b3ec43d54..6982d57e2b5 100644 --- a/TAO/tao/POA.i +++ b/TAO/tao/POA.i @@ -465,6 +465,13 @@ TAO_POA::system_id (void) ACE_INLINE CORBA::Boolean +TAO_POA::root (void) +{ + return this->parent_ == 0; +} + + +ACE_INLINE CORBA::Boolean TAO_POA::persistent (void) { return this->persistent_; @@ -562,6 +569,33 @@ TAO_POA::system_id_key_type_length (void) return sizeof (char); } +ACE_INLINE char +TAO_POA::root_key_char (void) +{ + return 'R'; +} + +ACE_INLINE char +TAO_POA::non_root_key_char (void) +{ + return 'N'; +} + +ACE_INLINE char +TAO_POA::root_key_type (void) +{ + if (this->root ()) + return TAO_POA::root_key_char (); + else + return TAO_POA::non_root_key_char (); +} + +ACE_INLINE CORBA::ULong +TAO_POA::root_key_type_length (void) +{ + return sizeof (char); +} + ACE_INLINE void TAO_POA_Current::clear (void) { |