00001
00002
00003
00004
00005 #include "orbsvcs/CosEvent/CEC_DynamicImplementation.h"
00006 #include "tao/DynamicInterface/Request.h"
00007 #include "tao/DynamicInterface/Unknown_User_Exception.h"
00008 #include "tao/debug.h"
00009 #include "orbsvcs/CosEvent/CEC_TypedEvent.h"
00010
00011 #if !defined(__ACE_INLINE__)
00012 #include "orbsvcs/CosEvent/CEC_DynamicImplementation.inl"
00013 #endif
00014
00015 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00016
00017
00018 TAO_CEC_DynamicImplementationServer::~TAO_CEC_DynamicImplementationServer (void)
00019 {
00020 }
00021
00022
00023 void
00024 TAO_CEC_DynamicImplementationServer::invoke (CORBA::ServerRequest_ptr request)
00025 {
00026
00027 if (ACE_OS::strcmp ("_is_a", request->operation () ) == 0)
00028 {
00029 this->is_a (request);
00030 }
00031 else
00032 {
00033 CORBA::NVList_ptr list;
00034
00035
00036 TAO_CEC_Operation_Params *oper_params =
00037 this->typed_event_channel_->find_from_ifr_cache (request->operation () );
00038
00039 if (oper_params == 0)
00040 {
00041 if (TAO_debug_level >= 10)
00042 {
00043 ACE_DEBUG ((LM_DEBUG,
00044 ACE_TEXT ("***** Operation not found in IFR cache *****\n")));
00045 }
00046
00047 this->typed_event_channel_->create_list (0, list);
00048 }
00049 else
00050 {
00051
00052 this->typed_event_channel_->create_operation_list (oper_params, list);
00053
00054
00055 request->arguments (list);
00056
00057
00058 TAO_CEC_TypedEvent typed_event (list, request->operation () );
00059
00060
00061 this->typed_pp_consumer_->invoke (typed_event);
00062 }
00063 }
00064 }
00065
00066 CORBA::RepositoryId
00067 TAO_CEC_DynamicImplementationServer::_primary_interface (const PortableServer::ObjectId &,
00068 PortableServer::POA_ptr)
00069 {
00070 return CORBA::string_dup (repository_id_);
00071 }
00072
00073 PortableServer::POA_ptr
00074 TAO_CEC_DynamicImplementationServer::_default_POA (void)
00075 {
00076 return PortableServer::POA::_duplicate (this->poa_.in ());
00077 }
00078
00079 void
00080 TAO_CEC_DynamicImplementationServer::is_a (CORBA::ServerRequest_ptr request)
00081 {
00082 CORBA::NVList_ptr list;
00083
00084 this->typed_event_channel_->create_list (0, list);
00085
00086 CORBA::Any any_1;
00087 any_1._tao_set_typecode(CORBA::_tc_string);
00088
00089 list->add_value ("value",
00090 any_1,
00091 CORBA::ARG_IN);
00092
00093 request->arguments (list);
00094
00095 CORBA::NamedValue_ptr nv = list->item (0);
00096
00097 CORBA::Any_ptr ap = nv->value ();
00098 const char *value;
00099 *ap >>= value;
00100
00101 if (TAO_debug_level >= 10)
00102 {
00103 ACE_DEBUG ((LM_DEBUG,
00104 ACE_TEXT ("***** TAO_CEC_DynamicImplementationServer::is_a called with value %s *****\n"),
00105 value));
00106 }
00107
00108 const char *object_id =
00109 CORBA::_tc_Object->id ();
00110
00111 if (TAO_debug_level >= 10)
00112 {
00113 ACE_DEBUG ((LM_DEBUG,
00114 ACE_TEXT ("***** is_a using Server's RepositoryId %s *****\n"),
00115 this->repository_id_));
00116 ACE_DEBUG ((LM_DEBUG,
00117 ACE_TEXT ("***** is_a using base interface %s *****\n"),
00118 object_id));
00119 }
00120
00121 CORBA::Boolean result = 0;
00122 if (ACE_OS::strcmp (value, this->repository_id_) == 0
00123 || ACE_OS::strcmp (value, object_id) == 0)
00124 {
00125 result = 1;
00126 }
00127 else
00128 {
00129 CORBA::ULong num = this->typed_event_channel_->number_of_base_interfaces ();
00130 for (CORBA::ULong base=0; base<num; base++)
00131 {
00132 if (TAO_debug_level >= 10)
00133 {
00134 ACE_DEBUG ((LM_DEBUG,
00135 ACE_TEXT ("***** is_a using base interface %s *****\n"),
00136 this->typed_event_channel_->base_interfaces (base) ));
00137 }
00138
00139 if (ACE_OS::strcmp (value, this->typed_event_channel_->base_interfaces (base) ) == 0)
00140 {
00141 result = 1;
00142 }
00143 }
00144 }
00145
00146 if (TAO_debug_level >= 10)
00147 {
00148 ACE_DEBUG ((LM_DEBUG,
00149 ACE_TEXT ("***** is_a returning %d *****\n"),
00150 result));
00151 }
00152
00153 CORBA::Any result_any;
00154 CORBA::Any::from_boolean from_boolean (result);
00155 result_any <<= from_boolean;
00156
00157 request->set_result (result_any);
00158 }
00159
00160 TAO_END_VERSIONED_NAMESPACE_DECL