Пример #1
0
void
TAO_RT_Notify_Service::init_i (CORBA::ORB_ptr orb)
{
  //Init the base class.
  TAO_CosNotify_Service::init_i (orb);

  TAO_Notify_RT_Properties* properties = TAO_Notify_RT_PROPERTIES::instance();

  // Resolve RTORB
  CORBA::Object_var object =
    orb->resolve_initial_references ("RTORB");

  RTCORBA::RTORB_var rt_orb =
    RTCORBA::RTORB::_narrow (object.in ());

  // Resolve RTCurrent
  object =
    orb->resolve_initial_references ("RTCurrent");

  RTCORBA::Current_var current =
    RTCORBA::Current::_narrow (object.in ());

 /// Set the properties
  properties->rt_orb (rt_orb.in ());
  properties->current (current.in ());
}
Пример #2
0
Test::Hello_var
prepare_tests (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
{
  register_factories(orb);

  CORBA::Object_var objectman =
    orb->resolve_initial_references ("ORBPolicyManager");

  CORBA::PolicyManager_var policy_manager =
    CORBA::PolicyManager::_narrow (objectman.in ());

  PortableServer::POA_var my_compress_poa = 0;
  CORBA::PolicyList policies(4);
  policies.length(4);

  try
    {
      policies[0] = create_compressor_id_level_list_policy (orb);
      policies[1] = create_low_value_policy (orb);
      policies[2] = create_compression_enabled_policy (orb);
      policies[3] = create_min_ratio_policy (orb);

      my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
    }
  catch(const CORBA::PolicyError&)
    {
      policies.length(0);
      my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
    }

  policy_manager->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

  CORBA::Object_var pcobject =
    orb->resolve_initial_references ("PolicyCurrent");

  CORBA::PolicyCurrent_var policy_current =
    CORBA::PolicyCurrent::_narrow (pcobject.in ());

  policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

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

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

  PortableServer::ObjectId_var id =
    my_compress_poa->activate_object (hello_impl);

  CORBA::Object_var object = my_compress_poa->id_to_reference (id.in ());

  Test::Hello_var hello = Test::Hello::_narrow (object.in ());

  poa_manager->activate ();

  return hello._retn ();
}
Пример #3
0
int main(int argc, char ** argv)
{
    try {
        // init ORB
        CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
 
        // init POA
        CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA");
        PortableServer::POA_var poa = PortableServer::POA::_narrow(poa_obj);
        PortableServer::POAManager_var manager = poa->the_POAManager();
 
        // create service
        Math_operation * service = new Math_operation;
 
        // register within the naming service
        try {
            CORBA::Object_var ns_obj = orb->resolve_initial_references("NameService");
            if (!CORBA::is_nil(ns_obj)) {
                CosNaming::NamingContext_ptr nc = CosNaming::NamingContext::_narrow(ns_obj);
                CosNaming::Name name;
                name.length(1);
                name[0].id = CORBA::string_dup("TestServer");
                name[0].kind = CORBA::string_dup("");
                nc->rebind(name, service->_this());
                cout << argv[0] << ": server 'TestServer' bound" << endl;
            }
        } catch (CosNaming::NamingContext::NotFound &) {
            cerr << "not found" << endl;
        } catch (CosNaming::NamingContext::InvalidName &) {
            cerr << "invalid name" << endl;
        } catch (CosNaming::NamingContext::CannotProceed &) {
            cerr << "cannot proceed" << endl;
        }
 
        // run
        manager->activate();
        orb->run();
 
        // clean up
        delete service;
 
        // quit
        orb->destroy();
    } catch (CORBA::UNKNOWN) {
        cerr << "unknown exception" << endl;
    } catch (CORBA::SystemException &) {
        cerr << "system exception" << endl;
    }
}
Пример #4
0
EDF_Scheduler::EDF_Scheduler (CORBA::ORB_ptr orb,
                              Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type,
                              int ace_sched_policy,
                              int ace_sched_scope)
  : orb_ (CORBA::ORB::_duplicate (orb)),
    disp_impl_type_ (disp_impl_type),
    ace_sched_policy_ (ace_sched_policy),
    ace_sched_scope_ (ace_sched_scope)
{

  Kokyu::DSRT_ConfigInfo config;

  config.impl_type_ = this->disp_impl_type_;
  config.sched_policy_ = ace_sched_policy_;
  config.sched_scope_ = ace_sched_scope_;

  Kokyu::DSRT_Dispatcher_Factory<EDF_Scheduler_Traits>::DSRT_Dispatcher_Auto_Ptr
    tmp( Kokyu::DSRT_Dispatcher_Factory<EDF_Scheduler_Traits>::
         create_DSRT_dispatcher (config) );
  DSUI_EVENT_LOG (EDF_SCHED_FAM, CONSTRUCTOR, 0, 0, 0);

  kokyu_dispatcher_ = tmp;

  CORBA::Object_var object =
    orb->resolve_initial_references ("RTScheduler_Current");

  this->current_ =
    RTScheduling::Current::_narrow (object.in ());

  IOP::CodecFactory_var codec_factory;
  CORBA::Object_var obj =
    orb->resolve_initial_references ("CodecFactory");

  if (CORBA::is_nil(obj.in ()))
    {
      ACE_ERROR ((LM_ERROR, "Nil Codec factory\n"));
    }
  else
    {
      codec_factory = IOP::CodecFactory::_narrow (obj.in ());
    }

  IOP::Encoding encoding;
  encoding.format = IOP::ENCODING_CDR_ENCAPS;
  encoding.major_version = 1;
  encoding.minor_version = 2;

  codec_ = codec_factory->create_codec (encoding);
}
Пример #5
0
int
TAO_IFR_Server::init_with_orb (int argc,
                               ACE_TCHAR *argv [],
                               CORBA::ORB_ptr orb,
                               int use_multicast_server)
{
  try
    {
      // Get the POA from the ORB.
      CORBA::Object_var poa_object =
        orb->resolve_initial_references ("RootPOA");

      if (CORBA::is_nil (poa_object.in ()))
        {
          ORBSVCS_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("(%P|%t) IFR_Service::init_with_orb ")
                             ACE_TEXT ("Unable to initialize the POA.\n")),
                            -1);
        }
      PortableServer::POA_var rp =
        PortableServer::POA::_narrow (poa_object.in ());
      return this->init_with_poa (argc, argv, orb, rp.in(), use_multicast_server);
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("IFR_Service::init_with_orb");

      throw;
    }
  return 0;
}
Пример #6
0
void
TAO_Notify_Service_Driver::apply_timeout (CORBA::ORB_ptr orb)
{
#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
  if (this->timeout_ != 0)
    {
      // convert from msec to "TimeT"
      CORBA::Any timeout;
      TimeBase::TimeT value = 10000 * this->timeout_;
      timeout <<= value;

      CORBA::Object_var object =
        orb->resolve_initial_references ("ORBPolicyManager");
      CORBA::PolicyManager_var policy_manager =
        CORBA::PolicyManager::_narrow (object.in ());
      if (CORBA::is_nil (policy_manager.in ()))
        throw CORBA::INTERNAL ();

      CORBA::PolicyList policy_list (1);
      policy_list.length (1);
      policy_list[0] = orb->create_policy (
                              Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
                              timeout);
      policy_manager->set_policy_overrides (policy_list, CORBA::SET_OVERRIDE);
      policy_list[0]->destroy ();
  }
#else
  ACE_UNUSED_ARG (orb);
#endif /* TAO_HAS_CORBA_MESSAGING != 0 */
}
Пример #7
0
int
TAO_Naming_Server::init (CORBA::ORB_ptr orb,
                         PortableServer::POA_ptr poa,
                         size_t context_size,
                         ACE_Time_Value *timeout,
                         bool resolve_for_existing_naming_service,
                         const ACE_TCHAR *persistence_location,
                         void *base_addr,
                         int enable_multicast,
                         int use_storable_context,
                         int round_trip_timeout,
                         int use_round_trip_timeout)
{
  if (resolve_for_existing_naming_service)
    {
      try
        {
          // Try to find an existing Naming Service.
          CORBA::Object_var naming_obj =
            orb->resolve_initial_references ("NameService", timeout);

          if (!CORBA::is_nil (naming_obj.in ()))
            {
              //
              // Success in finding a Naming Service.
              //
              if (TAO_debug_level > 0)
                ORBSVCS_DEBUG ((LM_DEBUG,
                            "\nNameService found!\n"));

              this->naming_context_ =
                CosNaming::NamingContext::_narrow (naming_obj.in ());

              this->naming_service_ior_ =
                orb->object_to_string (naming_obj.in ());

              return 0;
            }
        }
      catch (const CORBA::Exception& ex)
        {
          ex._tao_print_exception ("TAO_Naming_Server::init");
        }
    }

  if (TAO_debug_level > 0)
    ORBSVCS_DEBUG ((LM_DEBUG,
                "\nWe'll become a NameService\n"));

  // Become a Naming Service.
  return this->init_new_naming (orb,
                                poa,
                                persistence_location,
                                base_addr,
                                context_size,
                                enable_multicast,
                                use_storable_context,
                                round_trip_timeout,
                                use_round_trip_timeout);
}
Пример #8
0
void
TAO_CosNotify_Service::init_i2 (CORBA::ORB_ptr orb, CORBA::ORB_ptr dispatching_orb)
{
  // Obtain the Root POA
  CORBA::Object_var object  =
    orb->resolve_initial_references("RootPOA");

  if (CORBA::is_nil (object.in ()))
    ORBSVCS_ERROR ((LM_ERROR, " (%P|%t) Unable to resolve the RootPOA.\n"));

  PortableServer::POA_var default_poa = PortableServer::POA::_narrow (object.in ());

  // Set the properties
  TAO_Notify_Properties* properties = TAO_Notify_PROPERTIES::instance();

  properties->orb (orb);
  properties->dispatching_orb (dispatching_orb);
  properties->separate_dispatching_orb (true);

  properties->default_poa (default_poa.in ());

  // Init the factory and builder
  this->factory_.reset (this->create_factory ());
  ACE_ASSERT( this->factory_.get() != 0 );
  TAO_Notify_PROPERTIES::instance()->factory (this->factory_.get());

  this->builder_.reset (this->create_builder ());
  ACE_ASSERT( this->builder_.get() != 0 );
  TAO_Notify_PROPERTIES::instance()->builder (this->builder_.get());
}
Пример #9
0
static int init_compressor(::CORBA::ORB_ptr orb)
{
    try {

        ::CORBA::Object_var compression_manager =
            orb->resolve_initial_references(TAO_OBJID_COMPRESSIONMANAGER);

        ::Compression::CompressionManager_var manager =
            ::Compression::CompressionManager::_narrow(compression_manager.in());

        if (::CORBA::is_nil(manager.in())) {
            ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: nil compression manager.\n")),-1);
        }

        Compression::CompressorFactory_ptr compressor_factory;
        ACE_NEW_RETURN (compressor_factory, TAO::RLE_CompressorFactory (), 1);
        Compression::CompressorFactory_var compr_fact = compressor_factory;

        manager->register_factory (compr_fact.in ());

    } catch (...) {
        ACE_ERROR_RETURN((LM_ERROR,
            ACE_TEXT("ERROR: Unable to initialise RLE compressor manager.\n")),-1);
    }

    return 0;
}
CORBA::InterfaceDef_ptr
TAO_IFR_Client_Adapter_Impl::get_interface (
    CORBA::ORB_ptr orb,
    const char *repo_id)
{
    CORBA::Object_var obj =
        orb->resolve_initial_references ("InterfaceRepository");

    if (CORBA::is_nil (obj.in ()))
    {
        throw ::CORBA::INTF_REPOS ();
    }

    CORBA::Repository_var repo =
        CORBA::Repository::_narrow (obj.in ()
                                   );

    if (CORBA::is_nil (repo.in ()))
    {
        throw ::CORBA::INTF_REPOS ();
    }

    CORBA::Contained_var result = repo->lookup_id (repo_id);

    if (CORBA::is_nil (result.in ()))
    {
        return CORBA::InterfaceDef::_nil ();
    }
    else
    {
        return CORBA::InterfaceDef::_narrow (result.in ());
    }
}
Пример #11
0
TAO_Scheduler::TAO_Scheduler (CORBA::ORB_ptr orb)
{
  CORBA::Object_var current_obj =
    orb->resolve_initial_references ("RTScheduler_Current");

  current_ = RTScheduling::Current::_narrow (current_obj.in ());
}
Пример #12
0
int
register_factories (CORBA::ORB_ptr orb)
{
  CORBA::Object_var compression_manager_obj =
    orb->resolve_initial_references("CompressionManager");

  compression_manager = ::Compression::CompressionManager::_narrow (
            compression_manager_obj.in ());

  if (CORBA::is_nil(compression_manager.in ()))
    ACE_ERROR_RETURN ((LM_ERROR,
                       " (%P|%t) Panic: nil compression manager\n"),
                      1);
  //register Zlib compressor
  ::Compression::CompressorFactory_ptr compressor_factory;
  ACE_NEW_RETURN (compressor_factory, TAO::Zlib_CompressorFactory (), 1);
  ::Compression::CompressorFactory_var compr_fact = compressor_factory;
  compression_manager->register_factory(compr_fact.in ());

  // register bzip2 compressor
  ACE_NEW_RETURN (compressor_factory, TAO::Bzip2_CompressorFactory (), 1);
  compr_fact = compressor_factory;
  compression_manager->register_factory(compr_fact.in ());

  // register test compressor
  ACE_NEW_RETURN (compressor_factory, TAO::Test_CompressorFactory (), 1);
  compr_fact = compressor_factory;
  compression_manager->register_factory(compr_fact.in ());
  return 0;
}
Пример #13
0
int
configure_policies (CORBA::ORB_ptr orb,
                    const TAO::BufferingConstraint &buffering_constraint,
                    Test::AMI_Buffering_ptr ami_buffering,
                    Test::AMI_Buffering_out flusher)
{
  CORBA::Object_var object =
    orb->resolve_initial_references ("PolicyCurrent");

  CORBA::PolicyCurrent_var policy_current =
    CORBA::PolicyCurrent::_narrow (object.in ());

  if (CORBA::is_nil (policy_current.in ()))
    {
      ACE_ERROR ((LM_ERROR, "ERROR: Nil policy current\n"));
      return 1;
    }
  CORBA::Any scope_as_any;
  scope_as_any <<= Messaging::SYNC_NONE;

  CORBA::Any buffering_as_any;
  buffering_as_any <<= buffering_constraint;

  CORBA::PolicyList policies (2); policies.length (2);
  policies[0] =
    orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
                        scope_as_any);
  policies[1] =
    orb->create_policy (TAO::BUFFERING_CONSTRAINT_POLICY_TYPE,
                        buffering_as_any);

  policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

  policies[0]->destroy ();
  policies[1]->destroy ();

  TAO::BufferingConstraint flush_constraint;
  flush_constraint.mode = TAO::BUFFER_FLUSH;
  flush_constraint.message_count = 0;
  flush_constraint.message_bytes = 0;
  flush_constraint.timeout = 0;

  buffering_as_any <<= flush_constraint;
  policies.length (1);
  policies[0] =
    orb->create_policy (TAO::BUFFERING_CONSTRAINT_POLICY_TYPE,
                        buffering_as_any);

  object =
    ami_buffering->_set_policy_overrides (policies,
                                             CORBA::ADD_OVERRIDE);

  policies[0]->destroy ();

  flusher =
    Test::AMI_Buffering::_narrow (object.in ());

  return 0;
}
Пример #14
0
static CORBA::Object_ptr getObjectReference(CORBA::ORB_ptr orb) {
  CosNaming::NamingContext_var rootContext;
  
  try {
    // Obtain a reference to the root context of the Name service:
    CORBA::Object_var obj;
    obj = orb->resolve_initial_references("NameService");

    // Narrow the reference returned.
    rootContext = CosNaming::NamingContext::_narrow(obj);
    if( CORBA::is_nil(rootContext) ) {
      cerr << "Failed to narrow the root naming context." << endl;
      return CORBA::Object::_nil();
    }
  } catch (CORBA::NO_RESOURCES&) {
    cerr << "Caught NO_RESOURCES exception. You must configure omniORB "
	 << "with the location" << endl
	 << "of the naming service." << endl;
    return 0;
  } catch(CORBA::ORB::InvalidName& ex) {
    // This should not happen!
    cerr << "Service required is invalid [does not exist]." << endl;
    return CORBA::Object::_nil();
  }

  // Create a name object, containing the name test/context:
  CosNaming::Name name;
  name.length(2);

  name[0].id   = (const char*) "test";       // string copied
  name[0].kind = (const char*) "my_context"; // string copied
  name[1].id   = (const char*) "IdServer";
  name[1].kind = (const char*) "Object";
  // Note on kind: The kind field is used to indicate the type
  // of the object. This is to avoid conventions such as that used
  // by files (name.type -- e.g. test.ps = postscript etc.)

  try {
    // Resolve the name to an object reference.
    return rootContext->resolve(name);
  } catch(CosNaming::NamingContext::NotFound& ex) {
    // This exception is thrown if any of the components of the
    // path [contexts or the object] aren't found:
    cerr << "Context not found." << endl;
  } catch(CORBA::TRANSIENT& ex) {
    cerr << "Caught system exception TRANSIENT -- unable to contact the "
         << "naming service." << endl
	 << "Make sure the naming server is running and that omniORB is "
	 << "configured correctly." << endl;

  } catch(CORBA::SystemException& ex) {
    cerr << "Caught a CORBA::" << ex._name()
	 << " while using the naming service." << endl;
    return 0;
  }

  return CORBA::Object::_nil();
}
 /*!
  * @brief Constructor
  */
 OrganizationProxyTests()
 {
   int argc = 0;
   char** argv = NULL;
   m_pORB = CORBA::ORB_init(argc, argv);
   m_pPOA = PortableServer::POA::_narrow(
                    m_pORB->resolve_initial_references("RootPOA"));
   m_pPOA->the_POAManager()->activate();
 }
