コード例 #1
0
ファイル: server.cpp プロジェクト: asdlei00/ACE
static ostream &
operator<< (ostream & os, const CORBA::Exception & e)
{
    CORBA::Any tmp;
    tmp <<= e;
    CORBA::TypeCode_var tc = tmp.type ();
    const char * p = tc->name ();
    if (*p != '\0')
        os << p;
    else
        os << tc->id ();
    return os;
}
コード例 #2
0
void
Client_Request_Interceptor::receive_exception (
    PortableInterceptor::ClientRequestInfo_ptr ri)
{
  ++this->exception_count_;
  ACE_DEBUG ((LM_DEBUG, "received exception %d\n",
              this->exception_count_));
  if (CORBA::is_nil (this->orb_.in ()))
  {
    int argc = 0;
    ACE_TCHAR **argv = 0;
    this->orb_ = CORBA::ORB_init (argc, argv, this->orb_id_.in ());
  }

  if (this->exception_count_ == 1)
    {
      ACE_DEBUG ((LM_DEBUG, "forwarding client to the second server\n"));
      CORBA::Object_var first_forward =
        this->orb_->string_to_object (this->first_forward_str_.in ());

      // Notice that this is not a permanent forward.
      throw PortableInterceptor::ForwardRequest (first_forward.in ());
    }
  else if (this->exception_count_ == 2)
    {
      ACE_DEBUG ((LM_DEBUG, "forwarding client to the third server\n"));
      CORBA::Object_var second_forward =
        this->orb_->string_to_object (this->second_forward_str_.in ());

      // Notice that this is not a permanent forward.
      throw PortableInterceptor::ForwardRequest (second_forward.in ());
    }
  else if (this->exception_count_ == 3)
    {
      CORBA::Any_var ex = ri->received_exception ();

      CORBA::TypeCode_var tc;
      const char * id = 0;
      tc = ex->type ();
      id = tc->id ();

      if (ACE_OS_String::strcmp (id,
                                 "IDL:omg.org/CORBA/TRANSIENT:1.0") == 0)
          throw ::CORBA::TRANSIENT (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO);
    }
}
コード例 #3
0
  virtual void push_structured_event(CosNotification::StructuredEvent const& event)
    throw(CosEventComm::Disconnected)
  {
    cout << "domain_name: " << event.header.fixed_header.event_type.domain_name
	 << "  type_name: " << event.header.fixed_header.event_type.type_name << " " << flush;

    if (false) {
    Miro::Client client;
    DynamicAny::DynAnyFactory_var daf =
      client.resolveInit<DynamicAny::DynAnyFactory>("DynAnyFactory");
    DynamicAny::DynAny_var da = daf->create_dyn_any(event.remainder_of_body);
    
    CORBA::TypeCode_var tc = da->type();

    if (tc->kind() == CORBA::tk_struct) {
      CORBA::String_var name = tc->name();
      CORBA::String_var id = tc->id();

      DynamicAny::DynStruct_var ds =
	DynamicAny::DynStruct::_narrow(da);

      for (CORBA::ULong i = 0; i < ds->component_count(); ++i) {
	DynamicAny::DynAny_var member = ds->current_component();
	CORBA::String_var name = ds->current_member_name();
	if (std::string("timestamp") == name.in()) {
	  long long int i =  member->get_ulonglong();
	  ACE_Time_Value t;
	  ORBSVCS_Time::Absolute_TimeT_to_Time_Value(t, i);
	  cout << "latency: " << ACE_OS::gettimeofday() - t << endl;
	  break;
	}
	ds->next();
      }
    }
    else {
      cerr << "unknown event layout" << endl;
    }
    }
    ACE_Time_Value t;
    t.set(time_out);
    ACE_OS::sleep(t);

    cout << "waking up after sleep" << endl;
  }
コード例 #4
0
ファイル: DII_Invocation_Adapter.cpp プロジェクト: CCJY/ATCD
  void
  DII_Invocation_Adapter::invoke (TAO::Exception_Data * /*ex_data*/,
                                  unsigned long ex_count)
  {
    // Convert DII exception list to a form the invocation can use
    // to filter raised user exceptions.
    ex_count = this->exception_list_->count ();
    ACE_NEW_THROW_EX (this->ex_data_,
                      TAO::Exception_Data[ex_count],
                      CORBA::NO_MEMORY ());
    for (unsigned long l=0; l<ex_count ;++l)
    {
      CORBA::TypeCode_var xtc = this->exception_list_->item (l);
      this->ex_data_[l].id = xtc->id ();
      this->ex_data_[l].alloc = 0;
#if TAO_HAS_INTERCEPTORS == 1
      this->ex_data_[l].tc_ptr = xtc.in ();
#endif
    }

    Invocation_Adapter::invoke (this->ex_data_, ex_count);
  }
