• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ portableserver::ServantBase_var类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中portableserver::ServantBase_var的典型用法代码示例。如果您正苦于以下问题:C++ ServantBase_var类的具体用法?C++ ServantBase_var怎么用?C++ ServantBase_var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ServantBase_var类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: BAD_PARAM

void
ArrayDef_impl::element_type_def
(IR__::IDLType_ptr type)
throw(CORBA::SystemException)
{
	DEBUG_OUTLINE ( "ArrayDef_impl::element_type_def(...) called " );

	if ( CORBA::is_nil ( type ) )
	{
		DEBUG_ERRLINE ( "nil object reference passed to ArrayDef_impl::element_type_def()" );
		throw CORBA::BAD_PARAM();
	}

	IDLType_impl* impl = 0;

    try
    {
		PortableServer::ServantBase_var servant = 
			repository_ -> poa() -> reference_to_servant(type);
        impl = dynamic_cast<IDLType_impl*>(servant.in());
    }
    catch(...)
    {
    }
    if(!impl)
    {
        // Must be in the same repository
        throw CORBA::BAD_PARAM(4, CORBA::COMPLETED_NO);
    }

	impl -> _add_ref();
	if(element_type_)
		element_type_ -> _remove_ref();
	element_type_ = impl;
}
开发者ID:BackupTheBerlios,项目名称:qedo-svn,代码行数:35,代码来源:Anonymous.cpp


示例2: BAD_PARAM

void
AliasDef_impl::original_type_def
(IR__::IDLType_ptr original_idl_type )
throw(CORBA::SystemException)
{
	DEBUG_OUTLINE ( "AliasDef_impl::original_type_def(...) called" );

    if ( CORBA::is_nil ( original_idl_type ) )
        throw CORBA::BAD_PARAM(); // Is this exception correct?

    IDLType_impl* impl = 0;
    try
    {
		PortableServer::ServantBase_var servant = 
			repository_ -> poa() -> reference_to_servant ( original_idl_type );
        impl = dynamic_cast<IDLType_impl*>(servant.in());
    }
    catch(...)
    {
    }
    if(!impl)
    {
        // Must be same repository
        throw CORBA::BAD_PARAM ( 4, CORBA::COMPLETED_NO );
    }

    impl -> _add_ref();
    
	if ( original_idl_type_impl_ )
        original_idl_type_impl_ -> _remove_ref();

    original_idl_type_impl_ = impl;
}
开发者ID:BackupTheBerlios,项目名称:qedo-svn,代码行数:33,代码来源:AliasDef_impl.cpp


示例3: BAD_PARAM

void
AttributeDef_impl::type_def
(IR__::IDLType_ptr type )
throw(CORBA::SystemException)
{
    if ( CORBA::is_nil ( type ) )
        throw CORBA::BAD_PARAM(); // Is this exception correct?

    IDLType_impl* impl = 0;
    try
    {
		PortableServer::ServantBase_var servant = repository_ -> poa() -> reference_to_servant(type);
        impl = dynamic_cast<IDLType_impl*>(servant.in());
    }
    catch(...)
    {
    }
    if(!impl)
    {
        // Must be same repository
        throw CORBA::BAD_PARAM ( 4, CORBA::COMPLETED_NO );
    }

    impl -> _add_ref();
    if ( idl_type_ )
        idl_type_ -> _remove_ref();
    idl_type_ = impl;
}
开发者ID:BackupTheBerlios,项目名称:qedo,代码行数:28,代码来源:AttributeDef_impl.cpp


示例4: BAD_PARAM

void
ConstantDef_impl::type_def
(IR__::IDLType_ptr idl_type)
throw(CORBA::SystemException)
{
    if(CORBA::is_nil(idl_type))
        throw CORBA::BAD_PARAM();

    IDLType_impl* impl = 0;
    try
    {
		PortableServer::ServantBase_var servant = repository_ -> poa() -> reference_to_servant(idl_type);
        impl = dynamic_cast<IDLType_impl*>(servant.in());
    }
    catch(...)
    {
    }
    if(!impl)
    {
        // The idl type object must be in the same repository
        throw CORBA::BAD_PARAM ( 4, CORBA::COMPLETED_NO );
    }

    impl -> _add_ref();
    if(idl_type_)
        idl_type_ -> _remove_ref();
    idl_type_ = impl;
}
开发者ID:BackupTheBerlios,项目名称:qedo,代码行数:28,代码来源:ConstantDef_impl.cpp