Пример #16
0
  Stock_Publisher (CORBA::ORB_ptr orb,
                   CORBA::StringSeq &stocks)
  {
    CORBA::Object_var obj = orb->resolve_initial_references ("RTCurrent");
    rt_current_ = RTCORBA::Current::_narrow (obj.in ());

    // Create the message
    sn_ = new OBV_Stock::StockNames ();
    sn_->names (stocks);
  }
Пример #17
0
// Implementation skeleton constructor
CDBPropertySet::CDBPropertySet (CORBA::ORB_ptr orb,
				PortableServer::POAManager_ptr poa_manager,
				PortableServer::POA_ptr root_poa) :
  poa_m(PortableServer::POA::_nil()),
  poaCurrent_m(PortableServer::Current::_nil())
{
  ACS_TRACE("baci::CDBPropertySet::CDBPropertySet");

  CORBA::PolicyList policies (5);
  policies.length (5);

  // ID Assignment Policy
  policies[0] =
    root_poa->create_id_assignment_policy (PortableServer::USER_ID);
  
  // Lifespan Policy
  policies[1] =
    root_poa->create_lifespan_policy (PortableServer::PERSISTENT);
  
  // Request Processing Policy
  policies[2] =
    root_poa->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT);

  // Servant Retention Policy
  policies[3] =
    root_poa->create_servant_retention_policy (PortableServer::RETAIN);

  // Id Uniqueness Policy
  policies[4] =
    root_poa->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID);

  ACE_CString name = "DefaultServantPOA";
  poa_m = root_poa->create_POA (name.c_str (),
				poa_manager,
				policies);
  
  for (CORBA::ULong i = 0UL; i < policies.length (); ++i)
    {
      CORBA::Policy_ptr policy_p = policies[i];
      policy_p->destroy();
    }

  // Get the POA Current object reference
  CORBA::Object_var obj =
			orb->resolve_initial_references ("POACurrent");
  
  // Narrow the object reference to a POA Current reference
  this->poaCurrent_m =
      PortableServer::Current::_narrow (obj.in());
  
  // Set default servant
  poa_m->set_servant (this);
  
  instance_mp = this;
}
    /*!
     * @brief Constructor
     */
    OutPortConnectorTests()
    {

        int argc(0);
        char** argv(NULL);
        m_pORB = CORBA::ORB_init(argc, argv);
        m_pPOA = PortableServer::POA::_narrow(
		    m_pORB->resolve_initial_references("RootPOA"));
        m_pPOA->the_POAManager()->activate();

    }
