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 79324 2007-08-13 11:20:01Z elliott_c $")
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, "Proxyconsumer %x filter eval result = %d",&this->proxy_consumer_ , val));
00074
00075
00076 if (val == 0)
00077 return 0;
00078
00079
00080 TAO_Notify_Consumer_Map& map = this->proxy_consumer_->event_manager ().consumer_map ();
00081
00082 TAO_Notify_Consumer_Map::ENTRY* entry = map.find (this->event_->type ());
00083
00084 TAO_Notify_ProxySupplier_Collection* consumers = 0;
00085
00086 if (entry != 0)
00087 {
00088 consumers = entry->collection ();
00089
00090 if (consumers != 0)
00091 {
00092 consumers->for_each (this);
00093 }
00094
00095 map.release (entry);
00096 }
00097
00098
00099 consumers = map.broadcast_collection ();
00100
00101 if (consumers != 0)
00102 {
00103 consumers->for_each (this);
00104 }
00105 this->complete ();
00106 return 0;
00107 }
00108
00109
00110 TAO_Notify_Method_Request_Lookup_Queueable *
00111 TAO_Notify_Method_Request_Lookup::unmarshal (
00112 TAO_Notify::Delivery_Request_Ptr & delivery_request,
00113 TAO_Notify_EventChannelFactory &ecf,
00114 TAO_InputCDR & cdr)
00115 {
00116 bool ok = true;
00117 TAO_Notify_Method_Request_Lookup_Queueable * result = 0;
00118 CORBA::ULong count;
00119 if (cdr.read_ulong (count))
00120 {
00121 TAO_Notify::IdVec id_path (count);
00122 for (size_t nid = 0; ok && nid < count; ++nid)
00123 {
00124 TAO_Notify_Object::ID id = 0;
00125 if ( cdr.read_long (id))
00126 {
00127 id_path.push_back (id);
00128 }
00129 else
00130 {
00131 ok = false;
00132 }
00133 }
00134
00135 if (ok)
00136 {
00137 TAO_Notify_ProxyConsumer * proxy_consumer = ecf.find_proxy_consumer (
00138 id_path,
00139 0);
00140 if (proxy_consumer != 0)
00141 {
00142 ACE_NEW_NORETURN (result,
00143 TAO_Notify_Method_Request_Lookup_Queueable (delivery_request, proxy_consumer));
00144 }
00145 else
00146 {
00147 ACE_ERROR ((LM_ERROR,
00148 ACE_TEXT ("(%P|%t) TAO_Notify_Method_Request_Lookup_No_Copy::unmarshal: unknown proxy id\n")
00149 ));
00150 }
00151 }
00152 else
00153 {
00154 ACE_ERROR ((LM_ERROR,
00155 ACE_TEXT ("(%P|%t) TAO_Notify_Method_Request_Lookup_No_Copy::unmarshal: Cant read proxy id path\n")
00156 ));
00157 }
00158 }
00159 return result;
00160
00161 }
00162
00163
00164
00165
00166 TAO_Notify_Method_Request_Lookup_Queueable::TAO_Notify_Method_Request_Lookup_Queueable (
00167 const TAO_Notify_Event::Ptr& event,
00168 TAO_Notify_ProxyConsumer* proxy_consumer)
00169 : TAO_Notify_Method_Request_Lookup (event.get (), proxy_consumer)
00170 , TAO_Notify_Method_Request_Queueable (event.get ())
00171 , event_var_ (event)
00172 , proxy_guard_ (proxy_consumer)
00173 {
00174 }
00175
00176 TAO_Notify_Method_Request_Lookup_Queueable::TAO_Notify_Method_Request_Lookup_Queueable (
00177 TAO_Notify::Delivery_Request_Ptr & request,
00178 TAO_Notify_ProxyConsumer * proxy_consumer)
00179 : TAO_Notify_Method_Request_Lookup (request, proxy_consumer)
00180 , TAO_Notify_Method_Request_Queueable (request->event ().get ())
00181 , event_var_ (request->event ())
00182 , proxy_guard_ (proxy_consumer)
00183 {
00184 }
00185
00186
00187 TAO_Notify_Method_Request_Lookup_Queueable::~TAO_Notify_Method_Request_Lookup_Queueable ()
00188 {
00189 }
00190
00191 int
00192 TAO_Notify_Method_Request_Lookup_Queueable::execute (void)
00193 {
00194 return this->execute_i ();
00195 }
00196
00197
00198
00199 TAO_Notify_Method_Request_Lookup_No_Copy::TAO_Notify_Method_Request_Lookup_No_Copy (
00200 const TAO_Notify_Event* event,
00201 TAO_Notify_ProxyConsumer* proxy_consumer)
00202 : TAO_Notify_Method_Request_Lookup (event, proxy_consumer)
00203 {
00204 }
00205
00206 TAO_Notify_Method_Request_Lookup_No_Copy::~TAO_Notify_Method_Request_Lookup_No_Copy ()
00207 {
00208 }
00209
00210 int
00211 TAO_Notify_Method_Request_Lookup_No_Copy::execute (void)
00212 {
00213 return this->execute_i ();
00214 }
00215
00216 TAO_Notify_Method_Request_Queueable*
00217 TAO_Notify_Method_Request_Lookup_No_Copy::copy (void)
00218 {
00219 TAO_Notify_Method_Request_Queueable* request;
00220
00221 TAO_Notify_Event::Ptr event(this->event_->queueable_copy());
00222
00223 ACE_NEW_THROW_EX (request,
00224 TAO_Notify_Method_Request_Lookup_Queueable (event, this->proxy_consumer_),
00225 CORBA::INTERNAL ());
00226
00227 return request;
00228 }
00229
00230 TAO_END_VERSIONED_NAMESPACE_DECL