TAO_ORBInitInfo Class Reference

An implementation of the PortableInterceptor::ORBInitInfo_3_1 interface. More...

#include <ORBInitInfo.h>

Inheritance diagram for TAO_ORBInitInfo:

Inheritance graph
[legend]
Collaboration diagram for TAO_ORBInitInfo:

Collaboration graph
[legend]
List of all members.

Reference Related Methods

TAO_ORBInitInfo-specific methods and types.

typedef TAO_ORBInitInfo_ptr _ptr_type
typedef TAO_ORBInitInfo_var _var_type
TAO_ORBInitInfo_ptr _duplicate (TAO_ORBInitInfo_ptr obj)
TAO_ORBInitInfo_ptr _narrow (CORBA::Object_ptr obj)
TAO_ORBInitInfo_ptr _unchecked_narrow (CORBA::Object_ptr obj)
TAO_ORBInitInfo_ptr _nil (void)

Public Member Functions

 TAO_ORBInitInfo (TAO_ORB_Core *orb_core, int argc, char *argv[], PortableInterceptor::SlotId slotid)
 Constructor.

virtual const char * _interface_repository_id (void) const
PortableInterceptor::ORBInitInfo Methods
These methods are exported by the PortableInterceptor::ORBInitInfo interface.

virtual CORBA::StringSeqarguments (void)
virtual char * orb_id (void)
 Return the ORBid for the ORB currently being initialized.

virtual IOP::CodecFactory_ptr codec_factory (void)
virtual void register_initial_reference (const char *id, CORBA::Object_ptr obj)
virtual CORBA::Object_ptr resolve_initial_references (const char *id)
virtual void add_client_request_interceptor (PortableInterceptor::ClientRequestInterceptor_ptr interceptor)
virtual void add_server_request_interceptor (PortableInterceptor::ServerRequestInterceptor_ptr interceptor)
virtual void add_ior_interceptor (PortableInterceptor::IORInterceptor_ptr interceptor)
virtual void add_client_request_interceptor_with_policy (PortableInterceptor::ClientRequestInterceptor_ptr interceptor, const CORBA::PolicyList &policies)
virtual void add_server_request_interceptor_with_policy (PortableInterceptor::ServerRequestInterceptor_ptr interceptor, const CORBA::PolicyList &policies)
virtual void add_ior_interceptor_with_policy (PortableInterceptor::IORInterceptor_ptr interceptor, const CORBA::PolicyList &policies)
virtual PortableInterceptor::SlotId allocate_slot_id (void)
virtual void register_policy_factory (CORBA::PolicyType type, PortableInterceptor::PolicyFactory_ptr policy_factory)
virtual CORBA::ORB_ptr _get_orb (void)
TAO Extensions
These methods are not part of the PortableInterceptor specification, and are TAO-specific extensions.

size_t allocate_tss_slot_id (ACE_CLEANUP_FUNC cleanup)
 Allocate a slot in the ORB's TSS resources.

TAO_ORB_Coreorb_core (void) const
void invalidate (void)
 Invalidate this ORBInitInfo instance.

PortableInterceptor::SlotId slot_count (void) const

Protected Member Functions

 ~TAO_ORBInitInfo (void)
void check_validity (void)

Private Member Functions

 TAO_ORBInitInfo (const TAO_ORBInitInfo &)
void operator= (const TAO_ORBInitInfo &)

Private Attributes

TAO_ORB_Coreorb_core_
 Reference to the ORB Core.

int argc_
char ** argv_
 The argument vector passed to CORBA::ORB_init().

IOP::CodecFactory_var codec_factory_
PortableInterceptor::SlotId slot_count_
 The number of allocated slots.


Detailed Description

An implementation of the PortableInterceptor::ORBInitInfo_3_1 interface.

This class encapsulates the data passed to ORBInitializers during ORB initialization.

Definition at line 59 of file ORBInitInfo.h.


Member Typedef Documentation

typedef TAO_ORBInitInfo_ptr TAO_ORBInitInfo::_ptr_type
 

Reimplemented from CORBA::LocalObject.

Definition at line 200 of file ORBInitInfo.h.

