CEC_DynamicImplementation.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // CEC_DynamicImplementation.cpp,v 1.6 2006/03/14 06:14:24 jtc Exp
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.i"
00013 #endif /* __ACE_INLINE__ */
00014 
00015 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00016 
00017 // Destructor
00018 TAO_CEC_DynamicImplementationServer::~TAO_CEC_DynamicImplementationServer (void)
00019 {
00020 }
00021 
00022 // The DSI invoke request
00023 void
00024 TAO_CEC_DynamicImplementationServer::invoke (CORBA::ServerRequest_ptr request
00025                                              ACE_ENV_ARG_DECL)
00026   ACE_THROW_SPEC ((CORBA::SystemException))
00027 {
00028   // Trap the _is_a request
00029   if (ACE_OS::strcmp ("_is_a", request->operation () ) == 0)
00030     {
00031       this->is_a (request ACE_ENV_ARG_PARAMETER);
00032       ACE_CHECK;
00033     }
00034   else
00035     {
00036       CORBA::NVList_ptr list;
00037 
00038       // Get the operation paramter information from the IFR cache.
00039       TAO_CEC_Operation_Params *oper_params = 
00040         this->typed_event_channel_->find_from_ifr_cache (request->operation () );
00041 
00042       if (oper_params == 0)
00043         {
00044           if (TAO_debug_level >= 10)
00045             {
00046               ACE_DEBUG ((LM_DEBUG,
00047                           ACE_TEXT ("***** Operation not found in IFR cache *****\n")));
00048             }
00049 
00050           this->typed_event_channel_->create_list (0, list ACE_ENV_ARG_PARAMETER);
00051           ACE_CHECK;
00052         }
00053       else
00054         {
00055           // Populate the NVList from the parameter information.
00056           this->typed_event_channel_->create_operation_list (oper_params, list
00057                                                              ACE_ENV_ARG_PARAMETER);
00058           ACE_CHECK;
00059           
00060           // Get the operation arguments. This ahould demarshal correctly.
00061           request->arguments (list ACE_ENV_ARG_PARAMETER);
00062           ACE_CHECK;
00063 
00064           // Populate the TypedEvent with the list and operation name.
00065           TAO_CEC_TypedEvent typed_event (list, request->operation () );
00066 
00067           // Pass the TypedEvent to the TypedProxyPushConsumer
00068           this->typed_pp_consumer_->invoke (typed_event ACE_ENV_ARG_PARAMETER);
00069           ACE_CHECK;
00070         }
00071     }
00072 }
00073 
00074 CORBA::RepositoryId
00075 TAO_CEC_DynamicImplementationServer::_primary_interface (const PortableServer::ObjectId &,
00076                                                          PortableServer::POA_ptr
00077                                                          ACE_ENV_ARG_DECL_NOT_USED)
00078   ACE_THROW_SPEC (())
00079 {
00080   return CORBA::string_dup (repository_id_);
00081 }
00082 
00083 PortableServer::POA_ptr
00084 TAO_CEC_DynamicImplementationServer::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00085 {
00086   return PortableServer::POA::_duplicate (this->poa_.in ());
00087 }
00088 
00089 void
00090 TAO_CEC_DynamicImplementationServer::is_a (CORBA::ServerRequest_ptr request
00091                                            ACE_ENV_ARG_DECL)
00092 {
00093   CORBA::NVList_ptr list;
00094 
00095   this->typed_event_channel_->create_list (0, list ACE_ENV_ARG_PARAMETER);
00096   ACE_CHECK;
00097 
00098   CORBA::Any any_1;
00099   any_1._tao_set_typecode(CORBA::_tc_string);
00100 
00101   list->add_value ("value",
00102                    any_1,
00103                    CORBA::ARG_IN
00104                    ACE_ENV_ARG_PARAMETER);
00105   ACE_CHECK;
00106 
00107   request->arguments (list 
00108                       ACE_ENV_ARG_PARAMETER);
00109   ACE_CHECK;
00110 
00111   CORBA::NamedValue_ptr nv = list->item (0 ACE_ENV_ARG_PARAMETER);
00112   ACE_CHECK;
00113 
00114   CORBA::Any_ptr ap = nv->value ();
00115   const char *value;
00116   *ap >>= value;
00117 
00118   if (TAO_debug_level >= 10)
00119     {
00120       ACE_DEBUG ((LM_DEBUG,
00121                   ACE_TEXT ("***** TAO_CEC_DynamicImplementationServer::is_a called with value %s *****\n"),
00122                   value));
00123     }
00124 
00125   const char *object_id =
00126     CORBA::_tc_Object->id (ACE_ENV_SINGLE_ARG_PARAMETER);
00127   ACE_CHECK;
00128 
00129   if (TAO_debug_level >= 10)
00130     {
00131       ACE_DEBUG ((LM_DEBUG,
00132                   ACE_TEXT ("***** is_a using Server's RepositoryId %s *****\n"),
00133                   this->repository_id_));
00134       ACE_DEBUG ((LM_DEBUG,
00135                   ACE_TEXT ("***** is_a using base interface %s *****\n"),
00136                   object_id));
00137     }
00138 
00139   CORBA::Boolean result = 0;
00140   if (ACE_OS::strcmp (value, this->repository_id_) == 0
00141       || ACE_OS::strcmp (value, object_id) == 0)
00142     {
00143       result = 1;
00144     }
00145   else
00146     {
00147       CORBA::ULong num = this->typed_event_channel_->number_of_base_interfaces ();
00148       for (CORBA::ULong base=0; base<num; base++)
00149         {
00150           if (TAO_debug_level >= 10)
00151             {
00152               ACE_DEBUG ((LM_DEBUG,
00153                           ACE_TEXT ("***** is_a using base interface %s *****\n"),
00154                           this->typed_event_channel_->base_interfaces (base) ));
00155             }
00156           
00157           if (ACE_OS::strcmp (value, this->typed_event_channel_->base_interfaces (base) ) == 0)
00158             {
00159               result = 1;
00160             }
00161         }
00162     }
00163   
00164   if (TAO_debug_level >= 10)
00165     {
00166       ACE_DEBUG ((LM_DEBUG,
00167                   ACE_TEXT ("***** is_a returning %d *****\n"),
00168                   result));
00169     }
00170   
00171   CORBA::Any result_any;
00172   CORBA::Any::from_boolean from_boolean (result);
00173   result_any <<= from_boolean;
00174 
00175   request->set_result (result_any ACE_ENV_ARG_PARAMETER);
00176   ACE_CHECK;
00177 }
00178 
00179 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 13:18:16 2006 for TAO_CosEvent by doxygen 1.3.6