本文整理汇总了C++中portableinterceptor::ServerRequestInfo_ptr::get_request_service_context方法的典型用法代码示例。如果您正苦于以下问题:C++ ServerRequestInfo_ptr::get_request_service_context方法的具体用法?C++ ServerRequestInfo_ptr::get_request_service_context怎么用?C++ ServerRequestInfo_ptr::get_request_service_context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类portableinterceptor::ServerRequestInfo_ptr
的用法示例。
在下文中一共展示了ServerRequestInfo_ptr::get_request_service_context方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
EDF_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr ri,
RTScheduling::Current::IdType_out guid_out,
CORBA::String_out /*name*/,
CORBA::Policy_out sched_param_out,
CORBA::Policy_out /*implicit_sched_param_out*/)
{
Kokyu::Svc_Ctxt_DSRT_QoS* sc_qos_ptr;
RTScheduling::Current::IdType guid;
int int_guid;
DSUI_EVENT_LOG (EDF_SCHED_FAM, ENTER_SERVER_SCHED_TIME, 0, 0, 0);
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG, "(%t|%T):entered EDF_Scheduler::receive_request\n"));
#endif
CORBA::String_var operation = ri->operation ();
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG,
"(%t|%T): receive_request from "
"\"%s\"\n",
operation.in ()));
#endif
// Ignore the "_is_a" operation since it may have been invoked
// locally on the server side as a side effect of another call,
// meaning that the client hasn't added the service context yet.
if (ACE_OS::strcmp ("_is_a", operation.in ()) == 0)
return;
IOP::ServiceContext_var sc =
ri->get_request_service_context (Server_Interceptor::SchedulingInfo);
CORBA::Long importance;
TimeBase::TimeT deadline;
TimeBase::TimeT period;
CORBA::Long task_id=-1;
if (sc.ptr () == 0)
{
//Since send_request will add an QoS for any request, why can this case happen?
//24 hrs from now - infinity
ACE_Time_Value deadline_tv = ACE_OS::gettimeofday () + ACE_Time_Value (24*60*60,0);
deadline = deadline_tv.sec ()*1000000 + deadline_tv.usec ()*10; //100s of nanoseconds for TimeBase::TimeT
importance = 0;
period = 0;
// task_id = ID_BEGIN ++;
}
else
{
CORBA::OctetSeq oc_seq = CORBA::OctetSeq (sc->context_data.length (),
sc->context_data.length (),
sc->context_data.get_buffer (),
0);
CORBA::Any sc_qos_as_any;
CORBA::Any_var scqostmp = codec_->decode (oc_seq);
sc_qos_as_any = scqostmp.in ();
//Don't store in a _var, since >>= returns a pointer to an
//internal buffer and we are not supposed to free it.
sc_qos_as_any >>= sc_qos_ptr;
deadline = sc_qos_ptr->deadline;
importance = sc_qos_ptr->importance;
period = sc_qos_ptr->period;
task_id = sc_qos_ptr->task_id;
guid.length (sc_qos_ptr->guid.length ());
guid_copy (guid, sc_qos_ptr->guid);
ACE_NEW (guid_out.ptr (),
RTScheduling::Current::IdType);
guid_out.ptr ()->length (guid.length ());
*(guid_out.ptr ()) = guid;
ACE_OS::memcpy (&int_guid,
guid.get_buffer (),
guid.length ());
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG,
"(%t|%T): Importance = %d, guid = %d "
"in recvd service context\n",
importance,
int_guid));
#endif
EDF_Scheduling::SchedulingParameter sched_param;
sched_param.importance = importance;
sched_param.deadline = deadline;
sched_param.period = period;
sched_param.task_id = task_id;
sched_param_out = this->create_scheduling_parameter (sched_param);
}
//.........这里部分代码省略.........
示例2:
void
ServerInterceptor::receive_request (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
bool permission_granted = false;
std::cout << "Calling receive_request()." << std::endl;
if (ri->target_is_a(restricted_interfaces[0])){
IOP::ServiceId id = service_id;
// Check that the request service context can be retrieved.
IOP::ServiceContext_var sc =
ri->get_request_service_context (id);
CORBA::OctetSeq ocSeq = sc->context_data;
const char * buf =
reinterpret_cast<const char *> (ocSeq.get_buffer ());
for (unsigned int i=0; i<num_allowed_users; ++i) {
if (ACE_OS::strcmp (buf, allowed_users[i]) == 0)
{
permission_granted = true;
}
}
}
if (permission_granted == true) {
std::cout << "Permission Granted " << std::endl;
}
else {
std::cout << "Permission Denied " << std::endl;;
}
}
示例3:
void
Echo_Server_Request_Interceptor::receive_request_service_contexts (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::String_var operation = ri->operation ();
ACE_DEBUG ((LM_DEBUG,
"%C.receive_request_service_contexts from "
"\"%C\"\n",
this->myname_,
operation.in ()));
IOP::ServiceId id = ::service_id;
IOP::ServiceContext_var sc =
ri->get_request_service_context (id);
const char *buf =
reinterpret_cast<const char *> (sc->context_data.get_buffer ());
#if 0
ACE_DEBUG ((LM_DEBUG,
" Received service context: %C\n",
buf));
#endif /*if 0*/
if (ACE_OS::strcmp (buf, request_msg) != 0)
{
ACE_ERROR ((LM_ERROR,
"ERROR: Echo_Server_Request_Interceptor::receive_request_service_contexts: "
"Expected request service context to be: %C\n",
request_msg));
}
}
示例4: ForwardRequest
void
Echo_Server_Request_Interceptor::receive_request_service_contexts (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::String_var operation = ri->operation ();
ACE_DEBUG ((LM_DEBUG,
"%C.receive_request_service_contexts from "
"\"%C\"\n",
this->myname_,
operation.in ()));
// Ignore the "_is_a" operation since it may have been invoked
// locally on the server side as a side effect of another call,
// meaning that the client hasn't added the service context yet.
// Same goes for the shutdown call
if (ACE_OS_String::strcmp ("shutdown", operation.in ()) == 0)
return;
IOP::ServiceId id = ::service_id;
IOP::ServiceContext_var sc =
ri->get_request_service_context (id);
const char *buf =
reinterpret_cast<const char *> (sc->context_data.get_buffer ());
ACE_DEBUG ((LM_DEBUG,
" Received service context: %C\n",
buf));
if (ACE_OS::strcmp (buf, request_msg) == 0)
{
ACE_DEBUG ((LM_DEBUG, "Sending LOCATION_FORWARD\n"));
throw PortableInterceptor::ForwardRequest (this->forward_location_.in ());
}
else if (ACE_OS::strcmp (buf, forward_msg) == 0)
{
// Make the context to send the context to the client
IOP::ServiceContext scc;
scc.context_id = ::service_id;
CORBA::ULong string_len = ACE_OS::strlen (reply_msg) + 1;
CORBA::Octet *buff = CORBA::OctetSeq::allocbuf (string_len);
ACE_OS::strcpy (reinterpret_cast<char *> (buff), reply_msg);
scc.context_data.replace (string_len, string_len, buff, 1);
// Add this context to the service context list.
ri->add_reply_service_context (scc, 0);
}
else
{
ACE_ERROR ((LM_ERROR,
"ERROR: Echo_Server_Request_Interceptor::receive_request_service_contexts: "
"Expected request service context to be: %C or %C\n",
request_msg,
forward_msg));
}
}
示例5: catch
void
ServerRequest_Interceptor2::receive_request (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::String_var op = ri->operation ();
if (ACE_OS::strcmp (op.in (), "has_ft_request_service_context"))
{
// bail if not the op we are interested in -
// avoid excess spurious error clutter when client calls ::shutdown; ::ping etc..
return;
}
try
{
IOP::ServiceContext_var sc =
ri->get_request_service_context (IOP::FT_REQUEST);
// No exception therefore there was a context
has_ft_request_sc_ = true;
}
catch (const CORBA::BAD_PARAM& ex)
{
ACE_UNUSED_ARG (ex);
// No group version context
has_ft_request_sc_ = false;
}
catch (const CORBA::Exception&)
{
throw;
}
}
示例6: INTERNAL
void
Echo_Server_Request_Interceptor::receive_request_service_contexts (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::String_var operation = ri->operation ();
ACE_DEBUG ((LM_DEBUG,
"%C.receive_request_service_contexts from "
"\"%C\"\n",
this->myname_,
operation.in ()));
// Ignore the shutdown operation.
if (ACE_OS_String::strcmp ("shutdown", operation.in ()) == 0)
return;
// retrieve the context
IOP::ServiceId id = ::service_id;
IOP::ServiceContext_var sc =
ri->get_request_service_context (id);
const char *buf =
reinterpret_cast<const char *> (sc->context_data.get_buffer ());
ACE_DEBUG ((LM_DEBUG,
" Received service context: %C\n",
buf));
if (ACE_OS::strcmp (buf, request_msg) != 0)
{
ACE_ERROR ((LM_ERROR,
"ERROR: Echo_Server_Request_Interceptor::receive_request_service_contexts: "
"Expected request service context to be: %C\n",
request_msg ));
}
else
{
// put the context into s slot
CORBA::Any data;
data <<= buf;
try
{
ri->set_slot (slotId, data);
ACE_DEBUG ((LM_DEBUG, "receive_request_service_contexts filled Slot %d\n",(int)slotId));
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception (
"Exception thrown in receive_request_service_contexts()\n");
throw CORBA::INTERNAL ();
}
}
}
示例7:
void
IIOP_Server_Request_Interceptor::outbound_process_context (PortableInterceptor::ServerRequestInfo_ptr ri)
{
IOP::ServiceId id = Test::Transport::CurrentTest::ContextTag;
IOP::ServiceContext_var sc =
ri->get_request_service_context (id);
const char *buf =
reinterpret_cast <const char *> (sc->context_data.get_buffer ());
this->pop_request_info (ACE_OS::atoi (buf));
}
示例8:
void
Echo_Server_Request_Interceptor::send_exception (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::String_var operation = ri->operation ();
#if 0
ACE_DEBUG ((LM_DEBUG,
"%C.send_exception from \"%C\"\n",
this->myname_,
operation.in ()));
#endif /*if 0*/
// Check that the reply service context is set as expected.
IOP::ServiceContext_var sc =
ri->get_reply_service_context (::service_id);
const char *buf = reinterpret_cast<const char *> (sc->context_data.get_buffer ());
#if 0
ACE_DEBUG ((LM_DEBUG,
" Reply service context: %C\n",
buf));
#endif /*if 0*/
if (ACE_OS::strcmp (buf, reply_msg) != 0)
{
ACE_ERROR ((LM_ERROR,
"ERROR: Echo_Server_Request_Interceptor::send_exception: "
"Expected reply service context to be: %C\n",
reply_msg));
}
// Check that the request service context hasn't been changed.
IOP::ServiceContext_var sc2 =
ri->get_request_service_context (::service_id);
const char *buf2 = reinterpret_cast<const char *> (sc2->context_data.get_buffer ());
if (ACE_OS::strcmp (buf2, request_msg) != 0)
{
ACE_ERROR ((LM_ERROR,
"ERROR: Echo_Server_Request_Interceptor::send_exception: "
"Expected request service context to be: %C.\n"
" Got: %C\n",
request_msg,
buf2));
}
}
示例9: BAD_PARAM
void
Echo_Server_Request_Interceptor::receive_request_service_contexts (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::String_var operation =
ri->operation ();
if (ACE_OS::strcmp ("_is_a", operation.in ()) == 0)
return;
IOP::ServiceId id = ::service_id;
IOP::ServiceContext_var sc =
ri->get_request_service_context (id);
if (sc->context_data.length() != magic_cookie_len
|| ACE_OS::memcmp(
magic_cookie, sc->context_data.get_buffer(),
magic_cookie_len) != 0)
{
throw CORBA::BAD_PARAM();
}
}
示例10: sizeof
void
TAO_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr request_info,
RTScheduling::Current::IdType_out guid_out,
CORBA::String_out /*name*/,
CORBA::Policy_out /*sched_param*/,
CORBA::Policy_out /*implicit_sched_param*/)
{
IOP::ServiceContext_var serv_cxt;
try
{
serv_cxt = request_info->get_request_service_context (Server_Interceptor::SchedulingInfo);
size_t gu_id;
ACE_OS::memcpy (&gu_id,
serv_cxt->context_data.get_buffer (),
serv_cxt->context_data.length ());
ACE_DEBUG ((LM_DEBUG,
"The Guid is %d\n",
gu_id));
RTScheduling::Current::IdType* guid;
ACE_NEW (guid,
RTScheduling::Current::IdType);
guid->length (sizeof (size_t));
ACE_OS::memcpy (guid->get_buffer (),
serv_cxt->context_data.get_buffer (),
sizeof (size_t));
guid_out = guid;
}
catch (const CORBA::Exception&)
{
ACE_DEBUG ((LM_DEBUG,
"Invalid Service Context\n"));
}
}
示例11: INTERNAL
void
Echo_Server_Request_Interceptor::send_other (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::String_var operation = ri->operation ();
ACE_DEBUG ((LM_DEBUG,
"%C.send_other from \"%C\"\n",
this->myname_,
operation.in ()));
// Check that the request service context hasn't been changed.
IOP::ServiceContext_var sc =
ri->get_request_service_context (::service_id);
const char *buf = reinterpret_cast<const char *> (sc->context_data.get_buffer ());
if (ACE_OS::strcmp (buf, request_msg) != 0)
{
ACE_ERROR ((LM_ERROR,
"ERROR: Echo_Server_Request_Interceptor::send_reply: "
"Expected request service context to be: %C.\n"
" Got: %C\n",
request_msg,
buf));
}
// If we get this far then we should have received a
// LOCATION_FORWARD reply.
// This will throw an exception if a location forward has not
// occurred. If an exception is thrown then something is wrong with
// the PortableInterceptor::ForwardRequest support.
CORBA::Object_var forward = ri->forward_reference ();
if (CORBA::is_nil (forward.in ()))
throw CORBA::INTERNAL ();
}
示例12: name
void
IIOP_Server_Request_Interceptor::inbound_process_context (PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::String_var name (this->name ());
CORBA::String_var op (ri->operation());
if (TAO_debug_level >=1)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT("%C (%P|%t) Intercepted operation %C ()\n"),
name.in (),
op.in ()));
try
{
IOP::ServiceId id = Test::Transport::CurrentTest::ContextTag;
IOP::ServiceContext_var sc =
ri->get_request_service_context (id);
const char *buf =
reinterpret_cast <const char *> (sc->context_data.get_buffer ());
long requestID = ACE_OS::atoi (buf);
this->push_request_info (requestID);
}
catch (const CORBA::Exception&)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("%C (%P|%t) Service context")
ACE_TEXT (" is unavailable when invoking %C (). ")
ACE_TEXT ("A colocated invocation would have ")
ACE_TEXT ("no service context.\n"),
name.in (),
op.in ()));
}
}
示例13: int_buf
void
MIF_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr request_info,
RTScheduling::Current::IdType_out guid_out,
CORBA::String_out,
CORBA::Policy_out sched_param_out,
CORBA::Policy_out /*implicit_sched_param*/)
{
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
"MIF_Scheduler::receive_request\n"));
IOP::ServiceContext_var serv_cxt =
request_info->get_request_service_context (Server_Interceptor::SchedulingInfo);
if (serv_cxt != 0)
{
ACE_DEBUG ((LM_DEBUG,
"Got scheduling info\n"));
RTScheduling::Current::IdType* guid;
ACE_NEW (guid,
RTScheduling::Current::IdType);
guid->length (sizeof(size_t));
ACE_OS::memcpy (guid->get_buffer (),
serv_cxt->context_data.get_buffer (),
sizeof (size_t));
size_t gu_id;
ACE_OS::memcpy (&gu_id,
guid->get_buffer (),
guid->length ());
ACE_DEBUG ((LM_DEBUG,
"MIF_Scheduler::receive_request %d\n",
gu_id));
CORBA::OctetSeq int_buf (sizeof (long));
int_buf.length (int_buf.maximum ());
int i = sizeof (long);
for (unsigned int j = 0;j < sizeof (int);j++)
{
int_buf [j] = serv_cxt->context_data [i++];
}
int importance = 0;
ACE_OS::memcpy (&importance,
int_buf.get_buffer (),
sizeof (importance));
guid_out = guid;
sched_param_out = DT_TEST::instance ()->scheduler ()->create_segment_scheduling_parameter (importance);
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
"%t The Guid is %d Importance is %d\n",
gu_id,
importance));
DT* new_dt;
ACE_NEW (new_dt,
DT (this->lock_,
gu_id));
new_dt->msg_priority (importance);
lock_.acquire ();
ready_que_.enqueue_prio (new_dt);
new_dt->suspend ();
lock_.release ();
}
}
示例14: cdr
void
TAO_LB_ServerRequestInterceptor::receive_request_service_contexts (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
if (this->load_alert_.alerted ())
{
CORBA::String_var op = ri->operation ();
if (ACE_OS::strcmp (op.in (), "_get_loads") == 0 // LoadMonitor
|| ACE_OS::strcmp (op.in (), "disable_alert") == 0 // LoadAlert
|| ACE_OS::strcmp (op.in (), "enable_alert") == 0) // LoadAlert
return; // Do not redirect.
#if 0
try
{
IOP::ServiceContext_var service_context =
ri->get_request_service_context (CosLoadBalancing::LOAD_MANAGED);
/*
// Use TAO-specific "compiled marshaling" instead of
// standard interpretive marshaling via a CDR encapsulation
// Codec for efficiency reasons.
const char * buf =
reinterpret_cast<const char *> (service_context->context_data.get_buffer ());
TAO_InputCDR cdr (buf,
service_context->context_data.length ());
CORBA::Boolean byte_order;
if ((cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0)
throw CORBA::BAD_PARAM ();
cdr.reset_byte_order (static_cast<int> (byte_order));
CORBA::Object_var object_group;
if (cdr >> object_group.out ())
throw PortableInterceptor::ForwardRequest (object_group.in (,
0));
else
throw CORBA::BAD_PARAM ();
*/
// A ServiceContext of the given ServiceId exists. This
// means that the target is load balanced. Force the client
// to try another profile since this location is currently
// overloaded.
throw CORBA::TRANSIENT ();
}
catch (const CORBA::BAD_PARAM& ex)
{
// No CosLoadBalancing::LB_GROUP_REF ServiceContext. This
// probably means that the target object is not
// LoadBalanced.
// There is a huge DoS attack vulnerability with this load
// shedding model. The model relies on the client behaving
// correctly. In particular, it relies on the client to
// send the forward object group reference in the
// ServiceContextList. Any "misbehaving" client can avoid
// that, in which case no load will ever be shed!
// Make sure we get a CORBA::BAD_PARAM for the right
// reason.
if (ex.minor () != (CORBA::OMGVMCID | 26))
throw;
}
#else
// Force the client to try another profile since this location
// is currently overloaded.
//
// NOTE: This applies to both load balanced and non-load
// balanced targets.
throw CORBA::TRANSIENT ();
#endif /* 0 */
}
}
示例15:
void
MIF_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr ri,
RTScheduling::Current::IdType_out guid_out,
CORBA::String_out /*name*/,
CORBA::Policy_out sched_param_out,
CORBA::Policy_out /*implicit_sched_param_out*/)
{
Kokyu::Svc_Ctxt_DSRT_QoS* sc_qos_ptr;
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG, "(%t|%T):entered MIF_Scheduler::receive_request\n"));
#endif
RTScheduling::Current::IdType guid;
CORBA::String_var operation = ri->operation ();
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG,
"(%t|%T): receive_request from "
"\"%s\"\n",
operation.in ()));
#endif
// Ignore the "_is_a" operation since it may have been invoked
// locally on the server side as a side effect of another call,
// meaning that the client hasn't added the service context yet.
if (ACE_OS::strcmp ("_is_a", operation.in ()) == 0)
return;
IOP::ServiceContext_var sc =
ri->get_request_service_context (Server_Interceptor::SchedulingInfo);
CORBA::Short importance;
if (sc.ptr () == 0)
{
importance = 0;
}
else
{
CORBA::OctetSeq oc_seq = CORBA::OctetSeq (sc->context_data.length (),
sc->context_data.length (),
sc->context_data.get_buffer (),
0);
CORBA::Any sc_qos_as_any;
CORBA::Any_var scqostmp = codec_->decode (oc_seq);
sc_qos_as_any = scqostmp.in ();
//Don't store in a _var, since >>= returns a pointer to an
//internal buffer and we are not supposed to free it.
sc_qos_as_any >>= sc_qos_ptr;
importance = sc_qos_ptr->importance;
guid.length (sc_qos_ptr->guid.length ());
guid_copy (guid, sc_qos_ptr->guid);
ACE_NEW (guid_out.ptr (),
RTScheduling::Current::IdType);
guid_out.ptr ()->length (guid.length ());
*(guid_out.ptr ()) = guid;
#ifdef KOKYU_DSRT_LOGGING
int int_guid;
ACE_OS::memcpy (&int_guid,
guid.get_buffer (),
guid.length ());
ACE_DEBUG ((LM_DEBUG,
"(%t|%T): Importance = %d, guid = %d in recvd service context\n",
importance, int_guid));
#endif
MIF_Scheduling::SchedulingParameter sched_param;
sched_param.importance = importance;
sched_param_out = this->create_scheduling_parameter (sched_param);
}
MIF_Scheduler_Traits::QoSDescriptor_t qos;
qos.importance_ = importance;
this->kokyu_dispatcher_->schedule (guid, qos);
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG, "(%t|%T): receive_request interceptor done\n"));
#endif
}