示例5: TestException

Callback_ptr
ServerApp::create_callback(
    PortableServer::POA_ptr poa,
    const char* servant_name)
{
    PortableServer::ServantBase_var servant
        = new Callback_i();

    PortableServer::ObjectId_var id =
        PortableServer::string_to_ObjectId("callback");

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

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

    if (CORBA::is_nil(obj.in()))
    {
        ACE_ERROR((LM_ERROR,
                   "(%P|%t) Failed to activate servant (%s).\n",
                   servant_name));
        throw TestException();
    }

    Callback_var callback = Callback::_narrow (obj.in ());

    return callback._retn ();
}
开发者ID:akostrikov,项目名称:ATCD,代码行数:27,代码来源:ServerApp.cpp


示例6: catch

int
TAO_FT_Naming_Server::update_naming_context (
    const FT_Naming::NamingContextUpdate & context_info)
{
  ACE_GUARD_THROW_EX (ACE_SYNCH_RECURSIVE_MUTEX,
                      ace_mon,
                      this->lock_,
                      CORBA::INTERNAL ());

  PortableServer::ServantBase_var servant;

  // Lookup the servant for the identified context and see if it is
  // active here locally.
  try {
    // Get the servant if it exists in this process
    PortableServer::ObjectId_var context_id =
      PortableServer::string_to_ObjectId (context_info.context_name);
    servant = this->ns_poa_->id_to_servant (context_id);
  }
  catch (PortableServer::POA::ObjectNotActive&)
  { // No servant registered for this object reference so no need to create it.
    // It will be created on first access in incarnate function

    // This context is not currently active in this server so
    // there is nothing to be done, so return success.
    return 0;
  }

  TAO_Naming_Context* changed_context_servant =
    dynamic_cast<TAO_Naming_Context*> (servant.in ());

  if (changed_context_servant == 0)
  { // Another type of class was used as the servant. Should not happen.
    ORBSVCS_ERROR ((LM_ERROR,
               ACE_TEXT ("(%P|%t) ERROR: Invalid servant type registered")
               ACE_TEXT (" with oid: %s"),
               context_info.context_name.in ()));
    return -1;
  }

  if (TAO_debug_level > 3)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("%T %n (%P|%t) - ")
                  ACE_TEXT ("An update of naming context with name %s ")
                  ACE_TEXT ("has been made by the peer"),
                  context_info.context_name.in ()
                  ));
    }

  // Mark the local context stale, so we will reload it next
  // time it is modified or accessed.
  changed_context_servant->stale (true);

  return 0;
}
开发者ID:milan-mpathix,项目名称:ATCD,代码行数:56,代码来源:FT_Naming_Server.cpp


示例7: policies

void
Quoter_Stock_Factory_i::load_stock_objects (
      PortableServer::POA_ptr poa,
      PortableServer::POAManager_ptr poa_manager,
      RtecEventChannelAdmin::SupplierAdmin_ptr supplier_admin)
{
  if (!CORBA::is_nil (this->stock_factory_poa_.in ()))
    return;

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

  policies[0] =
    poa->create_id_assignment_policy (PortableServer::USER_ID);
  policies[1] =
    poa->create_implicit_activation_policy (PortableServer::NO_IMPLICIT_ACTIVATION);

  this->stock_factory_poa_ =
    poa->create_POA ("Stock_Factory_POA",
                     poa_manager,
                     policies);

  for (CORBA::ULong i = 0; i != policies.length (); ++i) {
    policies[i]->destroy ();
  }

  while (!cin.eof () && cin.peek () != EOF) {
    const int max_symbol_length = 8;
    char symbol[max_symbol_length];
    const int max_full_name_length = 64;
    char full_name[max_full_name_length];
    double price;

    cin.getline (symbol, max_symbol_length, '\n');
    cin.getline (full_name, max_full_name_length, '\n');
    cin >> price;
    cin.ignore (1, '\n');

    Quoter_Stock_i *stock =
      new Quoter_Stock_i (symbol, full_name, price);

    PortableServer::ServantBase_var servant = stock;

    PortableServer::ObjectId_var oid =
      PortableServer::string_to_ObjectId (symbol);

    this->stock_factory_poa_->activate_object_with_id (oid.in (),
                                                       servant.in ());
    stock->connect (supplier_admin);
  }
}
开发者ID:CCJY,项目名称:ATCD,代码行数:51,代码来源:Stock_Factory_i.cpp


