Esempio n. 1
0
int
make_ior (CORBA::ORB_ptr orb,
          PortableServer::POA_ptr poa,
          Hello * servant,
          const ACE_TCHAR *ior_file)
{
  CORBA::String_var poa_name = poa->the_name();
  ACE_DEBUG ((LM_DEBUG, "Creating IOR from %C\n", poa_name.in()));

  PortableServer::ObjectId_var oid = poa->activate_object (servant);
  CORBA::Object_var o = poa->id_to_reference (oid.in ());


  if (host_form == from_hostname || host_form == use_localhost)
    {
      CORBA::String_var ior =
        orb->object_to_string (o.in ());

      FILE *output_file= ACE_OS::fopen (ior_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file %s for writing IOR: %C",
                           ior_file,
                           ior.in ()),
                          1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);
    }
  return 0;
}
Esempio n. 2
0
CORBA::Object_ptr
TAO_DLL_Parser::parse_string (const char *ior,
                              CORBA::ORB_ptr orb)
{
  // Skip the prefix, we know it is there because this method in only
  // called if <match_prefix> returns 1.
  const char *name =
    ior + sizeof (::dll_prefix) - 1;

  TAO_ORB_Core *oc = orb->orb_core ();

  TAO_Object_Loader *loader =
    ACE_Dynamic_Service<TAO_Object_Loader>::instance
      (oc->configuration(), name);

  if (loader == 0)
    {
      throw
         CORBA::INV_OBJREF
         (CORBA::SystemException::_tao_minor_code (
            0,
            EINVAL),
          CORBA::COMPLETED_NO);
    }

  return loader->create_object (orb, 0, 0);
}
Esempio n. 3
0
TAO_Scheduler::TAO_Scheduler (CORBA::ORB_ptr orb)
{
  CORBA::Object_var current_obj =
    orb->resolve_initial_references ("RTScheduler_Current");

  current_ = RTScheduling::Current::_narrow (current_obj.in ());
}
bool
test_string_to_object (CORBA::ORB_ptr orb, const char* ior, CORBA::ULong minor)
{
  bool succeed = false;
  try
    {
      // Get the object reference with the IOR
      CORBA::Object_var object = orb->string_to_object (ior);
    }
  catch (const CORBA::BAD_PARAM& ex)
    {
      if ((ex.minor() & 0xFFFU) == minor)
        {
          succeed = true;
        }
    }
  catch (const CORBA::Exception&)
    {
    }

  if (!succeed)
  {
    ACE_ERROR ((LM_ERROR,
                "(%t) ERROR, test_string_to_object for <%C> didn't result in minor code %d\n",
                ior,
                minor));
  }

  return succeed;
}
Esempio n. 5
0
File: server.cpp Progetto: manut/TAO
int
write_ior_to_file (CORBA::ORB_ptr orb,
                   test_ptr test)
{
  CORBA::String_var ior =
    orb->object_to_string (test);

  char filename[BUFSIZ];
  ACE_OS::sprintf (filename,
                   "%s_%d",
                   ACE_TEXT_ALWAYS_CHAR (ior_output_file),
                   ior_count++);

  FILE *output_file =
    ACE_OS::fopen (filename,
                   "w");

  if (output_file == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "Cannot open output file for writing IOR: %s",
                       filename),
                      -1);

  ACE_OS::fprintf (output_file,
                   "%s",
                   ior.in ());

  ACE_OS::fclose (output_file);

  return 0;
}
Esempio n. 6
0
void
insecure_invocation_test (CORBA::ORB_ptr orb,
                          CORBA::Object_ptr obj)
{
  // 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 =
    obj->_set_policy_overrides (policy_list,
                                CORBA::SET_OVERRIDE);

  Foo::Bar_var server =
    Foo::Bar::_narrow (object.in ());

  if (CORBA::is_nil (server.in ()))
    {
      ACE_ERROR ((LM_ERROR,
                  "(%P|%t) ERROR: Object reference <%s> is "
                  "nil.\n",
                  ior));

      throw CORBA::INTERNAL ();
    }

  try
    {
      // This invocation should result in a CORBA::NO_PERMISSION
      // exception.
      server->baz ();
    }
  catch (const CORBA::NO_PERMISSION&)
    {
      ACE_DEBUG ((LM_INFO,
                  "(%P|%t) Received CORBA::NO_PERMISSION from "
                  "server, as expected.\n"));

      return;
    }

  ACE_ERROR ((LM_ERROR,
              "(%P|%t) ERROR: CORBA::NO_PERMISSION was not thrown.\n"
              "(%P|%t) ERROR: It should have been thrown.\n"));

  throw CORBA::INTERNAL ();
}
Esempio n. 7
0
int
FT_EventService::report_factory(CORBA::ORB_ptr orb,
                   FtRtecEventChannelAdmin::EventChannel_ptr ec)
{
  try{
    char* addr = ACE_OS::getenv("EventChannelFactoryAddr");

    if (addr != 0) {
      // instaniated by object factory, report my ior back to the factory
      ACE_INET_Addr factory_addr(addr);
      ACE_SOCK_Connector connector;
      ACE_SOCK_Stream stream;

      ORBSVCS_DEBUG((LM_DEBUG,"connecting to %s\n",addr));
      if (connector.connect(stream, factory_addr) == -1)
        ORBSVCS_ERROR_RETURN((LM_ERROR, "(%P|%t) Invalid Factory Address\n"), -1);

      ORBSVCS_DEBUG((LM_DEBUG,"Factory connected\n"));
      CORBA::String_var my_ior_string = orb->object_to_string(ec);

      int len = ACE_OS::strlen(my_ior_string.in()) ;

      if (stream.send_n(my_ior_string.in(), len) != len)
        ORBSVCS_ERROR_RETURN((LM_ERROR, "(%P|%t) IOR Transmission Error\n"), -1);

      stream.close();
    }
  }
  catch (...){
    return -1;
  }
  return 0;
}
Esempio n. 8
0
int
write_ior_to_file (const ACE_TCHAR *ior_file,
                   CORBA::ORB_ptr orb,
                   CORBA::Object_ptr object)
{
  CORBA::String_var ior =
    orb->object_to_string (object);

  FILE *output_file =
    ACE_OS::fopen (ior_file,
                   "w");

  if (output_file == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "Cannot open output file for writing IOR: %s",
                       ior_file),
                      -1);

  ACE_OS::fprintf (output_file,
                   "%s",
                   ior.in ());

  ACE_OS::fclose (output_file);

  return 0;
}
Esempio n. 9
0
Components::Deployment::ServerActivator_ptr
get_server_activator (CORBA::ORB_ptr orb, CosNaming::NamingContext_ptr ns, const char* hostname)
{
	cout << "Getting Component Server Activator from Qedo/Activators/" << hostname << endl;

	CosNaming::Name server_activator_name;
	server_activator_name.length (3);
	server_activator_name[0].id = CORBA::string_dup ("Qedo");
	server_activator_name[0].kind = CORBA::string_dup ("");
	server_activator_name[1].id = CORBA::string_dup ("Activators");
	server_activator_name[1].kind = CORBA::string_dup ("");
	server_activator_name[2].id = CORBA::string_dup (hostname);
	server_activator_name[2].kind = CORBA::string_dup ("");

	Components::Deployment::ServerActivator_var server_activator;
	CORBA::Object_var server_activator_obj;

	try
	{
		server_activator_obj = ns->resolve (server_activator_name);
	}
	catch (CosNaming::NamingContext::NotFound&)
	{
		cerr << "Component Server Activator not found in Name Service" << endl;
		orb->destroy();
		exit (1);
	}
	catch (CORBA::SystemException&)
	{
		cerr << "CORBA system exception during resolve()" << endl;
		orb->destroy();
		exit (1);
	}

	try
	{
		server_activator = Components::Deployment::ServerActivator::_narrow (server_activator_obj);
	}
	catch (CORBA::SystemException&)
	{
		cerr << "Cannot narrow Component Server Activator" << endl;
		orb->destroy();
		exit (1);
	}

	return server_activator._retn();
}
Esempio n. 10
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  int status = 0;
  try
  {
    Consumer_Client client;

    status = client.init (argc, argv);
    ACE_UNUSED_ARG(status);
    ACE_ASSERT(status == 0);

    CosNotifyChannelAdmin::EventChannel_var ec =
      client.create_event_channel ("MyEventChannel", 1);

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

    sig_var sig = sig::_narrow (object.in ());
    ACE_ASSERT(! CORBA::is_nil (sig.in ()));

    CosNotifyChannelAdmin::ConsumerAdmin_var admin =
      create_consumeradmin (ec.in ());
    ACE_ASSERT(!CORBA::is_nil (admin.in ()));

    create_consumers (admin.in (), &client);

    // Tell the supplier to go
    sig->go ();

    ACE_DEBUG((LM_DEBUG, "Consumer waiting for events...\n"));

    client.ORB_run( );

    ACE_DEBUG((LM_DEBUG, "Consumer done.\n"));
    consumer_1->disconnect();

    sig->done ();
  }
  catch (const CORBA::Exception& e)
  {
    e._tao_print_exception ("Error: ");
    status = 1;
  }

  return status;
}
Esempio n. 11
0
int
run(CORBA::ORB_ptr orb, int argc, char* argv[])
{
    //
    // Resolve Root POA
    //
    CORBA::Object_var poaObj = orb -> resolve_initial_references("RootPOA");
    PortableServer::POA_var rootPOA = PortableServer::POA::_narrow(poaObj);
    
    //
    // Get a reference to the POA manager
    //
    PortableServer::POAManager_var manager = rootPOA -> the_POAManager();
    
    //
    // Create implementation object
    //
    Testing_impl* testingImpl = new Testing_impl(rootPOA);
    PortableServer::ServantBase_var servant = testingImpl;
    Testing_var testing = testingImpl->_this();
    
    //
    // Save reference
    //
    CORBA::String_var s = orb->object_to_string(testing);
    
    const char* refFile = "testing.ref";
    ofstream out(refFile);
    if(out.fail())
    {
	cerr << argv[0] << ": can't open `" << refFile << "': "
	     << strerror(errno) << endl;
	return EXIT_FAILURE;
    }

    out << s << endl;
    out.close();
    
    //
    // Run implementation
    //
    manager->activate();
    orb->run();

    return EXIT_SUCCESS;
}
Esempio n. 12
0
MIF_Scheduler::MIF_Scheduler (CORBA::ORB_ptr orb,
                              Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type,
                              int ace_sched_policy,
                              int ace_sched_scope)
  : orb_ (CORBA::ORB::_duplicate (orb)),
    disp_impl_type_ (disp_impl_type),
    ace_sched_policy_ (ace_sched_policy),
    ace_sched_scope_ (ace_sched_scope)
{

  Kokyu::DSRT_ConfigInfo config;

  config.impl_type_ = this->disp_impl_type_;
  config.sched_policy_ = ace_sched_policy_;
  config.sched_scope_ = ace_sched_scope_;

  Kokyu::DSRT_Dispatcher_Factory<MIF_Scheduler_Traits>::DSRT_Dispatcher_Auto_Ptr
    tmp( Kokyu::DSRT_Dispatcher_Factory<MIF_Scheduler_Traits>::
         create_DSRT_dispatcher (config) );
  kokyu_dispatcher_ = tmp;

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

  this->current_ =
    RTScheduling::Current::_narrow (object.in ());

  IOP::CodecFactory_var codec_factory;
  CORBA::Object_var obj = orb->resolve_initial_references ("CodecFactory");

  if (CORBA::is_nil(obj.in ()))
    {
      ACE_ERROR ((LM_ERROR, "Nil Codec factory\n"));
    }
  else
    {
      codec_factory = IOP::CodecFactory::_narrow (obj.in ());
    }

  IOP::Encoding encoding;
  encoding.format = IOP::ENCODING_CDR_ENCAPS;
  encoding.major_version = 1;
  encoding.minor_version = 2;

  codec_ = codec_factory->create_codec (encoding);
}
Esempio n. 13
0
void
Lorica_MapperRegistry::init_mappers(PortableServer::POAManager_ptr outward,
				    PortableServer::POAManager_ptr inward,
				    CORBA::ORB_ptr orb,
				    bool has_security)
{
	// first, prevent multiple activation
	if (this->mappers_ready_)
		return;

	// consolidate the mapper list, to append first the generic mapper and
	// then the null mapper.
	if (this->generic_mapper_ != 0) {
		if (Lorica_debug_level > 0) {
			ACE_DEBUG((LM_DEBUG,
				   ACE_TEXT("(%T) %N:%l - adding generic mapper\n")));
		}

		this->add_proxy_mapper(this->generic_mapper_);
		this->generic_mapper_ = 0;
	}

	if (this->null_mapper_ != 0) {
		if (Lorica_debug_level > 0) {
			ACE_DEBUG((LM_DEBUG,
				   ACE_TEXT("(%T) %N:%l - adding null mapper\n")));
		}

		this->add_proxy_mapper (this->null_mapper_);
		this->null_mapper_ = 0;
	}

	if (this->mappers_ != 0) {
		if (Lorica_debug_level > 0) {
			ACE_DEBUG((LM_DEBUG,
				   ACE_TEXT("(%T) %N:%l - calling mapper init on the root.\n")));
		}

		this->mappers_->proxy_mapper_init(outward, inward, orb);
	}

	this->has_security_ = has_security;
#if !defined (LORICA_LACKS_SSLIOP)
	if (has_security) {
		this->sec_policies_.length(1);

		Security::QOP qop = Security::SecQOPIntegrityAndConfidentiality;
		CORBA::Any i_and_c;
		i_and_c <<= qop;

		// Create the Security::QOPPolicy.
		sec_policies_[0] = orb->create_policy(Security::SecQOPPolicy, i_and_c);
	} else
#endif // LORICA_LACKS_SSLIOP 
		this->sec_policies_.length(0);

	this->mappers_ready_ = true;
}
Esempio n. 14
0
static CORBA::Object_ptr getObjectReference(CORBA::ORB_ptr orb) {
  CosNaming::NamingContext_var rootContext;
  
  try {
    // Obtain a reference to the root context of the Name service:
    CORBA::Object_var obj;
    obj = orb->resolve_initial_references("NameService");

    // Narrow the reference returned.
    rootContext = CosNaming::NamingContext::_narrow(obj);
    if( CORBA::is_nil(rootContext) ) {
      cerr << "Failed to narrow the root naming context." << endl;
      return CORBA::Object::_nil();
    }
  } catch (CORBA::NO_RESOURCES&) {
    cerr << "Caught NO_RESOURCES exception. You must configure omniORB "
	 << "with the location" << endl
	 << "of the naming service." << endl;
    return 0;
  } catch(CORBA::ORB::InvalidName& ex) {
    // This should not happen!
    cerr << "Service required is invalid [does not exist]." << endl;
    return CORBA::Object::_nil();
  }

  // Create a name object, containing the name test/context:
  CosNaming::Name name;
  name.length(2);

  name[0].id   = (const char*) "test";       // string copied
  name[0].kind = (const char*) "my_context"; // string copied
  name[1].id   = (const char*) "IdServer";
  name[1].kind = (const char*) "Object";
  // Note on kind: The kind field is used to indicate the type
  // of the object. This is to avoid conventions such as that used
  // by files (name.type -- e.g. test.ps = postscript etc.)

  try {
    // Resolve the name to an object reference.
    return rootContext->resolve(name);
  } catch(CosNaming::NamingContext::NotFound& ex) {
    // This exception is thrown if any of the components of the
    // path [contexts or the object] aren't found:
    cerr << "Context not found." << endl;
  } catch(CORBA::TRANSIENT& ex) {
    cerr << "Caught system exception TRANSIENT -- unable to contact the "
         << "naming service." << endl
	 << "Make sure the naming server is running and that omniORB is "
	 << "configured correctly." << endl;

  } catch(CORBA::SystemException& ex) {
    cerr << "Caught a CORBA::" << ex._name()
	 << " while using the naming service." << endl;
    return 0;
  }

  return CORBA::Object::_nil();
}
Esempio n. 15
0
File: client.cpp Progetto: manut/TAO
CORBA::Policy_ptr
create_min_ratio_policy (CORBA::ORB_ptr orb)
{
  CORBA::Any min_compression_ratio_any;
  Compression::CompressionRatio min_compression_ratio = 0.50;
  min_compression_ratio_any <<= min_compression_ratio;

  return orb->create_policy (ZIOP::COMPRESSION_MIN_RATIO_POLICY_ID, min_compression_ratio_any);
}
 /*!
  * @brief Constructor
  */
 OrganizationProxyTests()
 {
   int argc = 0;
   char** argv = NULL;
   m_pORB = CORBA::ORB_init(argc, argv);
   m_pPOA = PortableServer::POA::_narrow(
                    m_pORB->resolve_initial_references("RootPOA"));
   m_pPOA->the_POAManager()->activate();
 }
