Example #1
0
void
ORB_Initializer::post_init (PortableInterceptor::ORBInitInfo_ptr info)
{
  // Allocate slot id.
  //
  state_slot_id (info->allocate_slot_id ());

  // Register replica controller as server request interceptor.
  //
  TAO_ORBInitInfo* tao_info = dynamic_cast<TAO_ORBInitInfo*> (info);

  CORBA::ORB_var orb (tao_info->orb_core ()->orb ());

  PortableInterceptor::ServerRequestInterceptor_var interceptor;

  {
    PortableInterceptor::ServerRequestInterceptor *tmp_interceptor = 0;

    ACE_NEW_THROW_EX (tmp_interceptor,
                      ReplicaController (orb.in ()),
                      CORBA::NO_MEMORY (
                        CORBA::SystemException::_tao_minor_code (
                          TAO::VMCID,
                          ENOMEM),
                      CORBA::COMPLETED_NO));


    interceptor = tmp_interceptor;
  }

  info->add_server_request_interceptor (interceptor.in ());
}
Example #2
0
void
ClientInitializer::post_init (PortableInterceptor::ORBInitInfo_ptr info)
{
  // Find the Naming Service
  CORBA::Object_var naming_obj =
    info->resolve_initial_references("NameService");
  CosNaming::NamingContext_var root =
    CosNaming::NamingContext::_narrow(naming_obj.in());
  if( CORBA::is_nil(root.in())) {
    std::cerr << "Nil Naming Context reference" << std::endl;
    ACE_ASSERT(false);
  }

  // Resolve the Messenger object
  CosNaming::Name name;
  name.length( 1 );
  name[0].id = CORBA::string_dup( "Messenger" );
  CORBA::Object_var obj = CORBA::Object::_nil();
  while ( CORBA::is_nil( obj.in() ) ) {
    try {
      obj = root->resolve( name );
    } catch (const CosNaming::NamingContext::NotFound&) {
      // Sleep for a second and try again
      ACE_OS::sleep(1);
    }
   }

  Messenger_var messenger = Messenger::_narrow( obj.in() );
  if( CORBA::is_nil( messenger.in() ) ) {
    std::cerr << "Not a Messenger reference" << std::endl;
    ACE_ASSERT(false);
  }

  // allocate slot
  slot_ = info->allocate_slot_id();

  // get PICurrent
  CORBA::Object_var current_obj = info->resolve_initial_references("PICurrent");

  current_ =
    PortableInterceptor::Current::_narrow(current_obj.in());

  // Create and register the request interceptors.
  PortableInterceptor::ClientRequestInterceptor_var ci =
      new ClientInterceptor(messenger, current_.in(), slot_);
  info->add_client_request_interceptor (ci.in());
}
Example #3
0
void
Client_ORBInitializer::post_init (
    PortableInterceptor::ORBInitInfo_ptr info)
{
  PortableInterceptor::SlotId slot_id = info->allocate_slot_id ();

  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;

  info->add_client_request_interceptor (client_interceptor.in ());

  ACE_UNUSED_ARG (slot_id);
}
void 
ORBInitializerImpl::post_init (PortableInterceptor::ORBInitInfo_ptr info)
{
    //
	// First resolve the Name Service
	//
    CORBA::Object_var obj;

	try
    {
        obj = info->resolve_initial_references("NameService");
    }
    catch (const CORBA::ORB::InvalidName&)
    {
		std::cerr << "ORBInitializerImpl: Can't resolve NameService" << std::endl;
		return;
    }

    if (CORBA::is_nil(obj.in()))
    {
		std::cerr << "ORBInitializerImpl: NameService is a nil object reference" << std::endl;
		return;
    }

	try
	{
		nameService_ = CosNaming::NamingContext::_narrow(obj.in());
	}
	catch (const CORBA::Exception&)
	{
		std::cerr << "ORBInitializerImpl: NameService is not running" << std::endl;
		return;
	}

    if (CORBA::is_nil(nameService_.in()))
    {
		std::cerr << "ORBInitializerImpl: NameService is not a NamingContext object reference" << std::endl;
		return;
    }

    //
	// Resolve the HomeFinder
	//
	Qedo_Components::HomeFinder_var home_finder;
	obj = resolveName("Qedo/HomeFinder");

	if (CORBA::is_nil(obj.in()))
    {
		std::cerr << "ORBInitializerImpl: HomeFinder not found" << std::endl;
		return;
    }

    try
    {
        home_finder = Qedo_Components::HomeFinder::_narrow(obj);
    }
    catch (CORBA::SystemException&)
    {
        std::cerr << "ORBInitializerImpl: HomeFinder is not running" << std::endl;
		return;
    }

	if (CORBA::is_nil(home_finder.in()))
    {
		std::cerr << "ORBInitializerImpl: HomeFinder is not running" << std::endl;
		return;
    }

	//
	// register HomeFinder
	//
	info->register_initial_reference ("ComponentHomeFinder", home_finder);

	//
	// Allocate a slot id to communicate data towards our components
	//
	slot_id_ = info->allocate_slot_id();
}