def __call__(self, clazz):
        """
        Adds the provided service information to the class context iPOPO field.
        Creates the field if needed.

        :param clazz: The class to decorate
        :return: The decorated class
        :raise TypeError: If *clazz* is not a type or if the service factory
                          methods are missing
        """
        if not inspect.isclass(clazz):
            raise TypeError(
                "@Provides can decorate only classes, not '{0}'".format(
                    type(clazz).__name__
                )
            )

        # Get the factory context
        context = get_factory_context(clazz)
        if context.completed:
            # Do nothing if the class has already been manipulated
            _logger.warning(
                "@Provides: Already manipulated class: %s",
                get_method_description(clazz),
            )
            return clazz

        # Avoid duplicates (but keep the order)
        filtered_specs = []
        if not self.__specifications:
            filtered_specs = _get_specifications(clazz.__bases__)
        else:
            # Avoid duplicates (but keep the order)
            specs = _get_specifications(self.__specifications)
            for spec in specs:
                if spec not in filtered_specs:
                    filtered_specs.append(spec)

        # Store the service information
        config = context.set_handler_default(self.HANDLER_ID, [])
        config.append(
            (
                filtered_specs,
                self.__controller,
                self.__is_factory,
                self.__is_prototype,
            )
        )

        if self.__controller:
            # Inject a property in the class. The property will call an
            # instance level getter / setter, injected by iPOPO after the
            # instance creation
            setattr(
                clazz,
                self.__controller,
                _ipopo_class_field_property(
                    self.__controller, True, constants.IPOPO_CONTROLLER_PREFIX
                ),
            )

            # Inject the future controller methods
            setattr(
                clazz,
                constants.IPOPO_CONTROLLER_PREFIX
                + constants.IPOPO_GETTER_SUFFIX,
                None,
            )
            setattr(
                clazz,
                constants.IPOPO_CONTROLLER_PREFIX
                + constants.IPOPO_SETTER_SUFFIX,
                None,
            )

        if self.__is_factory or self.__is_prototype:
            # Ensure that the service factory methods exist
            try:
                validate_method_arity(
                    clazz.get_service, "bundle", "service_registration"
                )
                validate_method_arity(
                    clazz.unget_service, "bundle", "service_registration"
                )
            except AttributeError as ex:
                raise TypeError(
                    "Service factories must provide an {} method".format(ex)
                )

        if self.__is_prototype:
            # Ensure that the prototype service factory methods exist
            try:
                validate_method_arity(
                    clazz.unget_service_instance,
                    "bundle",
                    "service_registration",
                    "service",
                )
            except AttributeError as ex:
                raise TypeError(
                    "Prototype Service factories must provide "
                    "an {} method".format(ex)
                )

        return clazz
def __call__ ( self , clazz ) : if not inspect . isclass ( clazz ) : raise TypeError ( "@Provides can decorate only classes, not '{0}'" . format ( type ( clazz ) . __name__ ) ) context = get_factory_context ( clazz ) if context . completed : _logger . warning ( "@Provides: Already manipulated class: %s" , get_method_description ( clazz ) , ) return clazz filtered_specs = [ ] if not self . __specifications : filtered_specs = _get_specifications ( clazz . __bases__ ) else : specs = _get_specifications ( self . __specifications ) for spec in specs : if spec not in filtered_specs : filtered_specs . append ( spec ) config = context . set_handler_default ( self . HANDLER_ID , [ ] ) config . append ( ( filtered_specs , self . __controller , self . __is_factory , self . __is_prototype , ) ) if self . __controller : setattr ( clazz , self . __controller , _ipopo_class_field_property ( self . __controller , True , constants . IPOPO_CONTROLLER_PREFIX ) , ) setattr ( clazz , constants . IPOPO_CONTROLLER_PREFIX + constants . IPOPO_GETTER_SUFFIX , None , ) setattr ( clazz , constants . IPOPO_CONTROLLER_PREFIX + constants . IPOPO_SETTER_SUFFIX , None , ) if self . __is_factory or self . __is_prototype : try : validate_method_arity ( clazz . get_service , "bundle" , "service_registration" ) validate_method_arity ( clazz . unget_service , "bundle" , "service_registration" ) except AttributeError as ex : raise TypeError ( "Service factories must provide an {} method" . format ( ex ) ) if self . __is_prototype : try : validate_method_arity ( clazz . unget_service_instance , "bundle" , "service_registration" , "service" , ) except AttributeError as ex : raise TypeError ( "Prototype Service factories must provide " "an {} method" . format ( ex ) ) return clazz
Adds the provided service information to the class context iPOPO field.
        Creates the field if needed.

        :param clazz: The class to decorate
        :return: The decorated class
        :raise TypeError: If *clazz* is not a type or if the service factory
                          methods are missing