Esempio n. 17
0
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  int status = 0;
  try
    {
      Consumer_Client client;

      status = client.init (argc, argv);
      if (status != 0)
        ACE_ERROR_RETURN ((LM_ERROR, "Error: Client init failed.\n"),1);

      CosNotifyChannelAdmin::EventChannel_var ec =
        client.create_event_channel ("MyEventChannel", 1);

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

      sig_var sig = sig::_narrow (object.in ());

      CosNotifyChannelAdmin::ConsumerAdmin_var admin =
        create_consumeradmin (ec.in ());

      if (CORBA::is_nil (admin.in ()))
        ACE_ERROR_RETURN ((LM_ERROR, "Error: nil ConsumerAdmin.\n"),1);

      create_consumers (admin.in (), &client);

      ACE_DEBUG ((LM_DEBUG, "\nConsumer waiting for events...\n"));

      sig->go ();
      ACE_Time_Value tv (5);
      orb->run (tv);

      ACE_DEBUG ((LM_DEBUG, "Consumer done.\n"));
    }
  catch (const CORBA::Exception& e)
    {
      e._tao_print_exception ("Consumer Error: ");
      status = 1;
    }

  return status;
}
Esempio n. 18
0
static void
test_forward_permanent (CORBA::ORB_ptr orb)
{
  CORBA::Object_var obj1 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:1111,iiop:192.168.1.3:1111/NameService");

  // the permanent profile
  CORBA::Object_var obj4 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:4444,iiop:192.168.1.3:4444/NameService");

  TAO_Stub *stub1 = obj1->_stubobj ();
  TAO_Stub *stub4 = obj4->_stubobj ();

  TAO_Profile *profile = 0;

  profile = stub1->profile_in_use ();

  FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 1111));

  // ----- forward to obj2 permanently
  stub1->add_forward_profiles (stub4->base_profiles(), true /* permanent */ );

  FRANKS_ASSERT (stub1->forward_profiles () != 0);

  profile = stub1->next_profile ();

  FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 4444));

  // ----- stringified object reference must be equal to obj4->base_prpfiles().
  FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub4->base_profiles())) );

  // ----- consume second profile of obj2

  profile = stub1->next_profile ();

  FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 4444));


  // ----- reached end, next_profile() must yield NULL

  profile = stub1->next_profile ();

  FRANKS_ASSERT (profile == 0);

  FRANKS_ASSERT (stub1->forward_profiles () != 0);
}
Esempio n. 19
0
File: client.cpp Progetto: manut/TAO
CORBA::Policy_ptr
create_compression_enabled_policy (CORBA::ORB_ptr orb)
{
  // Setting policy whether compression is used.
  CORBA::Boolean compression_enabling = true;
  CORBA::Any compression_enabling_any;
  compression_enabling_any <<= CORBA::Any::from_boolean(compression_enabling);

  return orb->create_policy (ZIOP::COMPRESSION_ENABLING_POLICY_ID, compression_enabling_any);
}
Esempio n. 20
0
  Stock_Publisher (CORBA::ORB_ptr orb,
                   CORBA::StringSeq &stocks)
  {
    CORBA::Object_var obj = orb->resolve_initial_references ("RTCurrent");
    rt_current_ = RTCORBA::Current::_narrow (obj.in ());

    // Create the message
    sn_ = new OBV_Stock::StockNames ();
    sn_->names (stocks);
  }
