<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def invalidate(self, callback=True):
 # type: (bool) -> bool """ Applies the component invalidation. :param callback: If True, call back the component before the invalidation :return: False if the component wasn't valid """

        with self._lock:
            if self.state != StoredInstance.VALID:
                # Instance is not running...
                return False

            # Change the state
            self.state = StoredInstance.INVALID

            # Call the handlers
            self.__safe_handlers_callback("pre_invalidate")

            # Call the component
            if callback:
                # pylint: disable=W0212
                self.__safe_validation_callback(
                    constants.IPOPO_CALLBACK_INVALIDATE
                )

                # Trigger an "Invalidated" event
                self._ipopo_service._fire_ipopo_event(
                    constants.IPopoEvent.INVALIDATED,
                    self.factory_name,
                    self.name,
                )

            # Call the handlers
            self.__safe_handlers_callback("post_invalidate")
            return True