00001 // $Id: Service_Context_Handler_Registry.cpp 80861 2008-03-07 13:48:34Z johnnyw $ 00002 00003 #include "tao/Service_Context_Handler_Registry.h" 00004 00005 ACE_RCSID (tao, 00006 Service_Context_Handler_Registry, 00007 "$Id: Service_Context_Handler_Registry.cpp 80861 2008-03-07 13:48:34Z johnnyw $") 00008 00009 #include "tao/TAO_Server_Request.h" 00010 #include "tao/Service_Context_Handler.h" 00011 00012 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00013 00014 int 00015 TAO_Service_Context_Registry::process_service_contexts ( 00016 TAO_ServerRequest& server_request) 00017 { 00018 IOP::ServiceContextList &service_info = 00019 server_request.request_service_context ().service_info (); 00020 for (CORBA::ULong index = 0; 00021 index != service_info.length (); 00022 ++index) 00023 { 00024 IOP::ServiceContext const & context = service_info[index]; 00025 TAO_Service_Context_Handler* const handler = registry_[context.context_id]; 00026 if (handler) 00027 { 00028 return handler->process_service_context (server_request, context); 00029 } 00030 } 00031 return 0; 00032 } 00033 00034 TAO_Service_Context_Registry::~TAO_Service_Context_Registry (void) 00035 { 00036 for (Table::iterator x = this->registry_.begin (); 00037 x != this->registry_.end (); 00038 ++x) 00039 { 00040 delete (*x).second; 00041 } 00042 } 00043 00044 int 00045 TAO_Service_Context_Registry::bind ( 00046 IOP::ServiceId id, 00047 TAO_Service_Context_Handler* handler) 00048 { 00049 value_type const value = 00050 std::make_pair (key_type (id), data_type (handler)); 00051 00052 std::pair<iterator, bool> result = this->registry_.insert (value); 00053 00054 return (result.second ? 0 : 1); 00055 } 00056 00057 TAO_Service_Context_Handler* 00058 TAO_Service_Context_Registry::operator[] (IOP::ServiceId id) 00059 { 00060 return registry_[id]; 00061 } 00062 00063 TAO_END_VERSIONED_NAMESPACE_DECL