Beispiel #1
0
int
ACE_TMAIN(int, ACE_TCHAR *[])
{
  // Process a Service Configurator directive that will cause the test
  // server module to be dynamically loaded.
  //
  // This is done to prevent the server binary from being forced to
  // explicitly link to the test server module library.  Hence, the
  // server binary is completely decoupled from the test server
  // module (and the ORB!).
  //
  // In the process of doing this, the Test CORBA object will be
  // activated, and the ORB will be run.
  if (ACE_Service_Config::process_directive (
        ACE_DYNAMIC_SERVICE_DIRECTIVE("Server_Module",
          "Test_Server_Module", "_make_Test_Server_Module", "")) != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "%p\n",
                         "ERROR: Server unable to process the "
                         "Service Configurator directive"),
                        -1);
    }

  ACE_DEBUG ((LM_INFO,
              "SERVER: CORBA-portion of the test dynamically loaded.\n"));

  // Wait for all threads to complete.
  ACE_Thread_Manager::instance ()->wait ();

  ACE_DEBUG ((LM_INFO,
              "SERVER:  Terminated successfully.\n"));

  return 0;
}
Beispiel #2
0
int
ACE_TMAIN(int, ACE_TCHAR *[])
{
  // Process a Service Configurator directive that will cause the test
  // client module to be dynamically loaded.
  //
  // This is done to prevent the client binary from being forced to
  // explicitly link to the test client module library.  Hence, the
  // client binary is completely decoupled from the test client
  // module (and the ORB!).
  //
  // In the process of doing this, the Test method provided by target
  // CORBA object will be invoked.
  if (ACE_Service_Config::process_directive (
        ACE_DYNAMIC_SERVICE_DIRECTIVE(
          "Client_Module",
          "Test_Client_Module",
          "_make_Test_Client_Module",
          "-k file://test.ior")) != 0)
    {

      ACE_ERROR_RETURN ((LM_ERROR,
                         "%p\n",
                         "ERROR: Client unable to process the "
                         "Service Configurator directive"),
                        -1);
    }

  ACE_DEBUG ((LM_INFO,
              "CLIENT: CORBA-portion of the test dynamically loaded.\n"));

  // Wait for all threads to complete.
  ACE_Thread_Manager::instance ()->wait ();

  ACE_DEBUG ((LM_INFO,
              "CLIENT:  Terminated successfully.\n"));

  return 0;
}
Beispiel #3
0
// $Id: server.cpp 96409 2012-11-29 10:12:36Z johnnyw $

#include "ace/ARGV.h"
#include "ace/Reactor.h"
#include "ace/Signal.h"
#include "ace/Service_Config.h"
#include "ace/Log_Msg.h"

ACE_TCHAR const * const scpc_loadOrb = ACE_DYNAMIC_SERVICE_DIRECTIVE(
  "testDllOrb",
  "Bug_3542",
  "_make_DllOrb",
  "testDllOrb -ORBDebugLevel 0 -ORBId testDllOrb -NumThreads 2 -ORBDottedDecimalAddresses 1 -ORBCollocationStrategy thru_poa"
);

ACE_TCHAR const * const scpc_unloadOrb = ACE_REMOVE_SERVICE_DIRECTIVE("testDllOrb");

