from typing import Type, List

from dependencyinjection import DependencyContext
from messageprocessor import DefaultMessageProcessorExecutorFactory, MessageProcessorCallback


class DiMessageProcessorExecutorFactory(DefaultMessageProcessorExecutorFactory):
    def __init__(
        self,
        dependency_context: DependencyContext,
        callback_definitions: List[Type[MessageProcessorCallback]]
    ):
        callbacks = []
        for callback_definition in callback_definitions:
            callbacks.append(dependency_context.get_instance(callback_definition))
        super().__init__(callbacks)

    def build_executor(self, message_processor):
        return super().build_executor(message_processor)
