void 
StandardConfiguratorImpl::configure(::Components::CCMObject_ptr comp)
throw( Components::WrongComponentType )
{
	for(CORBA::ULong i = 0; i < config_.length(); i++ )
	{
		DEBUG_OUT2( "\nStandardConfigurator: configure ", config_[i]->name() );


		// create a request according to the wire format of attribute operations
		std::string operation = "_set_";
		operation.append( config_[i]->name() );
		CORBA::Request_ptr request = comp->_request( operation.c_str() );
		request->add_in_arg() = config_[i]->value();


		// send the request
		try
		{
 			request->invoke();
		}
		catch( CORBA::SystemException& ex )
		{
 			std::cerr << "StandardConfigurator: Unexpected System Exception" << &ex << std::endl;
		}


		// check for exceptions
		CORBA::Exception* ex = request->env()->exception();
		if ( ex != 0 )
		{
			std::cerr << "StandardConfigurator: Exception during configuration : " << ex << std::endl;
		}
	}
}
예제 #2
0
파일: object.cpp 프로젝트: noda50/RubyItk
static VALUE _r2tao_invoke_request(CORBA::Request_ptr _req, bool& _raise)
{
  CORBA::ULong ret_num = 0;
  // get the ORB we're using for the request
  CORBA::ORB_var _orb  = _req->target ()->_get_orb ();

  CORBA::TypeCode_var _ret_tc = _req->return_value ().type ();
  // invoke twoway if resulttype specified (could be void!)
  if (_ret_tc->kind () != CORBA::tk_null)
  {
    if (_ret_tc->kind () != CORBA::tk_void)
      ++ret_num;

    CORBA::ULong arg_num = _req->arguments ()->count ();
    for (CORBA::ULong a=0; a<arg_num ;++a)
    {
      CORBA::NamedValue_ptr _arg = _req->arguments ()->item (a);
      if (ACE_BIT_DISABLED (_arg->flags (), CORBA::ARG_IN))
        ++ret_num;
    }

    // invoke request
    try
    {
      _req->invoke ();
    }
    catch (CORBA::UnknownUserException& user_ex)
    {
      CORBA::Any& _excany = user_ex.exception ();

      CORBA::ULong exc_len = _req->exceptions ()->count ();
      for (CORBA::ULong x=0; x<exc_len ;++x)
      {
        CORBA::TypeCode_var _xtc = _req->exceptions ()->item (x);
        if (ACE_OS::strcmp (_xtc->id (),
                            _excany._tao_get_typecode ()->id ()) == 0)
        {
          VALUE x_rtc = r2tao_Typecode_t2r(_xtc.in (), _orb.in ());
          VALUE rexc = r2tao_Typecode_Any2Ruby (_excany,
                                                _xtc.in (),
                                                x_rtc, x_rtc,
                                                _orb.in ());
          _raise = true;
          return rexc;
        }
      }

      // rethrow if we were not able to identify the exception
      // will be caught and handled in outer exception handler
      throw;
    }

    // handle result and OUT arguments
    VALUE result = (ret_num>1 ? rb_ary_new () : Qnil);

    if (_ret_tc->kind () != CORBA::tk_void)
    {
      CORBA::Any& retval = _req->return_value ();
      VALUE result_type = r2tao_Typecode_t2r(_ret_tc.in (), _orb.in ());
      // return value
      if (ret_num>1)
        rb_ary_push (result, r2tao_Typecode_Any2Ruby (retval, _ret_tc.in (), result_type, result_type, _orb.in ()));
      else
        result = r2tao_Typecode_Any2Ruby (retval, _ret_tc.in (), result_type, result_type, _orb.in ());

      --ret_num; // return value handled
    }

    // (in)out args
    if (ret_num > 0)
    {
      for (CORBA::ULong a=0; a<arg_num ;++a)
      {
        CORBA::NamedValue_ptr _arg = _req->arguments ()->item (a);
        if (ACE_BIT_DISABLED (_arg->flags (), CORBA::ARG_IN))
        {
          CORBA::TypeCode_var _arg_tc = _arg->value ()->type ();
          VALUE arg_rtc = r2tao_Typecode_t2r(_arg_tc.in (), _orb.in ());
          if (result != Qnil)
            rb_ary_push (result, r2tao_Typecode_Any2Ruby (*_arg->value (), _arg_tc.in (), arg_rtc, arg_rtc, _orb.in ()));
          else
            result = r2tao_Typecode_Any2Ruby (*_arg->value (), _arg_tc.in (), arg_rtc, arg_rtc, _orb.in ());
        }
      }
    }

    return result;
  }
  else  // invoke oneway
  {
    // oneway
    _req->send_oneway ();

    return Qtrue;
  }
}