コード例 #5
0
void
Server_Request_Interceptor::send_exception (
    PortableInterceptor::ServerRequestInfo_ptr ri)
{
  CORBA::Any_var exception = ri->sending_exception ();
  CORBA::TypeCode_var tc = exception->type ();
  const char *id = tc->id ();

  CORBA::OBJECT_NOT_EXIST nonexist_exception;

  if (ACE_OS::strcmp (id, nonexist_exception._rep_id ()) == 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "SERVER (%P|%t) OBJ_NOT_EXIST exception caught for request %d\n"
                  "SERVER (%P|%t) will be forwarded to object 1\n"
                  "SERVER (%P|%t) via send_exception().\n",
                  this->request_count_ - 2));

      throw PortableInterceptor::ForwardRequest (this->obj_[0]);

    }

}
コード例 #6
0
int
TAO_Log_Constraint_Visitor::visit_special (ETCL_Special *special)
{
  try
    {
      CORBA::TypeCode_var tc = this->current_member_->type ();

      switch (special->type ())
      {
        case ETCL_LENGTH:
          {
            // If the TCKind is not a sequence or an array, the
            // call to length() will raise an exception, and the
            // catch block will return -1;
            CORBA::ULong length = tc->length ();

            TAO_ETCL_Literal_Constraint lit (length);
            this->queue_.enqueue_head (lit);
            return 0;
          }
        case ETCL_DISCRIMINANT:
          {
            // If the TCKind is not a union, the
            // call to init() will raise an exception, and the
            // catch block will return -1;
            TAO_DynUnion_i dyn_union;
            dyn_union.init (this->current_member_.in ());

            DynamicAny::DynAny_var disc =
              dyn_union.get_discriminator ();

            CORBA::Any_var disc_any = disc->to_any ();

            TAO_ETCL_Literal_Constraint lit (disc_any.ptr ());
            this->queue_.enqueue_head (lit);
            return 0;
          }
        case ETCL_TYPE_ID:
          {
            const char *name = tc->name ();

            TAO_ETCL_Literal_Constraint lit (name);
            this->queue_.enqueue_head (lit);
            return 0;
          }
        case ETCL_REPOS_ID:
          {
            const char *id = tc->id ();

            TAO_ETCL_Literal_Constraint lit (id);
            this->queue_.enqueue_head (lit);
            return 0;
          }
        default:
          return -1;
      }
    }
  catch (const CORBA::Exception&)
    {
      return -1;
    }
}
コード例 #7
0
ファイル: acsutilAnyAide.cpp プロジェクト: ACS-Community/ACS
//----------------------------------------------------------------------
std::string
AnyAide::getId(const CORBA::Any& any)
{
    CORBA::TCKind kind = getRealType(any);
    
    //great - the identifier is already provided
    if ((kind==CORBA::tk_objref) ||
	(kind==CORBA::tk_struct) ||
	(kind==CORBA::tk_union)  ||
	(kind==CORBA::tk_enum)   ||
	(kind==CORBA::tk_except))
	{
	//have to create an _var type because this is actually a CORBA object
	CORBA::TypeCode_var tc;
	//get the type from the any
	tc = any.type();
	return std::string(tc->id());
	}
    else if(kind==CORBA::tk_null)
	{
	return nullType_m;
	}
    else if(kind==CORBA::tk_string)
	{
	return stringType_m;
	}
    else if(kind==CORBA::tk_double)
	{
	return doubleType_m;
	}
    else if(kind==CORBA::tk_long)
	{
	return longType_m;
	}
    else if(kind==CORBA::tk_ulong)
	{
	return uLongType_m;
	}
    else if(kind==CORBA::tk_longlong)
	{
	return longLongType_m;
	}
    else if(kind==CORBA::tk_ulonglong)
	{
	return uLongLongType_m;
	}
    else if(kind==CORBA::tk_float)
	{
	return floatType_m;
	}
    //aliases can be ...
    else if(kind==CORBA::tk_alias)
	{
	//first get a hold of the IFR id
	CORBA::TypeCode_var tc;
	//get the type from the any
	tc = any.type();

	return std::string(tc->id());
	}
    // after TAO 1.5.2 we have to handel seqence separatly
    else if (kind==CORBA::tk_sequence)
	{
//!!! here we play dirty !!!
// this solution does not work with seq of seq
// we can change it but first we have to change it on the places where seqences are used !!
	CORBA::TypeCode_var tc;
	//get the type from the any
	tc = any.type();
	//create another any with type of content type (long/double ..)
	CORBA::Any a;
	a._tao_set_typecode(tc->content_type());
	// get recursivly the ID of contained type
	std::string c = getId(a);
	return std::string("IDL:alma/ACS/" + c + "Seq:1.0"); // very dirty but should be OK 
	}
    
    //bad case
    else
	{
	UnsupportedType except;
	except.type = unknownType_m;
	throw except;
	}
}
コード例 #8
0
ファイル: client.cpp プロジェクト: CCJY/ATCD
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  //init IFR objref
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      TAO_IFR_Client_Adapter *ifr_client =
        ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance (
          TAO_ORB_Core::ifr_client_adapter_name ());

      if (ifr_client == 0)
        {
          throw ::CORBA::INTF_REPOS ();
        }

      ACE_DEBUG ((LM_DEBUG, "Got IFR_Client ref.\n"));

      CORBA::InterfaceDef_var intDef =
        ifr_client->get_interface (orb.in (), "IDL:IFR_Test/test_if:1.0");

      if (CORBA::is_nil (intDef.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                            "get interface returned nil ref\n"),
                            1);
        }

      CORBA::ContainedSeq_var attributes =
        intDef->contents (CORBA::dk_Attribute, 1);
      CORBA::ULong n_ats = attributes->length ();

      CORBA::ULong index = 0UL;
      CORBA::String_var name = attributes[index]->name ();
      ACE_DEBUG ((LM_DEBUG,
                  "found %d attributes, name = %s\n",
                  n_ats,
                  name.in ()));

      CORBA::AttributeDef_var attr =
        CORBA::AttributeDef::_narrow (attributes[index]);

      if (CORBA::is_nil (attr.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                            "could not narrow attribute ref\n"),
                            1);
        }

      CORBA::TypeCode_var tc = attr->type ();

      ACE_DEBUG ((LM_DEBUG, "foo attr typecode = %s\n", tc->id ()));
    }
  catch (const ::CORBA::Exception &ex)
    {
      ex._tao_print_exception("ERROR : unexpected CORBA exception caugth :");
      return 1;
    }

  return 0;
}
コード例 #9
0
ファイル: DII_Invocation.cpp プロジェクト: OspreyHub/ATCD
  Invocation_Status
  DII_Invocation::handle_user_exception (TAO_InputCDR &cdr)
  {
    Reply_Guard mon (this, TAO_INVOKE_FAILURE);

    if (TAO_debug_level > 3)
      {
        TAOLIB_DEBUG ((LM_DEBUG,
                    "TAO (%P|%t) - DII_Invocation::"
                    "handle_user_exception\n"));
      }

    // Match the exception interface repository id with the
    // exception in the exception list.
    // This is important to decode the exception.
    CORBA::String_var buf;

    TAO_InputCDR tmp_stream (cdr,
                             cdr.start ()->length (),
                             0);

    // Pull the exception ID out of the marshaling buffer.
    if (tmp_stream.read_string (buf.inout ()) == 0)
      {
        throw ::CORBA::MARSHAL (TAO::VMCID, CORBA::COMPLETED_YES);
      }

    for (CORBA::ULong i = 0;
         this->excp_list_ != 0 && i < this->excp_list_->count ();
         i++)
      {
          CORBA::TypeCode_var tc = this->excp_list_->item (i);

          const char *xid = tc->id ();

          if (ACE_OS::strcmp (buf.in (), xid) != 0)
            {
              continue;
            }

          CORBA::Any any;
          TAO::Unknown_IDL_Type *unk = 0;
          ACE_NEW_RETURN (unk,
                          TAO::Unknown_IDL_Type (
                              tc.in (),
                              cdr
                            ),
                          TAO_INVOKE_FAILURE);

          any.replace (unk);

          mon.set_status (TAO_INVOKE_USER_EXCEPTION);

          throw ::CORBA::UnknownUserException (any);
        }

    // If we couldn't find the right exception, report it as
    // CORBA::UNKNOWN.

    // But first, save the user exception in case we
    // are being used in a TAO gateway.
    this->host_->raw_user_exception (cdr);

    mon.set_status (TAO_INVOKE_USER_EXCEPTION);

    // @@ It would seem that if the remote exception is a
    //    UserException we can assume that the request was
    //    completed.
    throw ::CORBA::UNKNOWN (TAO::VMCID, CORBA::COMPLETED_YES);

  }