示例8: BAD_PARAM

IR__::ComponentDef_ptr
Container_impl::create_component
(const char* id,
 const char* name,
 const char* version,
 IR__::ComponentDef_ptr base_component,
 const IR__::InterfaceDefSeq& supports_interfaces)
throw(CORBA::SystemException)
{
	DEBUG_OUTLINE ( "Container_impl::create_component() called" );

	if ( repository_ -> check_for_id ( id ) )
		throw CORBA::BAD_PARAM ( 2, CORBA::COMPLETED_NO );
	if ( check_for_name ( name ) )
		throw CORBA::BAD_PARAM ( 3, CORBA::COMPLETED_NO );

    ComponentDef_impl* impl = 0;

	// Test the base component if there is one
	if ( !CORBA::is_nil ( base_component ) )
	{
		try
		{
			PortableServer::ServantBase_var servant =
				repository_ -> poa() -> reference_to_servant ( base_component );
			impl = dynamic_cast<ComponentDef_impl*>(servant.in());
		}
		catch(...)
		{
		}
		if(!impl)
		{
			// Must be same repository
			throw CORBA::BAD_PARAM ( 4, CORBA::COMPLETED_NO );
		}
	}

	ComponentDef_impl *new_component = new ComponentDef_impl ( this, repository_, impl );

	new_component -> id ( id );
	new_component -> name ( name );
	new_component -> version ( version );
	new_component -> supported_interfaces ( supports_interfaces );

	repository_ -> _add_ref();
	this -> _add_ref();

	return new_component -> _this();
}
开发者ID:BackupTheBerlios,项目名称:qedo-svn,代码行数:49,代码来源:Container_impl.cpp


示例9: BAD_PARAM

SegmentDef_impl::SegmentDef_impl
( Container_impl *container,
  Repository_impl *repository,
  IR__::ProvidesDefSeq provided_facets,
  IR__::StorageHomeDef_ptr stored_on)
: IRObject_impl ( repository ),
  Contained_impl ( container, repository )
{
	DEBUG_OUTLINE ( "SegmentDef_impl::SegmentDef_impl() called" );

    unsigned int i;

    vector < ProvidesDef_impl* > impl_seq;
    impl_seq.resize ( provided_facets.length(), NULL );

    for ( i = 0; i < provided_facets.length(); i++ )
    {
        if ( CORBA::is_nil ( provided_facets[i] ) )
            throw CORBA::BAD_PARAM(); // Is this exception correct?

        impl_seq[i] = 0;

        try
        {
			PortableServer::ServantBase_var servant =
				repository_ -> poa() -> reference_to_servant(provided_facets[i]);
            impl_seq[i] = dynamic_cast<ProvidesDef_impl*>(servant.in());
        }
        catch(...)
        {
        }
        if(!impl_seq[i])
        {
            // Must be same repository
            throw CORBA::BAD_PARAM(4, CORBA::COMPLETED_NO);
        }
    }

    for ( i = 0; i < impl_seq.size(); i++ )
        impl_seq[i] -> _add_ref();

    for ( i = 0; i < provided_facet_impls_.size(); i++)
        provided_facet_impls_[i] -> _remove_ref();

    provided_facet_impls_ = impl_seq;
	stored_on_ = stored_on;
}
开发者ID:BackupTheBerlios,项目名称:qedo-svn,代码行数:47,代码来源:SegmentDef_impl.cpp