Пример #19
0
void
LiveCheck::init (CORBA::ORB_ptr orb,
                 const ACE_Time_Value &pi)
{
  this->ping_interval_ = pi;
  ACE_Reactor *r = orb->orb_core()->reactor();
  this->reactor (r);
  CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
  this->poa_ = PortableServer::POA::_narrow (obj.in());
  this->running_ = true;
}
Пример #20
0
int
test_transport_current (CORBA::ORB_ptr orb)
{
  // Get the Current object.
  CORBA::Object_var tcobject =
    orb->resolve_initial_references ("TAO::Transport::IIOP::Current");

  if (TAO_debug_level >= 1)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("Tester (%P|%t) Resolved initial reference for IIOP::Current\n")));

  Transport::IIOP::Current_var tc =
    Transport::IIOP::Current::_narrow (tcobject.in ());

  if (TAO_debug_level >= 1)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("Tester (%P|%t) Narowed the IIOP Transport Current\n")));

  if (CORBA::is_nil (tc.in ()))
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("Tester (%P|%t) ERROR: Could not resolve ")
                  ACE_TEXT ("TAO::Transport::IIOP::Current object.\n")));

      throw CORBA::INTERNAL ();
    }

  ::CORBA::String_var rhost (tc->remote_host ());

  ::CORBA::String_var lhost (tc->local_host ());

  ::CORBA::Long id = tc->id ();

  ::TAO::CounterT bs = tc->bytes_sent ();

  ::TAO::CounterT br = tc->bytes_received ();

  ::TAO::CounterT rs = tc->messages_sent ();

  ::TAO::CounterT rr = tc->messages_received ();

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Tester (%P|%t) Transport [%q] [%C:%d -> %C:%d] ")
              ACE_TEXT ("Sent/Received [bytes=%q/%q, messages=%q/%q]\n"),
              (ACE_UINT64)id,
              rhost.in (), tc->remote_port (),
              lhost.in (), tc->local_port (),
              (ACE_UINT64)bs,
              (ACE_UINT64)br,
              (ACE_UINT64)rs,
              (ACE_UINT64)rr));
  return 0;
}
 OrbContext() {
   orb = ossie::corba::Orb();
   rootPOA = ossie::corba::RootPOA();
   namingService = ossie::corba::InitialNamingContext();
   namingServiceCtx = CosNaming::NamingContextExt::_nil();
   try {
     CORBA::Object_ptr obj;
     obj=orb->resolve_initial_references("NameService");
     namingServiceCtx = CosNaming::NamingContextExt::_narrow(obj);
   }
   catch(...){
   };
 };