typedef TAO_ORBInitInfo_var TAO_ORBInitInfo::_var_type
 

Reimplemented from CORBA::LocalObject.

Definition at line 201 of file ORBInitInfo.h.


Constructor & Destructor Documentation

TAO_ORBInitInfo::TAO_ORBInitInfo TAO_ORB_Core orb_core,
int  argc,
char *  argv[],
PortableInterceptor::SlotId  slotid
 

Constructor.

Definition at line 58 of file ORBInitInfo.cpp.

00062   : orb_core_ (orb_core),
00063     argc_ (argc),
00064     argv_ (argv),
00065     codec_factory_ (),
00066     slot_count_ (slotid)
00067 {
00068 }

TAO_ORBInitInfo::~TAO_ORBInitInfo void   )  [protected]
 

Destructor is protected to enforce proper memory management through the reference counting mechanism.

Definition at line 70 of file ORBInitInfo.cpp.

00071 {
00072 }

TAO_ORBInitInfo::TAO_ORBInitInfo const TAO_ORBInitInfo  )  [private]
 

Prevent copying through the copy constructor and the assignment operator.


Member Function Documentation

TAO_ORBInitInfo_ptr TAO_ORBInitInfo::_duplicate TAO_ORBInitInfo_ptr  obj  )  [static]
 

Definition at line 377 of file ORBInitInfo.cpp.

References TAO_Local_RefCounted_Object::_add_ref(), CORBA::is_nil(), and TAO_ORBInitInfo_ptr.

Referenced by _narrow(), and TAO::Objref_Traits< TAO_ORBInitInfo >::duplicate().

00378 {
00379   if (!CORBA::is_nil (obj))
00380     {
00381       obj->_add_ref ();
00382     }
00383 
00384   return obj;
00385 }

CORBA::ORB_ptr TAO_ORBInitInfo::_get_orb void   )  [virtual]
 

Return the argument vector for the ORB currently being initialized as a string sequence.

Reimplemented from CORBA::LocalObject.

Definition at line 356 of file ORBInitInfo.cpp.

References CORBA::ORB::_duplicate(), and check_validity().

00357 {
00358   this->check_validity ();
00359 
00360   return CORBA::ORB::_duplicate (this->orb_core_->orb ());
00361 }

const char * TAO_ORBInitInfo::_interface_repository_id void   )  const [virtual]
 

Reimplemented from CORBA::Object.

Definition at line 387 of file ORBInitInfo.cpp.

00388 {
00389   return "IDL:TAO_ORBInitInfo:1.0";
00390 }

TAO_ORBInitInfo_ptr TAO_ORBInitInfo::_narrow CORBA::Object_ptr  obj  )  [static]
 

Reimplemented from CORBA::LocalObject.

Definition at line 363 of file ORBInitInfo.cpp.

References _duplicate(), _nil(), CORBA::is_nil(), and TAO_ORBInitInfo_ptr.

00364 {
00365   if (CORBA::is_nil (_tao_objref))
00366     {
00367       return TAO_ORBInitInfo::_nil ();
00368     }
00369 
00370   TAO_ORBInitInfo_ptr proxy =
00371     dynamic_cast<TAO_ORBInitInfo_ptr> (_tao_objref);
00372 
00373   return TAO_ORBInitInfo::_duplicate (proxy);
00374 }

TAO_ORBInitInfo_ptr TAO_ORBInitInfo::_nil void   )  [inline, static]
 

Reimplemented from CORBA::LocalObject.

Definition at line 211 of file ORBInitInfo.h.

References TAO_ORBInitInfo_ptr.

Referenced by _narrow(), and TAO::Objref_Traits< TAO_ORBInitInfo >::nil().

00212     {
00213       return (TAO_ORBInitInfo_ptr)0;
00214     }

TAO_ORBInitInfo_ptr TAO_ORBInitInfo::_unchecked_narrow CORBA::Object_ptr  obj  )  [static]
 

void TAO_ORBInitInfo::add_client_request_interceptor PortableInterceptor::ClientRequestInterceptor_ptr  interceptor  )  [virtual]
 

Register a client request interceptor with the ORB currently being initialized.

Definition at line 177 of file ORBInitInfo.cpp.

