Exemple #1
0
Echo *
POA_Echo::_this (void)
{
  TAO_Stub *stub = this->_create_stub ();
  
  TAO_Stub_Auto_Ptr safe_stub (stub);
  ::CORBA::Object_ptr tmp = CORBA::Object_ptr ();
  
  ::CORBA::Boolean const _tao_opt_colloc =
    stub->servant_orb_var ()->orb_core ()->optimize_collocation_objects ();
  
  ACE_NEW_RETURN (
      tmp,
      ::CORBA::Object (stub, _tao_opt_colloc, this),
      0
    );
  
  ::CORBA::Object_var obj = tmp;
  (void) safe_stub.release ();
  
  typedef ::Echo STUB_SCOPED_NAME;
  return
    TAO::Narrow_Utils<STUB_SCOPED_NAME>::unchecked_narrow (
        obj.in (),
        _TAO_Echo_Proxy_Broker_Factory_function_pointer
      );
}
Exemple #2
0
TAO::Invocation_Retry_State::Invocation_Retry_State (TAO_Stub &stub)
  : forward_on_reply_closed_count_ (0)
  , forward_on_exception_limit_used_ (false)
{
  this->ex_count_map_[FOE_OBJECT_NOT_EXIST] = 0;
  this->ex_count_map_[FOE_COMM_FAILURE] = 0;
  this->ex_count_map_[FOE_TRANSIENT] = 0;
  this->ex_count_map_[FOE_INV_OBJREF] = 0;

  // Cast away const to avoid tedious iterator operations on the ACE_Array_Map.
  TAO::Invocation_Retry_Params &command_line_params =
    const_cast<TAO::Invocation_Retry_Params &> (stub.orb_core ()
      ->orb_params ()->invocation_retry_params ());
  TAO::Invocation_Retry_Params &client_factory_params =
    const_cast<TAO::Invocation_Retry_Params &> (stub.orb_core ()
      ->client_factory ()->invocation_retry_params ());

  retry_params_calc(command_line_params,
                    client_factory_params,
                    this->retry_params_);

  for (Invocation_Retry_Params::exception_limit_map_type::const_iterator i =
         this->retry_params_.forward_on_exception_limit_.begin();
       i != this->retry_params_.forward_on_exception_limit_.end(); ++i)
    {
      if (i->second > 0)
        {
          forward_on_exception_limit_used_ = true;
          break;
        }
    }
}
  void
  Asynch_Invocation_Adapter::invoke (
    Messaging::ReplyHandler_ptr reply_handler_ptr,
    const TAO_Reply_Handler_Stub &reply_handler_stub)
  {
    TAO_Stub * stub =
      this->get_stub ();

    if (TAO_debug_level >= 4)
      {
        TAOLIB_DEBUG ((LM_DEBUG,
                    "TAO_Messaging (%P|%t) - Asynch_Invocation_Adapter::"
                    "invoke\n"));
      }

    // If the reply handler is nil, we do not create a reply dispatcher.
    // The ORB will drop replies to which it cannot associate a reply
    // dispatcher.
    if (!CORBA::is_nil (reply_handler_ptr))
      {
        // New reply dispatcher on the heap or allocator, because
        // we will go out of scope and hand over the reply dispatcher
        // to the ORB.
        TAO_Asynch_Reply_Dispatcher *rd = 0;

        // Get the allocator we could use.
        ACE_Allocator* ami_allocator =
          stub->orb_core ()->lane_resources().ami_response_handler_allocator();

        // If we have an allocator, use it, else use the heap.
        if (ami_allocator)
          {
            ACE_NEW_MALLOC (
              rd,
              static_cast<TAO_Asynch_Reply_Dispatcher *> (
                ami_allocator->malloc (sizeof (TAO_Asynch_Reply_Dispatcher))),
              TAO_Asynch_Reply_Dispatcher (reply_handler_stub,
                                           reply_handler_ptr,
                                           stub->orb_core (),
                                           ami_allocator));
          }
        else
          {
            ACE_NEW (rd,
                     TAO_Asynch_Reply_Dispatcher (reply_handler_stub,
                                                  reply_handler_ptr,
                                                  stub->orb_core (),
                                                  0));
          }

        if (rd == 0)
          {
            throw ::CORBA::NO_MEMORY ();
          }

        this->safe_rd_.reset (rd);
      }

    Invocation_Adapter::invoke (0, 0);
  }
