Example #1
0
    CORBA::Object_ptr
    ImR_Client_Adapter_Impl::imr_key_to_object(TAO_Root_POA* poa,
                                               const TAO::ObjectKey &key,
                                               const char* type_id) const
    {
      TAO_ORB_Core& orb_core = poa->orb_core ();
      // Check to see if we alter the IOR.
      CORBA::Object_var imr = orb_core.implrepo_service ();

      if (CORBA::is_nil (imr.in ())
          || !imr->_stubobj ()
          || !imr->_stubobj ()->profile_in_use ())
        {
          if (TAO_debug_level > 1)
            {
              TAOLIB_DEBUG ((LM_DEBUG,
                             ACE_TEXT ("TAO_ImR_Client (%P|%t) - Missing ImR IOR, will not use the ImR\n")));
            }
          return CORBA::Object::_nil();
        }

      const TAO_MProfile& base_profiles = imr->_stubobj ()->base_profiles ();
      CORBA::String_var key_str;
      TAO::ObjectKey::encode_sequence_to_string (key_str.inout (), key);

      // if there is only one profile, no need to use IORManipulation
      if (base_profiles.profile_count() == 1)
        {
          return combine(orb_core,
                         *base_profiles.get_profile(0),
                         key_str.in(),
                         type_id);
        }

      // need to combine each profile in the ImR with the key and
      // then merge them all together into one ImR-ified ior
      ImRifyProfiles imrify (base_profiles,
                             imr->_stubobj ()->profile_in_use (),
                             orb_core,
                             key_str,
                             type_id);

      return imrify.combined_ior ();
    }
Example #2
0
void
TAO_Notify_SequencePushConsumer::init (CosNotifyComm::SequencePushConsumer_ptr push_consumer)
{
  // Initialize only once
  ACE_ASSERT( CORBA::is_nil (this->push_consumer_.in()) );

  if (CORBA::is_nil (push_consumer))
  {
    throw CORBA::BAD_PARAM();
  }

  if (!TAO_Notify_PROPERTIES::instance()->separate_dispatching_orb ())
    {
      this->push_consumer_ = CosNotifyComm::SequencePushConsumer::_duplicate (push_consumer);
      this->publish_ = CosNotifyComm::NotifyPublish::_duplicate (push_consumer);
    }
  else
    {
      // "Port" consumer's object reference from receiving ORB to dispatching ORB.
      CORBA::String_var temp =
        TAO_Notify_PROPERTIES::instance()->orb()->object_to_string(push_consumer);

      CORBA::Object_var obj =
        TAO_Notify_PROPERTIES::instance()->dispatching_orb()->string_to_object(temp.in());

      try
        {
          CosNotifyComm::SequencePushConsumer_var new_push_consumer =
            CosNotifyComm::SequencePushConsumer::_unchecked_narrow(obj.in());

          this->push_consumer_ = CosNotifyComm::SequencePushConsumer::_duplicate (new_push_consumer.in());
          this->publish_ = CosNotifyComm::NotifyPublish::_duplicate (new_push_consumer.in());

          //--cj verify dispatching ORB
          if (TAO_debug_level >= 10)
            {
              ORBSVCS_DEBUG ((LM_DEBUG,
                          "(%P|%t) Sequence push init dispatching ORB id is %s.\n",
                          obj->_stubobj()->orb_core()->orbid()));
            }
          //--cj end
        }
      catch (const CORBA::TRANSIENT& ex)
        {
          ex._tao_print_exception (
            "Got a TRANSIENT in NS_SequencePushConsumer::init");
          ORBSVCS_DEBUG ((LM_DEBUG, "(%P|%t) got it for NS_SequencePushConsumer %@\n", this));
        }
      catch (const CORBA::Exception&)
        {
          // _narrow failed
        }
    }
}
Example #3
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);
  }