References TAO_ORB_Core::add_interceptor(), check_validity(), and ENOTSUP.

00179 {
00180 # if TAO_HAS_INTERCEPTORS == 1
00181   this->check_validity ();
00182 
00183   this->orb_core_->add_interceptor (interceptor);
00184 #else
00185   ACE_UNUSED_ARG (interceptor);
00186   throw ::CORBA::NO_IMPLEMENT (
00187                CORBA::SystemException::_tao_minor_code (
00188                  0,
00189                  ENOTSUP),
00190                CORBA::COMPLETED_NO);
00191 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00192 }

void TAO_ORBInitInfo::add_client_request_interceptor_with_policy PortableInterceptor::ClientRequestInterceptor_ptr  interceptor,
const CORBA::PolicyList policies
[virtual]
 

Register a client request interceptor with the ORB currently being initialized, along with a list of policies.

Definition at line 223 of file ORBInitInfo.cpp.

References TAO_ORB_Core::add_interceptor(), check_validity(), and ENOTSUP.

00226 {
00227 # if TAO_HAS_INTERCEPTORS == 1
00228   this->check_validity ();
00229 
00230   this->orb_core_->add_interceptor (interceptor, policies);
00231 #else
00232   ACE_UNUSED_ARG (interceptor);
00233   ACE_UNUSED_ARG (policies);
00234   throw ::CORBA::NO_IMPLEMENT (
00235                CORBA::SystemException::_tao_minor_code (
00236                  0,
00237                  ENOTSUP),
00238                CORBA::COMPLETED_NO);
00239 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00240 }

void TAO_ORBInitInfo::add_ior_interceptor PortableInterceptor::IORInterceptor_ptr  interceptor  )  [virtual]
 

Register an IOR interceptor with the ORB currently being initialized.

Definition at line 214 of file ORBInitInfo.cpp.

References TAO_ORB_Core::add_interceptor(), and check_validity().

00216 {
00217   this->check_validity ();
00218 
00219   this->orb_core_->add_interceptor (interceptor);
00220 }

void TAO_ORBInitInfo::add_ior_interceptor_with_policy PortableInterceptor::IORInterceptor_ptr  interceptor,
const CORBA::PolicyList policies
[virtual]
 

Register an IOR interceptor with the ORB currently being initialized, along with a list of policies.

Definition at line 264 of file ORBInitInfo.cpp.

References check_validity(), and ENOTSUP.

00268 {
00269   this->check_validity ();
00270 
00271   // Since there are currently no PI Policies that pertain to
00272   // IOR Interceptors, we will always raise the NO_IMPLEMENT
00273   // CORBA System Exception here to indicate that this method
00274   // is currently not implemented/supported.
00275   ACE_UNUSED_ARG (interceptor);
00276   ACE_UNUSED_ARG (policies);
00277   throw ::CORBA::NO_IMPLEMENT (
00278                CORBA::SystemException::_tao_minor_code (
00279                  0,
00280                  ENOTSUP),
00281                CORBA::COMPLETED_NO);
00282 }

void TAO_ORBInitInfo::add_server_request_interceptor PortableInterceptor::ServerRequestInterceptor_ptr  interceptor  )  [virtual]
 

Register a server request interceptor with the ORB currently being initialized.

Definition at line 195 of file ORBInitInfo.cpp.

References TAO_ORB_Core::add_interceptor(), check_validity(), and ENOTSUP.

00197 {
00198 # if TAO_HAS_INTERCEPTORS == 1
00199   this->check_validity ();
00200 
00201   this->orb_core_->add_interceptor (interceptor);
00202 
00203 #else
00204   ACE_UNUSED_ARG (interceptor);
00205   throw ::CORBA::NO_IMPLEMENT (
00206                CORBA::SystemException::_tao_minor_code (
00207                  0,
00208                  ENOTSUP),
00209                CORBA::COMPLETED_NO);
00210 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00211 }

void TAO_ORBInitInfo::add_server_request_interceptor_with_policy PortableInterceptor::ServerRequestInterceptor_ptr  interceptor,
const CORBA::PolicyList policies
[virtual]
 

