Go to the documentation of this file.00001
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 84860 2009-03-17 10:17:38Z 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 IOP::ServiceContextList &sc,
00017 TAO_Transport& transport)
00018 {
00019 for (CORBA::ULong index = 0;
00020 index != sc.length ();
00021 ++index)
00022 {
00023 IOP::ServiceContext const & context = sc[index];
00024
00025 iterator handler_iter = this->registry_.find (context.context_id);
00026
00027 if (handler_iter != registry_.end ())
00028 {
00029 return handler_iter->second->process_service_context (transport, context);
00030 }
00031 }
00032 return 0;
00033 }
00034
00035 int
00036 TAO_Service_Context_Registry::generate_service_context (
00037 TAO_Stub *stub,
00038 TAO_Transport& transport,
00039 TAO_Operation_Details &opdetails,
00040 TAO_Target_Specification &spec,
00041 TAO_OutputCDR &msg)
00042 {
00043 int result = 0;
00044 for (Table::iterator x = this->registry_.begin ();
00045 x != this->registry_.end ();
00046 ++x)
00047 {
00048 if ((*x).second->generate_service_context (
00049 stub, transport, opdetails, spec, msg) == -1)
00050 {
00051 result = -1;
00052 }
00053 }
00054
00055 return result;
00056 }
00057
00058 TAO_Service_Context_Registry::~TAO_Service_Context_Registry (void)
00059 {
00060 for (Table::iterator x = this->registry_.begin ();
00061 x != this->registry_.end ();
00062 ++x)
00063 {
00064 delete (*x).second;
00065 }
00066 }
00067
00068 int
00069 TAO_Service_Context_Registry::bind (
00070 IOP::ServiceId id,
00071 TAO_Service_Context_Handler* handler)
00072 {
00073 value_type const value =
00074 std::make_pair (key_type (id), data_type (handler));
00075
00076 std::pair<iterator, bool> result = this->registry_.insert (value);
00077
00078 return (result.second ? 0 : 1);
00079 }
00080
00081 TAO_Service_Context_Handler*
00082 TAO_Service_Context_Registry::operator[] (IOP::ServiceId id)
00083 {
00084 return registry_[id];
00085 }
00086
00087 TAO_END_VERSIONED_NAMESPACE_DECL