当前位置: 首页>>代码示例>>C++>>正文


C++ ORB_var::create_policy方法代码示例

本文整理汇总了C++中corba::ORB_var::create_policy方法的典型用法代码示例。如果您正苦于以下问题:C++ ORB_var::create_policy方法的具体用法?C++ ORB_var::create_policy怎么用?C++ ORB_var::create_policy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corba::ORB_var的用法示例。


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

示例1: policies

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");

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

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

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

      // Policies for the childPOA to be created.
      CORBA::PolicyList policies (1);
      policies.length (1);

      CORBA::Any pol;
      pol <<= BiDirPolicy::BOTH;
      policies[0] =
        orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, pol);

      // Create POA as child of RootPOA with the above policies.  This POA
      // will receive request in the same connection in which it sent
      // the request
      PortableServer::POA_var child_poa =
        root_poa->create_POA ("childPOA", poa_manager.in (), policies);

      // Creation of childPOA is over. Destroy the Policy objects.
      for (CORBA::ULong i = 0; i < policies.length (); ++i)
        {
          policies[i]->destroy ();
        }

      poa_manager->activate ();

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

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

      Simple_Server_var server = Simple_Server::_narrow (object.in ());

      if (CORBA::is_nil (server.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Object reference <%C> is nil\n",
                             ior),
                            1);
        }

      Callback_i callback_impl (orb.in ());

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

      child_poa->activate_object_with_id (id.in (), &callback_impl);

      CORBA::Object_var callback_object =
        child_poa->id_to_reference (id.in ());

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

      CORBA::String_var ior = orb->object_to_string (callback.in ());

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) Client callback activated as <%C>\n",
                            ior.in ()));

      // Send the calback object to the server
      server->callback_object (callback.in ());

      int pre_call_connections =
        orb->orb_core ()->lane_resources ().transport_cache ().current_size ();

      // A method to kickstart callbacks from the server
      CORBA::Long r = server->test_method (1);

      if (r != 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "(%P|%t) unexpected result = %d ",
                      r));
        }

      orb->run ();

      int cur_connections =
        orb->orb_core ()->lane_resources ().transport_cache ().current_size ();

      if (cur_connections > pre_call_connections)
        {
          ACE_ERROR ((LM_ERROR,
                      "(%P|%t) Expected %d "
//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,代码来源:client.cpp

示例2: policies

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");

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

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

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

      // Policies for the childPOA to be created.
      CORBA::PolicyList policies (1);
      policies.length (1);

      CORBA::Any pol;
      pol <<= BiDirPolicy::BOTH;
      policies[0] =
        orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE,
                            pol);

      // Create POA as child of RootPOA with the above policies.  This POA
      // will receive request in the same connection in which it sent
      // the request
      PortableServer::POA_var child_poa =
        root_poa->create_POA ("childPOA",
                              poa_manager.in (),
                              policies);

      // Creation of childPOA is over. Destroy the Policy objects.
      for (CORBA::ULong i = 0;
           i < policies.length ();
           ++i)
        {
          policies[i]->destroy ();
        }

      poa_manager->activate ();

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

      Simple_Server_i server_impl (orb.in (),
                                   no_iterations);

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

      child_poa->activate_object_with_id (id.in (),
                                          &server_impl);

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

      CORBA::String_var ior =
        orb->object_to_string (obj.in ());

      ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ()));

      // If the ior_output_file exists, output the ior to it
      if (ior_output_file != 0)
        {
          FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
          if (output_file == 0)
            ACE_ERROR_RETURN ((LM_ERROR,
                               "Cannot open output file for writing IOR: %s",
                               ior_output_file),
                              1);
          ACE_OS::fprintf (output_file, "%s", ior.in ());
          ACE_OS::fclose (output_file);
        }

      int retval = 0;
      while (retval == 0)
        {
          // Just process one upcall. We know that we would get the
          // clients IOR in that call.
          CORBA::Boolean pending =
            orb->work_pending();

          if (pending)
            {
              orb->perform_work();
            }

          // Now that hopefully we have the clients IOR, just start
          // making remote calls to the client.
          retval = server_impl.call_client ();
        }
//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,代码来源:server.cpp