Register a server request interceptor with the ORB currently being initialized, along with a list of policies.

Definition at line 243 of file ORBInitInfo.cpp.

References TAO_ORB_Core::add_interceptor(), check_validity(), and ENOTSUP.

00246 {
00247 # if TAO_HAS_INTERCEPTORS == 1
00248   this->check_validity ();
00249 
00250   this->orb_core_->add_interceptor (interceptor, policies);
00251 
00252 #else
00253   ACE_UNUSED_ARG (interceptor);
00254   ACE_UNUSED_ARG (policies);
00255   throw ::CORBA::NO_IMPLEMENT (
00256                CORBA::SystemException::_tao_minor_code (
00257                  0,
00258                  ENOTSUP),
00259                CORBA::COMPLETED_NO);
00260 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00261 }

PortableInterceptor::SlotId TAO_ORBInitInfo::allocate_slot_id void   )  [virtual]
 

Reserve a slot in table found within the PortableInterceptor::Current object.

Implements PortableInterceptor::ORBInitInfo.

Definition at line 285 of file ORBInitInfo.cpp.

References check_validity(), ENOTSUP, and slot_count_.

00286 {
00287   this->check_validity ();
00288 
00289 #if TAO_HAS_INTERCEPTORS == 1
00290   // No need to acquire a lock.  This only gets called during ORB
00291   // initialization.  ORB initialization is already atomic.
00292   return this->slot_count_++;
00293 #else
00294   throw ::CORBA::NO_IMPLEMENT (
00295     CORBA::SystemException::_tao_minor_code (
00296       0,
00297       ENOTSUP),
00298     CORBA::COMPLETED_NO);
00299 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00300 }

size_t TAO_ORBInitInfo::allocate_tss_slot_id ACE_CLEANUP_FUNC  cleanup  ) 
 

Allocate a slot in the ORB's TSS resources.

TAO uses a single TSS key for these resources, so it is useful to place TSS objects in TAO's TSS resources on platforms where the number of TSS keys is low. The returned SlotId can be used to index into the array stored in ORB's TSS resources structure.

An accompanying cleanup function (e.g. a TSS destructor) can also be registered.

Definition at line 322 of file ORBInitInfo.cpp.

References TAO_ORB_Core::add_tss_cleanup_func(), and check_validity().

00323 {
00324   this->check_validity ();
00325 
00326   size_t slot_id = 0;
00327 
00328   const int result = this->orb_core_->add_tss_cleanup_func (cleanup, slot_id);
00329 
00330   if (result != 0)
00331     throw ::CORBA::INTERNAL (
00332       CORBA::SystemException::_tao_minor_code (
00333         0,
00334         errno),
00335       CORBA::COMPLETED_NO);
00336 
00337   return slot_id;
00338 }

CORBA::StringSeq * TAO_ORBInitInfo::arguments void   )  [virtual]
 

Return the argument vector for the ORB currently being initialized as a string sequence.

Definition at line 75 of file ORBInitInfo.cpp.

References ACE_NEW_THROW_EX, check_validity(), and CORBA::string_dup().

00076 {
00077   this->check_validity ();
00078 
00079   // In accordance with the C++ mapping for sequences, it is up to the
00080   // caller to deallocate storage for returned sequences.
00081 
00082   CORBA::StringSeq *args = 0;
00083   ACE_NEW_THROW_EX (args,
00084                     CORBA::StringSeq,
00085                     CORBA::NO_MEMORY (
00086                       CORBA::SystemException::_tao_minor_code (
00087                         0,
00088                         ENOMEM),
00089                       CORBA::COMPLETED_NO));
00090 
00091   CORBA::StringSeq_var safe_args (args);
00092 
00093   // Copy the argument vector to the string sequence.
00094 
00095   args->length (this->argc_);   // Not a problem if argc is zero.
00096   for (int i = 0; i < this->argc_; ++i)
00097     (*args)[i] = CORBA::string_dup (this->argv_[i]);
00098 
00099   return safe_args._retn ();
00100 }

void TAO_ORBInitInfo::check_validity void   )  [protected]
 

Check if this ORBInitInfo instance is valid. Once post_init() has been called on each of the ORBInitializers, this ORBInitInfo is no longer valid. Throw an exception in that case.

