Public Member Functions | Private Member Functions | Private Attributes

TAO_Adapter_Registry Class Reference

#include <Adapter_Registry.h>

Collaboration diagram for TAO_Adapter_Registry:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_Adapter_Registry (TAO_ORB_Core *orb_core)
 ~TAO_Adapter_Registry (void)
 Close the.
void close (int wait_for_completion)
void check_close (int wait_for_completion)
void insert (TAO_Adapter *adapter)
 Insert a new adapter into the registry.
void dispatch (TAO::ObjectKey &key, TAO_ServerRequest &request, CORBA::Object_out forward_to)
CORBA::Object_ptr create_collocated_object (TAO_Stub *, const TAO_MProfile &)
 Create a collocated object using the given profile and stub.
CORBA::Long initialize_collocated_object (TAO_Stub *)
TAO_Adapterfind_adapter (const char *name) const
 Fetch the adapter named name.

Private Member Functions

void operator= (const TAO_Adapter_Registry &)
 TAO_Adapter_Registry (const TAO_Adapter_Registry &)

Private Attributes

TAO_ORB_Coreorb_core_
 The ORB Core.
A simple array of adapters.

size_t adapters_capacity_
size_t adapters_count_
TAO_Adapter ** adapters_

Detailed Description

Definition at line 50 of file Adapter_Registry.h.


Constructor & Destructor Documentation

TAO_Adapter_Registry::TAO_Adapter_Registry ( TAO_ORB_Core orb_core  ) 

Definition at line 21 of file Adapter_Registry.cpp.

  : orb_core_ (oc),
    adapters_capacity_ (16), // @@ Make it configurable
    adapters_count_ (0),
    adapters_ (0)
{
  ACE_NEW (this->adapters_,
           TAO_Adapter*[this->adapters_capacity_]);
}

TAO_Adapter_Registry::~TAO_Adapter_Registry ( void   ) 

Close the.

Definition at line 31 of file Adapter_Registry.cpp.

{
  for (size_t i = 0; i != this->adapters_count_; ++i)
    delete this->adapters_[i];

  delete[] this->adapters_;
}

TAO_Adapter_Registry::TAO_Adapter_Registry ( const TAO_Adapter_Registry  )  [private]

Member Function Documentation

void TAO_Adapter_Registry::check_close ( int  wait_for_completion  ) 

Verify if the close() call can be invoked in the current context for *all* adapters. Raise the right exception if not.

Definition at line 63 of file Adapter_Registry.cpp.

{
  for (size_t i = 0; i != this->adapters_count_; ++i)
    {
      this->adapters_[i]->check_close (wait_for_completion);
    }
}

void TAO_Adapter_Registry::close ( int  wait_for_completion  ) 

Close each of of the Adapters and then cleanup the Registry. It is possible that an Adapter will reject a close() call if it is invoked in an innapropriate context (think shutting down the POA while performing an upcall).

Definition at line 40 of file Adapter_Registry.cpp.

{
  try
    {
      for (size_t i = 0; i != this->adapters_count_; ++i)
        {
          this->adapters_[i]->close (wait_for_completion);
        }
    }
  catch (const::CORBA::Exception &ex)
    {
      if (TAO_debug_level > 3)
        {
          ex._tao_print_exception (
            "Exception in TAO_Adapter_Registry::close ()");
        }
      return;
    }

  return;
}

CORBA::Object_ptr TAO_Adapter_Registry::create_collocated_object ( TAO_Stub stub,
const TAO_MProfile mprofile 
)

Create a collocated object using the given profile and stub.

Definition at line 129 of file Adapter_Registry.cpp.

{
  for (size_t i = 0; i != this->adapters_count_; ++i)
    {
      CORBA::Object_ptr x =
        this->adapters_[i]->create_collocated_object (stub, mprofile);
      if (x != 0)
        {
          if (!stub->collocated_servant ())
            {
              // This adapter created an object but it was not able to locate
              // a servant so we need to give the rest of the adapters a chance to
              // initialise the stub and find a servant or forward us or whatever.
              for (CORBA::Long go_on = 1; go_on && i != this->adapters_count_;
                   ++i)
                {
                  // initialize_collocated_object only returns 0 if it has completely
                  // initialised the object.
                  go_on = this->adapters_[i]->initialize_collocated_object (
                    stub);
                }
            }
          return x;
        }
    }
  return 0;
}

void TAO_Adapter_Registry::dispatch ( TAO::ObjectKey &  key,
TAO_ServerRequest request,
CORBA::Object_out  forward_to 
)

Dispatch the request to all the adapters. It tries the adapters ordered by priority, stopping when the adapter returns a status different from DS_MISMATCHED_KEY

Definition at line 108 of file Adapter_Registry.cpp.

{
  for (size_t i = 0; i != this->adapters_count_; ++i)
    {
      int const r = this->adapters_[i]->dispatch (key, request, forward_to);

      if (r != TAO_Adapter::DS_MISMATCHED_KEY)
        {
          return;
        }
    }

  if (!request.is_forwarded ())
    {
      throw ::CORBA::OBJECT_NOT_EXIST ();
    }
}

TAO_Adapter * TAO_Adapter_Registry::find_adapter ( const char *  name  )  const

Fetch the adapter named name.

Definition at line 176 of file Adapter_Registry.cpp.

{
  for (TAO_Adapter **i = this->adapters_;
       i != this->adapters_ + this->adapters_count_;
       ++i)
    if (ACE_OS::strcmp ((*i)->name (), name) == 0)
      return *i;

  return 0;
}

CORBA::Long TAO_Adapter_Registry::initialize_collocated_object ( TAO_Stub stub  ) 

Initialize a collocated object using the given stub and object pointer for lazily evaluated object references.

Definition at line 159 of file Adapter_Registry.cpp.

{
  for (size_t i = 0; i != this->adapters_count_; ++i)
    {
      int const retval =
        this->adapters_[i]->initialize_collocated_object (stub);
      if (retval == 0)
        {
          // initialize_collocated_object only returns 0 if it has completely
          // initialised the object. We can return early.
          return retval;
        }
    }
  return 0;
}

void TAO_Adapter_Registry::insert ( TAO_Adapter adapter  ) 

Insert a new adapter into the registry.

Definition at line 72 of file Adapter_Registry.cpp.

{
  if (this->adapters_capacity_ == this->adapters_count_)
    {
      this->adapters_capacity_ *= 2;
      TAO_Adapter **tmp = 0;
      ACE_NEW_THROW_EX (tmp,
                        TAO_Adapter*[this->adapters_capacity_],
                        CORBA::NO_MEMORY ());

      for (size_t i = 0; i != this->adapters_count_; ++i)
        tmp[i] = this->adapters_[i];
      delete[] this->adapters_;
      this->adapters_ = tmp;
    }

  int const priority = adapter->priority ();
  for (size_t i = 0; i != this->adapters_count_; ++i)
    {
      if (this->adapters_[i]->priority () >= priority)
        {
          for (size_t j = this->adapters_count_ + 1;
               j > i;
               --j)
            {
              this->adapters_[j] = this->adapters_[j - 1];
            }
          this->adapters_[i] = adapter;
          ++this->adapters_count_;
          return;
        }
    }
  this->adapters_[this->adapters_count_++] = adapter;
}

void TAO_Adapter_Registry::operator= ( const TAO_Adapter_Registry  )  [private]

Member Data Documentation

Definition at line 105 of file Adapter_Registry.h.

Definition at line 103 of file Adapter_Registry.h.

Definition at line 104 of file Adapter_Registry.h.

The ORB Core.

Definition at line 97 of file Adapter_Registry.h.


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