Esempio n. 21
0
// Implementation skeleton constructor
CDBPropertySet::CDBPropertySet (CORBA::ORB_ptr orb,
				PortableServer::POAManager_ptr poa_manager,
				PortableServer::POA_ptr root_poa) :
  poa_m(PortableServer::POA::_nil()),
  poaCurrent_m(PortableServer::Current::_nil())
{
  ACS_TRACE("baci::CDBPropertySet::CDBPropertySet");

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

  // ID Assignment Policy
  policies[0] =
    root_poa->create_id_assignment_policy (PortableServer::USER_ID);
  
  // Lifespan Policy
  policies[1] =
    root_poa->create_lifespan_policy (PortableServer::PERSISTENT);
  
  // Request Processing Policy
  policies[2] =
    root_poa->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT);

  // Servant Retention Policy
  policies[3] =
    root_poa->create_servant_retention_policy (PortableServer::RETAIN);

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

  ACE_CString name = "DefaultServantPOA";
  poa_m = root_poa->create_POA (name.c_str (),
				poa_manager,
				policies);
  
  for (CORBA::ULong i = 0UL; i < policies.length (); ++i)
    {
      CORBA::Policy_ptr policy_p = policies[i];
      policy_p->destroy();
    }

  // Get the POA Current object reference
  CORBA::Object_var obj =
			orb->resolve_initial_references ("POACurrent");
  
  // Narrow the object reference to a POA Current reference
  this->poaCurrent_m =
      PortableServer::Current::_narrow (obj.in());
  
  // Set default servant
  poa_m->set_servant (this);
  
  instance_mp = this;
}
    /*!
     * @brief Constructor
     */
    OutPortConnectorTests()
    {

        int argc(0);
        char** argv(NULL);
        m_pORB = CORBA::ORB_init(argc, argv);
        m_pPOA = PortableServer::POA::_narrow(
		    m_pORB->resolve_initial_references("RootPOA"));
        m_pPOA->the_POAManager()->activate();

    }
