Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

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.

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::StringSeq * arguments (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.

Reference Related Methods

TAO_ORBInitInfo-specific methods and types.



typedef TAO_ORBInitInfo_ptr _ptr_type
 Useful for template programming.
typedef TAO_ORBInitInfo_var _var_type
static TAO_ORBInitInfo_ptr _duplicate (TAO_ORBInitInfo_ptr obj)
static TAO_ORBInitInfo_ptr _narrow (CORBA::Object_ptr obj)
static TAO_ORBInitInfo_ptr _unchecked_narrow (CORBA::Object_ptr obj)
static TAO_ORBInitInfo_ptr _nil (void)
 Return a NIL object.

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 55 of file ORBInitInfo.h.


Member Typedef Documentation

Useful for template programming.

Reimplemented from CORBA::LocalObject.

Definition at line 196 of file ORBInitInfo.h.

Reimplemented from CORBA::LocalObject.

Definition at line 197 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.

  : orb_core_ (orb_core),
    argc_ (argc),
    argv_ (argv),
    codec_factory_ (),
    slot_count_ (slotid)
{
}

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.

{
}

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.

{
  if (!CORBA::is_nil (obj))
    {
      obj->_add_ref ();
    }

  return obj;
}

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.

{
  this->check_validity ();

  return CORBA::ORB::_duplicate (this->orb_core_->orb ());
}

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

The repository ID for the most derived class, this is an implementation method and does no remote invocations!

Reimplemented from CORBA::Object.

Definition at line 387 of file ORBInitInfo.cpp.

{
  return "IDL:TAO_ORBInitInfo:1.0";
}

TAO_ORBInitInfo_ptr TAO_ORBInitInfo::_narrow ( CORBA::Object_ptr  obj  )  [static]
Todo:
Narrowing a LocalObject to a CORBA::Object is broken right now. The solution seems to be making CORBA::Object an abstract base class and create a CORBA::RemoteObject for regular object. Or, even easier, add a is_local member into CORBA::Object. I'll take the easier route for now.

Reimplemented from CORBA::LocalObject.

Definition at line 363 of file ORBInitInfo.cpp.

{
  if (CORBA::is_nil (_tao_objref))
    {
      return TAO_ORBInitInfo::_nil ();
    }

  TAO_ORBInitInfo_ptr proxy =
    dynamic_cast<TAO_ORBInitInfo_ptr> (_tao_objref);

  return TAO_ORBInitInfo::_duplicate (proxy);
}

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

Return a NIL object.

Reimplemented from CORBA::LocalObject.

Definition at line 207 of file ORBInitInfo.h.

    {
      return (TAO_ORBInitInfo_ptr)0;
    }

static 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.

{
# if TAO_HAS_INTERCEPTORS == 1
  this->check_validity ();

  this->orb_core_->add_interceptor (interceptor);
#else
  ACE_UNUSED_ARG (interceptor);
  throw ::CORBA::NO_IMPLEMENT (
               CORBA::SystemException::_tao_minor_code (
                 0,
                 ENOTSUP),
               CORBA::COMPLETED_NO);
#endif  /* TAO_HAS_INTERCEPTORS == 1 */
}

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.

{
# if TAO_HAS_INTERCEPTORS == 1
  this->check_validity ();

  this->orb_core_->add_interceptor (interceptor, policies);
#else
  ACE_UNUSED_ARG (interceptor);
  ACE_UNUSED_ARG (policies);
  throw ::CORBA::NO_IMPLEMENT (
               CORBA::SystemException::_tao_minor_code (
                 0,
                 ENOTSUP),
               CORBA::COMPLETED_NO);
#endif  /* TAO_HAS_INTERCEPTORS == 1 */
}

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.

{
  this->check_validity ();

  this->orb_core_->add_interceptor (interceptor);
}

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.

{
  this->check_validity ();

  // Since there are currently no PI Policies that pertain to
  // IOR Interceptors, we will always raise the NO_IMPLEMENT
  // CORBA System Exception here to indicate that this method
  // is currently not implemented/supported.
  ACE_UNUSED_ARG (interceptor);
  ACE_UNUSED_ARG (policies);
  throw ::CORBA::NO_IMPLEMENT (
               CORBA::SystemException::_tao_minor_code (
                 0,
                 ENOTSUP),
               CORBA::COMPLETED_NO);
}

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.

{
# if TAO_HAS_INTERCEPTORS == 1
  this->check_validity ();

  this->orb_core_->add_interceptor (interceptor);

#else
  ACE_UNUSED_ARG (interceptor);
  throw ::CORBA::NO_IMPLEMENT (
               CORBA::SystemException::_tao_minor_code (
                 0,
                 ENOTSUP),
               CORBA::COMPLETED_NO);
#endif  /* TAO_HAS_INTERCEPTORS == 1 */
}

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.

{
# if TAO_HAS_INTERCEPTORS == 1
  this->check_validity ();

  this->orb_core_->add_interceptor (interceptor, policies);

#else
  ACE_UNUSED_ARG (interceptor);
  ACE_UNUSED_ARG (policies);
  throw ::CORBA::NO_IMPLEMENT (
               CORBA::SystemException::_tao_minor_code (
                 0,
                 ENOTSUP),
               CORBA::COMPLETED_NO);
#endif  /* TAO_HAS_INTERCEPTORS == 1 */
}

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

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

Definition at line 285 of file ORBInitInfo.cpp.

{
  this->check_validity ();

#if TAO_HAS_INTERCEPTORS == 1
  // No need to acquire a lock.  This only gets called during ORB
  // initialization.  ORB initialization is already atomic.
  return this->slot_count_++;
#else
  throw ::CORBA::NO_IMPLEMENT (
    CORBA::SystemException::_tao_minor_code (
      0,
      ENOTSUP),
    CORBA::COMPLETED_NO);
#endif  /* TAO_HAS_INTERCEPTORS == 1 */
}

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.

{
  this->check_validity ();

  size_t slot_id = 0;

  const int result = this->orb_core_->add_tss_cleanup_func (cleanup, slot_id);

  if (result != 0)
    throw ::CORBA::INTERNAL (
      CORBA::SystemException::_tao_minor_code (
        0,
        errno),
      CORBA::COMPLETED_NO);

  return slot_id;
}

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.

{
  this->check_validity ();

  // In accordance with the C++ mapping for sequences, it is up to the
  // caller to deallocate storage for returned sequences.

  CORBA::StringSeq *args = 0;
  ACE_NEW_THROW_EX (args,
                    CORBA::StringSeq,
                    CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        0,
                        ENOMEM),
                      CORBA::COMPLETED_NO));

  CORBA::StringSeq_var safe_args (args);

  // Copy the argument vector to the string sequence.

  args->length (this->argc_);   // Not a problem if argc is zero.
  for (int i = 0; i < this->argc_; ++i)
    (*args)[i] = CORBA::string_dup (this->argv_[i]);

  return safe_args._retn ();
}

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.

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

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.

