00001
00002
00003 #include "orbsvcs/Notify/Method_Request_Lookup.h"
00004
00005 ACE_RCSID(Notify, TAO_Notify_Method_Request_Lookup, "Method_Request_Lookup.cpp,v 1.17 2006/03/14 06:14:34 jtc Exp")
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 {
00036 }
00037
00038 void
00039 TAO_Notify_Method_Request_Lookup::work (
00040 TAO_Notify_ProxySupplier* proxy_supplier
00041 ACE_ENV_ARG_DECL)
00042 {
00043 if (delivery_request_.get () == 0)
00044 {
00045 TAO_Notify_Method_Request_Dispatch_No_Copy request (*this, proxy_supplier, true);
00046 proxy_supplier->deliver (request ACE_ENV_ARG_PARAMETER);
00047 ACE_CHECK;
00048 }
00049 else
00050 {
00051 delivery_request_->dispatch (proxy_supplier, true ACE_ENV_ARG_PARAMETER);
00052 ACE_CHECK;
00053 }
00054 }
00055
00056 int TAO_Notify_Method_Request_Lookup::execute_i (ACE_ENV_SINGLE_ARG_DECL)
00057 {
00058 if (this->proxy_consumer_->has_shutdown ())
00059 return 0;
00060
00061 TAO_Notify_SupplierAdmin& parent = this->proxy_consumer_->supplier_admin ();
00062
00063 CORBA::Boolean val = this->proxy_consumer_->check_filters (this->event_,
00064 parent.filter_admin (),
00065 parent.filter_operator ()
00066 ACE_ENV_ARG_PARAMETER);
00067 ACE_CHECK_RETURN (0);
00068
00069 if (TAO_debug_level > 1)
00070 ACE_DEBUG ((LM_DEBUG, "Proxyconsumer %x filter eval result = %d",&this->proxy_consumer_ , val));
00071
00072
00073 if (val == 0)
00074 return 0;
00075
00076
00077 TAO_Notify_Consumer_Map& map = this->proxy_consumer_->event_manager ().consumer_map ();
00078
00079 TAO_Notify_Consumer_Map::ENTRY* entry = map.find (this->event_->type () ACE_ENV_ARG_PARAMETER);
00080 ACE_CHECK_RETURN (0);
00081
00082 TAO_Notify_ProxySupplier_Collection* consumers = 0;
00083
00084 if (entry != 0)
00085 {
00086 consumers = entry->collection ();
00087
00088 if (consumers != 0)
00089 {
00090 consumers->for_each (this ACE_ENV_ARG_PARAMETER);
00091 ACE_CHECK_RETURN (0);
00092 }
00093
00094 map.release (entry);
00095 }
00096
00097
00098 consumers = map.broadcast_collection ();
00099
00100 if (consumers != 0)
00101 {
00102 consumers->for_each (this ACE_ENV_ARG_PARAMETER);
00103 ACE_CHECK_RETURN (0);
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 ACE_ENV_ARG_DECL)
00116 {
00117 bool ok = true;
00118 TAO_Notify_Method_Request_Lookup_Queueable * result = 0;
00119 CORBA::ULong count;
00120 if (cdr.read_ulong (count))
00121 {
00122 TAO_Notify::IdVec id_path (count);
00123 for (size_t nid = 0; ok && nid < count; ++nid)
00124 {
00125 TAO_Notify_Object::ID id = 0;
00126 if ( cdr.read_long (id))
00127 {
00128 id_path.push_back (id);
00129 }
00130 else
00131 {
00132 ok = false;
00133 }
00134 }
00135
00136 if (ok)
00137 {
00138 TAO_Notify_ProxyConsumer * proxy_consumer = ecf.find_proxy_consumer (
00139 id_path,
00140 0 ACE_ENV_ARG_PARAMETER);
00141 ACE_CHECK_RETURN(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->event ().get (), 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 (ACE_ENV_SINGLE_ARG_DECL)
00195 {
00196 return this->execute_i (ACE_ENV_SINGLE_ARG_PARAMETER);
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 (ACE_ENV_SINGLE_ARG_DECL)
00214 {
00215 return this->execute_i (ACE_ENV_SINGLE_ARG_PARAMETER);
00216 }
00217
00218 TAO_Notify_Method_Request_Queueable*
00219 TAO_Notify_Method_Request_Lookup_No_Copy::copy (ACE_ENV_SINGLE_ARG_DECL)
00220 {
00221 TAO_Notify_Method_Request_Queueable* request;
00222
00223 TAO_Notify_Event::Ptr event(this->event_->queueable_copy(ACE_ENV_SINGLE_ARG_PARAMETER));
00224 ACE_CHECK_RETURN (0);
00225
00226 ACE_NEW_THROW_EX (request,
00227 TAO_Notify_Method_Request_Lookup_Queueable (event, this->proxy_consumer_),
00228 CORBA::INTERNAL ());
00229
00230 return request;
00231 }
00232
00233 TAO_END_VERSIONED_NAMESPACE_DECL