Exemple #4
0
TAO_Stub *
TAO_Stub::set_policy_overrides (const CORBA::PolicyList & policies,
                                CORBA::SetOverrideType set_add)
{
  // Notice the use of an explicit constructor....
  auto_ptr<TAO_Policy_Set> policy_manager (
    new TAO_Policy_Set (TAO_POLICY_OBJECT_SCOPE));

  if (set_add == CORBA::SET_OVERRIDE)
    {
      policy_manager->set_policy_overrides (policies, set_add);
    }
  else if (this->policies_ == 0)
    {
      policy_manager->set_policy_overrides (policies, CORBA::SET_OVERRIDE);
    }
  else
    {
      policy_manager->copy_from (this->policies_);

      policy_manager->set_policy_overrides (policies, set_add);
    }

  TAO_Stub* stub = this->orb_core_->create_stub (this->type_id.in (),
                                                 this->base_profiles_);

  stub->policies_ = policy_manager.release ();

  // Copy the servant ORB if it is present.
  stub->servant_orb (this->servant_orb_var ().in ());

  return stub;
}
Exemple #5
0
IOP::TaggedProfile *
TAO_ClientRequestInfo::effective_profile (void)
{
  this->check_validity ();

  IOP::TaggedProfile *tagged_profile = 0;
  ACE_NEW_THROW_EX (tagged_profile,
                    IOP::TaggedProfile,
                    CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        TAO::VMCID,
                        ENOMEM),
                      CORBA::COMPLETED_NO));

  IOP::TaggedProfile_var safe_tagged_profile = tagged_profile;

  TAO_Stub *stub =
    this->invocation_->effective_target ()->_stubobj ();

  IOP::TaggedProfile *ep =
    stub->profile_in_use ()->create_tagged_profile ();

  if (ep == 0)
    {
      throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 28, CORBA::COMPLETED_NO);
    }

  // @@BAD_PARAM exception
  tagged_profile->tag = ep->tag;
  tagged_profile->profile_data = ep->profile_data;  // Deep copy

  return safe_tagged_profile._retn ();
}
Exemple #6
0
void
TAO::Invocation_Retry_State::next_profile_retry (TAO_Stub &stub) const
{
  if (!stub.next_profile_retry ())
    {
      stub.reset_profiles ();
    }

  this->sleep_at_starting_profile (stub);
}
Exemple #7
0
IOP::TaggedComponentSeq *
TAO_ClientRequestInfo::get_effective_components (IOP::ComponentId id)
{
  this->check_validity ();

  TAO_Stub *stub = this->invocation_->target ()->_stubobj ();

  TAO_Tagged_Components &ecs = stub->profile_in_use ()->tagged_components ();

  IOP::MultipleComponentProfile &components = ecs.components ();

  IOP::TaggedComponentSeq *tagged_components = 0;
  IOP::TaggedComponentSeq_var safe_tagged_components;

  const CORBA::ULong len = components.length ();
  for (CORBA::ULong i = 0; i < len; ++i)
    {
      if (components[i].tag == id)
        {
          if (tagged_components == 0)
            {
              // Only allocate a sequence if we have tagged components
              // to place into the sequence.
              ACE_NEW_THROW_EX (tagged_components,
                                IOP::TaggedComponentSeq,
                                CORBA::NO_MEMORY (
                                  CORBA::SystemException::_tao_minor_code (
                                    TAO::VMCID,
                                    ENOMEM),
                                  CORBA::COMPLETED_NO));

              safe_tagged_components = tagged_components;
            }

          const CORBA::ULong old_len = safe_tagged_components->length ();
          safe_tagged_components->length (old_len + 1);

          safe_tagged_components[old_len] = components[i];  // Deep copy
        }
    }

  if (tagged_components == 0)
    {
      // No tagged component sequence was allocated, meaning no tagged
      // components were found that matched the given
      // IOP::ComponentId.
      throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 28, CORBA::COMPLETED_NO);
    }

  return safe_tagged_components._retn ();
}
Exemple #8
0
  void
  Invocation_Adapter::object_forwarded (CORBA::Object_var &effective_target,
                                        TAO_Stub *stub,
                                        CORBA::Boolean permanent_forward)
  {
    // The object pointer has to be changed to a TAO_Stub pointer
    // in order to obtain the profiles.
    TAO_Stub *stubobj = 0;

    bool nil_forward_ref = false;
    if (CORBA::is_nil (effective_target.in ()))
      nil_forward_ref = true;
    else
      {
        stubobj = effective_target->_stubobj ();

        if (stubobj && stubobj->base_profiles ().size () == 0)
          nil_forward_ref = true;
      }

    if (nil_forward_ref)
      throw ::CORBA::TRANSIENT (
        CORBA::SystemException::_tao_minor_code (
          TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE,
          0),
        CORBA::COMPLETED_NO);

    if (stubobj == 0)
      throw ::CORBA::INTERNAL (
        CORBA::SystemException::_tao_minor_code (
          TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE,
          EINVAL),
        CORBA::COMPLETED_NO);

    // Reset the profile in the stubs
    stub->add_forward_profiles (stubobj->base_profiles (), permanent_forward);

    if (stub->next_profile () == 0)
      throw ::CORBA::TRANSIENT (
        CORBA::SystemException::_tao_minor_code (
          TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE,
          0),
        CORBA::COMPLETED_NO);
  }