Example #4
0
void
TAO_Notify_PushConsumer::init (CosEventComm::PushConsumer_ptr push_consumer)
{
    // Initialize only once
    ACE_ASSERT( CORBA::is_nil (this->push_consumer_.in()) );

    // push_consumer not optional
    if (CORBA::is_nil (push_consumer))
    {
        throw CORBA::BAD_PARAM();
    }

    try
    {
        if (!TAO_Notify_PROPERTIES::instance()->separate_dispatching_orb ())
        {
            this->push_consumer_ = CosEventComm::PushConsumer::_duplicate (push_consumer);

            this->publish_ =
                CosNotifyComm::NotifyPublish::_narrow (push_consumer);
        }
        else
        {
            // "Port" consumer's object reference from receiving ORB to dispatching ORB.
            CORBA::String_var temp =
                TAO_Notify_PROPERTIES::instance()->orb()->object_to_string(push_consumer);

            CORBA::Object_var obj =
                TAO_Notify_PROPERTIES::instance()->dispatching_orb()->string_to_object(temp.in());

            CosEventComm::PushConsumer_var new_cos_comm_pc =
                CosEventComm::PushConsumer::_unchecked_narrow(obj.in());

            this->push_consumer_ =
                CosEventComm::PushConsumer::_duplicate (new_cos_comm_pc.in());

            //
            // Note that here we do an _unchecked_narrow() in order to avoid
            // making a call on the consumer b/c the consumer may not have activated
            // its POA just yet.  That means that before we use this reference the first
            // time, we'll actually need to call _is_a() on it, i.e., the equivalent
            // of an _narrow().  At the time of this writing, the only use of
            // this->publish_ is in TAO_NS_Consumer::dispatch_updates_i (the superclass).
            // If any other use is made of this data member, then the code to validate
            // the actual type of the target object must be refactored.
            this->publish_ =
                CosNotifyComm::NotifyPublish::_unchecked_narrow (obj.in());


            //--cj verify dispatching ORB
            if (TAO_debug_level >= 10)
            {
                ORBSVCS_DEBUG ((LM_DEBUG, "(%P|%t) Any push init dispatching ORB id is %s.\n",
                                obj->_stubobj()->orb_core()->orbid()));
            }
            //--cj end
        }
    }
    catch (const CORBA::TRANSIENT& ex)
    {
        ex._tao_print_exception ("Got a TRANSIENT in NS_PushConsumer::init");
        ORBSVCS_DEBUG ((LM_DEBUG, "(%P|%t) got it for NS_PushConsumer %@\n", this));
    }
    catch (const CORBA::Exception&)
    {
        // _narrow failed which probably means the interface is CosEventComm type.
    }
}
Example #5
0
File: server.cpp Project: CCJY/ATCD
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references ("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Panic: nil RootPOA\n"), 1);

      PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();

      PortableServer::LifespanPolicy_var life =
        root_poa->create_lifespan_policy (PortableServer::PERSISTENT);

      PortableServer::IdAssignmentPolicy_var assign =
        root_poa->create_id_assignment_policy (PortableServer::USER_ID);

      CORBA::PolicyList pols;
      pols.length (2);
      pols[0] = PortableServer::LifespanPolicy::_duplicate (life.in ());
      pols[1] = PortableServer::IdAssignmentPolicy::_duplicate (assign.in ());

      PortableServer::POA_var poa =
        root_poa->create_POA ("ImRified POA", poa_manager.in (), pols);
      life->destroy ();
      assign->destroy ();

      Hello *hello_impl = 0;
      ACE_NEW_RETURN (hello_impl, Hello, 1);
      PortableServer::ServantBase_var owner_transfer (hello_impl);

      PortableServer::ObjectId_var id =
        PortableServer::string_to_ObjectId ("Test 3891 Object");

      poa->activate_object_with_id (id.in (), hello_impl);

      CORBA::Object_var obj = poa->id_to_reference (id.in ());

      if (!obj->_stubobj ()->type_id.in () ||
          ACE_OS::strcmp (obj->_stubobj ()->type_id.in (),
                          hello_impl->_repository_id ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR, "ERROR: type_id is incorrect\n"), 1);
        }

      root_poa->destroy (1, 1);
      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}