<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register(self, locator, factory):
 """ Registers a component using a factory method. :param locator: a locator to identify component to be created. :param factory: a factory function that receives a locator and returns a created component. """

        if locator == None:
            raise Exception("Locator cannot be null")
        if factory == None:
            raise Exception("Factory cannot be null")

        self._registrations.append(Registration(locator, factory))