Definition at line 341 of file ORBInitInfo.cpp.

Referenced by _get_orb(), add_client_request_interceptor(), add_client_request_interceptor_with_policy(), add_ior_interceptor(), add_ior_interceptor_with_policy(), add_server_request_interceptor(), add_server_request_interceptor_with_policy(), allocate_slot_id(), allocate_tss_slot_id(), arguments(), orb_id(), register_initial_reference(), register_policy_factory(), and resolve_initial_references().

00342 {
00343   if (this->orb_core_ == 0)
00344     {
00345       // As defined by the Portable Interceptor specification, throw a
00346       // CORBA::OBJECT_NOT_EXIST exception after CORBA::ORB_init() has
00347       // completed.  CORBA::ORB_init() sets the ORB core pointer in
00348       // this instance to zero when it is done initializing the ORB,
00349       // which is why we base "existence" on the validity of the ORB
00350       // core pointer.
00351       throw ::CORBA::OBJECT_NOT_EXIST (0, CORBA::COMPLETED_NO);
00352     }
00353 }

IOP::CodecFactory_ptr TAO_ORBInitInfo::codec_factory void   )  [virtual]
 

Return the CodecFactory for the ORB currently being initialized.

Definition at line 113 of file ORBInitInfo.cpp.

References ACE_DYNAMIC_SERVICE_DIRECTIVE, TAO_Object_Loader::create_object(), ACE_Dynamic_Service< TYPE >::instance(), CORBA::is_nil(), and ACE_Service_Config::process_directive().

00114 {
00115   if (CORBA::is_nil (this->codec_factory_.in ()))
00116     {
00117       TAO_Object_Loader *loader =
00118         ACE_Dynamic_Service<TAO_Object_Loader>::instance ("CodecFactory_Loader");
00119 
00120       if (loader == 0)
00121         {
00122           ACE_Service_Config::process_directive (
00123             ACE_DYNAMIC_SERVICE_DIRECTIVE("CodecFactory",
00124                                           "TAO_CodecFactory",
00125                                           "_make_TAO_CodecFactory_Loader",
00126                                           ""));
00127           loader =
00128             ACE_Dynamic_Service<TAO_Object_Loader>::instance ("CodecFactory_Loader");
00129         }
00130 
00131       if (loader != 0)
00132         {
00133           CORBA::Object_var cf =
00134             loader->create_object (this->orb_core_->orb (), 0, 0);
00135 
00136           this->codec_factory_ = IOP::CodecFactory::_narrow (cf.in ());
00137         }
00138     }
00139 
00140   return IOP::CodecFactory::_duplicate (this->codec_factory_.in ());
00141 }

ACE_INLINE void TAO_ORBInitInfo::invalidate void   ) 
 

Invalidate this ORBInitInfo instance.

Note:
This method is only meant to be called by the CORBA::ORB_init() function.

Definition at line 15 of file ORBInitInfo.inl.

00016 {
00017   this->orb_core_ = 0;
00018 }

void TAO_ORBInitInfo::operator= const TAO_ORBInitInfo  )  [private]
 

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_ORB_Core * TAO_ORBInitInfo::orb_core void   )  const
 

The ORB Core is essentialy fully initialized by the time ORBInitializer::post_init() is invoked. As such, it is generally best if this method is used in that method.

Note:
Only use this method if you know what you are doing.

Reimplemented from CORBA::Object.

Definition at line 9 of file ORBInitInfo.inl.

00010 {
00011   return this->orb_core_;
00012 }

char * TAO_ORBInitInfo::orb_id void   )  [virtual]
 

Return the ORBid for the ORB currently being initialized.

Definition at line 103 of file ORBInitInfo.cpp.

References check_validity(), and CORBA::string_dup().

00104 {
00105   this->check_validity ();
00106 
00107   // In accordance with the C++ mapping for strings, return a copy.
00108 
00109   return CORBA::string_dup (this->orb_core_->orbid ());
00110 }

void TAO_ORBInitInfo::register_initial_reference const char *  id,
CORBA::Object_ptr  obj
[virtual]
 

This method is particularly useful for registering references to local (locality constrained) objects. Note that this method should be called in ORBInitializer::pre_init() so that the registered reference will be available to the resolve_initial_references() that may be called in the ORBInitializer::post_init() call.

Definition at line 144 of file ORBInitInfo.cpp.

References check_validity(), CORBA::is_nil(), TAO_ORB_Core::object_ref_table(), TAO_Object_Ref_Table::register_initial_reference(), and ACE_OS::strlen().

00147 {
00148   this->check_validity ();
00149 
00150   if (id == 0 || ACE_OS::strlen (id) == 0)
00151     throw PortableInterceptor::ORBInitInfo::InvalidName ();
00152 
00153   if (CORBA::is_nil (obj))
00154     throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 27, CORBA::COMPLETED_NO);
00155 
00156   TAO_Object_Ref_Table &table = this->orb_core_->object_ref_table ();
00157 
00158   if (table.register_initial_reference (id, obj) == -1)
00159     throw PortableInterceptor::ORBInitInfo::InvalidName ();
00160 }

void TAO_ORBInitInfo::register_policy_factory CORBA::PolicyType  type,
PortableInterceptor::PolicyFactory_ptr  policy_factory
[virtual]
 

Register a policy factory of the given policy type with the ORB currently being initialized.

Definition at line 303 of file ORBInitInfo.cpp.

References check_validity(), TAO_ORB_Core::policy_factory_registry(), and TAO::PolicyFactory_Registry_Adapter::register_policy_factory().

00307 {
00308   this->check_validity ();
00309 
00310   TAO::PolicyFactory_Registry_Adapter *registry =
00311     this->orb_core_->policy_factory_registry ();
00312 
00313   if (registry == 0)
00314     {
00315       throw ::CORBA::INTERNAL ();
00316     }
00317 
00318   registry->register_policy_factory (type, policy_factory);
00319 }

CORBA::Object_ptr TAO_ORBInitInfo::resolve_initial_references const char *  id  )  [virtual]
 

Obtain a reference to an object that may not yet be available via the usual CORBA::ORB::resolve_initial_references() mechanism since the ORB may not be fully initialized yet.

Definition at line 163 of file ORBInitInfo.cpp.

References check_validity(), TAO_ORB_Core::orb(), and ACE_OS::strlen().

00164 {
00165   this->check_validity ();
00166 
00167   if (id == 0 || ACE_OS::strlen (id) == 0)
00168     throw PortableInterceptor::ORBInitInfo::InvalidName ();
00169 
00170   // The ORB is practically fully initialized by the time this point
00171   // is reached so just use the ORB's resolve_initial_references()
00172   // mechanism.
00173   return this->orb_core_->orb ()->resolve_initial_references (id);
00174 }

ACE_INLINE PortableInterceptor::SlotId TAO_ORBInitInfo::slot_count void   )  const
 

Return the number of allocated slots in for the PICurrent object.

Definition at line 21 of file ORBInitInfo.inl.

References slot_count_.

00022 {
00023   return this->slot_count_;
00024 }


Member Data Documentation

int TAO_ORBInitInfo::argc_ [private]
 

The number of arguments in the argument vector passed to CORBA::ORB_init().

Definition at line 244 of file ORBInitInfo.h.

char** TAO_ORBInitInfo::argv_ [private]
 

The argument vector passed to CORBA::ORB_init().

Definition at line 247 of file ORBInitInfo.h.

IOP::CodecFactory_var TAO_ORBInitInfo::codec_factory_ [private]
 

Reference to the CodecFactory returned by ORBInitInfo::codec_factory().

Definition at line 251 of file ORBInitInfo.h.

TAO_ORB_Core* TAO_ORBInitInfo::orb_core_ [private]
 

Reference to the ORB Core.

Reimplemented from CORBA::Object.

Definition at line 240 of file ORBInitInfo.h.

PortableInterceptor::SlotId TAO_ORBInitInfo::slot_count_ [private]
 

The number of allocated slots.

Definition at line 254 of file ORBInitInfo.h.

Referenced by allocate_slot_id(), and slot_count().


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:30:16 2008 for TAO_PI by doxygen 1.3.6