Implementation of the PortableInterceptor::ServerRequestInfo
IDL interface.
More...
#include <ServerRequestInfo.h>
Public Member Functions | |
ServerRequestInfo (TAO_ServerRequest &server_request, TAO::Argument *const *args, size_t nargs, void *servant_upcall, CORBA::TypeCode_ptr const *exceptions, CORBA::ULong nexceptions) | |
Constructor. | |
virtual CORBA::ULong | request_id (void) |
virtual char * | operation (void) |
Return the operation name for the current request. | |
virtual Dynamic::ParameterList * | arguments (void) |
Return the list of arguments passed to the current operation. | |
virtual Dynamic::ExceptionList * | exceptions (void) |
virtual Dynamic::ContextList * | contexts (void) |
virtual Dynamic::RequestContext * | operation_context (void) |
virtual CORBA::Any * | result (void) |
virtual CORBA::Boolean | response_expected (void) |
Returns true for a two-way operation, and false otherwise. | |
virtual Messaging::SyncScope | sync_scope (void) |
virtual PortableInterceptor::ReplyStatus | reply_status (void) |
Return the reply status for the current request. | |
virtual CORBA::Object_ptr | forward_reference (void) |
virtual CORBA::Any * | get_slot (PortableInterceptor::SlotId id) |
Retrieve data from the "request scope" PICurrent object. | |
virtual IOP::ServiceContext * | get_request_service_context (IOP::ServiceId id) |
virtual IOP::ServiceContext * | get_reply_service_context (IOP::ServiceId id) |
virtual CORBA::Any * | sending_exception (void) |
virtual PortableInterceptor::ObjectId * | object_id (void) |
Return the ObjectId for the target object. | |
virtual CORBA::OctetSeq * | adapter_id (void) |
virtual char * | server_id (void) |
virtual char * | orb_id (void) |
virtual PortableInterceptor::AdapterName * | adapter_name (void) |
virtual char * | target_most_derived_interface (void) |
Return the most derived interface of the target object. | |
virtual CORBA::Policy_ptr | get_server_policy (CORBA::PolicyType type) |
virtual void | set_slot (PortableInterceptor::SlotId id, const CORBA::Any &data) |
Insert data into the "request scope" PICurrent object. | |
virtual CORBA::Boolean | target_is_a (const char *id) |
virtual void | add_reply_service_context (const IOP::ServiceContext &service_context, CORBA::Boolean replace) |
TAO_ServerRequest & | server_request (void) |
Helper methods specific to TAO. | |
void | forward_reference (PortableInterceptor::ForwardRequest &exc) |
void | forward_reference (CORBA::Object_ptr obj) |
Protected Member Functions | |
IOP::ServiceContext * | get_service_context_i (TAO_Service_Context &service_context_list, IOP::ServiceId id) |
Protected Attributes | |
TAO_ServerRequest & | server_request_ |
TAO::Argument *const *const | args_ |
Operation argument list. | |
size_t const | nargs_ |
Number of element in the operation argument list. | |
TAO::Portable_Server::Servant_Upcall *const | servant_upcall_ |
CORBA::TypeCode_ptr const *const | exceptions_ |
CORBA::ULong const | nexceptions_ |
The number of elements in the exceptions_ array. |
Implementation of the PortableInterceptor::ServerRequestInfo
IDL interface.
Implementation of the PortableInterceptor::ServerRequestInfo
IDL interface.
Definition at line 70 of file ServerRequestInfo.h.
TAO::ServerRequestInfo::ServerRequestInfo | ( | TAO_ServerRequest & | server_request, | |
TAO::Argument *const * | args, | |||
size_t | nargs, | |||
void * | servant_upcall, | |||
CORBA::TypeCode_ptr const * | exceptions, | |||
CORBA::ULong | nexceptions | |||
) |
Constructor.
Definition at line 11 of file ServerRequestInfo.inl.
: server_request_ (server_request) , args_ (args) , nargs_ (nargs) , servant_upcall_ ( static_cast<TAO::Portable_Server::Servant_Upcall *> (servant_upcall)) , exceptions_ (exceptions) , nexceptions_ (nexceptions) { }
CORBA::OctetSeq * TAO::ServerRequestInfo::adapter_id | ( | void | ) | [virtual] |
Return the AdapterId
for the POA handling the current request.
Definition at line 393 of file ServerRequestInfo.cpp.
{ if (this->servant_upcall_ != 0) return this->servant_upcall_->poa ().id (); throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); }
PortableInterceptor::AdapterName * TAO::ServerRequestInfo::adapter_name | ( | void | ) | [virtual] |
Return the name of the object adapter that services requests for the invoked object.
Definition at line 339 of file ServerRequestInfo.cpp.
{ // The adapter_name attribute defines a name for the object adapter // that services requests for the invoked object. In the case of the // POA, the adapter_name is the sequence of names from the root POA // to the POA that services the request. The root POA is not named // in this sequence. if (this->servant_upcall_ != 0) return this->servant_upcall_->poa ().adapter_name (); throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); }
void TAO::ServerRequestInfo::add_reply_service_context | ( | const IOP::ServiceContext & | service_context, | |
CORBA::Boolean | replace | |||
) | [virtual] |
Add the IOP::ServiceContext
to the reply (outgoing) IOP::ServiceContextList
.
Definition at line 484 of file ServerRequestInfo.cpp.
{ // Get the service context from the list TAO_Service_Context &service_context_list = this->server_request_.reply_service_context (); if (service_context_list.set_context (service_context, replace) == 0) { throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 15, CORBA::COMPLETED_NO); } }
Dynamic::ParameterList * TAO::ServerRequestInfo::arguments | ( | void | ) | [virtual] |
Return the list of arguments passed to the current operation.
Definition at line 79 of file ServerRequestInfo.cpp.
{ if (this->args_ == 0) { throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); } // Generate the argument list on demand. Dynamic::ParameterList * const parameter_list = TAO_RequestInfo_Util::make_parameter_list (); Dynamic::ParameterList_var safe_parameter_list = parameter_list; // Return value is always generated as first TAO::Argument in // skeleton. It shouldn't be included in the parameter list. // Skip it. TAO::Argument * const * const begin = this->args_ + 1; TAO::Argument * const * const end = this->args_ + this->nargs_; ACE_ASSERT (end - begin >= 0); parameter_list->length (static_cast<CORBA::ULong> (end - begin)); CORBA::ULong p = 0; for (TAO::Argument * const * i = begin; i != end; ++i, ++p) { // Insert the operation parameters into the // Dynamic::ParameterList. Dynamic::Parameter& parameter = (*parameter_list)[p]; parameter.mode = (*i)->mode (); // When we are in receive_request and have an out argument, then // don't copy it, just let the any be empty with typecode tk_null if ((this->server_request_.pi_reply_status () != -1) || (this->server_request_.pi_reply_status () == -1 && (*i)->mode () != CORBA::PARAM_OUT)) { (*i)->interceptor_value (¶meter.argument); } } return safe_parameter_list._retn (); }
Dynamic::ContextList * TAO::ServerRequestInfo::contexts | ( | void | ) | [virtual] |
Definition at line 153 of file ServerRequestInfo.cpp.
{ throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); }
Dynamic::ExceptionList * TAO::ServerRequestInfo::exceptions | ( | void | ) | [virtual] |
Return the list of exceptions the current operation is capable of throwing.
Definition at line 123 of file ServerRequestInfo.cpp.
{ if (this->args_ == 0) { throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); } // Generate the exception list on demand. Dynamic::ExceptionList * const exception_list = TAO_RequestInfo_Util::make_exception_list (); Dynamic::ExceptionList_var safe_exception_list = exception_list; exception_list->length (this->nexceptions_); CORBA::TypeCode_ptr const * const begin = this->exceptions_; CORBA::TypeCode_ptr const * const end = this->exceptions_ + this->nexceptions_; CORBA::ULong e = 0; for (CORBA::TypeCode_ptr const * i = begin; i != end; ++i, ++e) { CORBA::TypeCode_ptr tcp_object = *i; (*exception_list)[e] = tcp_object; } return safe_exception_list._retn (); }
CORBA::Object_ptr TAO::ServerRequestInfo::forward_reference | ( | void | ) | [virtual] |
If the reply status is PortableInterceptor::LOCATION_FORWARD
return the object reference to which the request was forwarded.
Definition at line 214 of file ServerRequestInfo.cpp.
{ if (this->server_request_.pi_reply_status () != PortableInterceptor::LOCATION_FORWARD) throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); // TAO_ServerRequest::forward_location() already duplicates the // object reference. There is no need to duplicate it here. return this->server_request_.forward_location (); }
void TAO::ServerRequestInfo::forward_reference | ( | PortableInterceptor::ForwardRequest & | exc | ) |
Extract the forward object reference from the PortableInterceptor::ForwardRequest
exception, and set the reply status flag accordingly.
Definition at line 29 of file ServerRequestInfo.inl.
{ // Note that we're converting the ForwardRequest exception in to a // LOCATION_FORWARD reply, so we do not set the exception status. this->server_request_.pi_reply_status (PortableInterceptor::LOCATION_FORWARD); // Store the forward reference in the TAO_ServerRequest object. this->server_request_.forward_location (exc.forward.in ()); }
void TAO::ServerRequestInfo::forward_reference | ( | CORBA::Object_ptr | obj | ) |
Set the forward reference associated with the current LOCATION_FORWARD reply.
PortableServer::ForwardRequest
exception is thrown by a servant manager. Definition at line 42 of file ServerRequestInfo.inl.
{ // We only get here if a servant manager threw a // PortableServer::ForwardRequest exception. this->server_request_.pi_reply_status (PortableInterceptor::LOCATION_FORWARD); // Store the forward reference in the TAO_ServerRequest object. this->server_request_.forward_location (obj); }
IOP::ServiceContext * TAO::ServerRequestInfo::get_reply_service_context | ( | IOP::ServiceId | id | ) | [virtual] |
Return the IOP::ServiceContext
with the given IOP::ServiceId
from the reply service context list.
Definition at line 257 of file ServerRequestInfo.cpp.
{ TAO_Service_Context & service_context_list = this->server_request_.reply_service_context (); return this->get_service_context_i (service_context_list, id); }
IOP::ServiceContext * TAO::ServerRequestInfo::get_request_service_context | ( | IOP::ServiceId | id | ) | [virtual] |
Return the IOP::ServiceContext
with the given IOP::ServiceId
from the request service context list.
Definition at line 248 of file ServerRequestInfo.cpp.
{ TAO_Service_Context &service_context_list = this->server_request_.request_service_context (); return this->get_service_context_i (service_context_list, id); }
CORBA::Policy_ptr TAO::ServerRequestInfo::get_server_policy | ( | CORBA::PolicyType | type | ) | [virtual] |
Return the policy of the given type in effect for the current request.
Definition at line 418 of file ServerRequestInfo.cpp.
{ if (this->servant_upcall_ != 0) { CORBA::Policy_var policy = this->servant_upcall_->poa ().get_policy (type); if (!CORBA::is_nil (policy.in ())) { return policy._retn (); } else { // No policy matching the given PolicyType was found. throw ::CORBA::INV_POLICY (CORBA::OMGVMCID | 3, CORBA::COMPLETED_NO); } } // @@ Technically, we shouldn't be throwing this exception since // this method should be valid in all server side request // interception points. throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); }
IOP::ServiceContext * TAO::ServerRequestInfo::get_service_context_i | ( | TAO_Service_Context & | service_context_list, | |
IOP::ServiceId | id | |||
) | [protected] |
Helper method to get the request and response service contexts.
Definition at line 266 of file ServerRequestInfo.cpp.
{ IOP::ServiceContext_var service_context; if (service_context_list.get_context (id, service_context.out ()) != 0) { // Found. return service_context._retn (); } else { // Not found. throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 26, CORBA::COMPLETED_NO); } }
CORBA::Any * TAO::ServerRequestInfo::get_slot | ( | PortableInterceptor::SlotId | id | ) | [virtual] |
Retrieve data from the "request scope" PICurrent
object.
Definition at line 225 of file ServerRequestInfo.cpp.
{ // Retrieve the total number of assigned slots from the PICurrent. // No TSS access is incurred. CORBA::Object_ptr pi_current_obj = this->server_request_.orb_core ()->pi_current (); TAO::PICurrent *pi_current = dynamic_cast <TAO::PICurrent*> (pi_current_obj); if (pi_current == 0) throw ::CORBA::INTERNAL (); pi_current->check_validity (id); // Retrieve the request scope PICurrent object. TAO::PICurrent_Impl *rsc = this->server_request_.rs_pi_current (); return rsc->get_slot (id); }
PortableInterceptor::ObjectId * TAO::ServerRequestInfo::object_id | ( | void | ) | [virtual] |
Return the ObjectId
for the target object.
Definition at line 354 of file ServerRequestInfo.cpp.
{ if (this->servant_upcall_ != 0) { const PortableServer::ObjectId &id = this->servant_upcall_->user_id (); PortableInterceptor::ObjectId *tmp = 0; ACE_NEW_THROW_EX (tmp, PortableInterceptor::ObjectId, CORBA::NO_MEMORY ( CORBA::SystemException::_tao_minor_code ( TAO::VMCID, ENOMEM), CORBA::COMPLETED_NO)); PortableInterceptor::ObjectId_var obj_id = tmp; // @@ It would be nice to avoid this copy. However, we can't be // sure if the octet sequence will out live the POA from // which the object ID is ultimately obtained. In the event // the octet sequence does out live the POA, a copy is indeed // necessary. Do a copy to be on the safe side. In any // case, this is still faster than the // PortableServer::Current::object_id() method since no TSS // access is involved. CORBA::ULong const len = id.length (); obj_id->length (len); CORBA::Octet *buffer = obj_id->get_buffer (); ACE_OS::memcpy (buffer, id.get_buffer (), len); return obj_id._retn (); } throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); }
char * TAO::ServerRequestInfo::operation | ( | void | ) | [virtual] |
Return the operation name for the current request.
Definition at line 73 of file ServerRequestInfo.cpp.
{ return CORBA::string_dup (this->server_request_.operation ()); }
Dynamic::RequestContext * TAO::ServerRequestInfo::operation_context | ( | void | ) | [virtual] |
Definition at line 159 of file ServerRequestInfo.cpp.
{ throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); }
char * TAO::ServerRequestInfo::orb_id | ( | void | ) | [virtual] |
Return the ORBId value that is passed to the ORB_init
call.
Definition at line 329 of file ServerRequestInfo.cpp.
{ if (this->servant_upcall_ != 0) return CORBA::string_dup (this->server_request_.orb_core ()->orbid ()); throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); }
PortableInterceptor::ReplyStatus TAO::ServerRequestInfo::reply_status | ( | void | ) | [virtual] |
Return the reply status for the current request.
Statuses can be PortableInterceptor::SUCCESSFUL
, SYSTEM_EXCEPTION
, USER_EXCEPTION
, LOCATION_FORWARD
, TRANSPORT_RETRY
, UNKNOWN
..
Definition at line 204 of file ServerRequestInfo.cpp.
{ if (this->server_request_.pi_reply_status () == -1) // A reply hasn't been received yet. throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); return this->server_request_.pi_reply_status (); }
CORBA::ULong TAO::ServerRequestInfo::request_id | ( | void | ) | [virtual] |
Return an ID unique to the current request. This request ID may or may not be the same as the GIOP request ID.
Definition at line 35 of file ServerRequestInfo.cpp.
{ // The request ID returned by this method need not correspond to the // GIOP request ID sent with the client request. The request ID // must be unique across all outstanding requests. To avoid locking // overhead, the address of the TAO_ServerRequest object is used as // the request ID. This guarantees that the request ID is unique. // // For 64-bit platforms, only the lower 32 bits are used. Hopefully // that will be enough to ensure uniqueness. CORBA::ULong id = 0; // Note that we reinterpret_cast to an "unsigned long" instead of // CORBA::ULong since we need to first cast to an integer large // enough to hold an address to avoid compile-time warnings on some // 64-bit platforms. if (sizeof (this) == 4) // 32 bit address id = static_cast <CORBA::ULong> ( reinterpret_cast <ptrdiff_t> (&(this->server_request_))); else if (sizeof (this) == 8) // 64 bit address -- use lower 32 bits id = static_cast <CORBA::ULong> ( reinterpret_cast <ptrdiff_t> (&(this->server_request_)) & 0xFFFFFFFFu); else // @@ Rather than fallback on the GIOP request ID, we should use // an atomically incremented variable specific to the ORB, or // perhaps specific to the process. id = this->server_request_.request_id (); // Fallback return id; }
CORBA::Boolean TAO::ServerRequestInfo::response_expected | ( | void | ) | [virtual] |
Returns true
for a two-way operation, and false
otherwise.
Definition at line 189 of file ServerRequestInfo.cpp.
{ return this->server_request_.response_expected (); }
CORBA::Any * TAO::ServerRequestInfo::result | ( | void | ) | [virtual] |
Return the result of the current request. If there is no return value then an Any
with tk_void
TypeCode
is returned. This method is not valid for oneway operations.
Definition at line 165 of file ServerRequestInfo.cpp.
{ if (this->args_ == 0) { throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); } // Generate the result on demand. static CORBA::Boolean const tk_void_any = true; CORBA::Any * result_any = TAO_RequestInfo_Util::make_any (tk_void_any); CORBA::Any_var safe_result_any = result_any; // Result is always first element in TAO::Argument array. TAO::Argument * const r = this->args_[0]; r->interceptor_value (result_any); return safe_result_any._retn (); }
CORBA::Any * TAO::ServerRequestInfo::sending_exception | ( | void | ) | [virtual] |
Return an Any
containing the exception being sent, if any. Otherwise, throw a CORBA::BAD_INV_ORDER
exception.
Any
. Definition at line 288 of file ServerRequestInfo.cpp.
{ if (this->server_request_.pi_reply_status () != PortableInterceptor::SYSTEM_EXCEPTION && this->server_request_.pi_reply_status () != PortableInterceptor::USER_EXCEPTION) { throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); } // The spec says that if it is a user exception which cannot be // inserted then the UNKNOWN exception should be thrown with minor // code 1. CORBA::Any * temp = 0; ACE_NEW_THROW_EX (temp, CORBA::Any, CORBA::NO_MEMORY ( CORBA::SystemException::_tao_minor_code ( TAO::VMCID, ENOMEM), CORBA::COMPLETED_NO)); CORBA::Any_var caught_exception_var = temp; if (this->server_request_.caught_exception () != 0) (*temp) <<= *(this->server_request_.caught_exception ()); return caught_exception_var._retn (); }
char * TAO::ServerRequestInfo::server_id | ( | void | ) | [virtual] |
Return the server_id of the server. The value is passed to the ORB via -ORBServerId
parameter.
Definition at line 319 of file ServerRequestInfo.cpp.
{ if (this->servant_upcall_ != 0) return CORBA::string_dup (this->server_request_.orb_core ()->server_id ()); throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); }
TAO_ServerRequest & TAO::ServerRequestInfo::server_request | ( | void | ) |
Return a reference to the underlying TAO_ServerRequest
object.
Definition at line 54 of file ServerRequestInfo.inl.
{ return this->server_request_; }
void TAO::ServerRequestInfo::set_slot | ( | PortableInterceptor::SlotId | id, | |
const CORBA::Any & | data | |||
) | [virtual] |
Insert data into the "request scope" PICurrent
object.
Definition at line 443 of file ServerRequestInfo.cpp.
{ // Retrieve the total number of assigned slots from the PICurrent // object. No TSS access is incurred. CORBA::Object_ptr pi_current_obj = this->server_request_.orb_core ()->pi_current (); TAO::PICurrent *pi_current = dynamic_cast <TAO::PICurrent*> (pi_current_obj); if (pi_current == 0) throw ::CORBA::INTERNAL (); pi_current->check_validity (id); // Retrieve the "request scope current" (RSC). TAO::PICurrent_Impl * rsc = this->server_request_.rs_pi_current (); rsc->set_slot (id, data); }
Messaging::SyncScope TAO::ServerRequestInfo::sync_scope | ( | void | ) | [virtual] |
Return the sync_scope
policy value for the current one-way operation. If the operation is not a one-way, a CORBA::BAD_INV_ORDER
exception is thrown.
Definition at line 195 of file ServerRequestInfo.cpp.
{ if (this->server_request_.sync_with_server ()) return Messaging::SYNC_WITH_SERVER; throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO); }
CORBA::Boolean TAO::ServerRequestInfo::target_is_a | ( | const char * | id | ) | [virtual] |
Returns true if the target's type corresponds to the given RepositoryId
.
Definition at line 466 of file ServerRequestInfo.cpp.
{ // Implemented in the generated skeleton. PortableServer::Servant const servant = (this->servant_upcall_ == 0 ? 0 : this->servant_upcall_->servant ()); if (servant == 0) { throw ::CORBA::NO_RESOURCES (CORBA::OMGVMCID | 1, CORBA::COMPLETED_NO); } return servant->_is_a (id); }
char * TAO::ServerRequestInfo::target_most_derived_interface | ( | void | ) | [virtual] |
Return the most derived interface of the target object.
Definition at line 402 of file ServerRequestInfo.cpp.
{ PortableServer::Servant const servant = (this->servant_upcall_ == 0 ? 0 : this->servant_upcall_->servant ()); if (servant == 0) { throw ::CORBA::NO_RESOURCES (CORBA::OMGVMCID | 1, CORBA::COMPLETED_NO); } return CORBA::string_dup (servant->_interface_repository_id ()); }
TAO::Argument* const* const TAO::ServerRequestInfo::args_ [protected] |
Operation argument list.
Definition at line 233 of file ServerRequestInfo.h.
CORBA::TypeCode_ptr const* const TAO::ServerRequestInfo::exceptions_ [protected] |
Array of TypeCodes
for user exceptions the operation is capable of raising.
Definition at line 244 of file ServerRequestInfo.h.
size_t const TAO::ServerRequestInfo::nargs_ [protected] |
Number of element in the operation argument list.
Definition at line 236 of file ServerRequestInfo.h.
CORBA::ULong const TAO::ServerRequestInfo::nexceptions_ [protected] |
The number of elements in the exceptions_
array.
Definition at line 247 of file ServerRequestInfo.h.
TAO::Portable_Server::Servant_Upcall* const TAO::ServerRequestInfo::servant_upcall_ [protected] |
Pointer to the Servant_Upcall
object that contains the object ID, among other things.
Definition at line 240 of file ServerRequestInfo.h.
TAO_ServerRequest& TAO::ServerRequestInfo::server_request_ [protected] |
Underlying request object that contains much of the information encapsulated by this ServerRequestInfo
implementation.
Definition at line 230 of file ServerRequestInfo.h.