Пример #22
0
MIF_Scheduler::MIF_Scheduler (CORBA::ORB_ptr orb)
  : wait_cond_ (lock_),
    wait_ (0)
{
  try
    {
      CORBA::Object_var object =
        orb->resolve_initial_references ("RTScheduler_Current");

      this->current_ =
        RTScheduling::Current::_narrow (object.in ());

      object =
        orb->resolve_initial_references ("PriorityMappingManager");

      this->mapping_manager_ =
        RTCORBA::PriorityMappingManager::_narrow (object.in ());
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Caught exception:");
    }
}
Пример #23
0
CORBA::Object_ptr getObjectReference(CORBA::ORB_ptr orb, const char serviceName[])
{  
   CosNaming::NamingContext_var rootContext;

   try
   {  
      // Obtain a reference to the root context of the name service:
      CORBA::Object_var initServ;
      initServ = orb->resolve_initial_references("NameService");

      // Narrow the object returned by resolve_initial_references() to a CosNaming::NamingContext 
      // object
      rootContext = CosNaming::NamingContext::_narrow(initServ);
      if (CORBA::is_nil(rootContext))
      {  
         cerr << "Failed to narrow naming context." << endl;
         return CORBA::Object::_nil();
      }
   }
   catch (CORBA::ORB::InvalidName&)
   {  
      cerr << "Name service does not exist." << endl;
      return CORBA::Object::_nil();
   }

   // Create a name object, containing the name corejava/SysProp:
   CosNaming::Name name;
   name.length(1);

   name[0].id   = serviceName;
   name[0].kind = "Object";

   CORBA::Object_ptr obj;
   try
   {  
      // Resolve the name to an object reference, and assign the returned reference to a 
      // CORBA::Object:
      obj = rootContext->resolve(name);
   }
   catch (CosNaming::NamingContext::NotFound&)
   {  
      // This exception is thrown if any of the components of the path [contexts or the object] 
      // aren't found:
      cerr << "Context not found." << endl;
      return CORBA::Object::_nil();
   }
   return obj;
}
Пример #24
0
// Creates DynUnion using typecodes generated through IDL compiler.
int runStatic(CORBA::ORB_ptr orb)
{
  try
    {
        CORBA::Object_var obj =
          orb->resolve_initial_references("DynAnyFactory");

        DynamicAny::DynAnyFactory_var dfact =
          DynamicAny::DynAnyFactory::_narrow(obj.in ());

        if (CORBA::is_nil (dfact.in ()))
          {
            ACE_ERROR_RETURN ((LM_ERROR,
                               "Nil dynamic any factory after narrow\n"),
                              -1);
          }

        DynamicAny::DynAny_var dany =
           dfact->create_dyn_any_from_type_code(DynAnyTest::_tc_EventData);

        DynamicAny::DynUnion_var dunion =
          DynamicAny::DynUnion::_narrow(dany.in ());

        DynamicAny::DynAny_var disc = dunion->get_discriminator();

        DynamicAny::DynEnum_var denum =
          DynamicAny::DynEnum::_narrow(disc.in ());

        if (CORBA::is_nil (denum.in ()))
          {
            ACE_ERROR_RETURN ((LM_ERROR,
                               "Nil dynamic enum after narrow\n"),
                              -1);
          }

        ACE_DEBUG ((LM_DEBUG, "Static Test Passed\n"));
    }
  catch (const CORBA::Exception & ex)
    {
      ex._tao_print_exception ("runStatic");
      return -1;
    }

  return 0;
}
Пример #25
0
void
ImR_DSI_Forwarder::init (CORBA::ORB_ptr orb)
{
  ACE_ASSERT (! CORBA::is_nil(orb));
  this->orb_ = orb;
  try
    {
      CORBA::Object_var tmp =
        orb->resolve_initial_references ("POACurrent");

      this->poa_current_var_ =
        PortableServer::Current::_narrow (tmp.in ());
    }
  catch (const CORBA::Exception&)
    {
    }
  ACE_ASSERT (!CORBA::is_nil (this->poa_current_var_.in ()));
}
Пример #26
0
// Implementation skeleton constructor
Stock_StockBroker_i::Stock_StockBroker_i (CORBA::ORB_ptr orb,
                                          Stock::StockDistributor_ptr dist,
                                          const char *stock_name)
  : orb_ (CORBA::ORB::_duplicate (orb)),
    quoter_ (Stock::StockQuoter::_nil()),
    consumer_ (0),
    distributor_ (Stock::StockDistributor::_duplicate (dist))
{
  // Get a reference to the <RTORB>.
  CORBA::Object_var obj = orb->resolve_initial_references ("RTORB");
  RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (obj.in ());

  // Create a <CORBA::PolicyList> for the child POA.
  TAO::Utils::PolicyList_Destroyer  consumer_policies (1);
  consumer_policies.length (1);

  // Create a <CLIENT_PROPAGATED> priority model policy.
    consumer_policies[0] =
      rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
                                            Stock::Priority_Mapping::MEDIUM);

  PortableServer::POA_var poa = this->_default_POA ();
  PortableServer::POAManager_var poa_mgr = poa->the_POAManager ();

  // Create a child POA with CLIENT_PROPAGATED policies. The name of
  // the POA will be <StockNameConsumer_POA>.  Instances of the
  // Stock_StockNameConsumer_i will be activated under this POA.
  PortableServer::POA_var child_poa =
    poa->create_POA ("StockNameConsumer_POA",
                     poa_mgr. in(),
                     consumer_policies);

  // Narrow the POA to a <RTPortableServer::POA>.
  RTPortableServer::POA_var rt_poa =
    RTPortableServer::POA::_narrow (child_poa.in ());

  // Create and activate the <consumer_>.
  this->consumer_ =
    new Stock_StockNameConsumer_i (*this, stock_name);
  PortableServer::ServantBase_var nameconsumer_owner_transfer =
    this->consumer_;
  rt_poa->activate_object (this->consumer_);
}
Пример #27
0
int
test_transport_current (CORBA::ORB_ptr orb)
{
  // Get the Current object.
  CORBA::Object_var tcobject =
    orb->resolve_initial_references ("TAO::Transport::Current");

  Transport::Current_var tc =
    Transport::Current::_narrow (tcobject.in ());

  if (CORBA::is_nil (tc.in ()))
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("(%P|%t) client - ERROR: Could not resolve ")
                  ACE_TEXT ("TAOTransportCurrent object.\n")));

      throw CORBA::INTERNAL ();
    }

  return test_transport_current (tc.in ());
}
Пример #28
0
static CORBA::Object_ptr
get_distributor_reference (CORBA::ORB_ptr orb)
{
  if (use_naming)
    {
      CORBA::Object_var tmp =
        orb->resolve_initial_references ("NameService");

      CosNaming::NamingContext_var pns =
        CosNaming::NamingContext::_narrow (tmp.in ());

      CosNaming::Name name (1);
      name.length (1);
      name[0].id = distributor_name.c_str ();

      return pns->resolve (name);
    }
  else
    // Read and destringify the Stock_Distributor object's IOR.
    return orb->string_to_object (ior.c_str ());
}
Пример #29
0
bool
NameServiceBase::initNameService(CORBA::ORB_ptr orb)
{
    // get naming service
    CORBA::Object_var obj;

    try
    {
        obj = orb->resolve_initial_references("NameService");
    }
    catch (const CORBA::ORB::InvalidName&)
    {
        std::cerr << "Can't resolve NameService" << std::endl;
		return false;
    }

    if (CORBA::is_nil(obj.in()))
    {
        std::cerr << "NameService is a nil object reference" << std::endl;
		return false;
    }

	try
	{
		nameService_ = CosNaming::NamingContext::_narrow(obj.in());
	}
	catch (const CORBA::Exception&)
	{
		std::cerr << "NameService is not running" << std::endl;
		return false;
	}

    if (CORBA::is_nil(nameService_.in()))
    {
        std::cerr << "NameService is not a NamingContext object reference" << std::endl;
		return false;
    }

    return true;
}
Пример #30
0
void Checkpointable::
associate_state (CORBA::ORB_ptr orb, CORBA::Any const& state)
{
  try
  {
    CORBA::Object_var pic_obj =
      orb->resolve_initial_references ("PICurrent");


    PortableInterceptor::Current_var pic =
      PortableInterceptor::Current::_narrow (
        pic_obj.in ());


    pic->set_slot (state_slot_id (), state);

  }
  catch (const CORBA::Exception& ex)
  {
    ex._tao_print_exception ("Caught exception:");
  }
}