00001 // $Id: EC_Lifetime_Utils_T.cpp 76589 2007-01-25 18:04:11Z elliott_c $ 00002 00003 #ifndef TAO_EC_LIFETIME_UTILS_T_CPP 00004 #define TAO_EC_LIFETIME_UTILS_T_CPP 00005 00006 #include "orbsvcs/Event/EC_Lifetime_Utils_T.h" 00007 00008 #if ! defined (__ACE_INLINE__) 00009 #include "orbsvcs/Event/EC_Lifetime_Utils_T.inl" 00010 #endif /* __ACE_INLINE__ */ 00011 00012 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00013 00014 template <typename T> 00015 void 00016 activate (T & obj_ref, 00017 PortableServer::POA_ptr poa, 00018 PortableServer::ServantBase * servant, 00019 TAO_EC_Object_Deactivator & suggested_object_deactivator) 00020 { 00021 // Activate the servant into the POA. 00022 PortableServer::ObjectId_var obj_id = 00023 poa->activate_object (servant); 00024 00025 suggested_object_deactivator.set_values (poa, obj_id.in ()); 00026 00027 // Get the object reference of the activated object. 00028 CORBA::Object_var obj = 00029 poa->id_to_reference (obj_id.in ()); 00030 00031 // Don't try to use T::_obj_type::_narrow, some compilers don't like it so 00032 // do this in two steps 00033 typedef typename T::_obj_type my_object_type; 00034 00035 obj_ref = 00036 my_object_type::_narrow (obj.in()); 00037 00038 if (CORBA::is_nil (obj_ref.in ())) 00039 { 00040 throw CORBA::INTERNAL (); 00041 } 00042 } 00043 00044 TAO_END_VERSIONED_NAMESPACE_DECL 00045 00046 #endif /* TAO_EC_LIFETIME_UTILS_T_CPP */