#include <IORManip_IIOP_Filter.h>
Inheritance diagram for TAO_IORManip_IIOP_Filter:
Public Member Functions | |
TAO_IORManip_IIOP_Filter (void) | |
Constructor. | |
virtual | ~TAO_IORManip_IIOP_Filter (void) |
Destructor. | |
virtual CORBA::Boolean | compare_profile_info (const TAO_IORManip_IIOP_Filter::Profile_Info &left, const TAO_IORManip_IIOP_Filter::Profile_Info &right) |
Compares the profile to the profile info. | |
virtual CORBA::Boolean | profile_info_matches (const TAO_IORManip_IIOP_Filter::Profile_Info &pinfo) |
Protected Member Functions | |
virtual void | filter_and_add (TAO_Profile *profile, TAO_MProfile &profiles, TAO_Profile *guideline=0) |
This is the bulk of the filtering code. | |
Private Member Functions | |
int | fill_profile_info (TAO_Profile *profile, TAO_IORManip_IIOP_Filter::Profile_Info &pinfo) |
Fill in the Profile_Info with information from the profile. | |
int | get_endpoints (TAO_Profile *profile, TAO::IIOPEndpointSequence &endpoints) |
Get the endpoint sequence from the profile. | |
TAO_IIOP_Profile * | create_profile (TAO_Profile *profile) |
Allocate a new IIOP Profile based on the profile passed in. |
|
Constructor.
Definition at line 15 of file IORManip_IIOP_Filter.cpp.
00016 { 00017 } |
|
Destructor.
Definition at line 20 of file IORManip_IIOP_Filter.cpp.
00021 { 00022 } |
|
Compares the profile to the profile info.
Definition at line 26 of file IORManip_IIOP_Filter.cpp. References TAO_IORManip_IIOP_Filter::Profile_Info::host_name_, TAO_GIOP_Message_Version::major, TAO_GIOP_Message_Version::minor, TAO_IORManip_IIOP_Filter::Profile_Info::port_, and TAO_IORManip_IIOP_Filter::Profile_Info::version_. Referenced by filter_and_add().
|
|
Allocate a new IIOP Profile based on the profile passed in.
Definition at line 223 of file IORManip_IIOP_Filter.cpp. References ACE_NEW_THROW_EX, TAO_Profile::object_key(), TAO_Profile::orb_core(), TAO_Tagged_Components::set_component(), IOP::TaggedComponent::tag, TAO_Profile::tagged_components(), and TAO_Profile::version(). Referenced by filter_and_add().
00224 { 00225 ACE_INET_Addr addr; 00226 TAO_IIOP_Profile* new_profile = 0; 00227 ACE_NEW_THROW_EX (new_profile, 00228 TAO_IIOP_Profile (addr, 00229 profile->object_key (), 00230 profile->version (), 00231 profile->orb_core ()), 00232 CORBA::NO_MEMORY ( 00233 CORBA::SystemException::_tao_minor_code ( 00234 0, 00235 ENOMEM), 00236 CORBA::COMPLETED_NO)); 00237 00238 // Copy all of the tagged components 00239 const TAO_Tagged_Components& comps = profile->tagged_components (); 00240 new_profile->tagged_components () = comps; 00241 00242 // Set the endpoints component to an empty list 00243 IOP::TaggedComponent tagged_component; 00244 tagged_component.tag = TAO_TAG_ENDPOINTS; 00245 new_profile->tagged_components ().set_component (tagged_component); 00246 00247 return new_profile; 00248 } |
|
Fill in the Profile_Info with information from the profile.
Definition at line 160 of file IORManip_IIOP_Filter.cpp. References TAO_Endpoint::addr_to_string(), ACE_OS::atoi(), TAO_Profile::endpoint(), TAO_IORManip_IIOP_Filter::Profile_Info::host_name_, TAO_IORManip_IIOP_Filter::Profile_Info::port_, ACE_OS::strchr(), TAO_Profile::version(), and TAO_IORManip_IIOP_Filter::Profile_Info::version_. Referenced by filter_and_add().
00163 { 00164 static const int host_length = 384; 00165 int status = 0; 00166 if (profile != 0) 00167 { 00168 char host[host_length] = ""; 00169 if (profile->endpoint ()->addr_to_string (host, host_length) != -1) 00170 { 00171 char* delim = ACE_OS::strchr (host, ':'); 00172 if (delim != 0) 00173 { 00174 *delim = '\0'; 00175 pinfo.port_ = ACE_OS::atoi (delim + 1); 00176 status = 1; 00177 } 00178 } 00179 00180 pinfo.host_name_ = host; 00181 pinfo.version_ = profile->version (); 00182 } 00183 00184 return status; 00185 } |
|
This is the bulk of the filtering code.
Implements TAO_IORManip_Filter. Definition at line 46 of file IORManip_IIOP_Filter.cpp. References TAO_Profile::_decr_refcnt(), ACE_NEW, TAO_IIOP_Profile::add_endpoint(), TAO_MProfile::add_profile(), compare_profile_info(), create_profile(), TAO_IIOP_Profile::encode_endpoints(), TAO_IIOP_Profile::endpoint(), fill_profile_info(), get_endpoints(), TAO_IIOP_Endpoint::host(), TAO_IORManip_IIOP_Filter::Profile_Info::host_name_, TAO_IIOP_Endpoint::port(), TAO_IORManip_IIOP_Filter::Profile_Info::port_, TAO_Endpoint::priority(), and profile_info_matches().
00049 { 00050 TAO_IORManip_IIOP_Filter::Profile_Info ginfo; 00051 TAO_IORManip_IIOP_Filter::Profile_Info pinfo; 00052 TAO::IIOPEndpointSequence endpoints; 00053 00054 this->fill_profile_info (guideline, ginfo); 00055 this->get_endpoints (profile, endpoints); 00056 if (endpoints.length () == 0) 00057 { 00058 CORBA::Boolean matches = false; 00059 this->fill_profile_info (profile, pinfo); 00060 00061 if (guideline == 0) 00062 { 00063 matches = this->profile_info_matches (pinfo); 00064 } 00065 else 00066 { 00067 // Compare the current profile with the guideline profile 00068 matches = this->compare_profile_info (pinfo, ginfo); 00069 } 00070 00071 if (matches) 00072 { 00073 if (new_profiles.add_profile (profile) == -1) 00074 { 00075 throw CORBA::NO_MEMORY (); 00076 } 00077 } 00078 } 00079 else 00080 { 00081 // Create a new profile with just the 00082 // components we are looking for 00083 TAO_IIOP_Profile* new_profile = 00084 this->create_profile (profile); 00085 00086 // Set pinfo to match the current profile 00087 this->fill_profile_info (profile, pinfo); 00088 00089 // Add each endpoint if it matches. Begin from the end 00090 // of the sequence to preserve endpoint order, since <add_endpoint> 00091 // method reverses the order of endpoints in the list. 00092 for (CORBA::Long i = endpoints.length () - 1; i >= 0; i--) { 00093 // Set pinfo host name to the current endpoint host name 00094 pinfo.host_name_ = endpoints[i].host.in (); 00095 pinfo.port_ = endpoints[i].port; 00096 00097 CORBA::Boolean matches = false; 00098 if (guideline == 0) 00099 { 00100 matches = this->profile_info_matches (pinfo); 00101 } 00102 else 00103 { 00104 // Compare the current profile with the guideline profile 00105 matches = this->compare_profile_info (pinfo, ginfo); 00106 } 00107 00108 if (matches) 00109 { 00110 // Set the main endpoint on the profile 00111 if (i == 0) 00112 { 00113 TAO_IIOP_Endpoint* ep = dynamic_cast<TAO_IIOP_Endpoint*> ( 00114 new_profile->endpoint ()); 00115 if (ep == 0) 00116 { 00117 new_profile->_decr_refcnt (); 00118 return; 00119 } 00120 else 00121 { 00122 ep->host (CORBA::string_dup (endpoints[i].host)); 00123 ep->port (endpoints[i].port); 00124 ep->priority (endpoints[i].priority); 00125 } 00126 } 00127 else 00128 { 00129 TAO_IIOP_Endpoint *endpoint = 0; 00130 ACE_NEW (endpoint, 00131 TAO_IIOP_Endpoint (endpoints[i].host, 00132 endpoints[i].port, 00133 endpoints[i].priority)); 00134 if (endpoint == 0) 00135 { 00136 new_profile->_decr_refcnt (); 00137 return; 00138 } 00139 00140 new_profile->add_endpoint (endpoint); 00141 } 00142 } 00143 } 00144 00145 if (new_profiles.add_profile (new_profile) == -1) 00146 { 00147 throw CORBA::NO_MEMORY (); 00148 } 00149 00150 new_profile->encode_endpoints (); 00151 00152 // After adding the profile to the MProfile, 00153 // we must decrement the reference to avoid a memory leak 00154 new_profile->_decr_refcnt (); 00155 } 00156 } |
|
Get the endpoint sequence from the profile.
Definition at line 189 of file IORManip_IIOP_Filter.cpp. References IOP::TaggedComponent::component_data, TAO_Tagged_Components::get_component(), ACE_InputCDR::reset_byte_order(), IOP::TaggedComponent::tag, and TAO_Profile::tagged_components(). Referenced by filter_and_add().
00191 { 00192 // Reset the endpoints 00193 endpoints.length (0); 00194 00195 // Get the endpoints tagged component 00196 const TAO_Tagged_Components& comps = profile->tagged_components (); 00197 IOP::TaggedComponent tagged_component; 00198 tagged_component.tag = TAO_TAG_ENDPOINTS; 00199 comps.get_component (tagged_component); 00200 00201 // Prepare the CDR for endpoint extraction 00202 const CORBA::Octet *buf = 00203 tagged_component.component_data.get_buffer (); 00204 00205 TAO_InputCDR in_cdr (reinterpret_cast<const char*> (buf), 00206 tagged_component.component_data.length ()); 00207 00208 // Extract the Byte Order. 00209 CORBA::Boolean byte_order; 00210 if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) 00211 return 0; 00212 in_cdr.reset_byte_order (static_cast<int> (byte_order)); 00213 00214 // Extract endpoints sequence. 00215 if ((in_cdr >> endpoints) == 0) 00216 return 0; 00217 00218 return 1; 00219 } |
|
Empty virtual method to match on the profile info. Users must provide an implementation to use the first form of sanitize_profiles(). Definition at line 38 of file IORManip_IIOP_Filter.cpp. Referenced by filter_and_add().
00040 { 00041 return true; 00042 } |