Exemple #9
0
IOP::TaggedComponent *
TAO_ClientRequestInfo::get_effective_component (IOP::ComponentId id)
{
  this->check_validity ();

  TAO_Stub *stub = this->invocation_->effective_target ()->_stubobj ();

  TAO_Tagged_Components &ecs = stub->profile_in_use ()->tagged_components ();

  IOP::MultipleComponentProfile &components = ecs.components ();

  CORBA::ULong const len = components.length ();
  for (CORBA::ULong i = 0; i < len; ++i)
    {
      if (components[i].tag == id)
        {
          IOP::TaggedComponent *tagged_component = 0;

          // Only allocate a sequence if we have a tagged component
          // that matches the given IOP::ComponentId.
          ACE_NEW_THROW_EX (tagged_component,
                            IOP::TaggedComponent,
                            CORBA::NO_MEMORY (
                              CORBA::SystemException::_tao_minor_code (
                                TAO::VMCID,
                                ENOMEM),
                              CORBA::COMPLETED_NO));

          IOP::TaggedComponent_var safe_tagged_component =
            tagged_component;

          (*tagged_component) = components[i];  // Deep copy

          return safe_tagged_component._retn ();
        }
    }

  // No tagged component was found that matched the given
  // IOP::ComponentId.
  throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 28, CORBA::COMPLETED_NO);
}
Exemple #10
0
  template<typename T>  T *
  AbstractBase_Narrow_Utils<T>::unchecked_narrow (CORBA::AbstractBase_ptr obj)
  {
    if (CORBA::is_nil (obj))
      {
        return T::_nil ();
      }

    T_ptr proxy = T::_nil ();

    try
      {
        if (obj->_is_objref ())
          {
            TAO_Stub* stub = obj->_stubobj ();

            bool const collocated =
              !CORBA::is_nil (stub->servant_orb_var ().in ())
              && stub->optimize_collocation_objects ()
              && obj->_is_collocated ();

            ACE_NEW_RETURN (proxy,
                            T (obj->_stubobj (),
                               collocated,
                               obj->_servant ()),
                            T::_nil ());
          }
        else
          {
            proxy = dynamic_cast<T *> (obj);
            if (proxy)
              proxy->_add_ref ();
          }
      }
    catch (const ::CORBA::Exception&)
      {
      }

    return proxy;
  }