Esempio n. 23
0
TAO_BEGIN_VERSIONED_NAMESPACE_DECL

CORBA::Object_ptr
TAO_CodecFactory_Loader::create_object (CORBA::ORB_ptr orb,  int, ACE_TCHAR *[])
{
  CORBA::Object_ptr obj = CORBA::Object_ptr ();
  ACE_NEW_RETURN (obj,
                  TAO_CodecFactory (orb->orb_core ()),
                  CORBA::Object::_nil ());
  return obj;
}
Esempio n. 24
0
//---------------------------------------------------------//
bool CServer::destroy_corba()
{
	try 
	{
		int count = 0;
		char** args = 0;
	
		CORBA::ORB_ptr orb = CORBA::ORB_init(count, args);
		CORBA::release(orb);

		orb->shutdown(true);
		orb->destroy();

		omniORB::setLogFunction(0);
	}
	catch(CORBA::SystemException& err) 
	{
		LOG4CPLUS_ERROR(CServer::server_logger(), 
		"corba::SystemException: " << ToString(err));
	}
	catch(CORBA::Exception& err) 
	{
		LOG4CPLUS_ERROR(CServer::server_logger(), 
		"corba::Exception: " << ToString(err));
	}
	catch(omniORB::fatalException& err) 
	{		
		LOG4CPLUS_ERROR(CServer::server_logger(), 
		"omniORB::FatalException: " << ToString(err));
	}
	catch (std::exception err) {
		LOG4CPLUS_ERROR(CServer::server_logger(),
		"std::exception occured while destroy_corba()" <<
		err.what());	
	}
	catch (...) {
		LOG4CPLUS_ERROR(CServer::server_logger(),
		"Unknown exception occured while destroying corba.");
	};
	return true;
}
Esempio n. 25
0
void
sync_server (CORBA::ORB_ptr orb,
             Test::AMI_Buffering_ptr flusher)
{
  // Get back in sync with the server...
  flusher->flush ();
  flusher->sync ();

  // Drain responses from the queue
  ACE_Time_Value tv (0, 100000);
  orb->run (tv);
}
Esempio n. 26
0
CORBA::Policy_ptr
create_low_value_policy (CORBA::ORB_ptr orb)
{
  // Setting policy for minimum amount of bytes that needs to be
  // compressed. If a message is smaller than this, it doesn't get
  // compressed
  CORBA::ULong compression_low_value = 100;
  CORBA::Any low_value_any;
  low_value_any <<= compression_low_value;

  return orb->create_policy (ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID, low_value_any);
}
Esempio n. 27
0
static CORBA::Object_ptr
get_distributor_reference (CORBA::ORB_ptr orb)
{
  if (use_naming)
    {
      CORBA::Object_var tmp =
        orb->resolve_initial_references ("NameService");

      CosNaming::NamingContext_var pns =
        CosNaming::NamingContext::_narrow (tmp.in ());

      CosNaming::Name name (1);
      name.length (1);
      name[0].id = distributor_name.c_str ();

      return pns->resolve (name);
    }
  else
    // Read and destringify the Stock_Distributor object's IOR.
    return orb->string_to_object (ior.c_str ());
}
Esempio n. 28
0
int
test_transport_current (CORBA::ORB_ptr orb)
{
  // Get the Current object.
  CORBA::Object_var tcobject =
    orb->resolve_initial_references ("TAO::Transport::IIOP::Current");

  if (TAO_debug_level >= 1)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("Tester (%P|%t) Resolved initial reference for IIOP::Current\n")));

  Transport::IIOP::Current_var tc =
    Transport::IIOP::Current::_narrow (tcobject.in ());

  if (TAO_debug_level >= 1)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("Tester (%P|%t) Narowed the IIOP Transport Current\n")));

  if (CORBA::is_nil (tc.in ()))
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("Tester (%P|%t) ERROR: Could not resolve ")
                  ACE_TEXT ("TAO::Transport::IIOP::Current object.\n")));

      throw CORBA::INTERNAL ();
    }

  ::CORBA::String_var rhost (tc->remote_host ());

  ::CORBA::String_var lhost (tc->local_host ());

  ::CORBA::Long id = tc->id ();

  ::TAO::CounterT bs = tc->bytes_sent ();

  ::TAO::CounterT br = tc->bytes_received ();

  ::TAO::CounterT rs = tc->messages_sent ();

  ::TAO::CounterT rr = tc->messages_received ();

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Tester (%P|%t) Transport [%q] [%C:%d -> %C:%d] ")
              ACE_TEXT ("Sent/Received [bytes=%q/%q, messages=%q/%q]\n"),
              (ACE_UINT64)id,
              rhost.in (), tc->remote_port (),
              lhost.in (), tc->local_port (),
              (ACE_UINT64)bs,
              (ACE_UINT64)br,
              (ACE_UINT64)rs,
              (ACE_UINT64)rr));
  return 0;
}
Esempio n. 29
0
AMH_Servant::AMH_Servant (CORBA::ORB_ptr orb)
  : sleep_time_ (0)
{
  // @@ Mayur, why do you obtain the reactor each time this method is
  //    called?  Why not just cache it once in the constructor.
  //    Furthermore, you don't appear to need the ORB pseudo-reference
  //    anything other than to obtain the Reactor.  Why not just
  //    remove the cached ORB pseudo-reference altogether?
  //
  // Mayur: Good point.  Never crossed my mind :)
  this->reactor_ = orb->orb_core ()->reactor ();
}
 OrbContext() {
   orb = ossie::corba::Orb();
   rootPOA = ossie::corba::RootPOA();
   namingService = ossie::corba::InitialNamingContext();
   namingServiceCtx = CosNaming::NamingContextExt::_nil();
   try {
     CORBA::Object_ptr obj;
     obj=orb->resolve_initial_references("NameService");
     namingServiceCtx = CosNaming::NamingContextExt::_narrow(obj);
   }
   catch(...){
   };
 };