示例3: policy_list

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

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

    CORBA::Object_var obj = orb->resolve_initial_references("Test");
    if (CORBA::is_nil(obj.in()))
      {
        ACE_DEBUG ((LM_DEBUG, "Client could not RIR Test\n"));
        return 1;
      }
    Test_var test = Test::_narrow( obj.in() );
    if (CORBA::is_nil(test.in()))
      {
        ACE_DEBUG ((LM_DEBUG, "Client could not narrow Test\n"));
        return 1;
      }

    test->_stubobj()->reset_profiles();

    test->foo ();

    CORBA::Any a;
    a <<= Messaging::SYNC_WITH_SERVER;

    CORBA::PolicyList policy_list (1);
    policy_list.length (1);
    policy_list[0] =
      orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE, a);

    obj = test->_set_policy_overrides (policy_list, CORBA::ADD_OVERRIDE);
    test = Test::_narrow ( obj.in());

    test->_stubobj()->reset_profiles();

    test->foo ();

    CORBA::Short n = test->get_call_count();
    ACE_DEBUG ((LM_DEBUG,
                "Got call count of %d\n",
                n));

    return n != 1;

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

  return -1;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:56,代码来源:client.cpp

示例4: policy_list

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int retval = 1;

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

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

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

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

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

      CORBA::Any timeout_as_any;
      timeout_as_any <<= timeout_period;

      CORBA::PolicyList policy_list (1);
      policy_list.length (1);
      policy_list[0] =
        orb->create_policy (TAO::CONNECTION_TIMEOUT_POLICY_TYPE,
                            timeout_as_any);

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

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

      retval = test_timeout (tmp.in ());

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

  return retval;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:53,代码来源:client.cpp

示例5: INTERNAL

void
Echo_Client_ORBInitializer::post_init (
    PortableInterceptor::ORBInitInfo_ptr info)
{
    // TAO-Specific way to get to the ORB Core (and thus, the ORB).
    TAO_ORBInitInfo_var tao_info =
        TAO_ORBInitInfo::_narrow (info);

    CORBA::ORB_var orb = CORBA::ORB::_duplicate(tao_info->orb_core()->orb());

    if (CORBA::is_nil(orb.in()))
    {
        throw CORBA::INTERNAL ();
    }

    PortableInterceptor::ORBInitInfo_3_1_var info_3_1 =
        PortableInterceptor::ORBInitInfo_3_1::_narrow(info);

    if (CORBA::is_nil(info_3_1.in()))
    {
        throw CORBA::INTERNAL ();
    }

    PortableInterceptor::ClientRequestInterceptor_ptr interceptor =
        PortableInterceptor::ClientRequestInterceptor::_nil ();

    // Install the Echo client request interceptor
    ACE_NEW_THROW_EX (interceptor,
                      Echo_Client_Request_Interceptor,
                      CORBA::NO_MEMORY ());

    PortableInterceptor::ClientRequestInterceptor_var
    client_interceptor = interceptor;

    CORBA::Any client_proc_mode_as_any;
    client_proc_mode_as_any <<= this->processing_mode_;

    CORBA::PolicyList policy_list (1);

    policy_list.length (1);
    policy_list[0] =
        orb->create_policy (PortableInterceptor::PROCESSING_MODE_POLICY_TYPE,
                            client_proc_mode_as_any);

    info_3_1->add_client_request_interceptor_with_policy (
        client_interceptor.in (),
        policy_list);

    policy_list[0]->destroy ();
    policy_list[0] = CORBA::Policy::_nil ();
}
开发者ID:akostrikov,项目名称:ATCD,代码行数:51,代码来源:Echo_Client_ORBInitializer.cpp

示例6: register_with_proxy

CORBA::Object_ptr register_with_proxy (CORBA::Object_ptr native)
{
	// Disable protection for this insecure invocation test.

	Security::QOP qop = Security::SecQOPNoProtection;

	CORBA::Any no_protection;
	no_protection <<= qop;

	// Create the Security::QOPPolicy.
	CORBA::Policy_var policy =
		orb->create_policy (Security::SecQOPPolicy,
				    no_protection);

	CORBA::PolicyList policy_list (1);
	policy_list.length (1);
	policy_list[0] = CORBA::Policy::_duplicate (policy.in ());

	// Create an object reference that uses plain IIOP (i.e. no
	// protection).
	CORBA::Object_var object =
		mapper->_set_policy_overrides (policy_list,
					       CORBA::SET_OVERRIDE);

	ACE_DEBUG ((LM_DEBUG,"Trying to narrow an insecure reference\n"));

	Lorica::ReferenceMapper_var open_mapper =
		Lorica::ReferenceMapper::_narrow(object.in());

	ACE_DEBUG ((LM_DEBUG,"Using open mapper for registering\n"));

	try
	{
		return open_mapper->as_server(native,"Hello",
					      Lorica::ServerAgent::_nil());
	}
	catch (CORBA::Exception &ex)
	{
		ACE_DEBUG ((LM_DEBUG,"open_mapper->as_server raised %s\n",ex._name()));
		return CORBA::Object::_nil();
	}
}
开发者ID:snaewe,项目名称:lorica,代码行数:42,代码来源:server.cpp