Exemple #11
0
Test::Roundtrip *
POA_Test::Roundtrip::_this (void)
{
  TAO_Stub *stub = this->_create_stub ();

  TAO_Stub_Auto_Ptr safe_stub (stub);
  ::CORBA::Object_ptr tmp = CORBA::Object_ptr ();

  ::CORBA::Boolean const _tao_opt_colloc =
    stub->servant_orb_var ()->orb_core ()->optimize_collocation_objects ();

  ACE_NEW_RETURN (
      tmp,
      ::CORBA::Object (stub, _tao_opt_colloc, this),
      0);

  ::CORBA::Object_var obj = tmp;
  (void) safe_stub.release ();

  typedef ::Test::Roundtrip STUB_SCOPED_NAME;
  return
    TAO::Narrow_Utils<STUB_SCOPED_NAME>::unchecked_narrow (
        obj.in ());
}
Exemple #12
0
  TAO::Collocation_Strategy
  Invocation_Adapter::collocation_strategy (CORBA::Object_ptr object)
  {
    TAO::Collocation_Strategy strategy = TAO::TAO_CS_REMOTE_STRATEGY;
    TAO_Stub *stub = object->_stubobj ();
    if (!CORBA::is_nil (stub->servant_orb_var ().in ()) &&
        stub->servant_orb_var ()->orb_core () != 0)
      {
        TAO_ORB_Core *orb_core = stub->servant_orb_var ()->orb_core ();

        if (orb_core->collocation_resolver ().is_collocated (object))
          {
            switch (orb_core->get_collocation_strategy ())
              {
              case TAO_ORB_Core::TAO_COLLOCATION_THRU_POA:
                {
                  // check opportunity
                  if (ACE_BIT_ENABLED (this->collocation_opportunity_,
                                      TAO::TAO_CO_THRU_POA_STRATEGY))
                    {
                      strategy = TAO::TAO_CS_THRU_POA_STRATEGY;
                    }
                  else
                    {
                      if (TAO_debug_level > 0)
                        {
                          TAOLIB_ERROR ((LM_ERROR,
                                      ACE_TEXT ("Invocation_Adapter::collocation_strategy, ")
                                      ACE_TEXT ("request for through poa collocation ")
                                      ACE_TEXT ("without needed collocation opportunity.\n")));
                        }
                      // collocation object, but no collocation_opportunity for Thru_poa
                      throw ::CORBA::INTERNAL (
                        CORBA::SystemException::_tao_minor_code (
                          TAO::VMCID,
                          EINVAL),
                        CORBA::COMPLETED_NO);
                    }
                  break;
                }
              case TAO_ORB_Core::TAO_COLLOCATION_DIRECT:
                {
                  if (ACE_BIT_ENABLED (this->collocation_opportunity_,
                                      TAO::TAO_CO_DIRECT_STRATEGY)
                                      && (object->_servant () != 0))
                    {
                      strategy = TAO::TAO_CS_DIRECT_STRATEGY;
                    }
                  else
                    {
                      if (TAO_debug_level > 0)
                        {
                          TAOLIB_ERROR ((LM_ERROR,
                                      ACE_TEXT ("Invocation_Adapter::collocation_strategy, ")
                                      ACE_TEXT ("request for direct collocation ")
                                      ACE_TEXT ("without needed collocation opportunity.\n")));
                        }
                      // collocation object, but no collocation_opportunity for Direct
                      // or servant() == 0
                      throw ::CORBA::INTERNAL (
                      CORBA::SystemException::_tao_minor_code (
                        TAO::VMCID,
                        EINVAL),
                      CORBA::COMPLETED_NO);
                    }
                  break;
                }
              case TAO_ORB_Core::TAO_COLLOCATION_BEST:
                {
                  if (ACE_BIT_ENABLED (this->collocation_opportunity_,
                                      TAO::TAO_CO_DIRECT_STRATEGY)
                      && (object->_servant () != 0))
                    {
                      strategy = TAO::TAO_CS_DIRECT_STRATEGY;
                    }
                  else if (ACE_BIT_ENABLED (this->collocation_opportunity_,
                                            TAO::TAO_CO_THRU_POA_STRATEGY))
                    {
                      strategy = TAO::TAO_CS_THRU_POA_STRATEGY;
                    }
                  else
                    {
                      strategy = TAO::TAO_CS_REMOTE_STRATEGY;
                    }
                  break;
                }
              }
          }
      }

    return strategy;
  }
Exemple #13
0
void
TAO::Invocation_Retry_State::sleep_at_starting_profile (TAO_Stub &stub) const
{
  if (stub.at_starting_profile ())
    this->sleep ();
}
Exemple #14
0
CORBA::Boolean
operator<< (TAO_OutputCDR &strm, const CORBA::AbstractBase_ptr abs)
{
  CORBA::Boolean discriminator = true;

  // We marshal a null abstract interface ptr as a discriminator
  // plus null object reference (see CORBA::Object::marshal()
  // and operator << for CORBA::Object).
  if (CORBA::is_nil (abs))
    {
      // Marshal discriminator, then empty type hint.
      strm << ACE_OutputCDR::from_boolean (discriminator);
      return strm << CORBA::Object::_nil ();
    }

  if (abs->_is_objref ())
    {
      if (strm << ACE_OutputCDR::from_boolean (discriminator))
        {
          TAO_Stub *stubobj = abs->_stubobj ();

          if (stubobj == 0)
            {
              return false;
            }

          // STRING, a type ID hint
          if ((strm << stubobj->type_id.in ()) == 0)
            {
              return false;
            }

          const TAO_MProfile& mprofile = stubobj->base_profiles ();

          CORBA::ULong const profile_count = mprofile.profile_count ();

          if ((strm << profile_count) == 0)
            {
              return false;
            }

          // @@ The MProfile should be locked during this iteration, is there
          // anyway to achieve that?
          for (CORBA::ULong i = 0; i < profile_count; ++i)
            {
              const TAO_Profile *p = mprofile.get_profile (i);

              if (p->encode (strm) == 0)
                {
                  return false;
                }
            }

          return (CORBA::Boolean) strm.good_bit ();
        }
    }
  else
    {
      discriminator = false;

      if (strm << ACE_OutputCDR::from_boolean (discriminator))
        {
          CORBA::ULong value_tag = TAO_OBV_GIOP_Flags::Value_tag_base
                                   | TAO_OBV_GIOP_Flags::Type_info_single;

          if ((strm.write_ulong (value_tag)) == 0)
            {
              return false;
            }

          if ((strm << abs->_tao_obv_repository_id ()) == 0)
            {
              return false;
            }

          return abs->_tao_marshal_v (strm);
        }
    }

  return false;
}