Beispiel #1
0
// Insert <naming_context> with <name> relative to <this> context
// (String version)
int
ACE_Registry::Naming_Context::bind_new_context (const ACE_TString &name,
                                                Naming_Context &naming_context,
                                                u_long persistence,
                                                u_long security_access,
                                                LPSECURITY_ATTRIBUTES security_attributes)
{
  u_long reason;

  long result = ACE_TEXT_RegCreateKeyEx (this->key_,
                                         name.c_str (),
                                         0,
                                         0,
                                         persistence,
                                         security_access,
                                         security_attributes,
                                         &naming_context.key_,
                                         &reason);
  if (result == ERROR_SUCCESS)
    // If create succeeds
    {
      if (reason == REG_CREATED_NEW_KEY)
        // If new key: success
        {
          // Set the correct parent
          naming_context.parent (this->key_);
          // Set the correct name
          naming_context.name (name);
        }
      else
        // reason == REG_OPENED_EXISTING_KEY
        // Failed to make new key
        {
          // reset result to failure
          result = -1;
          // Close the key first
          ::RegCloseKey (naming_context.key_);
          // Reset key
          naming_context.key_ = (HKEY) 0;
        }
    }

  ACE_REGISTRY_CALL_RETURN (result);
}
Beispiel #2
0
int
ACE_Registry_Name_Space::list_name_entries (ACE_BINDING_SET &set,
                                            const ACE_NS_WString &pattern)
{
  ACE_UNUSED_ARG(pattern);

  ACE_Registry::Binding_List list;
  int result = this->context_.list (list);
  if (result != 0)
    return result;

  // Iterator through all entries
  for (ACE_Registry::Binding_List::iterator i = list.begin ();
       i != list.end ();
       i++)
    {
      // Yeeesss! STL rules!
      ACE_Registry::Binding &binding = *i;

      if (binding.type () == ACE_Registry::OBJECT)
        {
          // Key
          ACE_TString string = binding.name ();
          ACE_NS_WString key (string.c_str ());

          // Value
          ACE_NS_WString value;
          char *type = 0;
          result = this->resolve (key,
                                  value,
                                  type);
          if (result != 0)
            ACELIB_ERROR_RETURN ((LM_ERROR,
                              ACE_TEXT ("%p\n"),
                              ACE_TEXT ("ACE_Registry::Naming_Context::resolve")),
                              result);

          // Complete binding
          ACE_Name_Binding binding (key, value, type);
          set.insert (binding);
        }
    }
  return 0;
}
Beispiel #3
0
int KSGateway::get_scheduler_alg_thr_count(const std::string &alg_name)
{
	int count = 0;
	std::string config_path = KSGOSUtil::JoinPath(_configuration._basedir,KSG_CONFIG_FILENAME);
	ACE_Configuration_Heap config;
	if(config.open() == -1)
	{
		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
	}
	ACE_Ini_ImpExp config_importer(config);

	if(config_importer.import_config(config_path.c_str()) == -1)
	{
		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
	}

	ACE_Configuration_Section_Key section;
	if(config.open_section(config.root_section(),ACE_TEXT(KSG_COMMON_SECT)
		,0,section) == -1)
	{
		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
	}

	ACE_TString v;

	if(config.open_section(config.root_section(),ACE_TEXT(KSG_SCHEDULER_SECT)
		,0,section) == -1)
		ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
	

	std::string key_name = alg_name;
	key_name += "_thr_count";
	if(config.get_string_value(section,key_name.c_str(),v) == -1)
	{
		count = 5;
	}
	else
	{
		count = ACE_OS::atoi(v.c_str());
		count = (count <= 0) ? 5 : count;
	}
	
	return count;
}
Beispiel #4
0
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  try {
    // Initialize the ORB.
    CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );

    if (parse_args(argc, argv) != 0) {
      return 1;
    }

    // Read and destringify the Messenger object's IOR.
    CORBA::Object_var obj = orb->string_to_object(ior.c_str());
    if( CORBA::is_nil( obj.in() ) ) {
      std::cerr << "Could not get Messenger IOR." << std::endl;
      return 1;
    }

    // Narrow the IOR to a Messenger object reference.
    DevGuide::Messenger_var messenger =
      DevGuide::Messenger::_narrow( obj.in() );
    if( CORBA::is_nil( messenger.in() ) ) {
      std::cerr << "IOR was not a Messenger object reference." << std::endl;
      return 1;
    }

    // Send a message the the Messenger object.
    CORBA::String_var msg = CORBA::string_dup( "Hello!" );
    messenger->send_message( "TAO User", "TAO Test", msg.inout() );

    // Print the Messenger's reply.
    std::cout << "Reply: " << msg.in() << std::endl;

    orb->destroy();

    return 0;
  }
  catch(const CORBA::Exception& ex) {
    std::cerr << "CORBA exception: " << ex << std::endl;
  }

  return 1;
}
Beispiel #5
0
bool Config::GetBoolDefault(const char* name, bool def)
{
    ACE_TString val;
    if (!GetValueHelper(mConf, name, val))
    {
        return def;
    }

    const char* str = val.c_str();
    if (strcmp(str, "true") == 0 || strcmp(str, "TRUE") == 0 ||
            strcmp(str, "yes") == 0 || strcmp(str, "YES") == 0 ||
            strcmp(str, "1") == 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}
Beispiel #6
0
// Find <naming_context> with <name> in <this> context
// (String version)
int
ACE_Registry::Naming_Context::resolve_context (const ACE_TString &name,
                                               Naming_Context &naming_context,
                                               u_long security_access)
{
  long result = ACE_TEXT_RegOpenKeyEx (this->key_,
                                       name.c_str (),
                                       0,
                                       security_access,
                                       &naming_context.key_);
  if (result == ERROR_SUCCESS)
    {
      // set the correct parent
      naming_context.parent (this->key_);
      // set the correct name
      naming_context.name (name);
    }

  ACE_REGISTRY_CALL_RETURN (result);
}
Beispiel #7
0
int
SubDriver::parse_pub_arg(const ACE_TString& arg)
{
  size_t pos;

  // Find the first ':' character, and make sure it is in a legal spot.
  if ((pos = std::find(arg.c_str(), arg.c_str() + arg.length(), ACE_TEXT(':')) - arg.c_str()) == arg.length()) {
    ACE_ERROR((LM_ERROR,
               "(%P|%t) Bad -p command-line value (%s). Missing ':' char.\n",
               arg.c_str()));
    return -1;
  }

  if (pos == 0) {
    ACE_ERROR((LM_ERROR,
               "(%P|%t) Bad -p command-line value (%s). "
               "':' char cannot be first char.\n",
               arg.c_str()));
    return -1;
  }

  if (pos == (arg.length() - 1)) {
    ACE_ERROR((LM_ERROR,
               "(%P|%t) Bad -p command-line value  (%s) - "
               "':' char cannot be last char.\n",
               arg.c_str()));
    return -1;
  }

  // Parse the pub_id from left of ':' char, and remainder to right of ':'.
  ACE_TString pub_id_str(arg.c_str(), pos);
  this->pub_addr_str_ = arg.c_str() + pos + 1;

  this->pub_id_fname_ = pub_id_str.c_str();
  this->pub_addr_ = ACE_INET_Addr(this->pub_addr_str_.c_str());

  return 0;
}
Beispiel #8
0
      void
      IDREF_Base<T>::bind_next_available (ACE_TString &id)
      {
        // Note:  For this function to compile and work properly,
        // T must have the postincrement operator defined.
        DANCE_TRACE ("IDREF_Base<T>::bind_next_available");
        //      ACE_DEBUG ((LM_DEBUG, "**** Binding %s to %i\n",
        //            id.c_str (),
        //            this->next_));

        int retval = idref_map_.bind (id, this->next_);

        int pos_retval = pos_map_.bind (this->next_, id);

        ++this->next_;

        if (retval < 0 || pos_retval < 0)
          throw Config_Error (id.c_str (),
                              ACE_TEXT ("Failed to bind an IDRef.  This likely indicates a name clash"));

      }
Beispiel #9
0
CORBA::Contained_ptr
TAO_Repository_i::lookup_id_i (const char *search_id)
{
  if (ACE_OS::strcmp (search_id, "IDL:omg.org/CORBA/Object:1.0") == 0
      || ACE_OS::strcmp (search_id, "IDL:omg.org/CORBA/ValueBase:1.0") == 0)
    {
      return CORBA::Contained::_nil ();
    }

  ACE_TString path;
  if (this->config_->get_string_value (this->repo_ids_key_,
                                       search_id,
                                       path)
       != 0)
    {
      return CORBA::Contained::_nil ();
    }

  ACE_Configuration_Section_Key key;
  this->config_->expand_path (this->root_key_,
                              path,
                              key);

  u_int kind = 0;
  this->config_->get_integer_value (key,
                                    "def_kind",
                                    kind);

  CORBA::DefinitionKind def_kind =
    static_cast<CORBA::DefinitionKind> (kind);

  CORBA::Object_var obj =
    TAO_IFR_Service_Utils::create_objref (def_kind,
                                          path.c_str (),
                                          this->repo_);

  return CORBA::Contained::_narrow (obj.in ());
}
Beispiel #10
0
  virtual int process (Message *message)
  {
    ACE_TRACE ("SaveMetaData::process()");

    ACE_TString path (message->addr ().get_path_name ());
    path += ACE_TEXT (".xml");

    ACE_FILE_Connector connector;
    ACE_FILE_IO file;
    ACE_FILE_Addr addr (path.c_str ());
    if (connector.connect (file, addr) == -1)
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("%p\n"),
                         ACE_TEXT ("create meta-data file")),
                        0);

    file.truncate (0);
    this->write (file, "<Message>\n");
    // ...
    this->write (file, "</Message>\n");
    file.close ();
    return 0;
  }