示例7: policies

CORBA::Object_ptr
set_timeout_policy (CORBA::Object_ptr obj, const ACE_Time_Value& to)
{
  CORBA::Object_var ret;

  try
    {
      TimeBase::TimeT timeout;
      ORBSVCS_Time::Time_Value_to_TimeT (timeout, to);
      CORBA::Any tmp;
      tmp <<= timeout;

      CORBA::PolicyList policies (1);
      policies.length (1);
      policies[0] = orb->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
                                        tmp);

      ret = obj->_set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

      policies[0]->destroy ();

      if (CORBA::is_nil (ret.in ()))
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("Unable to set timeout policy.\n")));
          ret = CORBA::Object::_duplicate (obj);
        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (ACE_TEXT ("set_timeout_policy ()"));
      ret = CORBA::Object::_duplicate (obj);
    }

  return ret._retn ();
}
开发者ID:CCJY,项目名称:ATCD,代码行数:36,代码来源:client.cpp

示例8: self_manage

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

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

      // Get reference to Root POA.
      CORBA::Object_var obj =
        orb->resolve_initial_references ("RootPOA");

      PortableServer::POA_var rootpoa =
        PortableServer::POA::_narrow (obj.in ());

      // Activate POA manager
      PortableServer::POAManager_var mgr =
        rootpoa->the_POAManager ();

      mgr->activate ();

      PortableServer::POA_var poa;

      TAO::Utils::PolicyList_Destroyer PolicyList (3);
      PolicyList.length (3);

      PolicyList [0] =
        rootpoa->create_lifespan_policy (PortableServer::PERSISTENT);

      PolicyList [1] =
        rootpoa->create_id_assignment_policy (PortableServer::USER_ID);

      CORBA::Any CallbackPolicy;
      CallbackPolicy <<= BiDirPolicy::BOTH;
      const char* sServerPoaName = "TelemetryServer";

      PolicyList [2] =
        orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE,
                            CallbackPolicy);

      poa = rootpoa->create_POA (sServerPoaName,
                                 mgr.in(),
                                 PolicyList);


      PortableServer::ObjectId_var ServerId =
        PortableServer::string_to_ObjectId ("TimeServer");

      // Create an object
      Time_impl *time_servant = new Time_impl;
      PortableServer::ServantBase_var self_manage (time_servant);

      poa->activate_object_with_id (ServerId.in (),
                                    time_servant);

      // Get a reference after activating the object
      CORBA::Object_var object = poa->id_to_reference (ServerId.in ());
      TimeModule::Time_var tm = TimeModule::Time::_narrow (object.in ());

      // Get reference to initial naming context
      CORBA::Object_var name_obj =
        orb->resolve_initial_references ("NameService");

      CosNaming::NamingContext_var inc =
        CosNaming::NamingContext::_narrow (name_obj.in ());

      if (CORBA::is_nil (inc.in ()))
        {
          ACE_ERROR ((LM_ERROR,
                      "(%P|%t) Error fetching naming context\n"));
        }

      CosNaming::Name service_name;
      service_name.length(1);
      service_name[0].id   =
        CORBA::string_dup ("Time");

      inc->rebind (service_name,
                   tm.in ());

      // Run the event loop for fun
      ACE_Time_Value tv (3, 0);

      // Accept requests
      orb->run (&tv);

      rootpoa->destroy (0 , 0);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Caught an exception\n");

      return -1;
    }

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

