Go to the documentation of this file.00001
00002
00003 #include "orbsvcs/Notify/Method_Request_Lookup.h"
00004
00005 ACE_RCSID(Notify, TAO_Notify_Method_Request_Lookup, "$Id: Method_Request_Lookup.cpp 85524 2009-06-05 14:35:28Z johnnyw $")
00006
00007 #include "orbsvcs/Notify/Consumer_Map.h"
00008 #include "orbsvcs/Notify/ProxySupplier.h"
00009 #include "orbsvcs/Notify/ProxyConsumer.h"
00010 #include "orbsvcs/Notify/Proxy.h"
00011 #include "orbsvcs/Notify/Admin.h"
00012 #include "orbsvcs/Notify/SupplierAdmin.h"
00013 #include "orbsvcs/Notify/Method_Request_Dispatch.h"
00014 #include "orbsvcs/Notify/Delivery_Request.h"
00015 #include "orbsvcs/Notify/EventChannelFactory.h"
00016 #include "orbsvcs/Notify/Event_Manager.h"
00017 #include "orbsvcs/Notify/Factory.h"
00018
00019 #include "orbsvcs/ESF/ESF_Proxy_Collection.h"
00020
00021 #include "tao/debug.h"
00022 #include "tao/CDR.h"
00023
00024 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00025
00026 TAO_Notify_Method_Request_Lookup::TAO_Notify_Method_Request_Lookup (
00027 const TAO_Notify_Event * event,
00028 TAO_Notify_ProxyConsumer * proxy)
00029 : TAO_Notify_Method_Request_Event (event)
00030 , proxy_consumer_ (proxy)
00031 {
00032 }
00033
00034 TAO_Notify_Method_Request_Lookup::TAO_Notify_Method_Request_Lookup (
00035 const TAO_Notify::Delivery_Request_Ptr& delivery,
00036 TAO_Notify_ProxyConsumer * proxy)
00037 : TAO_Notify_Method_Request_Event (delivery)
00038 , proxy_consumer_ (proxy)
00039 {
00040 }
00041
00042 TAO_Notify_Method_Request_Lookup::~TAO_Notify_Method_Request_Lookup ()
00043 {
00044 }
00045
00046 void
00047 TAO_Notify_Method_Request_Lookup::work (
00048 TAO_Notify_ProxySupplier* proxy_supplier)
00049 {
00050 if (delivery_request_.get () == 0)
00051 {
00052 TAO_Notify_Method_Request_Dispatch_No_Copy request (*this, proxy_supplier, true);
00053 proxy_supplier->deliver (request);
00054 }
00055 else
00056 {
00057 delivery_request_->dispatch (proxy_supplier, true);
00058 }
00059 }
00060
00061 int TAO_Notify_Method_Request_Lookup::execute_i (void)
00062 {
00063 if (this->proxy_consumer_->has_shutdown ())
00064 return 0;
00065
00066 TAO_Notify_SupplierAdmin& parent = this->proxy_consumer_->supplier_admin ();
00067
00068 CORBA::Boolean val = this->proxy_consumer_->check_filters (this->event_,
00069 parent.filter_admin (),
00070 parent.filter_operator ());
00071
00072 if (TAO_debug_level > 1)
00073 ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Notify (%P|%t) Proxyconsumer %x filter ")
00074 ACE_TEXT("eval result = %d\n"),
00075 &this->proxy_consumer_ , val));
00076
00077
00078 if (!val)
00079 return 0;
00080
00081
00082 TAO_Notify_Consumer_Map& map = this->proxy_consumer_->event_manager ().consumer_map ();
00083
00084 TAO_Notify_Consumer_Map::ENTRY* entry = map.find (this->event_->type ());
00085
00086 TAO_Notify_ProxySupplier_Collection* consumers = 0;
00087
00088 if (entry != 0)
00089 {
00090 consumers = entry->collection ();
00091
00092 if (consumers != 0)
00093 {
00094 consumers->for_each (this);
00095 }
00096
00097 map.release (entry);
00098 }
00099
00100
00101 consumers = map.broadcast_collection ();
00102
00103 if (consumers != 0)
00104 {
00105 consumers->for_each (this);
00106 }
00107 this->complete ();
00108 return 0;
00109 }
00110
00111
00112 TAO_Notify_Method_Request_Lookup_Queueable *
00113 TAO_Notify_Method_Request_Lookup::unmarshal (
00114 TAO_Notify::Delivery_Request_Ptr & delivery_request,
00115 TAO_Notify_EventChannelFactory &ecf,
00116 TAO_InputCDR & cdr)
00117 {
00118 bool ok = true;
00119 TAO_Notify_Method_Request_Lookup_Queueable * result = 0;
00120 CORBA::ULong count;
00121 if (cdr.read_ulong (count))
00122 {
00123 TAO_Notify::IdVec id_path (count);
00124 for (size_t nid = 0; ok && nid < count; ++nid)
00125 {
00126 TAO_Notify_Object::ID id = 0;
00127 if ( cdr.read_long (id))
00128 {
00129 id_path.push_back (id);
00130 }
00131 else
00132 {
00133 ok = false;
00134 }
00135 }
00136
00137 if (ok)
00138 {
00139 TAO_Notify_ProxyConsumer * proxy_consumer = ecf.find_proxy_consumer (
00140 id_path,
00141 0);
00142 if (proxy_consumer != 0)
00143 {
00144 ACE_NEW_NORETURN (result,
00145 TAO_Notify_Method_Request_Lookup_Queueable (delivery_request, proxy_consumer));
00146 }
00147 else
00148 {
00149 ACE_ERROR ((LM_ERROR,
00150 ACE_TEXT ("(%P|%t) TAO_Notify_Method_Request_Lookup_No_Copy::unmarshal: unknown proxy id\n")
00151 ));
00152 }
00153 }
00154 else
00155 {
00156 ACE_ERROR ((LM_ERROR,
00157 ACE_TEXT ("(%P|%t) TAO_Notify_Method_Request_Lookup_No_Copy::unmarshal: Cant read proxy id path\n")
00158 ));
00159 }
00160 }
00161 return result;
00162
00163 }
00164
00165
00166
00167
00168 TAO_Notify_Method_Request_Lookup_Queueable::TAO_Notify_Method_Request_Lookup_Queueable (
00169 const TAO_Notify_Event::Ptr& event,
00170 TAO_Notify_ProxyConsumer* proxy_consumer)
00171 : TAO_Notify_Method_Request_Lookup (event.get (), proxy_consumer)
00172 , TAO_Notify_Method_Request_Queueable (event.get ())
00173 , event_var_ (event)
00174 , proxy_guard_ (proxy_consumer)
00175 {
00176 }
00177
00178 TAO_Notify_Method_Request_Lookup_Queueable::TAO_Notify_Method_Request_Lookup_Queueable (
00179 TAO_Notify::Delivery_Request_Ptr & request,
00180 TAO_Notify_ProxyConsumer * proxy_consumer)
00181 : TAO_Notify_Method_Request_Lookup (request, proxy_consumer)
00182 , TAO_Notify_Method_Request_Queueable (request->event ().get ())
00183 , event_var_ (request->event ())
00184 , proxy_guard_ (proxy_consumer)
00185 {
00186 }
00187
00188
00189 TAO_Notify_Method_Request_Lookup_Queueable::~TAO_Notify_Method_Request_Lookup_Queueable ()
00190 {
00191 }
00192
00193 int
00194 TAO_Notify_Method_Request_Lookup_Queueable::execute (void)
00195 {
00196 return this->execute_i ();
00197 }
00198
00199
00200
00201 TAO_Notify_Method_Request_Lookup_No_Copy::TAO_Notify_Method_Request_Lookup_No_Copy (
00202 const TAO_Notify_Event* event,
00203 TAO_Notify_ProxyConsumer* proxy_consumer)
00204 : TAO_Notify_Method_Request_Lookup (event, proxy_consumer)
00205 {
00206 }
00207
00208 TAO_Notify_Method_Request_Lookup_No_Copy::~TAO_Notify_Method_Request_Lookup_No_Copy ()
00209 {
00210 }
00211
00212 int
00213 TAO_Notify_Method_Request_Lookup_No_Copy::execute (void)
00214 {
00215 return this->execute_i ();
00216 }
00217
00218 TAO_Notify_Method_Request_Queueable*
00219 TAO_Notify_Method_Request_Lookup_No_Copy::copy (void)
00220 {
00221 TAO_Notify_Method_Request_Queueable* request;
00222
00223 TAO_Notify_Event::Ptr event(this->event_->queueable_copy());
00224
00225 ACE_NEW_THROW_EX (request,
00226 TAO_Notify_Method_Request_Lookup_Queueable (event, this->proxy_consumer_),
00227 CORBA::INTERNAL ());
00228
00229 return request;
00230 }
00231
00232 TAO_END_VERSIONED_NAMESPACE_DECL