Beispiel #11
0
CORBA::DefinitionKind
TAO_IFR_Service_Utils::path_to_def_kind (ACE_TString &path,
                                         TAO_Repository_i *repo)
{
  int status =
    repo->config ()->expand_path (repo->root_key (),
                                  path,
                                  TAO_IFR_Service_Utils::tmp_key_,
                                  0);

  if (status != 0)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                  "path_to_def_kind - bad path: '%s'\n",
                  path.c_str ()));
      return CORBA::dk_none;
    }

  u_int kind = 0;
  repo->config ()->get_integer_value (TAO_IFR_Service_Utils::tmp_key_,
                                      "def_kind",
                                      kind);
  return static_cast<CORBA::DefinitionKind> (kind);
}
Beispiel #12
0
void
TAO_OperationDef_i::make_description (
    CORBA::OperationDescription &od)
{
  od.name = this->name_i ();

  od.id = this->id_i ();

  ACE_TString container_id;
  this->repo_->config ()->get_string_value (this->section_key_,
                                            "container_id",
                                            container_id);

  od.defined_in = container_id.c_str ();

  od.version = this->version_i ();

  od.result = this->result_i ();

  od.mode = this->mode_i ();

  CORBA::ContextIdSeq_var cid_seq =
    this->contexts_i ();

  od.contexts = cid_seq.in ();

  CORBA::ParDescriptionSeq_var pd_seq =
    this->params_i ();

  od.parameters = pd_seq.in ();

  ACE_Configuration_Section_Key excepts_key;
  int status =
    this->repo_->config ()->open_section (this->section_key_,
                                          "excepts",
                                          0,
                                          excepts_key);

  // This section may not have been created.
  if (status == 0)
    {
      int index = 0;
      int status = 0;
      ACE_TString field_name, type_path;
      ACE_Configuration::VALUETYPE type;
      ACE_Unbounded_Queue<ACE_TString> path_queue;

      while (this->repo_->config ()->enumerate_values (excepts_key,
                                                       index++,
                                                       field_name,
                                                       type)
              == 0)
        {
          status =
            this->repo_->config ()->get_string_value (excepts_key,
                                                      field_name.c_str (),
                                                      type_path);

          if (status == 0)
            {
              path_queue.enqueue_tail (type_path);
            }
        }

      CORBA::ULong size = static_cast<CORBA::ULong> (path_queue.size ());

      od.exceptions.length (size);

      for (CORBA::ULong i = 0; i < size; ++i)
        {
          ACE_TString type_path;
          path_queue.dequeue_head (type_path);

          ACE_Configuration_Section_Key type_key;
          this->repo_->config ()->expand_path (this->repo_->root_key (),
                                               type_path,
                                               type_key,
                                               0);

          ACE_TString name;
          this->repo_->config ()->get_string_value (type_key,
                                                    "name",
                                                    name);

          od.exceptions[i].name = name.c_str ();

          ACE_TString id;
          this->repo_->config ()->get_string_value (type_key,
                                                    "id",
                                                    id);

          od.exceptions[i].id = id.c_str ();

          ACE_TString container_id;
          this->repo_->config ()->get_string_value (type_key,
                                                    "container_id",
                                                    container_id);

          od.exceptions[i].defined_in = container_id.c_str ();

          ACE_TString version;
          this->repo_->config ()->get_string_value (type_key,
                                                    "version",
                                                    version);

          od.exceptions[i].version = version.c_str ();

          TAO_ExceptionDef_i impl (this->repo_);
          impl.section_key (type_key);

          od.exceptions[i].type = impl.type_i ();
        }
    }
  else
    {
      od.exceptions.length (0);
    }
}
Beispiel #13
0
void init ()
{
  participant
    = dpf->create_participant(domain_id,
                              PARTICIPANT_QOS_DEFAULT,
                              ::DDS::DomainParticipantListener::_nil(),
                              ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
  if (CORBA::is_nil (participant.in ()))
    {
      ACE_ERROR ((LM_ERROR,
                ACE_TEXT("(%P|%t) create_participant failed.\n")));
      throw TestException ();
    }

  ::Xyz::FooTypeSupportImpl* fts_servant
    = new ::Xyz::FooTypeSupportImpl();

  if (::DDS::RETCODE_OK != fts_servant->register_type(participant.in (), type_name))
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) register_type failed.\n")));
      throw TestException ();
    }

  ::DDS::TopicQos topic_qos;
  participant->get_default_topic_qos(topic_qos);

  topic[0]
    = participant->create_topic (topic_name[0],
                                  type_name,
                                  topic_qos,
                                  ::DDS::TopicListener::_nil(),
                                  ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
  if (CORBA::is_nil (topic[0].in ()))
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT("(%P|%t) create_topic failed.\n")));
      throw TestException ();
    }

  topic[1]
    = participant->create_topic (topic_name[1],
                                  type_name,
                                  topic_qos,
                                  ::DDS::TopicListener::_nil(),
                                  ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
  if (CORBA::is_nil (topic[1].in ()))
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT("(%P|%t) create_topic failed.\n")));
      throw TestException ();
    }

  writer_impl
    = TheTransportFactory->create_transport_impl (PUB_TRAFFIC_TCP,
                                                  ACE_TEXT("SimpleTcp"),
                                                  OpenDDS::DCPS::DONT_AUTO_CONFIG);

  OpenDDS::DCPS::TransportConfiguration_rch writer_config
    = TheTransportFactory->create_configuration (PUB_TRAFFIC_TCP, ACE_TEXT("SimpleTcp"));

  OpenDDS::DCPS::SimpleTcpConfiguration* writer_tcp_config
    = static_cast <OpenDDS::DCPS::SimpleTcpConfiguration*> (writer_config.in ());

  if (writer_address_given)
    {
      ACE_INET_Addr writer_address (writer_address_str.c_str ());
      writer_tcp_config->local_address_ = writer_address;
      writer_tcp_config->local_address_str_ = writer_address_str.c_str ();
    }
    // else use default address - OS assigned.

  if (writer_impl->configure(writer_config.in()) != 0)
    {
      ACE_ERROR((LM_ERROR,
                ACE_TEXT("(%P|%t) init_writer_tranport: pub TCP")
                ACE_TEXT(" Failed to configure the transport.\n")));
      throw TestException ();
    }

  // Create the default publisher
  publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT,
                                ::DDS::PublisherListener::_nil(),
                                ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
  if (CORBA::is_nil (publisher.in ()))
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT("(%P|%t) create_publisher failed.\n")));
      throw TestException ();
    }

  // Attach the publisher to the transport.
  OpenDDS::DCPS::PublisherImpl* pub_impl
    = dynamic_cast<OpenDDS::DCPS::PublisherImpl*>
    (publisher.in ());

  if (0 == pub_impl)
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT("(%P|%t) Failed to obtain publisher servant \n")));
      throw TestException ();
    }

  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) attach to tcp \n")));
  OpenDDS::DCPS::AttachStatus attach_status
    = pub_impl->attach_transport(writer_impl.in());

  if (attach_status != OpenDDS::DCPS::ATTACH_OK)
    {
      // We failed to attach to the transport for some reason.
      ACE_TString status_str;

      switch (attach_status)
        {
          case OpenDDS::DCPS::ATTACH_BAD_TRANSPORT:
            status_str = ACE_TEXT("ATTACH_BAD_TRANSPORT");
            break;
          case OpenDDS::DCPS::ATTACH_ERROR:
            status_str = ACE_TEXT("ATTACH_ERROR");
            break;
          case OpenDDS::DCPS::ATTACH_INCOMPATIBLE_QOS:
            status_str = ACE_TEXT("ATTACH_INCOMPATIBLE_QOS");
            break;
          default:
            status_str = ACE_TEXT("Unknown Status");
            break;
        }

      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT("(%P|%t) Failed to attach to the transport. ")
                  ACE_TEXT("AttachStatus == %s\n"),
                  status_str.c_str()));
      throw TestException ();
    }

  // Create the datawriters
  ::DDS::DataWriterQos dw_qos;
  publisher->get_default_datawriter_qos (dw_qos);

  // Make it KEEP_ALL history so we can verify the received
  // data without dropping.
  dw_qos.history.kind = ::DDS::KEEP_ALL_HISTORY_QOS;
  dw_qos.reliability.kind = ::DDS::RELIABLE_RELIABILITY_QOS;
  dw_qos.resource_limits.max_samples_per_instance = ::DDS::LENGTH_UNLIMITED;
  dw_qos.reliability.max_blocking_time.sec = 0;
  dw_qos.reliability.max_blocking_time.nanosec = 0;

  for (int i = 0; i < 2; ++i)
    {
      datawriter[i] = publisher->create_datawriter(topic[i].in (),
                                          dw_qos,
                                          ::DDS::DataWriterListener::_nil(),
                                          ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);

      if (CORBA::is_nil (datawriter[i].in ()))
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT("(%P|%t) create_datawriter failed.\n")));
          throw TestException ();
        }

      writers[i] = new Writer (datawriter[i].in (), i);
    }
}
Beispiel #14
0
CORBA::ParDescriptionSeq *
TAO_OperationDef_i::params_i (void)
{
  CORBA::ULong i = 0;
  ACE_Configuration_Section_Key params_key;
  int status =
    this->repo_->config ()->open_section (this->section_key_,
                                          "params",
                                          0,
                                          params_key);

  ACE_Unbounded_Queue<ACE_Configuration_Section_Key> key_queue;

  // This section may not have been created.
  if (status == 0)
    {
      u_int count = 0;
      this->repo_->config ()->get_integer_value (params_key,
                                                 "count",
                                                 count);

      for (i = 0; i < count; ++i)
        {
          ACE_Configuration_Section_Key param_key;
          char *stringified = TAO_IFR_Service_Utils::int_to_string (i);
          status =
            this->repo_->config ()->open_section (params_key,
                                                  stringified,
                                                  0,
                                                  param_key);

          if (status == 0)
            {
              key_queue.enqueue_tail (param_key);
            }
        }
    }

  CORBA::ULong size = static_cast<CORBA::ULong> (key_queue.size ());

  CORBA::ParDescriptionSeq *pd_seq = 0;
  ACE_NEW_THROW_EX (pd_seq,
                    CORBA::ParDescriptionSeq (size),
                    CORBA::NO_MEMORY ());

  pd_seq->length (size);

  if (size == 0)
    {
      return pd_seq;
    }

  CORBA::ParDescriptionSeq_var retval = pd_seq;

  for (i = 0; i < size; ++i)
    {
      ACE_Configuration_Section_Key key;
      key_queue.dequeue_head (key);

      ACE_TString name;
      this->repo_->config ()->get_string_value (key,
                                                "name",
                                                name);

      retval[i].name = name.c_str ();

      u_int mode = 0;
      this->repo_->config ()->get_integer_value (key,
                                                 "mode",
                                                 mode);

      retval[i].mode = static_cast<CORBA::ParameterMode> (mode);

      ACE_TString type_path;
      this->repo_->config ()->get_string_value (key,
                                                "type_path",
                                                type_path);

      TAO_IDLType_i *impl =
        TAO_IFR_Service_Utils::path_to_idltype (type_path,
                                                this->repo_);

      // We have an undefined interface
      if (impl == 0)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("Encountered undefined parameter type "
                                "for variable: %s\n"),
                      name.c_str ()));

          throw CORBA::INTF_REPOS ();
        }

      retval[i].type = impl->type_i ();

      CORBA::Object_var obj =
        TAO_IFR_Service_Utils::path_to_ir_object (type_path,
                                                  this->repo_);

      retval[i].type_def = CORBA::IDLType::_narrow (obj.in ());
    }

  return retval._retn ();
}
Beispiel #15
0
CORBA::ExceptionDefSeq *
TAO_OperationDef_i::exceptions_i ( )
{
  ACE_Configuration_Section_Key excepts_key;
  int status =
    this->repo_->config ()->open_section (this->section_key_,
                                          "excepts",
                                          0,
                                          excepts_key);

  int index = 0;
  ACE_Unbounded_Queue<ACE_TString> path_queue;

  // This section may not have been created.
  if (status == 0)
    {
      ACE_TString field_name, type_path;
      ACE_Configuration::VALUETYPE type;

      while (this->repo_->config ()->enumerate_values (excepts_key,
                                                       index++,
                                                       field_name,
                                                       type)
              == 0)
        {
          this->repo_->config ()->get_string_value (excepts_key,
                                                    field_name.c_str (),
                                                    type_path);

          path_queue.enqueue_tail (type_path);
        }
    }

  CORBA::ULong size = static_cast<CORBA::ULong> (path_queue.size ());

  CORBA::ExceptionDefSeq *ed_seq = 0;
  ACE_NEW_THROW_EX (ed_seq,
                    CORBA::ExceptionDefSeq (size),
                    CORBA::NO_MEMORY ());

  ed_seq->length (size);

  if (index == 0)
    {
      return ed_seq;
    }

  CORBA::ExceptionDefSeq_var retval = ed_seq;

  for (CORBA::ULong i = 0; i < size; ++i)
    {
      ACE_TString path;
      path_queue.dequeue_head (path);

      CORBA::Object_var obj =
        TAO_IFR_Service_Utils::create_objref (CORBA::dk_Exception,
                                              path.c_str (),
                                              this->repo_);

      retval[i] = CORBA::ExceptionDef::_narrow (obj.in ());
    }

  return retval._retn ();
}
Beispiel #16
0
int DDS_TEST::test(ACE_TString host, u_short port)
{
  if (host.empty() || port == 0) {
    std::cerr << "ERROR: -h <host> and -p <port> options are required\n";
    return 1;
  }

  // 0. initialization

  ACE_INET_Addr remote_addr(port, host.c_str());

  TransportInst_rch inst = TheTransportRegistry->create_inst("my_rtps",
                                                             "rtps_udp");

  RtpsUdpInst* rtps_inst = dynamic_cast<RtpsUdpInst*>(inst.in());
  if (!rtps_inst) {
    std::cerr << "ERROR: Failed to cast to RtpsUdpInst\n";
    return 1;
  }
  rtps_inst->datalink_release_delay_ = 0;
  rtps_inst->heartbeat_period_ = ACE_Time_Value(0, 100*1000 /*microseconds*/);

  TransportConfig_rch cfg = TheTransportRegistry->create_config("cfg");
  cfg->instances_.push_back(inst);

  TheTransportRegistry->global_config(cfg);

  RepoIdBuilder local;
  local.federationId(0x01234567);  // guidPrefix1
  local.participantId(0x89abcdef); // guidPrefix2
  local.entityKey(0x012345);
  local.entityKind(ENTITYKIND_USER_WRITER_WITH_KEY);
  OpenDDS::RTPS::GUID_t local_guid(local);
  const OpenDDS::RTPS::GuidPrefix_t& local_prefix = local_guid.guidPrefix;

  RepoIdBuilder remote; // these values must match what's in subscriber.cpp
  remote.federationId(0x01234567);  // guidPrefix1
  remote.participantId(0xefcdab89); // guidPrefix2
  remote.entityKey(0x452310);
  remote.entityKind(ENTITYKIND_USER_READER_WITH_KEY);

  LocatorSeq locators;
  locators.length(1);
  locators[0].kind = (remote_addr.get_type() == AF_INET6)
                     ? LOCATOR_KIND_UDPv6 : LOCATOR_KIND_UDPv4;
  locators[0].port = port;
  address_to_bytes(locators[0].address, remote_addr);

  size_t size_locator = 0, padding_locator = 0;
  gen_find_size(locators, size_locator, padding_locator);
  ACE_Message_Block mb_locator(size_locator + padding_locator + 1);
  Serializer ser_loc(&mb_locator, ACE_CDR_BYTE_ORDER, Serializer::ALIGN_CDR);
  ser_loc << locators;
  ser_loc << ACE_OutputCDR::from_boolean(false); // requires inline QoS

  SimpleDataWriter sdw(local_guid);
  sdw.enable_transport(true /*reliable*/, false /*durable*/);
  AssociationData subscription;
  subscription.remote_id_ = remote;
  subscription.remote_reliable_ = false;
  subscription.remote_data_.length(1);
  subscription.remote_data_[0].transport_type = "rtps_udp";
  subscription.remote_data_[0].data.replace(
    static_cast<CORBA::ULong>(mb_locator.length()), &mb_locator);

  if (!sdw.init(subscription)) {
    std::cerr << "publisher TransportClient::associate() failed\n";
    return 1;
  }

  // 1. send by directly writing an RTPS Message to the socket

  const Header hdr = { {'R', 'T', 'P', 'S'}, PROTOCOLVERSION, VENDORID_OPENDDS,
    {local_prefix[0], local_prefix[1], local_prefix[2], local_prefix[3],
     local_prefix[4], local_prefix[5], local_prefix[6], local_prefix[7],
     local_prefix[8], local_prefix[9], local_prefix[10], local_prefix[11]} };

  const ACE_Time_Value now = ACE_OS::gettimeofday();
  log_time(now);
  const double conv = 4294.967296; // NTP fractional (2^-32) sec per microsec
  const InfoTimestampSubmessage it = { {INFO_TS, 1, 8},
    {static_cast<ACE_CDR::Long>(now.sec()),
     static_cast<ACE_CDR::ULong>(now.usec() * conv)} };

  DataSubmessage ds = { {DATA, 7, 20 + 24 + 12 + sizeof(text)}, 0, 16,
    ENTITYID_UNKNOWN, local_guid.entityId, {0, 1}, ParameterList() };

  TestMsg data;
  data.key = 0x09230923;
  data.value = text;

  ds.inlineQos.length(1);
  OpenDDS::RTPS::KeyHash_t hash;
  marshal_key_hash(data, hash);
  ds.inlineQos[0].key_hash(hash);

  const ACE_CDR::ULong encap = 0x00000100; // {CDR_LE, options} in BE format
  size_t size = 0, padding = 0;
  gen_find_size(hdr, size, padding);
  gen_find_size(it, size, padding);
  gen_find_size(ds, size, padding);
  find_size_ulong(size, padding);
  gen_find_size(data, size, padding);

  ACE_Message_Block msg(size + padding);
  Serializer ser(&msg, host_is_bigendian, Serializer::ALIGN_CDR);
  bool ok = (ser << hdr) && (ser << it) && (ser << ds)
    && (ser << encap) && (ser << data);
  if (!ok) {
    std::cerr << "ERROR: failed to serialize RTPS message\n";
    return 1;
  }

  ACE_INET_Addr local_addr;
  ACE_SOCK_Dgram sock(local_addr);
  ssize_t res = sock.send(msg.rd_ptr(), msg.length(), remote_addr);
  if (res < 0) {
    std::cerr << "ERROR: error in send()\n";
    return 1;
  } else {
    std::ostringstream oss;
    oss << "Sent " << res << " bytes.\n";
    ACE_DEBUG((LM_INFO, oss.str().c_str()));
  }

  // 2a. send control messages through the OpenDDS transport

  // Send an instance registration
  {
    TestMsg control_sample;
    control_sample.key = 0x04030201;
    DataSampleHeader dsh;
    dsh.message_id_ = INSTANCE_REGISTRATION;
    dsh.sequence_ = SequenceNumber::SEQUENCENUMBER_UNKNOWN();
    dsh.publication_id_ = local_guid;
    dsh.key_fields_only_ = true;

    // Calculate the data buffer length
    size = 0;
    padding = 0;
    OpenDDS::DCPS::KeyOnly<const TestMsg> ko_instance_data(control_sample);
    find_size_ulong(size, padding);   // encap
    gen_find_size(ko_instance_data, size, padding);
    dsh.message_length_ = static_cast<ACE_UINT32>(size + padding);

    ACE_Message_Block* ir_mb = new ACE_Message_Block(DataSampleHeader::max_marshaled_size(),
                                                     ACE_Message_Block::MB_DATA,
                                                     new ACE_Message_Block(dsh.message_length_));
    *ir_mb << dsh;

    OpenDDS::DCPS::Serializer serializer(ir_mb->cont(),
                                         host_is_bigendian,
                                         Serializer::ALIGN_CDR);
    ok = (serializer << encap) && (serializer << ko_instance_data);
    if (!ok) {
      std::cerr << "ERROR: failed to serialize data for instance registration\n";
      return 1;
    }
    ::DDS_TEST::force_inline_qos(false);  // No inline QoS
    sdw.send_control(dsh, ir_mb);

    // Send a dispose instance
    {
      dsh.message_id_ = DISPOSE_INSTANCE;
      ACE_Message_Block* di_mb = new ACE_Message_Block(DataSampleHeader::max_marshaled_size(),
                                                       ACE_Message_Block::MB_DATA,
                                                       new ACE_Message_Block(dsh.message_length_));
      *di_mb << dsh;
      OpenDDS::DCPS::Serializer serializer(di_mb->cont(),
                                           host_is_bigendian,
                                           Serializer::ALIGN_CDR);
      ok = (serializer << encap) && (serializer << ko_instance_data);
      if (!ok) {
        std::cerr << "ERROR: failed to serialize data for dispose instance\n";
        return 1;
      }
      ::DDS_TEST::force_inline_qos(true);  // Inline QoS
      sdw.inline_qos_mode_ = SimpleDataWriter::PARTIAL_MOD_QOS;
      sdw.send_control(dsh, di_mb);
    }

    // Send an unregister instance
    {
      dsh.message_id_ = UNREGISTER_INSTANCE;
      ACE_Message_Block* ui_mb = new ACE_Message_Block(DataSampleHeader::max_marshaled_size(),
                                                       ACE_Message_Block::MB_DATA,
                                                       new ACE_Message_Block(dsh.message_length_));
      *ui_mb << dsh;
      OpenDDS::DCPS::Serializer serializer(ui_mb->cont(),
                                           host_is_bigendian,
                                           Serializer::ALIGN_CDR);
      ok = (serializer << encap) && (serializer << ko_instance_data);
      if (!ok) {
        std::cerr << "ERROR: failed to serialize data for unregister instance\n";
        return 1;
      }
      ::DDS_TEST::force_inline_qos(true);  // Inline QoS
      sdw.inline_qos_mode_ = SimpleDataWriter::FULL_MOD_QOS;
      sdw.send_control(dsh, ui_mb);
    }

    // Send a dispose & unregister instance
    {
      dsh.message_id_ = DISPOSE_UNREGISTER_INSTANCE;
      ACE_Message_Block* ui_mb = new ACE_Message_Block(DataSampleHeader::max_marshaled_size(),
                                                       ACE_Message_Block::MB_DATA,
                                                       new ACE_Message_Block(dsh.message_length_));
      *ui_mb << dsh;
      OpenDDS::DCPS::Serializer serializer(ui_mb->cont(),
                                           host_is_bigendian,
                                           Serializer::ALIGN_CDR);
      ok = (serializer << encap) && (serializer << ko_instance_data);
      if (!ok) {
        std::cerr << "ERROR: failed to serialize data for dispose unregister instance\n";
        return 1;
      }
      ::DDS_TEST::force_inline_qos(true);  // Inline QoS
      sdw.inline_qos_mode_ = SimpleDataWriter::FULL_MOD_QOS;
      sdw.send_control(dsh, ui_mb);
    }
  }

  // 2b. send sample data through the OpenDDS transport

  TransportSendElementAllocator alloc(2, sizeof(TransportSendElementAllocator));
  DataSampleElement elements[] = {
    DataSampleElement(local_guid, &sdw, 0, &alloc, 0),  // Data Sample
    DataSampleElement(local_guid, &sdw, 0, &alloc, 0),  // Data Sample (key=99 means end)
  };
  SendStateDataSampleList list;
  list.head_ = elements;
  list.size_ = sizeof(elements) / sizeof(elements[0]);
  list.tail_ = &elements[list.size() - 1];
  for (int i = 0; i < list.size() - 1; ++i) {
    DDS_TEST::set_next_send_sample(elements[i], &elements[i + 1]);
  }

  // Send a regular data sample
  int index = 0;
  DataSampleHeader& dsh = elements[index].header_;
  dsh.message_id_ = SAMPLE_DATA;
  dsh.publication_id_ = local_guid;
  dsh.sequence_ = 3; // test GAP generation
  const ACE_Time_Value tv = ACE_OS::gettimeofday();
  log_time(tv);
  DDS::Time_t st = time_value_to_time(tv);
  dsh.source_timestamp_sec_ = st.sec;
  dsh.source_timestamp_nanosec_ = st.nanosec;

  // Calculate the data buffer length
  size = 0;
  padding = 0;
  find_size_ulong(size, padding);   // encap
  gen_find_size(data, size, padding);
  dsh.message_length_ = static_cast<ACE_UINT32>(size + padding);

  elements[index].sample_ =
    new ACE_Message_Block(DataSampleHeader::max_marshaled_size(),
      ACE_Message_Block::MB_DATA, new ACE_Message_Block(dsh.message_length_));

  *elements[index].sample_ << dsh;

  Serializer ser2(elements[index].sample_->cont(), host_is_bigendian,
                  Serializer::ALIGN_CDR);
  ok = (ser2 << encap) && (ser2 << data);
  if (!ok) {
    std::cerr << "ERROR: failed to serialize data for elements[" << index << "]\n";
    return 1;
  }

  // Send a data sample with a key of 99 to terminate the subscriber
  index++;
  DataSampleHeader& dsh2 = elements[index].header_;
  dsh2.sequence_ = dsh.sequence_+1;
  dsh2.message_id_ = SAMPLE_DATA;
  dsh.publication_id_ = local_guid;
  dsh2.key_fields_only_ = false;
  const ACE_Time_Value tv2 = ACE_OS::gettimeofday();
  log_time(tv2);
  DDS::Time_t st2 = time_value_to_time(tv2);
  dsh2.source_timestamp_sec_ = st2.sec;
  dsh2.source_timestamp_nanosec_ = st2.nanosec;
  data.key = 99;
  data.value = "";

  // Calculate the data buffer length
  size = 0;
  padding = 0;
  find_size_ulong(size, padding);   // encap
  gen_find_size(data, size, padding);
  dsh2.message_length_ = static_cast<ACE_UINT32>(size + padding);

  elements[index].sample_ =
    new ACE_Message_Block(DataSampleHeader::max_marshaled_size(),
      ACE_Message_Block::MB_DATA, new ACE_Message_Block(dsh2.message_length_));

  *elements[index].sample_ << dsh2;

  Serializer ser3(elements[index].sample_->cont(), host_is_bigendian,
                  Serializer::ALIGN_CDR);
  ok = (ser3 << encap) && (ser3 << data.key) && (ser3 << data.value);
  if (!ok) {
    std::cerr << "ERROR: failed to serialize data for elements[" << index << "]\n";
    return 1;
  }

  sdw.callbacks_expected_ = list.size();
  ::DDS_TEST::force_inline_qos(true);  // Inline QoS
  sdw.send(list);

  while (sdw.callbacks_expected_) {
    ACE_OS::sleep(1);
  }

  // Allow enough time for a HEARTBEAT message to be generated
  ACE_OS::sleep(rtps_inst->heartbeat_period_ * 2.0);


  // 3. cleanup

  sdw.disassociate(subscription.remote_id_);

  TheServiceParticipant->shutdown();
  ACE_Thread_Manager::instance()->wait();

  return 0;
}
Beispiel #17
0
int
run_main (int argc, ACE_TCHAR *argv[])
{
  int retval = 0;
  MCT_Config config;
  retval = config.open (argc, argv);
  if (retval != 0)
    return 1;

  const ACE_TCHAR *temp = ACE_TEXT ("Multicast_Test");
  ACE_TString test = temp;

  u_long role = config.role ();
  if (ACE_BIT_DISABLED (role, MCT_Config::PRODUCER)
      || ACE_BIT_DISABLED (role, MCT_Config::CONSUMER))
    {
      if (ACE_BIT_ENABLED (role, MCT_Config::PRODUCER))
        test += ACE_TEXT ("-PRODUCER");
      else
        test += ACE_TEXT ("-CONSUMER");
    }

  // Start test only if options are valid.
  ACE_START_TEST (test.c_str ());

  // Register a signal handler to close down application gracefully.
  ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);

  // Dump the configuration info to the log if caller passed debug option.
  if (config.debug ())
    config.dump ();

  ACE_Reactor *reactor = ACE_Reactor::instance ();

  MCT_Task *task = new MCT_Task (config, reactor);

  if (ACE_BIT_ENABLED (role, MCT_Config::CONSUMER))
    {
      ACE_DEBUG ((LM_INFO, ACE_TEXT ("Starting consumer...\n")));
      // Open makes it an active object.
      retval += task->open ();
    }

  // now produce the datagrams...
  if (ACE_BIT_ENABLED (role, MCT_Config::PRODUCER))
    retval += producer (config);

  if (ACE_BIT_ENABLED (role, MCT_Config::CONSUMER))
    {
      // and wait for everything to finish
      ACE_DEBUG ((LM_INFO,
                  ACE_TEXT ("start waiting for consumer to finish...\n")));
      // Wait for the threads to exit.
      // But, wait for a limited time since we could hang if the last udp
      // message isn't received.
      ACE_Time_Value max_wait ( config.wait ()/* seconds */);
      ACE_Time_Value wait_time (ACE_OS::gettimeofday () + max_wait);
      ACE_Time_Value *ptime = ACE_BIT_ENABLED (role, MCT_Config::PRODUCER)
                                ? &wait_time : 0;
      if (ACE_Thread_Manager::instance ()->wait (ptime) == -1)
        {
          // We will no longer wait for this thread, so we must
          // force it to exit otherwise the thread will be referencing
          // deleted memory.
          finished = 1;
          reactor->end_reactor_event_loop ();

          if (errno == ETIME)
            ACE_ERROR ((LM_ERROR,
                        ACE_TEXT ("maximum wait time of %d msec exceeded\n"),
                        max_wait.msec ()));
          else
            ACE_OS::perror (ACE_TEXT ("wait"));

          ++error;

          // This should exit now that we ended the reactor loop.
          task->wait ();
        }
    }

  delete task;
  ACE_END_TEST;
  return (retval == 0 && error == 0) ? 0 : 1;
}
Beispiel #18
0
void
TAO_InterfaceDef_i::interface_contents (
    ACE_Unbounded_Queue<CORBA::DefinitionKind> &kind_queue,
    ACE_Unbounded_Queue<ACE_TString> &path_queue,
    CORBA::DefinitionKind limit_type,
    CORBA::Boolean exclude_inherited
  )
{
  ACE_TString id;
  this->repo_->config ()->get_string_value (this->section_key_,
                                            "id",
                                            id);

  ACE_TString path;
  this->repo_->config ()->get_string_value (this->repo_->repo_ids_key (),
                                            id.c_str (),
                                            path);

  ACE_TString section_name;
  int index = 0;
  int status = 0;

  // Attributes
  if (limit_type == CORBA::dk_Attribute
      || limit_type == CORBA::dk_all)
    {
      ACE_Configuration_Section_Key attrs_key;
      status =
        this->repo_->config ()->open_section (this->section_key_,
                                              "attrs",
                                              0,
                                              attrs_key);

      // Only if we have any.
      if (status == 0)
        {
          while (this->repo_->config ()->enumerate_sections (attrs_key,
                                                             index++,
                                                             section_name)
                  == 0)
            {
              kind_queue.enqueue_tail (CORBA::dk_Attribute);

              path_queue.enqueue_tail (
                  path + "\\attrs\\" + section_name.c_str ()
                );
            }
        }
    }

  // Operations
  if (limit_type == CORBA::dk_Operation
      || limit_type == CORBA::dk_all)
    {
      index = 0;

      ACE_Configuration_Section_Key ops_key;
      status =
        this->repo_->config ()->open_section (this->section_key_,
                                              "ops",
                                              0,
                                              ops_key);

      // Only if we have any.
      if (status == 0)
        {
          while (this->repo_->config ()->enumerate_sections (ops_key,
                                                             index++,
                                                             section_name)
                  == 0)
            {
              kind_queue.enqueue_tail (CORBA::dk_Operation);

              path_queue.enqueue_tail (
                  path + "\\ops\\" + section_name.c_str ()
                );
            }
        }
    }

  if (exclude_inherited == 0)
    {
      // Must recurse through the base interfaces.
      ACE_Configuration_Section_Key inherited_key;
      status =
        this->repo_->config ()->open_section (this->section_key_,
                                              "inherited",
                                              0,
                                              inherited_key);

      if (status == 0)
        {
          ACE_TString base_path;
          ACE_Configuration_Section_Key base_key;
          ACE_Configuration::VALUETYPE type;
          index = 0;

          while (this->repo_->config ()->enumerate_values (inherited_key,
                                                           index++,
                                                           section_name,
                                                           type)
                  == 0)
            {
              this->repo_->config ()->get_string_value (inherited_key,
                                                        section_name.c_str (),
                                                        base_path);

              this->repo_->config ()->expand_path (this->repo_->root_key (),
                                                   base_path,
                                                   base_key,
                                                   0);

              TAO_InterfaceDef_i base_iface (this->repo_);
              base_iface.section_key (base_key);

              base_iface.interface_contents (kind_queue,
                                             path_queue,
                                             limit_type,
                                             exclude_inherited);
            }
        }
    }
}
Beispiel #19
0
CORBA::Contained::Description *
TAO_ComponentDef_i::describe_i (void)
{
  CORBA::ComponentIR::ComponentDescription cd;
  TAO_IFR_Desc_Utils<CORBA::ComponentIR::ComponentDescription,
                     TAO_ComponentDef_i>::fill_desc_begin (
                                              cd,
                                              this->repo_,
                                              this->section_key_
                                            );

  ACE_TString holder;
  int status =
    this->repo_->config ()->get_string_value (this->section_key_,
                                              "base_component",
                                              holder);

  if (status == 0)
    {
      ACE_Configuration_Section_Key base_key;
      this->repo_->config ()->expand_path (this->repo_->root_key (),
                                           holder,
                                           base_key,
                                           0);
      this->repo_->config ()->get_string_value (base_key,
                                                "id",
                                                holder);
    }

  // If status wasn't 0, holder will contain the empty string.
  cd.base_component = holder.fast_rep ();

  CORBA::ULong count = 0;
  ACE_Configuration_Section_Key supports_key;
  status = this->repo_->config ()->open_section (this->section_key_,
                                                 "supported",
                                                 0,
                                                 supports_key);

  if (status == 0)
    {
      this->repo_->config ()->get_integer_value (supports_key,
                                                 "count",
                                                 count);
    }

  cd.supported_interfaces.length (count);
  char *stringified = 0;
  CORBA::ULong i = 0;

  for (i = 0; i < count; ++i)
    {
      stringified = TAO_IFR_Service_Utils::int_to_string (i);
      this->repo_->config ()->get_string_value (supports_key,
                                                stringified,
                                                holder);

      cd.supported_interfaces[i] = holder.c_str ();
    }

  TAO_Port_Desc_Seq_Utils<
      CORBA::ComponentIR::ProvidesDescriptionSeq
    >::port_descriptions (cd.provided_interfaces,
       this->repo_->config (),
       this->section_key_,
       "provides");

  TAO_Port_Desc_Seq_Utils<
      CORBA::ComponentIR::UsesDescriptionSeq
    >::port_descriptions (cd.used_interfaces,
       this->repo_->config (),
       this->section_key_,
       "uses");

  TAO_Port_Desc_Seq_Utils<
      CORBA::ComponentIR::EventPortDescriptionSeq
    >::port_descriptions (cd.emits_events,
      this->repo_->config (),
      this->section_key_,
      "emits");

  TAO_Port_Desc_Seq_Utils<
      CORBA::ComponentIR::EventPortDescriptionSeq
    >::port_descriptions (cd.publishes_events,
      this->repo_->config (),
      this->section_key_,
      "publishes");

  TAO_Port_Desc_Seq_Utils<
      CORBA::ComponentIR::EventPortDescriptionSeq
    >::port_descriptions (cd.consumes_events,
      this->repo_->config (),
      this->section_key_,
      "consumes");

  count = 0;
  ACE_Configuration_Section_Key attrs_key;
  status =
    this->repo_->config ()->open_section (this->section_key_,
                                          "attrs",
                                          0,
                                          attrs_key);
  if (status == 0)
    {
      this->repo_->config ()->get_integer_value (attrs_key,
                                                 "count",
                                                 count);
    }

  cd.attributes.length (count);
  ACE_Configuration_Section_Key attr_key;

  for (i = 0; i < count; ++i)
    {
      stringified = TAO_IFR_Service_Utils::int_to_string (i);
      this->repo_->config ()->open_section (attrs_key,
                                            stringified,
                                            0,
                                            attr_key);

      TAO_ExtAttributeDef_i impl (this->repo_);
      impl.section_key (attr_key);
      impl.fill_description (cd.attributes[i]);
    }

  cd.type = this->type_i ();

  CORBA::Contained::Description *cont_desc_ptr = 0;
  ACE_NEW_THROW_EX (cont_desc_ptr,
                    CORBA::Contained::Description,
                    CORBA::NO_MEMORY ());
  CORBA::Contained::Description_var retval = cont_desc_ptr;

  cont_desc_ptr->kind = CORBA::dk_Component;

  cont_desc_ptr->value <<= cd;
  return retval._retn ();
}
int ACE_TMAIN (int argc, ACE_TCHAR **argv)
{
  DANCE_DISABLE_TRACE ();

  auto_ptr<DAnCE::Logger_Service> logger;

  int retval (0);

  try
    {
      DAnCE::Logger_Service
        * dlf = ACE_Dynamic_Service<DAnCE::Logger_Service>::instance ("DAnCE_Logger");

      if (dlf)
        {
          dlf->init (argc, argv);
        }

      DANCE_TRACE_LOG (DANCE_LOG_TRACE,
                       (LM_TRACE, DLINFO
                    ACE_TEXT ("Module_main.h - initializing ORB\n")));

      CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

      Options options;
      int const error = options.parse_args (argc, argv);
      if (error == -1)
        {
          DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("repository_manager_admin_exec::main - ")
                        ACE_TEXT ("Failed to parse command line arguments.\n")));
        }
      else if (error == 1)
        { //help was issued -> quit
          return 0;
        }

      if (options.rm_ior_ == 0)
        {
          DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("repository_manager_admin_exec::main - ")
                        ACE_TEXT ("No RepositoryManager IOR provided\n")));
          return -1;
        }

      // Resolve the RepositoryManager reference
      CORBA::Object_var obj = orb->string_to_object (options.rm_ior_);

      Deployment::RepositoryManager_var rm =
        Deployment::RepositoryManager::_narrow (obj);

      if (CORBA::is_nil (obj))
        {
          DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("repository_manager_admin_exec::main - ")
                        ACE_TEXT ("Provided IOR was invalid or could not be narrowed: %s\n"),
                        options.rm_ior_));
          return -1;
        }

      DAnCE::RepositoryManager::Admin admin (rm.in ());

      ACE_Unbounded_Set_Iterator<Options::Installation> inst_it =
        options.install_.begin ();
      Options::Installation *inst (0);

      while (inst_it.next (inst) == 1)
        {
          if (!admin.install_package (inst->path_.c_str (),
                                      inst->name_.c_str (),
                                      inst->replace_))
            retval = -1;
          inst_it.advance ();
        }

      ACE_Unbounded_Set_Iterator<Options::Creation> creat_it (options.create_);
      Options::Creation *creat (0);

      while (creat_it.next (creat) == 1)
        {
          if (!admin.create_package (creat->path_.c_str (),
                                     creat->name_.c_str (),
                                     creat->base_location_.c_str (),
                                     creat->replace_))
            retval = -1;
          creat_it.advance ();
        }

      ACE_Unbounded_Set_Iterator<ACE_TString> uninst_it (options.uninstall_);
      ACE_TString *uninst = 0;

      while (uninst_it.next (uninst) == 1)
        {
          if (!admin.uninstall_package (uninst->c_str ()))
            retval = -1;
          uninst_it.advance ();
        }

      if (options.list_)
        {
          ::CORBA::StringSeq * packages = admin.list_packages ();
          if (packages == 0)
            {
              DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("repository_manager_admin_exec::main - ")
                            ACE_TEXT ("No packages returned from list_packages\n")));
              retval = -1;
            }

          DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                       (LM_EMERGENCY, ACE_TEXT ("Listing %u packages installed on server:\n")));

          for (CORBA::ULong i = 0; i < packages->length (); ++i)
            {
              DANCE_TRACE_LOG (DANCE_LOG_DETAILED_TRACE, (LM_TRACE, "\t%s\n",
                                                          (*packages)[i].in ()));
            }

          delete packages;
        }

      if (options.shutdown_)
        {
          DANCE_DEBUG (DANCE_LOG_MAJOR_EVENT,
                       (LM_EMERGENCY, ACE_TEXT ("Shutting down the Repository Manager\n")));
          if (!admin.shutdown ())
            retval = -1;
        }

      orb->destroy ();
    }
  catch (const CORBA::Exception &ex)
    {
      DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("repository_manager_admin_exec::main - ")
                    ACE_TEXT ("Caught unexpected CORBA Exception: %s\n"),
                    ex._info ().c_str ()));
      return -1;
    }
  catch (...)
    {
      DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("repository_manager_admin_exec::main - ")
                    ACE_TEXT ("Caught unexpected C++ exception.\n")));
      return -1;
    }

  return retval;
}
Beispiel #21
0
std::string FileConfig::GetStringDefault(const char* name, const char* def)
{
    ACE_TString val;
    return GetValueHelper(mConf, name, val) ? val.c_str() : def;
}
Beispiel #22
0
void Directory::scan_dir(const ACE_TString& relative, DDS_Dirent& dir,
                         unsigned int overflow_index)
{
  ACE_TString path = physical_dirname_ + relative;
  add_slash(path);

  while (DDS_DIRENT* ent = dir.read()) {
    if (ent->d_name[0] == ACE_TEXT('.') && (!ent->d_name[1] ||
        (ent->d_name[1] == ACE_TEXT('.') && !ent->d_name[2]))) {
      continue; // skip '.' and '..'
    }

    ACE_TString file = path + ent->d_name;

    if (is_dir(file.c_str())) {
      ACE_TString phys(relative);
      add_slash(phys);
      phys += ent->d_name;

      if (ACE_OS::strncmp(ent->d_name, ACE_TEXT("_overflow."), 10) == 0) {
        unsigned int n = ACE_OS::atoi(ent->d_name + 10);
        DDS_Dirent overflow(file.c_str());
        scan_dir(ent->d_name, overflow, n);

      } else if (ACE_OS::strlen(ent->d_name) <= FSS_MAX_FILE_NAME_ENCODED) {
        dirs_[b32h_decode(ent->d_name)] = phys;
        ++overflow_[overflow_index];

      } else {
        CwdGuard cg(file);
        std::ifstream fn("_fullname");
        std::string fullname;

        if (!std::getline(fn, fullname)) {
          throw std::runtime_error("Can't read .../_fullname");
        }

        ACE_TString full_t(ACE_TEXT_CHAR_TO_TCHAR(fullname.c_str()));
        dirs_[full_t] = phys;
        ++overflow_[overflow_index];

        String_Index_t idx = phys.rfind(ACE_TEXT('.'));

        if (idx == ACE_TString::npos) {
          throw std::runtime_error("Badly formatted long dir name");
        }

        ACE_TString prefix(phys.c_str(), idx);
        unsigned int serial = ACE_OS::atoi(&phys[idx + 1]);
        unsigned int& counter = long_names_[prefix];

        if (serial >= counter) counter = serial + 1;
      }

    } else { // regular file
      if (ent->d_name[0] != ACE_TEXT('_')) {
        files_[b32h_decode(ent->d_name)] = ent->d_name;
        ++overflow_[overflow_index];
      }
    }
  }
}
Beispiel #23
0
int GetIntDefault(const char* name, int def)
{
    ACE_TString val;
    return GetValueHelper(name, val) ? atoi(val.c_str()) : def;
};
Beispiel #24
0
std::string GetStringDefault(const char* name, const std::string &def)
{
    ACE_TString val;
    return GetValueHelper(name, val) ? val.c_str() : def;
};
Beispiel #25
0
int32 FileConfig::GetIntDefault(const char* name, int32 def)
{
    ACE_TString val;
    return GetValueHelper(mConf, name, val) ? atoi(val.c_str()) : def;
}
Beispiel #26
0
void
Locator_XMLHandler::startElement (const ACEXML_Char*,
                                  const ACEXML_Char*,
                                  const ACEXML_Char* qName,
                                  ACEXML_Attributes* attrs)
{
  if (ACE_OS::strcasecmp (qName, SERVER_INFO_TAG) == 0)
    {
      ACE_NEW (this->si_, Server_Info);
      this->env_vars_.clear ();

      // if attrs exists and if the previously required 9 fields
      const size_t previous_size = 9;
      if (attrs != 0 && attrs->getLength () >= previous_size)
        {
          size_t index = 0;
          this->si_->server_id = ACE_TEXT_ALWAYS_CHAR (attrs->getValue (index++));
          this->si_->poa_name = ACE_TEXT_ALWAYS_CHAR (attrs->getValue (index++));
          this->si_->activator = ACE_TEXT_ALWAYS_CHAR (attrs->getValue (index++));
          this->si_->cmdline = ACE_TEXT_ALWAYS_CHAR (attrs->getValue (index++));
          this->si_->dir = ACE_TEXT_ALWAYS_CHAR (attrs->getValue (index++));
          this->si_->activation_mode_ =
            ImR_Utils::stringToActivationMode (ACE_TEXT_ALWAYS_CHAR (attrs->getValue (index++)));
          this->si_->start_limit_ = ACE_OS::atoi (attrs->getValue (index++));
          this->si_->partial_ior = ACE_TEXT_ALWAYS_CHAR (attrs->getValue (index++));
          this->si_->ior = ACE_TEXT_ALWAYS_CHAR (attrs->getValue (index++));

          if (attrs->getLength () >= index)
            {
              this->server_started_ =
                (ACE_OS::atoi (attrs->getValue (index++)) != 0);
            }
          if (attrs->getLength () >= index)
            {
              this->si_->is_jacorb =
                (ACE_OS::atoi (attrs->getValue (index++)) != 0);
            }

          for ( ; index < attrs->getLength(); ++index)
            {
              ACE_TString name (attrs->getLocalName (index));
              ACE_CString value (ACE_TEXT_ALWAYS_CHAR (attrs->getValue (index)));
              if (name == KEYNAME_TAG)
                {
                  this->si_->key_name_ = value;
                }
              else if (name == ALTKEY_TAG)
                {
                  if (value.length() > 0 &&
                      this->repo_.servers ().find (value, this->si_->alt_info_) != 0)
                    {
                      Server_Info *base_si = 0;
                      ACE_NEW (base_si, Server_Info);
                      base_si->key_name_ = value;
                      this->si_->alt_info_.reset (base_si);
                      this->repo_.servers ().bind (value, this->si_->alt_info_);
                    }
                }
              else if (name == PID_TAG)
                {
                  this->si_->pid =
                    ACE_OS::atoi (attrs->getValue (index++));
                }
              else
                {
                  const ACE_CString name_cstr (ACE_TEXT_ALWAYS_CHAR (name.c_str ()));
                  this->extra_params_.push_back (std::make_pair (name_cstr, value));
                }
            }
        }
    }
  else if (ACE_OS::strcasecmp (qName, ACTIVATOR_INFO_TAG) == 0)
  {
    if (attrs != 0 && attrs->getLength () >= 3)
      {
        size_t index = 0;
        const ACE_CString aname =
          ACE_TEXT_ALWAYS_CHAR(attrs->getValue (index++));
        const ACE_TString token_str = attrs->getValue (index++);
        long token = ACE_OS::atoi (token_str.c_str ());
        const ACE_CString ior =
          ACE_TEXT_ALWAYS_CHAR(attrs->getValue (index++));
        NameValues extra_params;
        for ( ; index < attrs->getLength(); ++index)
          {
            ACE_CString name (ACE_TEXT_ALWAYS_CHAR (attrs->getLocalName(index)));
            ACE_CString value (ACE_TEXT_ALWAYS_CHAR (attrs->getValue(index)));
            extra_params.push_back (std::make_pair (name, value));
          }
        this->repo_.load_activator (aname, token, ior, extra_params);
      }
  }
  else if (ACE_OS::strcasecmp (qName, ENVIRONMENT_TAG) == 0)
    {
      if (attrs != 0 && attrs->getLength () == 2)
        {
          EnvVar ev;
          ev.name = attrs->getValue ((size_t)0);
          ev.value = attrs->getValue ((size_t)1);
          this->env_vars_.push_back (ev);
        }
    }
  else if (ACE_OS::strcasecmp (qName, PEER_TAG) == 0)
    {
      if (attrs != 0)
        {
          ACE_CString peer (ACE_TEXT_ALWAYS_CHAR (attrs->getValue((size_t)0)));
          this->peer_list_.push_back (peer);
        }
    }
}
Beispiel #27
0
float FileConfig::GetFloatDefault(const char* name, float def)
{
    ACE_TString val;
    return GetValueHelper(mConf, name, val) ? (float)atof(val.c_str()) : def;
}
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
    try {
        // Initialize the ORB.
        CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

        // Create a MessengerServer object.
        MessengerServer * server = new MessengerServer (orb.in());
        ACE_Auto_Ptr<MessengerServer> safe_ptr (server);

        // Parse arguments to determine how we should shutdown.
        if (server->parse_args (argc, argv) != 0)
            return 1;

        //Get reference to the RootPOA.
        CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" );
        PortableServer::POA_var poa = PortableServer::POA::_narrow( obj.in() );

        // Activate the POAManager.
        PortableServer::POAManager_var mgr = poa->the_POAManager();
        mgr->activate();

        // Create a servant.
        Messenger_i messenger_servant (orb.in());

        // Register the servant with the RootPOA, obtain its object
        // reference, stringify it, and write it to a file.
        PortableServer::ObjectId_var oid =
            poa->activate_object( &messenger_servant );
        CORBA::Object_var messenger_obj = poa->id_to_reference( oid.in() );
        CORBA::String_var str = orb->object_to_string( messenger_obj.in() );
        std::ofstream iorFile(ACE_TEXT_ALWAYS_CHAR (ior_output_file.c_str ()));
        iorFile << str.in() << std::endl;
        iorFile.close();
        std::cout << "IOR written to file " <<
                  ACE_TEXT_ALWAYS_CHAR (ior_output_file.c_str ()) << std::endl;

        switch (s_method)
        {
        // shutdown on client invocation
        case MessengerServer::s_client_call:
            std::cout << "Will shutdown on client invocation." << std::endl;
            server->run ();
            break;

        // shutdown after some iterations through loop
        case MessengerServer::s_polling_loop:
            server->poll (loop_iterations);
            break;

        // schedule a timer to shutdown
        case MessengerServer::s_timer:
            server->schedule_shutdown_timer (timeout);
            server->run ();
            break;

        // shutdown on console input
        case MessengerServer::s_console_input:
            server->shutdown_on_console_input ();
            server->run ();
            break;

        // use CORBA::ORB::run() with time value
        case MessengerServer::s_run_time_value:
            server->run (timeout);
            break;
        }
    }
    catch(const CORBA::Exception& ex) {
        std::cerr << "CORBA exception: " << ex << std::endl;
        return 1;
    }

    return 0;
}
Beispiel #29
0
int
ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
                      int open_mode,
                      ACE_SHLIB_HANDLE handle)
{
  ACE_TRACE ("ACE_DLL_Handle::open");
  ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));

  if (this->dll_name_)
    {
      // Once dll_name_ has been set, it can't be changed..
      if (ACE_OS::strcmp (this->dll_name_, dll_name) != 0)
        {
          if (ACE::debug ())
            ACE_ERROR ((LM_ERROR,
                        ACE_TEXT ("(%P|%t) DLL_Handle::open: error, ")
                        ACE_TEXT ("tried to reopen %s with name %s\n"),
                        this->dll_name_,
                        dll_name));

          return -1;
        }
    }
  else
    this->dll_name_ = ACE::strnew (dll_name);

  if (!this->open_called_)
    this->open_called_ = 1;

  // If it hasn't been loaded yet, go ahead and do that now.
  if (this->handle_ == ACE_SHLIB_INVALID_HANDLE)
    {
      if (handle)
        this->handle_ = handle;
      else
        {
          /*
          ** Get the set of names to try loading. We need to do this to
          ** properly support the ability for a user to specify a simple,
          ** unadorned name (for example, "ACE") that will work across
          ** platforms. We apply platform specifics to get a name that will
          ** work (e.g. libACE, ACEd.dll, ACE.dll, etc.) We rely on the
          ** underlying dlopen() implementation to "Do The Right Thing" in
          ** terms of using relative paths, LD_LIBRARY_PATH, system security
          ** rules, etc. except when ACE_MUST_HELP_DLOPEN_SEARCH_PATH is set.
          ** If it is set, then ACE::ldfind() scans the configured path
          ** looking for a match on the name and prefix/suffix applications.
          ** NOTE: having ACE scan for a file and then pass a fully-qualified
          ** pathname to dlopen() is a potential security hole; therefore,
          ** do not use ACE_MUST_HELP_DLOPEN_SEARCH_PATH unless necessary
          ** and only after considering the risks.
          */
          ACE_Array<ACE_TString> dll_names;
          dll_names.max_size (10);    // Decent guess to avoid realloc later

#if defined (ACE_MUST_HELP_DLOPEN_SEARCH_PATH)
          // Find out where the library is
          ACE_TCHAR dll_pathname[MAXPATHLEN + 1];

          // Transform the pathname into the appropriate dynamic link library
          // by searching the ACE_LD_SEARCH_PATH.
          ACE::ldfind (dll_name,
                       dll_pathname,
                       (sizeof dll_pathname / sizeof (ACE_TCHAR)));
          ACE_TString dll_str (dll_pathname);
          dll_names.size (1);
          dll_names.set (dll_str, 0);
#else
          this->get_dll_names (dll_name, dll_names);
#endif

          ACE_Array_Iterator<ACE_TString> name_iter (dll_names);
          ACE_TString *name = 0;
          while (name_iter.next (name))
            {
              // The ACE_SHLIB_HANDLE object is obtained.
              this->handle_ = ACE_OS::dlopen (name->c_str (),
                                              open_mode);

              if (ACE::debug ())
                {
                  ACE_DEBUG ((LM_DEBUG,
                              ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
                              ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"),
                              name->c_str (),
                              open_mode,
                              ((this->handle_ != ACE_SHLIB_INVALID_HANDLE)
                               ? ACE_TEXT ("succeeded")
                               : ACE_TEXT ("failed")),
                              this->error()->c_str()));
                }

              if (this->handle_ != ACE_SHLIB_INVALID_HANDLE)   // Good one?
                break;

              // If errno is ENOENT we just skip over this one,
              // anything else - like an undefined symbol, for
              // instance must be flagged here or the next error will
              // mask it.
              // @TODO: If we've found our DLL _and_ it's
              // broken, should we continue at all?
              if ((errno != 0) && (errno != ENOENT) && ACE::debug ())
                ACE_ERROR ((LM_ERROR,
                            ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
                            ACE_TEXT ("(\'%s\') failed, errno=")
                            ACE_TEXT ("%d: %s\n"),
                            name->c_str (),
                            errno,
                            this->error ()->c_str ()));

#if defined (AIX)
              // AIX often puts the shared library file (most often named
              // shr.o) inside an archive library. If this is an archive
              // library name, then try appending [shr.o] and retry.
              if (ACE_TString::npos != name->strstr (ACE_TEXT (".a")))
                {
                  ACE_TCHAR aix_pathname[MAXPATHLEN + 1];
                  ACE_OS::strncpy (aix_pathname,
                                   name->c_str (),
                                   name->length ());
                  aix_pathname[name->length ()] = '\0';
                  ACE_OS::strcat (aix_pathname, ACE_TEXT ("(shr.o)"));
                  open_mode |= RTLD_MEMBER;

                  if (ACE::debug ())
                    {
                      ACE_DEBUG ((LM_DEBUG,
                                  ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
                                  ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"),
                                  aix_pathname,
                                  open_mode,
                                  ACE_TEXT ((this->handle_ != ACE_SHLIB_INVALID_HANDLE)
                                                ? "succeeded"
                                                : "failed"),
                                  this->error()->c_str()));
                    }

                  this->handle_ = ACE_OS::dlopen (aix_pathname, open_mode);
                  if (this->handle_ != ACE_SHLIB_INVALID_HANDLE)
                    break;

                  // If errno is ENOENT we just skip over this one, anything
                  // else - like an undefined symbol, for instance
                  // must be flagged here or the next error will mask it.
                  //
                  // @TODO: If we've found our DLL _and_ it's broken,
                  // should we continue at all?
                  if (ACE::debug () && (errno != 0) && (errno != ENOENT))
                    ACE_ERROR ((LM_ERROR,
                                ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
                                ACE_TEXT ("(\'%s\') failed, errno=")
                                ACE_TEXT ("%d: %s\n"),
                                name->c_str (),
                                errno,
                                this->error ()->c_str ()));

                }
#endif /* AIX */

              name_iter.advance ();
            }

          if (this->handle_ == ACE_SHLIB_INVALID_HANDLE)
            {
              if (ACE::debug ())
                ACE_ERROR ((LM_ERROR,
                            ACE_TEXT ("ACE (%P|%t) DLL_Handle::open (\"%s\"): ")
                            ACE_TEXT ("Invalid handle error: %s\n"),
                            this->dll_name_,
                            this->error ()->c_str ()));

              return -1;
            }
        }
    }

  ++this->refcount_;

  if (ACE::debug ())
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("ACE (%P|%t) DLL_Handle::open - %s (%d), refcount=%d\n"),
                this->dll_name_,
                this->handle_,
                this->refcount_));
  return 0;
}
Beispiel #30
0
CORBA::OperationDef_ptr
TAO_InterfaceDef_i::create_operation_i (const char *id,
                                        const char *name,
                                        const char *version,
                                        CORBA::IDLType_ptr result,
                                        CORBA::OperationMode mode,
                                        const CORBA::ParDescriptionSeq &params,
                                        const CORBA::ExceptionDefSeq &exceptions,
                                        const CORBA::ContextIdSeq &contexts)
{
  // This will throw an exception if a name clash is found.
  // create_common() will check for all other errors.
  this->check_inherited (name,
                         CORBA::dk_Operation);

  TAO_Container_i::tmp_name_holder_ = name;
  ACE_Configuration_Section_Key new_key;

  // Common to all IR objects created in CORBA::Container.
  ACE_TString path =
    TAO_IFR_Service_Utils::create_common (CORBA::dk_Interface,
                                          CORBA::dk_Operation,
                                          this->section_key_,
                                          new_key,
                                          this->repo_,
                                          id,
                                          name,
                                          &TAO_Container_i::same_as_tmp_name,
                                          version,
                                          "ops");

  // Get the TypeCode for the return type.
  ACE_TString result_path (TAO_IFR_Service_Utils::reference_to_path (result));
  TAO_IDLType_i *result_impl =
    TAO_IFR_Service_Utils::path_to_idltype (result_path,
                                            this->repo_);

  CORBA::TypeCode_var rettype =
    result_impl->type_i ();

  CORBA::TCKind kind = rettype->kind ();

  // Oneway operations cannot have a non-void return type.
  if (mode == CORBA::OP_ONEWAY && kind != CORBA::tk_void)
    {
      throw CORBA::BAD_PARAM (CORBA::OMGVMCID | 31, CORBA::COMPLETED_NO);
    }

  this->repo_->config ()->set_string_value (new_key,
                                            "result",
                                            result_path);

  // Store the operation mode.
  this->repo_->config ()->set_integer_value (new_key,
                                             "mode",
                                             mode);

  CORBA::ULong i = 0;

  // Store the operation's parameter info.
  CORBA::ULong length = params.length ();

  if (length > 0)
    {
      ACE_Configuration_Section_Key params_key;
      this->repo_->config ()->open_section (new_key,
                                            "params",
                                            1,
                                            params_key);

      this->repo_->config ()->set_integer_value (params_key,
                                                 "count",
                                                 length);
      char *type_path = 0;

      for (i = 0; i < length; ++i)
        {
          // Oneway operations cannot have INOUT or OUT parameters.
          if (mode == CORBA::OP_ONEWAY && params[i].mode != CORBA::PARAM_IN)
            {
              throw CORBA::BAD_PARAM (31, CORBA::COMPLETED_NO);
            }

          ACE_Configuration_Section_Key param_key;
          char *stringified = TAO_IFR_Service_Utils::int_to_string (i);
          this->repo_->config ()->open_section (params_key,
                                                stringified,
                                                1,
                                                param_key);

          this->repo_->config ()->set_string_value (param_key,
                                                    "name",
                                                    params[i].name.in ());
          type_path =
            TAO_IFR_Service_Utils::reference_to_path (
                params[i].type_def.in ()
              );

          this->repo_->config ()->set_string_value (param_key,
                                                    "type_path",
                                                    type_path);

          this->repo_->config ()->set_integer_value (param_key,
                                                     "mode",
                                                     params[i].mode);
       }
    }

  // Store the operation's exception info.
  length = exceptions.length ();

  if (length > 0)
    {
      // Oneway operations cannot throw any user exceptions.
      if (mode == CORBA::OP_ONEWAY)
        {
          throw CORBA::BAD_PARAM (CORBA::OMGVMCID | 31, CORBA::COMPLETED_NO);
        }

      ACE_Configuration_Section_Key excepts_key;
      this->repo_->config ()->open_section (new_key,
                                            "excepts",
                                            1,
                                            excepts_key);
      char *type_path = 0;

      for (i = 0; i < length; ++i)
        {
          type_path =
            TAO_IFR_Service_Utils::reference_to_path (exceptions[i]);

          char *stringified = TAO_IFR_Service_Utils::int_to_string (i);
          this->repo_->config ()->set_string_value (excepts_key,
                                                    stringified,
                                                    type_path);
        }
    }

  // Store the operation's context info.
  length = contexts.length ();

  if (length > 0)
    {
      ACE_Configuration_Section_Key contexts_key;

      this->repo_->config ()->open_section (new_key,
                                            "contexts",
                                            1,
                                            contexts_key);

      for (i = 0; i < length; ++i)
        {
          char *stringified = TAO_IFR_Service_Utils::int_to_string (i);
          this->repo_->config ()->set_string_value (contexts_key,
                                                    stringified,
                                                    contexts[i].in ());
        }
    }

  // Create the object reference.
  CORBA::Object_var obj =
    TAO_IFR_Service_Utils::create_objref (CORBA::dk_Operation,
                                          path.c_str (),
                                          this->repo_);

  CORBA::OperationDef_var retval =
    CORBA::OperationDef::_narrow (obj.in ());

  return retval._retn ();
}