示例9: policy_list

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int priority =
    (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
     + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
  priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO,
                                                  priority);
  // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.

  if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
                                              priority,
                                              ACE_SCOPE_PROCESS)) != 0)
    {
      if (ACE_OS::last_error () == EPERM)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "server (%P|%t): user is not superuser, "
                      "test runs in time-shared class\n"));
        }
      else
        ACE_ERROR ((LM_ERROR,
                    "server (%P|%t): sched_params failed\n"));
    }

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

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

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

      CORBA::Any sync_scope;
      sync_scope <<= Messaging::SYNC_WITH_TARGET;

      CORBA::PolicyList policy_list (1);
      policy_list.length (1);
      policy_list[0] =
        orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
                            sync_scope);
      policy_manager->set_policy_overrides (policy_list,
                                            CORBA::SET_OVERRIDE);

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

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

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

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

      poa_manager->activate ();

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

      Server_i server_i;

      Test::Server_var server = server_i._this ();

      CORBA::String_var str =
        orb->object_to_string (server.in ());

      if (ior_file_name != 0)
        {
          FILE *output_file = ACE_OS::fopen (ior_file_name, "w");
          if (output_file == 0)
            ACE_ERROR_RETURN ((LM_ERROR,
                               "Cannot open output file for writing IOR: %s",
                               ior_file_name),
                              1);
          ACE_OS::fprintf (output_file, "%s", str.in ());
          ACE_OS::fclose (output_file);
        }

      while (!server_i.done ())
        {
          ACE_Time_Value tv (1, 0);
          orb->run (tv);
        }

      PortableServer::ObjectId_var id =
        root_poa->servant_to_id (&server_i);
      root_poa->deactivate_object (id.in ());

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (argv[0]);
//.........这里部分代码省略.........
开发者ID:CCJY,项目名称:ATCD,代码行数:101,代码来源:server.cpp

示例10: policies

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

        // Destringify ior
        CORBA::Object_var obj = orb->string_to_object( "file://IOR" );
        if( CORBA::is_nil( obj.in() ) ) {
            cerr << "Nil  reference" << endl;
            throw 0;
        }

        // Narrow
        CallbackServer_var cb_server = CallbackServer::_narrow( obj.in() );
        if( CORBA::is_nil( cb_server.in() ) ) {
            cerr << "Argument is not a CallbackServer reference" << endl;
            throw 0;
        }

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

        // Policies for the childPOA to be created.
        CORBA::PolicyList policies (4);
        policies.length (4);

        CORBA::Any pol;
        pol <<= BiDirPolicy::BOTH;
        policies[0] =
            orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE,
                                pol);

        policies[1] = 
            poa->create_id_assignment_policy(PortableServer::SYSTEM_ID);

        policies[2] = 
            poa->create_implicit_activation_policy( PortableServer::IMPLICIT_ACTIVATION );

        policies[3] = 
            poa->create_lifespan_policy(PortableServer::TRANSIENT);
          
        PortableServer::POAManager_var mgr = poa->the_POAManager();

        // Create POA as child of RootPOA with the above policies.  This POA
        // will receive request in the same connection in which it sent
        // the request
        PortableServer::POA_var child_poa =
            poa->create_POA ("childPOA",
                             mgr.in(),
                             policies);

        // Creation of childPOA is over. Destroy the Policy objects.
        for (CORBA::ULong i = 0;
             i < policies.length ();
             ++i)
        {
            policies[i]->destroy ();
        }

        // Activate POA Manager
        mgr->activate();

        // Create an object
        ClientCallback_i servant;

        // Register the servant with the RootPOA, obtain its object
        // reference, stringify it, and write it to a file.
        obj = child_poa->servant_to_reference( &servant );
        //ClientCallback_var ccb = ClientCallback::_narrow( obj.in() );

        cb_server->callback_hello( ClientCallback::_narrow( obj.in() ),
                                   CORBA::string_dup( "Greetings earthling" ));
    }
    catch( const CORBA::Exception &ex ) {
        cerr << "Uncaught CORBA exception: " << ex << endl;
        return 1;
    }
}
开发者ID:2pirad,项目名称:jacorb,代码行数:81,代码来源:client.cpp