示例10: ftr

void
ReplicaController::send_reply (
  PortableInterceptor::ServerRequestInfo_ptr ri)
{
  FT::FTRequestServiceContext_var ftr (
    extract_context (ri));


  ACE_DEBUG ((LM_DEBUG,
              "(%P|%t) Sending reply for %s with rid %i\n",
              ftr->client_id.in (),
              ftr->retention_id));


  // Prepare reply for logging.

  CORBA::Any_var result =
    ri->result ();

  TAO_OutputCDR cdr;
  result->impl ()->marshal_value (cdr);

  Dynamic::ParameterList_var pl =
    ri->arguments ();

  CORBA::ULong len = pl->length ();

  for (CORBA::ULong index = 0; index != len ; ++index)
  {
    //@@ No chance for PARAM_OUT
    if ((*pl)[index].mode == CORBA::PARAM_INOUT)
    {
      (*pl)[index].argument.impl ()->marshal_value (cdr);
    }
  }

  CORBA::OctetSeq_var reply;

  ACE_NEW (reply.out (), CORBA::OctetSeq (cdr.total_length ()));

  reply->length (cdr.total_length ());

  CORBA::Octet* buf = reply->get_buffer ();

  // @@ What if this throws an exception??  We don't have any way to
  // check whether this succeeded
  for (ACE_Message_Block const* mb = cdr.begin ();
       mb != 0;
       mb = mb->cont ())
  {
    ACE_OS::memcpy (buf, mb->rd_ptr (), mb->length ());
    buf += mb->length ();
  }

  // Logging the reply and state update.
  //

  // First send message to members.
  //
  {
    // Extract state update.

    CORBA::OctetSeq_var oid = ri->object_id ();
    PortableInterceptor::AdapterName_var an = ri->adapter_name ();

    CORBA::Any_var state = ri->get_slot (state_slot_id ());

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

    if (tc->kind () == CORBA::tk_null)
    {
      ACE_DEBUG ((LM_DEBUG, "Slot update is void\n"));

      PortableServer::POA_var poa = resolve_poa (an.in ());

      PortableServer::ServantBase_var servant =
        poa->id_to_servant (oid.in ());

      Checkpointable* target =
        dynamic_cast<Checkpointable*> (servant.in ());

      if (target)
      {
        CORBA::Any_var tmp = target->get_state ();

        if (tmp.ptr () != 0) state = tmp._retn ();
      }
    }

    TAO_OutputCDR cdr;

    cdr << oid.in ();
    cdr << an.in ();
    cdr << ftr->client_id.in ();
    cdr << ftr->retention_id;
    cdr << reply.in ();
    cdr << state.in ();

    size_t size = cdr.total_length ();

//.........这里部分代码省略.........
开发者ID:CCJY,项目名称:ATCD,代码行数:101,代码来源:ReplicaController.cpp


示例11: policies

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{

  try
    {
      // Initialize the ORB.
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      // Obtain the RootPOA.
      CORBA::Object_var object =
        orb->resolve_initial_references ("RootPOA");

      // Narrow to POA.
      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (object.in ());

      // Get the POAManager of the RootPOA.
      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

      // Policies for the new POA.
      CORBA::PolicyList policies (3);
      policies.length (3);

      // Request Processing Policy.
      policies[0] =
        root_poa->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT);

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

      // Servant Retention Policy.
      policies[2] =
        root_poa->create_servant_retention_policy (PortableServer::NON_RETAIN);

      // Create POA to host default servant.
      ACE_CString name = "Default Servant";
      PortableServer::POA_var default_servant_poa =
        root_poa->create_POA (name.c_str (),
                              poa_manager.in (),
                              policies);

      // Destroy policies.
      for (CORBA::ULong i = 0;
           i < policies.length ();
           ++i)
        {
          CORBA::Policy_ptr policy = policies[i];
          policy->destroy ();
        }

      // Activate POA manager.
      poa_manager->activate ();

      test_reference_to_servant_active_object(root_poa.in ());

      // Test servant.
      test_i test;
      CORBA::ULong expected_refcount = 1;

      (void) test_get_servant_with_no_set (default_servant_poa.in());

      (void) test_get_servant_manager (default_servant_poa.in());

      (void) test_set_servant_manager (default_servant_poa.in());

      // Register default servant.
      default_servant_poa->set_servant (&test);
      expected_refcount++;

      // Create dummy id.
      PortableServer::ObjectId_var id =
        PortableServer::string_to_ObjectId ("id");

      // Create dummy object.
      object =
        default_servant_poa->create_reference ("IDL:test:1.0");

      // Invoke id_to_servant(). Should retrieve default servant.
      PortableServer::ServantBase_var servant =
        default_servant_poa->id_to_servant (id.in ());
      expected_refcount++;

      // Assert correctness.
      ACE_ASSERT (&test == servant.in());

      // Invoke reference_to_servant(). Should retrieve default servant.
      servant =
        default_servant_poa->reference_to_servant (object.in ());
      expected_refcount++;

      // Assert correctness.
      ACE_ASSERT (&test == servant.in());

      // Report success.
      ACE_DEBUG ((LM_DEBUG,
                  "Default_Servant test successful\n"));

//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,代码来源:Default_Servant.cpp


示例12: InitError


//.........这里部分代码省略.........
		list.length(in_points.size());
		if (Lorica_debug_level > 2) {
			ACE_DEBUG((LM_DEBUG,
				   ACE_TEXT("(%T) %N:%l - setting up Internal POA manager with %d endpoints\n"),
				   in_points.size()));
		}
		for (size_t count = 0; count < in_points.size(); count++) {
			std::string inter = in_points[count].hostname_;
			if (!in_points[count].alias_.empty())
				inter = in_points[count].alias_;

			list[count] = new IIOPEndpointValue_i(inter.c_str(),
							      in_points[count].port_);
		}
		policy_value <<= list;
		policies[0] = orb_->create_policy(EndpointPolicy::ENDPOINT_POLICY_TYPE,
						  policy_value);
		inside_pm_ = pmf_->create_POAManager("InsidePOAManager",
						     policies);

		if (Lorica_debug_level > 2) {
			ACE_DEBUG((LM_DEBUG,
				   ACE_TEXT("(%T) %N:%l - creating admin POA with internal POA manager\n")));
		}
		policies.length(0);
		admin_poa_ = root_poa_->create_POA("adminPOA",
						   inside_pm_.in(),
						   policies);

		try {
			ReferenceMapper_i *refMapper = new ReferenceMapper_i(orb_.in(),
									     iorTable_.in(),
									     config.secure_available());
			PortableServer::ServantBase_var refMapperServant = refMapper;

			PortableServer::ObjectId_var oid = admin_poa_->activate_object(refMapperServant.in());
			obj = admin_poa_->id_to_reference(oid.in());

			// refMapper->allow_insecure_access (obj.in());
		}
		catch (CORBA::Exception & ex) {
			ACE_DEBUG((LM_ERROR, ACE_TEXT("(%T) %N:%l - %s\n"), ex._info().c_str()));
			throw InitError();
		}

		ReferenceMapper_var refMapper_obj = ReferenceMapper::_narrow(obj.in());

		CORBA::String_var ior = 
			orb_->object_to_string(refMapper_obj.in());
		iorTable_->bind(Lorica::ReferenceMapper::IOR_TABLE_KEY,
				ior.in());

		this->ior_file_ = config.get_value("IOR_FILE", def_ior_file);

		FILE *output_file =
			ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR (this->ior_file_.c_str()), ACE_TEXT("w"));
		if (!output_file) {
			ACE_ERROR((LM_ERROR,
				   "(%T) %N:%l - cannot open output file for writing IOR: %s\n",
				   this->ior_file_.c_str()));
			throw InitError();
		}
		ACE_OS::fprintf(output_file, "%s", ior.in());
		ACE_OS::fclose(output_file);

		if (!setup_shutdown_handler()) {
开发者ID:colding,项目名称:lorica,代码行数:67,代码来源:proxy.cpp


示例13: policies

int
main (int argc, char *argv[])
{
	try
	{
		orb = CORBA::ORB_init (argc, argv, "");

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

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

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

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

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

		CORBA::PolicyList policies(2);
    policies.length(2);
		policies[0] = 
			root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
		policies[1] = 
			root_poa->create_id_assignment_policy(PortableServer::USER_ID);

		PortableServer::POA_var child_poa = 
			root_poa->create_POA ("persistent", poa_manager.in(), policies);

		poa_manager->activate();

		PortableServer::ServantBase_var servant (new Hello);

		PortableServer::ObjectId_var oid = 
			PortableServer::string_to_ObjectId ("gctest");
    child_poa->activate_object_with_id (oid.in(), servant.in() );
		CORBA::Object_var obj = child_poa->id_to_reference (oid.in());
		Test::Hello_var hello = Test::Hello::_narrow (obj.in());

		if (!no_register) 
			{
				obj = orb->string_to_object (lorica_ior);

				mapper = Lorica::ReferenceMapper::_narrow(obj.in());
				if (CORBA::is_nil(mapper.in()))
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Cannot get reference to Lorica "
														 "reference mapper\n"),1);

				obj = mapper->as_server(hello.in(),"Hello",
																Lorica::ServerAgent::_nil());

				if (CORBA::is_nil (obj.in()))
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Lorica reference mapper returned a nil "
														 "mapped reference.\n"),1);
				mapped_hello = Test::Hello::_narrow(obj.in());
				if (CORBA::is_nil(mapped_hello.in()))
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Lorica reference mapper returned an "
														 "incorrectly typed reference\n"),1);

				CORBA::String_var orig_ior =
					orb->object_to_string (hello.in ());
				CORBA::String_var mapped_ior =
					orb->object_to_string (mapped_hello.in());

				if (ACE_OS::strcmp (orig_ior.in(), mapped_ior.in()) == 0)
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Lorica reference mapper returned "
														 "the original reference unmapped.\n"),1);

				ACE_DEBUG ((LM_DEBUG,"writing original IOR to file %s\n",orig_file));
				ACE_DEBUG ((LM_DEBUG,"writing mapped IOR to file %s\n",mapped_file));
				ACE_DEBUG ((LM_DEBUG,"Size of orig IOR = %d, size of mapped = %d\n",
										ACE_OS::strlen(orig_ior.in()),
										ACE_OS::strlen(mapped_ior.in())));

				FILE *output_file= ACE_OS::fopen (mapped_file, "w");
				if (output_file == 0)
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Cannot open output file for writing IOR: %s\n",
														 mapped_file),
														1);
				ACE_OS::fprintf (output_file, "%s", mapped_ior.in());
				ACE_OS::fclose (output_file);
		
				output_file= ACE_OS::fopen (orig_file, "w");
				if (output_file == 0)
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Cannot open output file for writing IOR: %s\n",
														 orig_file),
														1);
				ACE_OS::fprintf (output_file, "%s", orig_ior.in());
				ACE_OS::fclose (output_file);
