fastoad.module_management.bundle_loader module

Basis for registering and retrieving services

class fastoad.module_management.bundle_loader.BundleLoader[source]

Bases: object

Helper class for loading Pelix bundles.

Constructor

property context

BundleContext instance of running Pelix framework

property framework

The currently running Pelix framework instance, or a new one if none is running (anyway, the framework instance will continue after deletion of this BundleLoader instance)

get_factory_names(service_name: str = None, properties: dict = None, case_sensitive: bool = False) → List[str][source]

Browses the available factory names to find what factories provide service_name (if provided) and match provided properties (if provided).

if neither service_name nor properties are provided, all registered factory names are returned.

Parameters
  • service_name

  • properties

  • case_sensitive – if False, case of property values will be ignored

Returns

the list of factory names

get_factory_path(factory_name: str)str[source]
Parameters

factory_name

Returns

path of the file where the factory is defined

get_factory_properties(factory_name: str)dict[source]
Parameters

factory_name

Returns

properties of the factory

get_factory_property(factory_name: str, property_name: str) → Any[source]
Parameters
  • factory_name

  • property_name

Returns

property value, or None if property is not found

get_instance_property(instance: Any, property_name: str) → Any[source]
Parameters
  • instance – any instance from :meth:~BundleLoader.instantiate_component

  • property_name

Returns

property value, or None if property is not found

get_services(service_name: str, properties: dict = None, case_sensitive: bool = False) → Optional[list][source]

Returns the services that match service_name and provided properties (if provided).

Parameters
  • service_name

  • properties

  • case_sensitive – if False, case of property values will be ignored

Returns

the list of service instances

install_packages(folder_path: str) → Tuple[Set[pelix.framework.Bundle], Set[str]][source]

Installs bundles found in folder_path.

Bundles that contain factories that are programmatically registered will try to register them again if they are “started”, which will result in error log messages from iPOPO. On the other side, bundles that define factories using iPOPO decorators will need to be started for these factories to be registered.

Parameters

folder_path – The path of folder to scan

Returns

A 2-tuple, with the list of installed bundles (Bundle) and the list of the names of the modules which import failed.

Raises

ValueError – Invalid path

instantiate_component(factory_name: str, properties: dict = None) → Any[source]

Instantiates a component from given factory

Parameters
  • factory_name – name of the factory

  • properties – Initial properties of the component instance

Returns

the component instance

register_factory(component_class: type, factory_name: str, service_names: Union[List[str], str], properties: dict = None)type[source]

Registers provided class as iPOPO component factory.

Parameters
  • component_class – the class of the components that will be provided by the factory

  • factory_name – the name of the factory

  • service_names – the service(s) that will be provided by the components

  • properties – the properties associated to the factory

Returns

the input class, amended by iPOPO

Raises

FastDuplicateFactoryError