コード例 #1
0
Components::CCMHome_ptr
ContainerInterfaceImpl::install_home (const char* id,
									  const char* entrypt,
									  const Components::ConfigValues& config)
throw (Components::Deployment::UnknownImplId,
       Components::Deployment::ImplEntryPointNotFound,
       Components::Deployment::InstallationFailure,
       Components::Deployment::InvalidConfiguration,
       CORBA::SystemException)
{
	DEBUG_OUT2("ContainerInterfaceImpl: install_home() called for ", id);

	//
	// analyse the configuration values
	//
	Components::ConfigValue* value;
	const char* homefinder_name = 0;
	const char* service_name = 0;

	for (CORBA::ULong i = 0; i < config.length(); i++)
	{
		value = config[i].in();

		if (! strcmp (config[i]->name(), "HOMEFINDERNAME"))
		{
			config[i]->value() >>= homefinder_name;
			break;
		}

		if (! strcmp (config[i]->name(), "CCMSERVICE"))
		{
			config[i]->value() >>= service_name;
			break;
		}
コード例 #2
0
ファイル: DDS_Servant.cpp プロジェクト: SEDS/CUTS
void DDS_Servant <T>::handle_config (const ::Components::ConfigValues & config)
{
  // Locate the DDSParticipantQoS property.
  size_t length = config.length ();
  const char * filename = 0;

  for (size_t i = 0; i < length; ++ i)
  {
    if (0 == ACE_OS::strcmp (config[i]->name (), "ParticipantQoS"))
    {
      config[i]->value () >>= filename;
      break;
    }
  }
コード例 #3
0
ファイル: CIAO_Handler_Common.cpp プロジェクト: CCJY/ATCD
  void
  Deployment_Common::create_attribute_configuration (const ::Deployment::Properties &props,
                                                     ::Components::ConfigValues & values)
  {
    values.length (props.length ());

    for (CORBA::ULong i = 0;
         i < props.length ();
         ++i)
      {
        values[i] = new CIAO::ConfigValue_impl (props[i].name.in (),
                                                props[i].value);
      }
  }
コード例 #4
0
::Components::Deployment::Container_ptr 
ComponentServerImpl::create_container(const ::Components::ConfigValues& config)
throw (Components::CreateFailure, Components::Deployment::InvalidConfiguration, CORBA::SystemException)
{
	Qedo::ContainerInterfaceImpl* container_if;

	// handle configuration
	const char* container_type_string = "";

	for (unsigned int i = 0; i < config.length(); i++)
	{
		DEBUG_OUT2 ("ComponentServerImpl: Got ConfigValue: ", config[i]->name());
		if (! strcmp (config[i]->name(), "CONTAINER_TYPE"))
		{
			config[i]->value() >>= container_type_string;

			break;
		}
	}
コード例 #5
0
ファイル: CHAOS_Servant_T.cpp プロジェクト: SEDS/CUTS
void
CHAOS_Servant_T <T, CONTEXT, EXECUTOR, POA_EXEC>::
handle_config (const ::Components::ConfigValues & props)
{
  // Call the base implementation, which calls back into load_port
  base_type::handle_config (props);

  // Find the configuration property so we can load the servants, and
  // configure servant.
  for (CORBA::ULong i = 0, length = props.length (); i < length; ++ i)
  {
    const ::Components::ConfigValue * config = props[i];

    if (PROPERTY_SERVANT_CONFIG == config->name ())
    {
      std::string value;
      config->value () >>= value;
    
      this->load_servant_configuration (value);
    }
  }
コード例 #6
0
ファイル: main.cpp プロジェクト: BackupTheBerlios/qedo
int
main (int argc, char** argv)
{
	cout << "Test Client for Stream Container" << endl;

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

    orb->register_value_factory ("IDL:omg.org/Components/FacetDescription:1.0", new FacetDescriptionFactory_impl());
	orb->register_value_factory ("IDL:omg.org/Components/ReceptacleDescription:1.0", new ReceptacleDescriptionFactory_impl());
    orb->register_value_factory ("IDL:omg.org/Components/SubscriberDescription:1.0", new SubscriberDescriptionFactory_impl());
    orb->register_value_factory ("IDL:omg.org/Components/EmitterDescription:1.0", new EmitterDescriptionFactory_impl());
    orb->register_value_factory ("IDL:omg.org/Components/ConsumerDescription:1.0", new ConsumerDescriptionFactory_impl());
    orb->register_value_factory ("IDL:omg.org/Components/ComponentPortDescription:1.0", new ComponentPortDescriptionFactory_impl());
    orb->register_value_factory ("IDL:omg.org/Components/Cookie:1.0", new CookieFactory_impl());

	CosNaming::NamingContext_var ns;

	try
	{
		CORBA::Object_var ns_obj = orb->resolve_initial_references ("NameService");
		ns = CosNaming::NamingContext::_narrow (ns_obj);
	}
	catch (CORBA::ORB::InvalidName&)
	{
		cerr << "Name Service not found" << endl;
		orb->destroy();
		exit (1);
	}
	catch (CORBA::SystemException&)
	{
		cerr << "Cannot narrow object reference of Name Service" << endl;
		orb->destroy();
		exit (1);
	}

	if (CORBA::is_nil (ns))
	{
		cerr << "Name Service is nil" << endl;
		orb->destroy();
		exit (1);
	}

	// Now get the Component Server Activator from the Name Service, use the name TETRA/Activators/<hostname>
	char hostname[256];
	if (gethostname (hostname, 256))
	{
		cerr << "Cannot determine my hostname" << endl;
		orb->destroy();
		exit (1);
	}

	// Get the Server Activator
	Components::Deployment::ServerActivator_var server_activator = get_server_activator (orb, ns, hostname);

	// Feed our test deployment into the Component Installer
	deploy_test_components (orb, ns, hostname);

	//
	// Begin tests
	//

	// Create Component Server
	Components::ConfigValues config;
	Components::ConfigValues config1;
	Components::Deployment::ComponentServer_var component_server;
	Components::Deployment::ComponentServer_var component_server1;
	Components::Deployment::ComponentServer_var component_server2;

	try
	{
		component_server = 	server_activator->create_component_server (config1);
	}
	catch (CORBA::Exception&)
	{
		cerr << "Exception during test run" << endl;
		orb->destroy();
		exit (1);
	}

	if (CORBA::is_nil (component_server))
	{
		cerr << "I got a nil reference for the created Component Server" << endl;
		orb->destroy();
		exit (1);
	}
#if 0
	try
	{
		component_server1 = 	server_activator->create_component_server (config1);
	}
	catch (CORBA::Exception&)
	{
		cerr << "Exception during test run" << endl;
		orb->destroy();
		exit (1);
	}

	if (CORBA::is_nil (component_server1))
	{
		cerr << "I got a nil reference for the created Component Server" << endl;
		orb->destroy();
		exit (1);
	}

	try
	{
		component_server2 = 	server_activator->create_component_server (config1);
	}
	catch (CORBA::Exception&)
	{
		cerr << "Exception during test run" << endl;
		orb->destroy();
		exit (1);
	}

	if (CORBA::is_nil (component_server2))
	{
		cerr << "I got a nil reference for the created Component Server" << endl;
		orb->destroy();
		exit (1);
	}
#endif
	// Create Container
	Components::Deployment::Container_var container;
	Components::Deployment::Container_var container1;
	Components::Deployment::Container_var container2;
	config.length (1);
	CORBA::Any any;
	any <<= "SESSION";
	config[0] = new ConfigValue_impl ("CONTAINER_TYPE", any);

	try
	{
		container = component_server->create_container (config);
	}
	catch (CORBA::SystemException& ex)
	{
		cerr << "CORBA system exception during creating container : " << ex << endl;
		orb->destroy();
		exit (1);
	}

#if 0
	try
	{
		container1 = component_server1->create_container (config);
	}
	catch (CORBA::SystemException& ex)
	{
		cerr << "CORBA system exception during creating container : " << ex << endl;
		orb->destroy();
		exit (1);
	}

	try
	{
		container2 = component_server2->create_container (config);
	}
	catch (CORBA::SystemException& ex)
	{
		cerr << "CORBA system exception during creating container : " << ex << endl;
		orb->destroy();
		exit (1);
	}
#endif
	//config.length(0);

	Components::CCMHome_var home;

	home = container->install_home ("PHILOSOPHER", "", config1);
	dinner::PhilosopherHome_var p_home = dinner::PhilosopherHome::_narrow (home);

#if 0
	home = container1->install_home ("CUTLERY", "", config1);
	dinner::CutleryHome_var c_home = dinner::CutleryHome::_narrow (home);

	home = container2->install_home ("OBSERVER", "", config1);
	dinner::ObserverHome_var o_home = dinner::ObserverHome::_narrow (home);
#else
	home = container->install_home ("CUTLERY", "", config1);
	dinner::CutleryHome_var c_home = dinner::CutleryHome::_narrow (home);

	home = container->install_home ("OBSERVER", "", config1);
	dinner::ObserverHome_var o_home = dinner::ObserverHome::_narrow (home);
#endif
	dinner::Philosopher_var phil1;
	dinner::Philosopher_var phil2;
	dinner::Philosopher_var phil3;
	dinner::Cutlery_var cut1;
	dinner::Cutlery_var cut2;
	dinner::Observer_var obs;
	dinner::Observer_var obs1;

	try 
	{
		phil1 = p_home->create();
		phil2 = p_home->create();
		phil3 = p_home->create();
		cut1 = c_home->create();
		cut2 = c_home->create();
		obs = o_home->create();
		obs1 = o_home->create();
	}
	catch (Components::CreateFailure&)
	{
		cerr << "Create Failure exception" << endl;
	}
	catch (CORBA::SystemException& ex)
	{
		cerr << ex << endl;
	}

	try
	{
		phil1->name ("Frank"); 
		phil2->name ("Bert"); 
		phil3->name ("Harry");
		phil1->thinking_seconds (5);
		phil2->thinking_seconds (3); 
		phil3->thinking_seconds (6);
		phil1->eating_seconds (4); 
		phil2->eating_seconds (6); 
		phil3->eating_seconds (3);
		phil1->sleeping_seconds (6); 
		phil2->sleeping_seconds (7); 
		phil3->sleeping_seconds (5);
		dinner::Fork_var a_fork;
		a_fork = cut1->provide_the_fork();
		phil1->connect_left_hand (a_fork);
		phil2->connect_left_hand (a_fork);
		phil3->connect_left_hand (a_fork);
		a_fork = cut2->provide_the_fork();
		phil1->connect_right_hand (a_fork);
		phil2->connect_right_hand (a_fork);
		phil3->connect_right_hand (a_fork);
		Components::Cookie* ck;
		dinner::PhilosopherStateConsumer_var consumer = obs->get_consumer_philosopher_state();
		ck = phil1->subscribe_philosopher_state (consumer);
		ck = phil2->subscribe_philosopher_state (consumer);
		ck = phil3->subscribe_philosopher_state (consumer);
		consumer = obs1->get_consumer_philosopher_state();
		ck = phil1->subscribe_philosopher_state (consumer);
		ck = phil2->subscribe_philosopher_state (consumer);
		ck = phil3->subscribe_philosopher_state (consumer);
		phil1->configuration_complete(); 
		phil2->configuration_complete(); 
		phil3->configuration_complete();
		cut1->configuration_complete();
		cut2->configuration_complete();
		obs->configuration_complete();
		obs1->configuration_complete();
	}
	catch (CORBA::SystemException& ex)
	{
		cerr << ex << endl;
	}

	sleep (30);

	try
	{
		phil1->remove();
		phil2->remove();
		phil3->remove();
		c_home->remove_component (cut1);
		c_home->remove_component (cut2);
		obs->remove();
		obs1->remove();
	}
	catch (Components::RemoveFailure&)
	{
		cerr << "Remove Failure during remove_component()" << endl;
	}
	catch (CORBA::SystemException& ex)
	{
		cerr << ex << endl;
	}


	try
	{
#if 0
		container1->remove_home (c_home);
		container2->remove_home (o_home);
#else
		container->remove_home (c_home);
		container->remove_home (o_home);
#endif
		// remove at last because of it was installed first
		// registering the valuetype factories
		container->remove_home (p_home);
	}
	catch (Components::RemoveFailure&)
	{
		cerr << "Remove Failure during removing home" << endl;
	}
	catch (CORBA::SystemException& ex)
	{
		cerr << ex << endl;
	}
	try
	{
		container->remove();
	}
	catch (Components::RemoveFailure&)
	{
		cerr << "Remove Failure during removing container" << endl;
	}
	catch (CORBA::SystemException& ex)
	{
		cerr << ex << endl;
	}
	try
	{
		component_server->remove();
#if 0
		getchar();
		component_server1->remove();
		getchar();
		component_server2->remove();
#endif
	}
	catch (Components::RemoveFailure&)
	{
		cerr << "Remove Failure during removing component server" << endl;
	}
	catch (CORBA::SystemException& ex)
	{
		cerr << ex << endl;
	}

	return 0;
}
コード例 #7
0
Components::ConfigValues*
Properties::getConfigValues()
{
	char* fileName = strdup( descriptor_.c_str() );
	parser_->parse( fileName );
	document_ = parser_->getDocument();
	DOM_Element property = document_.getDocumentElement();
	
	Components::ConfigValues* config = new Components::ConfigValues();
	int len = 0;
	DOM_Node child = property.getFirstChild();
    while( child != 0)
    {
		// simple
		if( ( child.getNodeType() == DOM_Node::ELEMENT_NODE ) &&
			( child.getNodeName().equals( "simple" ) ) )
		{
			DOM_NodeList nodeList;
			DOM_Element simple = ( DOM_Element& )child;
			std::string type = simple.getAttribute( "type" ).transcode();
			std::string name = simple.getAttribute( "name" ).transcode();

			nodeList = simple.getElementsByTagName( "value" );
			DOM_Element value = ( const DOM_Element& )nodeList.item( 0 );

			CORBA::Any any;
			std::string val = value.getFirstChild().getNodeValue().transcode();
			
			if( type == "boolean" )
			{
				CORBA::Boolean v;
				if( val == "true" )
				{
					v = true;
				}
				else
				{
					v = false;
				}
				any <<= CORBA::Any::from_boolean( v );
			}

			if( type == "char" )
			{
				CORBA::Char v = val[0];
				any <<= CORBA::Any::from_char( v );
			}

			if( type == "double" )
			{
				CORBA::Double v = atof( val.c_str() );
				any <<= v;
			}

			if( type == "float" )
			{
				CORBA::Float v = atof( val.c_str() );
				any <<= v;
			}

			if( type == "short" )
			{
				CORBA::Short v = atoi( val.c_str() );
				any <<= v;
			}

			if( type == "long" )
			{
				CORBA::Long v = atol( val.c_str() );
				any <<= v;
			}

			if( type == "objref" )
			{
				// TODO
			}

			if( type == "octet" )
			{
				CORBA::Octet v = val[0];
				any <<= CORBA::Any::from_octet( v );
			}

			if( type == "string" )
			{
				any <<= val.c_str();
			}

			if( type == "ulong" )
			{
				CORBA::ULong v = atol( val.c_str() );
				any <<= v;
			}

			if( type == "ushort" )
			{
				CORBA::UShort v = atol( val.c_str() );
				any <<= v;
			}

			// new config entry
			config->length( ++len );
			( *config )[len - 1] = new ConfigValue_impl( CORBA::string_dup( name.c_str() ), any );
		}

		// sequence
		if( ( child.getNodeType() == DOM_Node::ELEMENT_NODE ) &&
			( child.getNodeName().equals( "sequence" ) ) )
		{
		}

		// struct
		if( ( child.getNodeType() == DOM_Node::ELEMENT_NODE ) &&
			( child.getNodeName().equals( "struct" ) ) )
		{
		}

		// value
		if( ( child.getNodeType() == DOM_Node::ELEMENT_NODE ) &&
			( child.getNodeName().equals( "valuetype" ) ) )
		{
		}

		// next element
		child = child.getNextSibling();
	}

	return config;
}