//.........这里部分代码省略.........
开发者ID:colding,项目名称:lorica,代码行数:101,代码来源:server.cpp


示例14: worker

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

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

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

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

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

      PortableServer::ServantBase_var impl;
      {
        Echo * tmp = 0;
        // ACE_NEW_RETURN is the worst possible way to handle
        // exceptions (think: what if the constructor allocates memory
        // and fails?), but I'm not in the mood to fight for a more
        // reasonable way to handle allocation errors in ACE.
        ACE_NEW_RETURN (tmp,
                        Echo(orb.in(), 1000 / serverthreads),
                        1);
        impl = tmp;
      }

      PortableServer::ObjectId_var id =
        root_poa->activate_object (impl.in ());

      CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());

      Test::Echo_var echo =
        Test::Echo::_narrow (object_act.in ());

      CORBA::Object_var tmp =
        orb->string_to_object(ior);

      Test::Echo_Caller_var server =
        Test::Echo_Caller::_narrow(tmp.in ());

      if (CORBA::is_nil (server.in ()))
        {
          ACE_ERROR_RETURN ((LM_DEBUG,
                             "Nil Test::Echo_Caller reference <%s>\n",
                             ior),
                            1);
        }

      poa_manager->activate ();

      ORB_Task worker (orb.in());
      worker.activate (THR_NEW_LWP | THR_JOINABLE,
                       serverthreads);

      try
        {
          for(int i = serverthreads; i; --i)
            {
              server->start_task(echo.in());
            }
        }
      catch (...)
        {
        }

      Client_Timer * task = new Client_Timer (orb->orb_core()->reactor());
      task->activate ();
      task->remove_reference ();

      orb->run ();

      worker.wait ();

      ACE_DEBUG ((LM_DEBUG,
                  "(%P|%t) client - event loop finished\n"));

      // Actually the code here should never be reached.
      root_poa->destroy (1, 1);

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

  return 0;
//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,代码来源:client.cpp


示例15: ActivatorReceiver

bool
AsyncAccessManager::send_start_request (void)
{
  if (ImR_Locator_i::debug () > 4)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) AsyncAccessManager::send_start_request, manual_start_ %d\n"),
                      this->manual_start_));
    }

  if ((this->locator_.opts ()->lockout () && !this->info_.edit ()->start_allowed ()) ||
      (this->retries_ == 0))
    {
      this->status (ImplementationRepository::AAM_RETRIES_EXCEEDED);
      return false;
    }

  --this->retries_;

  if (this->info_->is_mode (ImplementationRepository::MANUAL) &&
      !this->manual_start_)
    {
      this->status (ImplementationRepository::AAM_NOT_MANUAL);
      return false;
    }

  const Server_Info *startup = this->info_->active_info ();

  if (startup->cmdline.length () == 0)
    {
      this->status (ImplementationRepository::AAM_NO_COMMANDLINE);
      return false;
    }

  Activator_Info_Ptr ainfo =
    this->locator_.get_activator (startup->activator);

  if (ainfo.null () || CORBA::is_nil (ainfo->activator.in ()))
    {
      this->status (ImplementationRepository::AAM_NO_ACTIVATOR);
      return false;
    }

  PortableServer::ServantBase_var callback = new ActivatorReceiver (this,
                                                                    this->poa_.in());
  PortableServer::ObjectId_var oid = this->poa_->activate_object (callback.in());
  CORBA::Object_var obj = this->poa_->id_to_reference (oid.in());
  ImplementationRepository::AMI_ActivatorHandler_var cb =
    ImplementationRepository::AMI_ActivatorHandler::_narrow (obj.in());

  ACE_CString servername;

  if (this->info_->is_mode (ImplementationRepository::PER_CLIENT))
    {
      servername = startup->key_name_;
    }
  else
    {
      servername = unique_prefix + startup->key_name_;
    }

  ainfo->activator->sendc_start_server (cb.in(),
                                        servername.c_str (),
                                        startup->cmdline.c_str (),
                                        startup->dir.c_str (),
                                        startup->env_vars);
  this->update_status (ImplementationRepository::AAM_ACTIVATION_SENT);
  return true;
}
开发者ID:opensourcecodeformyself,项目名称:ATCD,代码行数:69,代码来源:AsyncAccessManager.cpp


示例16: cdr

void ReplicaController::
listener ()
{
  try
  {
    for (char buffer[1024];;)
    {
      size_t n = group_->recv (buffer, sizeof (buffer));

      ACE_HEX_DUMP ((LM_DEBUG, buffer, n));

      TAO_InputCDR cdr (buffer, n);

      CORBA::OctetSeq object_id;
      PortableInterceptor::AdapterName adapter_name;
      CORBA::String_var client_id;
      CORBA::Long retention_id;
      CORBA::OctetSeq reply;
      CORBA::Any state;

      cdr >> object_id;
      cdr >> adapter_name;
      cdr >> client_id.out ();
      cdr >> retention_id;
      cdr >> reply;
      cdr >> state;

      if (!cdr.good_bit ())
      {
        ACE_DEBUG ((LM_DEBUG, "CDR failed\n"));
        //@@ what to do?
      }

      ACE_DEBUG ((LM_DEBUG,
                  "Received log for %s with rid %i\n",
                  client_id.in (),
                  retention_id));


      RecordId rid (client_id.in (), retention_id);

      CORBA::OctetSeq_var tmp (new CORBA::OctetSeq (reply));
      log_.insert (rid, tmp);

      // Update state.
      CORBA::TypeCode_var tc = state.type ();

      if (tc->kind () != CORBA::tk_null)
      {
        PortableServer::POA_var poa = resolve_poa (adapter_name);

        PortableServer::ServantBase_var servant =
          poa->id_to_servant (object_id);

        Checkpointable* target =
          dynamic_cast<Checkpointable*> (servant.in ());

        if (target) target->set_state (state);
      }
    }
  }
  catch (ACE_TMCast::Group::Failed const&)
  {
    ACE_DEBUG ((LM_DEBUG,
                "Group failure. Perhaps, I am alone in the group.\n"));
  }
  catch (ACE_TMCast::Group::InsufficienSpace const&)
  {
    ACE_DEBUG ((LM_DEBUG, "Group::InsufficienSpace\n"));
  }

  orb_->shutdown (0);
}
开发者ID:CCJY,项目名称:ATCD,代码行数:73,代码来源:ReplicaController.cpp


示例17: catch

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

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

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

      Hello_impl * h = 0;
      ACE_NEW_RETURN (h,Hello_impl, 1);

      CORBA::ULong before_act = h->_refcount_value ();

      ACE_DEBUG ((LM_DEBUG, "Before activation: %d\n", before_act));

      PortableServer::ObjectId_var oid = poa->activate_object (h);

      CORBA::ULong after_act = h->_refcount_value ();

      ACE_DEBUG ((LM_DEBUG, "After activation: %d\n", after_act));
        {
          /*
           * C++ Language Mapping (formal/03-06-03), section 1.37.3 (Servant
           * Memory Management Considerations), first bullet on page 1-136:
           *
           *   POA::id_to_servant returns a Servant. The POA invokes _add_ref
           *   once on the Servant before returning it; the caller of
           *   id_to_servant is responsible for invoking _remove_ref on the
           *   returned servant when it is finished with it.
           */

          CORBA::ULong refCountBeforeIdToServant =
            h->_refcount_value ();

          ACE_DEBUG ((LM_DEBUG, "Before id_to_servant:  %d\n", refCountBeforeIdToServant));

          PortableServer::ServantBase_var srv = poa->id_to_servant (oid.in());

          CORBA::ULong refCountAfterIdToServant =
            srv->_refcount_value ();;

          ACE_DEBUG ((LM_DEBUG, "After id_to_servant:  %d\n", refCountAfterIdToServant));

           /*
           * According to the above quote, this assertion shall be true.
           */
          ACE_ASSERT (refCountAfterIdToServant == refCountBeforeIdToServant + 1);

          /*
           * At the end of this scope, "srv" is destructed, which decrements
           * the servant's reference count.
           */
        }

      CORBA::ULong before_deact = h->_refcount_value ();

      ACE_DEBUG ((LM_DEBUG, "Before deactivate_object: %d\n", before_deact));

      poa->deactivate_object (oid.in());

      /*
       * Because id_to_servant did not increment the reference count, but
       * the reference count was decremented by the "srv" destructor, the
       * reference count, using TAO 1.4.5, is now 0, and the servant has
       * been destructed. So the following will crash, despite being
       * correct.
       */

      CORBA::ULong after_deact = h->_refcount_value ();

      ACE_DEBUG ((LM_DEBUG, "After deactivate_object: %d\n", after_deact));

      h->_remove_ref ();

      orb->shutdown (1);

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

  return 0;
}
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:97,代码来源:test.cpp



注:本文中的portableserver::ServantBase_var类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ positionstopmap::ConstIterator类代码示例发布时间:2022-05-31
下一篇:
C++ portableserver::Servant类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap