Go to the documentation of this file.00001
00002
00003 #include "tao/EndpointPolicy/Endpoint_Acceptor_Filter.h"
00004 #include "tao/EndpointPolicy/EndpointPolicyC.h"
00005 #include "tao/EndpointPolicy/Endpoint_Value_Impl.h"
00006
00007 #include "tao/Transport_Acceptor.h"
00008 #include "tao/MProfile.h"
00009 #include "tao/Profile.h"
00010 #include "tao/Endpoint.h"
00011
00012 ACE_RCSID(EndpointPolicy,
00013 Endpoint_Acceptor_Filter,
00014 "$Id: Endpoint_Acceptor_Filter.cpp 79701 2007-09-21 23:25:30Z ossama $")
00015
00016
00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00018
00019 TAO_Endpoint_Acceptor_Filter::TAO_Endpoint_Acceptor_Filter (const EndpointPolicy::EndpointList & eps)
00020 : endpoints_(eps)
00021 {
00022 }
00023
00024 int
00025 TAO_Endpoint_Acceptor_Filter::fill_profile (const TAO::ObjectKey &object_key,
00026 TAO_MProfile &mprofile,
00027 TAO_Acceptor **acceptors_begin,
00028 TAO_Acceptor **acceptors_end,
00029 CORBA::Short priority)
00030 {
00031 CORBA::ULong const num_endpoints = endpoints_.length ();
00032
00033 for (TAO_Acceptor** acceptor = acceptors_begin;
00034 acceptor != acceptors_end;
00035 ++acceptor)
00036 {
00037 bool tagfound = false;
00038 for (CORBA::ULong epx = 0; !tagfound && epx < num_endpoints; epx++)
00039 {
00040 tagfound = (*acceptor)->tag () == endpoints_[epx]->protocol_tag();
00041 }
00042 if (!tagfound)
00043 continue;
00044
00045 if ((*acceptor)->create_profile (object_key,
00046 mprofile,
00047 priority) == -1)
00048 return -1;
00049 }
00050
00051 if (TAO_debug_level > 2)
00052 ACE_DEBUG ((LM_DEBUG,
00053 ACE_TEXT("(%P|%t) EndpointPolicy filtering acceptors")
00054 ACE_TEXT(" - mprofile has %d profiles,")
00055 ACE_TEXT(" endpoint list has %d entries\n"),
00056 mprofile.profile_count(), num_endpoints));
00057
00058 for (TAO_PHandle pfile_ndx = 0;
00059 pfile_ndx < mprofile.profile_count ();
00060 ++pfile_ndx)
00061 {
00062 TAO_Profile * const pfile = mprofile.get_profile (pfile_ndx);
00063 TAO_Endpoint * ep_in_pfile = pfile->base_endpoint ();
00064
00065 if (TAO_debug_level > 2)
00066 ACE_DEBUG ((LM_DEBUG,
00067 ACE_TEXT("(%P|%t) Testing profile %d - ")
00068 ACE_TEXT("it contains %d endpoints\n"),
00069 pfile_ndx, pfile->endpoint_count()));
00070
00071 bool first_endpoint = true;
00072
00073 while (ep_in_pfile != 0 && pfile->endpoint_count() > 0)
00074 {
00075
00076
00077 CORBA::ULong ep_ndx = 0;
00078 bool epmatch = false;
00079 for (ep_ndx = 0; !epmatch && ep_ndx < num_endpoints; ++ep_ndx)
00080 {
00081 if (endpoints_[ep_ndx]->protocol_tag() != pfile->tag())
00082 continue;
00083
00084 const EndpointPolicy::EndpointValueBase_ptr evb =
00085 endpoints_[ep_ndx];
00086
00087 const TAO_Endpoint_Value_Impl *evi =
00088 dynamic_cast <const TAO_Endpoint_Value_Impl*>(evb);
00089
00090 epmatch = evi->is_equivalent(ep_in_pfile);
00091 }
00092
00093
00094
00095 if (!epmatch)
00096 {
00097
00098 TAO_Endpoint * next = ep_in_pfile->next ();
00099 if (TAO_debug_level > 2)
00100 ACE_DEBUG ((LM_DEBUG,
00101 ACE_TEXT ("(%P|%t) EndpointPolicy filter ")
00102 ACE_TEXT ("removing endpoint\n")));
00103 pfile->remove_generic_endpoint (ep_in_pfile);
00104 ep_in_pfile = first_endpoint ? pfile->endpoint() : next;
00105 }
00106 else
00107 {
00108 if (TAO_debug_level > 2)
00109 ACE_DEBUG ((LM_DEBUG,
00110 ACE_TEXT ("(%P|%t) EndpointPolicy filter ")
00111 ACE_TEXT ("Endpoint matched policy value\n")));
00112 ep_in_pfile = ep_in_pfile->next();
00113 first_endpoint = false;
00114 }
00115 }
00116
00117 CORBA::ULong const ep_count = pfile->endpoint_count ();
00118
00119
00120
00121 if (ep_count == 0
00122 && mprofile.remove_profile (pfile) != -1)
00123 {
00124 --pfile_ndx;
00125
00126 if (TAO_debug_level > 2)
00127 ACE_DEBUG ((LM_DEBUG,
00128 ACE_TEXT("(%P|%t) EndpointPolicy filter ")
00129 ACE_TEXT("removing profile\n")));
00130 }
00131 else if (ep_count != 0)
00132 {
00133 if (TAO_debug_level > 2)
00134 ACE_DEBUG ((LM_DEBUG,
00135 ACE_TEXT("(%P|%t) EndpointPolicy filter ")
00136 ACE_TEXT("profile retained with %d endpoints\n"),
00137 ep_count));
00138 }
00139 }
00140
00141 if (mprofile.profile_count () == 0) {
00142 if (TAO_debug_level > 0)
00143 ACE_DEBUG ((LM_DEBUG,
00144 ACE_TEXT("(%P|%t) EndpointPolicy filter ")
00145 ACE_TEXT("eliminated all profiles\n")));
00146
00147 return -1;
00148 }
00149
00150 if (TAO_debug_level > 2)
00151 ACE_DEBUG ((LM_DEBUG,
00152 ACE_TEXT("(%P|%t) EndpointPolicy filter returning mprofile ")
00153 ACE_TEXT("with %d profiles\n"),
00154 mprofile.profile_count()));
00155
00156 return 0;
00157 }
00158
00159
00160 TAO_END_VERSIONED_NAMESPACE_DECL