示例11: policies

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int ret_val = 0;

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

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

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

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

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

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

      policies[0]->destroy ();

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

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

      Test::Peer_var peer =
        Test::Peer::_narrow(tmp.in ());

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

      while(1)
      {
        peer->noop ();
      }

      /* Warning with TRU 64 builds
       ACE_DEBUG ((LM_DEBUG, "(%P|%t) scavenger - event loop finished\n"));

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

  return ret_val;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:69,代码来源:scavenger.cpp

示例12: policies

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  CORBA::ORB_var orb = CORBA::ORB::_nil();
  PortableServer::POA_var root_poa = PortableServer::POA::_nil();
  Callback_i *servant = 0;

  try
    {
      orb = CORBA::ORB_init (argc, argv);

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

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

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

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

      // Policies for the childPOA to be created.
      CORBA::PolicyList policies (1);
      policies.length (1);

      CORBA::Any pol;
      pol <<= BiDirPolicy::BOTH;
      policies[0] =
        orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE,
                            pol);

      // Create POA as child of RootPOA with the above policies.  This POA
      // will receive request in the same connection in which it sent
      // the request
      PortableServer::POA_var child_poa =
        root_poa->create_POA ("childPOA",
                              poa_manager.in (),
                              policies);

      // Creation of childPOA is over. Destroy the Policy objects.
      for (CORBA::ULong i = 0;
           i < policies.length ();
           ++i)
        {
          policies[i]->destroy ();
        }

      poa_manager->activate ();

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

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

      Simple_Server_var server =
        Simple_Server::_narrow (object.in ());

      if (CORBA::is_nil (server.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Object reference <%s> is nil\n",
                             ior),
                            1);
        }


      servant = new Callback_i (orb.in ());

      Callback_var callback =
        servant->_this ();

      // Send the calback object to the server
      server->callback_object (callback.in ());

      // A  method to kickstart callbacks from the server
      CORBA::Long r =
        server->test_method (1);

      if (r != 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "(%P|%t) unexpected result = %d ",
                      r));
        }

      orb->run ();

      root_poa->destroy (1, 1);

    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Caught exception:");
      return 1;
    }
//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,代码来源:client.cpp

示例13: policies

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");

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

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

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

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

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

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

      CORBA::PolicyList policies (1); policies.length (1);
      policies[0] =
        orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
                            scope_as_any);
      policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

      policies[0]->destroy ();

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

      // Get the sender reference..
      CORBA::Object_var tmp =
        orb->string_to_object(ior);

      Test::Sender_var sender =
        Test::Sender::_narrow(tmp.in ());

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

      Client_Task client_task (orb.in(),
                               sender.in (),
                               ACE_Thread_Manager::instance (),
                               number_of_oneways);

      Server_Task server_task (orb.in (),
                               ACE_Thread_Manager::instance ());

      // Before creating threads we will let the sender know that we
      // will have two threads that would make invocations..
      // this is the first oneway we do, so after this we would have a queue
      // on one of the transports
      sender->active_objects ((CORBA::Short) number_of_client_tasks);

      TAO::Transport_Cache_Manager& manager = orb->orb_core()->lane_resources ().transport_cache ();

      TAO::Transport_Cache_Manager::HASH_MAP& cachemap = manager.map();
      TAO::Transport_Cache_Manager::HASH_MAP_ITER end_iter = cachemap.end ();

      bool tranportwithqueue = false;
      for (TAO::Transport_Cache_Manager::HASH_MAP_ITER iter = cachemap.begin ();
           iter != end_iter;
           ++iter)
        {
          TAO_Transport* transport = (*iter).int_id_.transport ();
          if (transport->queue_is_empty() == 0 && transport->is_connected() == false)
            {
              tranportwithqueue = true;
              break;
            }
        }

        if (!tranportwithqueue)
          {
            ACE_ERROR ((LM_ERROR, "(%P|%t) Error: expect a not connected transport with a queue\n"));
          }
        else
          {
//.........这里部分代码省略.........
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:101,代码来源:client.cpp

示例14: impl

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,
                "backend_server(%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::Object_var tmp = orb->string_to_object(ior);

      // one second in TimeT units
      TimeBase::TimeT const second = 10 * TimeBase::TimeT(1000000);

      CORBA::Any timeout_as_any;
      timeout_as_any <<= TimeBase::TimeT(timeout * second);

      CORBA::Any scope_as_any;
      scope_as_any <<= scope;

      TAO::Utils::PolicyList_Destroyer plist(1);
      plist.length(2);
      plist[0] =
          orb->create_policy(Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
              timeout_as_any);
      plist[1] =
          orb->create_policy(Messaging::SYNC_SCOPE_POLICY_TYPE,
              scope_as_any);

      CORBA::PolicyCurrent_var policy_current =
          TAO::Utils::RIR_Narrow<CORBA::PolicyCurrent>::narrow(
               orb.in (),
               "PolicyCurrent");

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

      Bug_3647_Regression::Backend_var backend =
          Bug_3647_Regression::Backend::_narrow(tmp.in ());

      if (CORBA::is_nil (backend.in ()))
        {
          ACE_ERROR_RETURN ((LM_DEBUG,
                  "middle_server(%P|%t) - nil backend reference <%s>\n",
                  ior),
              1);
        }

      using namespace Bug_3647_Regression;
      PortableServer::ServantBase_var impl(
          new Middle_Impl(backend.in(), orb.in(), verbose,
                          timeout));

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

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


      Bug_3647_Regression::Middle_var middle =
          Bug_3647_Regression::Middle::_narrow (object.in ());

      CORBA::String_var ior = orb->object_to_string (middle.in ());

      // Output the IOR to the <ior_output_file>
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                "middle_server(%P|%t) - Cannot open output file "
                "for writing IOR: %s\n",
                ior_output_file),
            1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      orb->run ();

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

//.........这里部分代码省略.........
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:101,代码来源:middle_server.cpp

示例15: catch

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  CORBA::ORB_var orb;
  CORBA::Object_var obj;
  PortableServer::POA_var root_poa;
  PortableServer::POAManagerFactory_var poa_manager_factory;

  if (parse_args (argc, argv) != 0)
    return 1;
  ACE_TCHAR *extra[4];
#ifdef ACE_USES_WCHAR
  extra[0] = CORBA::wstring_dup (ACE_TEXT ("-ORBEndpoint"));
  extra[1] =CORBA::wstring_alloc (100);
#else
  extra[0] = CORBA::string_dup ("-ORBEndpoint");
  extra[1] = CORBA::string_alloc (100);
#endif
  ACE_OS::sprintf (extra[1],
                   ACE_TEXT ("iiop://localhost:%d/ssl_port=%d"),
                   endpoint_port, endpoint_port+1);

#ifdef ACE_USES_WCHAR
  extra[2] = CORBA::wstring_dup (ACE_TEXT ("-ORBEndpoint"));
  extra[3] = CORBA::wstring_alloc (100);
#else
  extra[2] = CORBA::string_dup ("-ORBEndpoint");
  extra[3] = CORBA::string_alloc (100);
#endif
  ACE_OS::sprintf (extra[3],
                   ACE_TEXT ("iiop://localhost:%d/ssl_port=%d"),
                   endpoint_port+10, endpoint_port+11);

  ACE_TCHAR **largv = new ACE_TCHAR *[argc+4];
  int i = 0;
  for (i = 0; i < argc; i++)
    largv[i] = argv[i];
  for (i = 0; i < 4; i++)
    largv[argc+i] = extra[i];
  argc += 4;

  try
    {
      orb =
        CORBA::ORB_init (argc, largv, "EndpointPolicy");

      obj =
        orb->resolve_initial_references("RootPOA");

      root_poa =
        PortableServer::POA::_narrow (obj.in ());

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

      poa_manager_factory
        = root_poa->the_POAManagerFactory ();
    }
  catch (CORBA::Exception &ex)
    {
      ex._tao_print_exception("initialization error ");
      return 1;
    }

  for (i = 0; i < 4; i++)
#ifdef ACE_USES_WCHAR
    CORBA::wstring_free (extra[i]);
#else
    CORBA::string_free (extra[i]);
#endif

  delete [] largv;


  //-----------------------------------------------------------------------


  // Create two valid endpoint policies. One to match each of the generated
  // endpoint arguments supplied to ORB_init().
  PortableServer::POAManager_var good_pm;
  PortableServer::POAManager_var bad_pm;
  CORBA::PolicyList policies;
  policies.length (1);

  EndpointPolicy::EndpointList list;
  list.length (1);
  list[0] = new IIOPEndpointValue_i("localhost", endpoint_port);

  try
    {
      CORBA::Any policy_value;
      policy_value <<= list;
      policies[0] = orb->create_policy (EndpointPolicy::ENDPOINT_POLICY_TYPE,
                                        policy_value);
      good_pm = poa_manager_factory->create_POAManager ("goodPOAManager",
                                                        policies);
    }
  catch (CORBA::Exception &ex)
//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,代码来源:test.cpp


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