{
  if (CORBA::is_nil (this->codec_factory_.in ()))
    {
      TAO_Object_Loader *loader =
        ACE_Dynamic_Service<TAO_Object_Loader>::instance ("CodecFactory_Loader");

      if (loader == 0)
        {
          ACE_Service_Config::process_directive (
            ACE_DYNAMIC_SERVICE_DIRECTIVE("CodecFactory",
                                          "TAO_CodecFactory",
                                          "_make_TAO_CodecFactory_Loader",
                                          ""));
          loader =
            ACE_Dynamic_Service<TAO_Object_Loader>::instance ("CodecFactory_Loader");
        }

      if (loader != 0)
        {
          CORBA::Object_var cf =
            loader->create_object (this->orb_core_->orb (), 0, 0);

          this->codec_factory_ = IOP::CodecFactory::_narrow (cf.in ());
        }
    }

  return IOP::CodecFactory::_duplicate (this->codec_factory_.in ());
}

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.

{
  this->orb_core_ = 0;
}

void TAO_ORBInitInfo::operator= ( const TAO_ORBInitInfo  )  [private]
TAO_ORB_Core * TAO_ORBInitInfo::orb_core ( void   )  const

Return a pointer to the ORB Core associated with the ORB being initialized. 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.

{
  return this->orb_core_;
}

char * TAO_ORBInitInfo::orb_id ( void   )  [virtual]

Return the ORBid for the ORB currently being initialized.

Definition at line 103 of file ORBInitInfo.cpp.

{
  this->check_validity ();

  // In accordance with the C++ mapping for strings, return a copy.

  return CORBA::string_dup (this->orb_core_->orbid ());
}

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

Register a mapping between a string and a corresponding object reference with the ORB being initialized. 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.

{
  this->check_validity ();

  if (id == 0 || ACE_OS::strlen (id) == 0)
    throw PortableInterceptor::ORBInitInfo::InvalidName ();

  if (CORBA::is_nil (obj))
    throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 27, CORBA::COMPLETED_NO);

  TAO_Object_Ref_Table &table = this->orb_core_->object_ref_table ();

  if (table.register_initial_reference (id, obj) == -1)
    throw PortableInterceptor::ORBInitInfo::InvalidName ();
}

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.

{
  this->check_validity ();

  TAO::PolicyFactory_Registry_Adapter *registry =
    this->orb_core_->policy_factory_registry ();

  if (registry == 0)
    {
      throw ::CORBA::INTERNAL ();
    }

  registry->register_policy_factory (type, policy_factory);
}

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.

{
  this->check_validity ();

  if (id == 0 || ACE_OS::strlen (id) == 0)
    throw PortableInterceptor::ORBInitInfo::InvalidName ();

  // The ORB is practically fully initialized by the time this point
  // is reached so just use the ORB's resolve_initial_references()
  // mechanism.
  return this->orb_core_->orb ()->resolve_initial_references (id);
}

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.

{
  return this->slot_count_;
}


Member Data Documentation

int TAO_ORBInitInfo::argc_ [private]

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

Definition at line 240 of file ORBInitInfo.h.

char** TAO_ORBInitInfo::argv_ [private]

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

Definition at line 243 of file ORBInitInfo.h.

IOP::CodecFactory_var TAO_ORBInitInfo::codec_factory_ [private]

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

Definition at line 247 of file ORBInitInfo.h.

Reference to the ORB Core.

Reimplemented from CORBA::Object.

Definition at line 236 of file ORBInitInfo.h.

The number of allocated slots.

Definition at line 250 of file ORBInitInfo.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines