00001
00002
00003 #include "orbsvcs/Notify/Method_Request_Dispatch.h"
00004
00005 ACE_RCSID(Notify, TAO_Notify_Method_Request_Dispatch, "$Id: Method_Request_Dispatch.cpp 85524 2009-06-05 14:35:28Z johnnyw $")
00006
00007 #include "orbsvcs/Notify/ProxySupplier.h"
00008 #include "orbsvcs/Notify/Consumer.h"
00009 #include "orbsvcs/Notify/Admin.h"
00010 #include "orbsvcs/Notify/ConsumerAdmin.h"
00011 #include "orbsvcs/Notify/EventChannelFactory.h"
00012
00013 #include "tao/debug.h"
00014 #include "tao/CDR.h"
00015
00016 #include "ace/OS_NS_stdio.h"
00017
00018 #ifndef DEBUG_LEVEL
00019 # define DEBUG_LEVEL TAO_debug_level
00020 #endif //DEBUG_LEVEL
00021
00022 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00023
00024
00025 TAO_Notify_Method_Request_Dispatch::TAO_Notify_Method_Request_Dispatch (
00026 const TAO_Notify_Event * event,
00027 TAO_Notify_ProxySupplier* proxy_supplier,
00028 bool filtering)
00029 : TAO_Notify_Method_Request_Event (event)
00030 , proxy_supplier_ (proxy_supplier)
00031 , filtering_ (filtering)
00032 {
00033 }
00034
00035
00036 TAO_Notify_Method_Request_Dispatch::TAO_Notify_Method_Request_Dispatch (
00037 const TAO_Notify::Delivery_Request_Ptr & delivery,
00038 TAO_Notify_ProxySupplier* proxy_supplier,
00039 bool filtering)
00040 : TAO_Notify_Method_Request_Event (delivery)
00041 , proxy_supplier_ (proxy_supplier)
00042 , filtering_ (filtering)
00043 {
00044 }
00045
00046
00047
00048
00049 TAO_Notify_Method_Request_Dispatch::TAO_Notify_Method_Request_Dispatch (
00050 const TAO_Notify_Method_Request_Event & request,
00051 const TAO_Notify_Event * event,
00052 TAO_Notify_ProxySupplier* proxy_supplier,
00053 bool filtering)
00054 : TAO_Notify_Method_Request_Event (request, event)
00055 , proxy_supplier_ (proxy_supplier)
00056 , filtering_ (filtering)
00057 {
00058 }
00059
00060 TAO_Notify_Method_Request_Dispatch::~TAO_Notify_Method_Request_Dispatch ()
00061 {
00062 }
00063
00064 int TAO_Notify_Method_Request_Dispatch::execute_i (void)
00065 {
00066 if (this->proxy_supplier_->has_shutdown ())
00067 return 0;
00068
00069 if (this->filtering_ == 1)
00070 {
00071 TAO_Notify_Admin& parent = this->proxy_supplier_->consumer_admin ();
00072 CORBA::Boolean const val = this->proxy_supplier_->check_filters (this->event_,
00073 parent.filter_admin (),
00074 parent.filter_operator ());
00075
00076 if (TAO_debug_level > 1)
00077 ACE_DEBUG ((LM_DEBUG,
00078 ACE_TEXT ("Notify (%P|%t) Proxysupplier %x filter ")
00079 ACE_TEXT ("eval result = %d\n"),
00080 &this->proxy_supplier_ , val));
00081
00082
00083 if (!val)
00084 return 0;
00085 }
00086
00087 try
00088 {
00089 TAO_Notify_Consumer* consumer = this->proxy_supplier_->consumer ();
00090
00091 if (consumer != 0)
00092 {
00093 consumer->deliver (this);
00094 }
00095 }
00096 catch (const CORBA::Exception& ex)
00097 {
00098 if (TAO_debug_level > 0)
00099 ex._tao_print_exception (
00100 ACE_TEXT (
00101 "TAO_Notify_Method_Request_Dispatch::: error sending event.\n"));
00102 }
00103
00104 return 0;
00105 }
00106
00107
00108 TAO_Notify_Method_Request_Dispatch_Queueable *
00109 TAO_Notify_Method_Request_Dispatch::unmarshal (
00110 TAO_Notify::Delivery_Request_Ptr & delivery_request,
00111 TAO_Notify_EventChannelFactory &ecf,
00112 TAO_InputCDR & cdr)
00113 {
00114 bool ok = true;
00115 TAO_Notify_Method_Request_Dispatch_Queueable * result = 0;
00116 ACE_CString textpath;
00117 CORBA::ULong count;
00118 if (cdr.read_ulong (count))
00119 {
00120 TAO_Notify::IdVec id_path (count);
00121 for (size_t nid = 0; ok && nid < count; ++nid)
00122 {
00123 TAO_Notify_Object::ID id = 0;
00124 if ( cdr.read_long (id))
00125 {
00126 id_path.push_back (id);
00127 char idbuf[20];
00128 ACE_OS::snprintf (idbuf, sizeof(idbuf), "/%d", static_cast<int> (id));
00129 textpath += idbuf;
00130 }
00131 else
00132 {
00133 ok = false;
00134 }
00135 }
00136
00137 if (ok)
00138 {
00139 TAO_Notify_ProxySupplier* proxy_supplier = ecf.find_proxy_supplier (id_path,
00140 0);
00141 if (proxy_supplier != 0)
00142 {
00143 if (DEBUG_LEVEL > 6)
00144 ACE_DEBUG ((LM_DEBUG,
00145 ACE_TEXT ("(%P|%t) TAO_Notify_Method_Request_Dispatch")
00146 ACE_TEXT (" reload event for %C\n"),
00147 textpath.c_str()));
00148 ACE_NEW_NORETURN (result,
00149 TAO_Notify_Method_Request_Dispatch_Queueable (delivery_request, proxy_supplier, true));
00150 }
00151 else
00152 {
00153 TAO_Notify_ProxyConsumer * proxy_consumer = ecf.find_proxy_consumer (id_path, 0);
00154 if (proxy_consumer == 0)
00155 {
00156 ACE_ERROR ((LM_ERROR,
00157 ACE_TEXT ("(%P|%t) TAO_Notify_Method_Request_Dispatch")
00158 ACE_TEXT ("::unmarshal: unknown proxy id %C\n"),
00159 textpath.c_str()));
00160 }
00161 else
00162 {
00163 ACE_ERROR ((LM_ERROR,
00164 ACE_TEXT ("(%P|%t) TAO_Notify_Method_Request_Dispatch")
00165 ACE_TEXT ("::unmarshal: wrong type of proxy id %C\n"),
00166 textpath.c_str()));
00167 }
00168 }
00169 }
00170 else
00171 {
00172 ACE_ERROR ((LM_ERROR,
00173 ACE_TEXT ("(%P|%t) TAO_Notify_Method_Request_Dispatch")
00174 ACE_TEXT ("::unmarshal: Cant read proxy id path\n")));
00175 }
00176 }
00177 return result;
00178 }
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 TAO_Notify_Method_Request_Dispatch_Queueable::TAO_Notify_Method_Request_Dispatch_Queueable (
00189 const TAO_Notify_Method_Request_Event & request,
00190 TAO_Notify_Event::Ptr & event,
00191 TAO_Notify_ProxySupplier* proxy_supplier,
00192 bool filtering)
00193 : TAO_Notify_Method_Request_Dispatch (request, event.get (), proxy_supplier, filtering)
00194 , TAO_Notify_Method_Request_Queueable (event.get ())
00195 , event_var_( event )
00196 {
00197 }
00198
00199
00200
00201 TAO_Notify_Method_Request_Dispatch_Queueable::TAO_Notify_Method_Request_Dispatch_Queueable (
00202 const TAO_Notify::Delivery_Request_Ptr & request,
00203 TAO_Notify_ProxySupplier* proxy_supplier,
00204 bool filtering)
00205 : TAO_Notify_Method_Request_Dispatch (request, request->event ().get (), proxy_supplier, filtering)
00206 , TAO_Notify_Method_Request_Queueable (request->event ().get ())
00207 , event_var_( request->event () )
00208
00209 {
00210 }
00211
00212 TAO_Notify_Method_Request_Dispatch_Queueable::~TAO_Notify_Method_Request_Dispatch_Queueable ()
00213 {
00214 }
00215
00216 int
00217 TAO_Notify_Method_Request_Dispatch_Queueable::execute (void)
00218 {
00219 return this->execute_i ();
00220 }
00221
00222
00223
00224
00225 TAO_Notify_Method_Request_Dispatch_No_Copy::TAO_Notify_Method_Request_Dispatch_No_Copy (
00226 const TAO_Notify_Method_Request_Event & request,
00227 TAO_Notify_ProxySupplier* proxy_supplier,
00228 bool filtering)
00229 : TAO_Notify_Method_Request_Dispatch (request, request.event (), proxy_supplier, filtering)
00230 {
00231 }
00232
00233 TAO_Notify_Method_Request_Dispatch_No_Copy:: ~TAO_Notify_Method_Request_Dispatch_No_Copy ()
00234 {
00235 }
00236
00237 int
00238 TAO_Notify_Method_Request_Dispatch_No_Copy::execute (void)
00239 {
00240 return this->execute_i ();
00241 }
00242
00243 TAO_Notify_Method_Request_Queueable*
00244 TAO_Notify_Method_Request_Dispatch_No_Copy::copy (void)
00245 {
00246 TAO_Notify_Method_Request_Queueable* request = 0;
00247
00248 TAO_Notify_Event::Ptr event_var (
00249 this->event_->queueable_copy () );
00250
00251 ACE_NEW_THROW_EX (request,
00252 TAO_Notify_Method_Request_Dispatch_Queueable (*this, event_var, this->proxy_supplier_.get(), this->filtering_),
00253
00254 CORBA::INTERNAL ());
00255
00256 return request;
00257 }
00258
00259 TAO_END_VERSIONED_NAMESPACE_DECL