int
ACE_TMAIN(int, ACE_TCHAR **)
{
  int result = 0;
#if 0
  ACE_Service_Config serviceConfig;

  char signum[64];
  ACE_OS::sprintf(signum, "%d", SIGUSR1);

  ACE_ARGV args;
  args.add(argv[0]);
  args.add("-s");
  args.add(signum);
Beispiel #4
0
// $Id: bug2936.cpp 96398 2012-11-28 07:33:51Z johnnyw $

#include "ace/Service_Config.h"
#include "ace/Log_Msg.h"
#include "ace/OS_NS_unistd.h"

char const * const scpc_orbId = "testDllOrb";

ACE_TCHAR const * const scpc_loadOrb = ACE_DYNAMIC_SERVICE_DIRECTIVE(
        "testDllOrb",
        "bug2936",
        "_make_DllORB",
        "testDllOrb -ORBDebugLevel 0 -ORBId testDllOrb -ORBDottedDecimalAddresses 1"
                                       );

ACE_TCHAR const * const scpc_unloadOrb = ACE_REMOVE_SERVICE_DIRECTIVE("testDllOrb");


ACE_TCHAR const * const scpc_loadPersistentPoa = ACE_DYNAMIC_SERVICE_DIRECTIVE(
            "testPersistentPoa",
            "bug2936",
            "_make_PersistentPoa",
            "testPersistentPoa testDllOrb"
        );

ACE_TCHAR const * const scpc_unloadPersistentPoa = ACE_REMOVE_SERVICE_DIRECTIVE("testPersistentPoa");

void loadunloadcycle()
{
    int result = 0;
Beispiel #5
0
void
Lorica::Proxy::configure(Config & config, 
			 const std::string &def_ior_file )
	throw (InitError)
{
	try {
		// This should be OK even if multiple copies of Proxy
		// get created as they all create the same ORB instance
		// and therefore the single ORB instance will get shutdown.
		Lorica::Proxy::this_ = this;

		std::auto_ptr<ACE_ARGV> arguments(config.get_orb_options());

		// Create proxy ORB.
		int argc = arguments->argc();
		if (Lorica_debug_level > 2) {
			ACE_DEBUG((LM_DEBUG,
				   ACE_TEXT("(%T) %N:%l - passing %d args to ORB_init:\n"), 
				   argc));

			for (int i = 0; i < argc; i++)
				ACE_DEBUG((LM_DEBUG, ACE_TEXT("%N:%l - %s\n"), arguments->argv()[i]));
		}
		orb_ = CORBA::ORB_init(argc, arguments->argv());

		// test if we have any security functionality
		ACE_Service_Repository * repo = 
			orb_->orb_core()->configuration()->
			current_service_repository();
		config.secure_available(repo->find("SSLIOP_Factory") == 0);

		int attempts = 3;
		CORBA::Object_var obj = CORBA::Object::_nil();
		resolve_again:
		try {
			obj = orb_->resolve_initial_references("RootPOA");
		}
		catch (CORBA::Exception & ex) {
			if (attempts--) {
				ACE_DEBUG((LM_INFO, ACE_TEXT("(%T) %N:%l - Exception trying to resolve initial references\n")));
				ACE_OS::sleep(10);
				goto resolve_again;
			}
			ACE_DEBUG((LM_ERROR, ACE_TEXT("(%T) %N:%l - %s\n"), ex._info().c_str()));
			throw InitError();
		}

		root_poa_ = PortableServer::POA::_narrow(obj.in());
		if (CORBA::is_nil(root_poa_.in())) {
			ACE_ERROR((LM_ERROR,
				   "(%T) %N:%l - could not get root POA\n"));
			throw InitError();
		}

		pmf_ = root_poa_->the_POAManagerFactory();
		if (CORBA::is_nil(pmf_.in())) {
			ACE_ERROR((LM_ERROR,
				   "(%T) %N:%l - could not get PMF\n"));
			throw InitError();
		}

		obj = orb_->resolve_initial_references("IORTable");
		iorTable_ = IORTable::Table::_narrow(obj.in());
		if (CORBA::is_nil(iorTable_.in())) {
			ACE_ERROR((LM_ERROR,
				   "(%T) %N:%l - could not get IORTable\n"));
			throw InitError();
		}

		CORBA::PolicyList policies;
		EndpointPolicy::EndpointList list;
		CORBA::Any policy_value;

		// Create external POA manager
		Config::Endpoints ex_points = config.get_endpoints(true);
		policies.length(1);
		list.length(ex_points.size());
		if (Lorica_debug_level > 2) {
			ACE_DEBUG((LM_DEBUG,
				   ACE_TEXT("(%T) %N:%l - setting up External POA manager with %d endpoints\n"),
				   ex_points.size()));
		}
		for (size_t count = 0; count < ex_points.size(); count++) {
			std::string inter = ex_points[count].hostname_;
			if (!ex_points[count].alias_.empty())
				inter = ex_points[count].alias_;

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

		// Create internal POA manager.
		Config::Endpoints in_points = config.get_endpoints(false);
		policies.length(1);
		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()) {
			ACE_ERROR ((LM_ERROR,
				    "(%T) %N:%l - could not set up shutdown handler\n"));
			throw InitError();
		}

		// Initialize the mapper registry
		Lorica_MapperRegistry *mreg = 
			ACE_Dynamic_Service<Lorica_MapperRegistry>::instance
			(this->orb_->orb_core()->configuration(),"MapperRegistry");

		std::string ne_ids = config.null_eval_type_ids();
		if (!ne_ids.empty()) {
			if (Lorica_debug_level > 2) {
				ACE_DEBUG((LM_DEBUG,
					   ACE_TEXT("(%T) %N:%l - adding type ids for null ")
					   ACE_TEXT("evaluator: %s\n"),
					   ne_ids.c_str()));
			}

			size_t space = ne_ids.find(' ');
			size_t start = 0;
			while (space != std::string::npos) {
				mreg->add_null_mapper_type(ne_ids.substr(start,space - start));
				start = space+1;
				space = ne_ids.find(' ',start);
			}
			mreg->add_null_mapper_type(ne_ids.substr(start));
		} else if (config.null_eval_any()) {
			if (Lorica_debug_level > 2)
				ACE_DEBUG((LM_DEBUG,
					   ACE_TEXT("(%T) %N:%l - creating default null mapper\n")));
			mreg->create_default_null_mapper();
		}
		if (config.generic_evaluator()) {
			if (Lorica_debug_level > 0) {
				ACE_DEBUG((LM_DEBUG,
					   ACE_TEXT("(%T) %N:%l - loading generic evaluator\n")));
			}
#ifdef ACE_WIN32
			this->orb_->orb_core()->configuration()->process_directive
				(ACE_TEXT_ALWAYS_CHAR
				 (ACE_DYNAMIC_SERVICE_DIRECTIVE("Lorica_GenericLoader",
								"lorica_GenericEvaluator",
								"_make_Lorica_GenericLoader",
								"")
					 )
					);
#else
			Lorica::GenericMapper *gen_eval =
				new Lorica::GenericMapper(debug_, *mreg);
			mreg->add_proxy_mapper(gen_eval);
#endif
		}

		// add generic or other mappers...
		mreg->init_mappers(this->outside_pm_,
				   this->inside_pm_,
				   this->orb_,
				   config.secure_available());



		// last thing to do, put both POAs in the active state.
		outside_pm_->activate();
		inside_pm_->activate();

	}
	catch (CORBA::Exception & ex) {
		ACE_DEBUG((LM_ERROR, ACE_TEXT("(%T) %N:%l - %s\n"), ex._info().c_str()));
		throw InitError();
	}
	catch (...) {
		ACE_ERROR((LM_ERROR, "%N:%l - Caught an otherwise unknown exception\n"));
		throw InitError();
	}
}