package riomhaire.lti.core.model.interfaces;

import riomhaire.lti.core.model.configuration.ClientConfiguration;
import riomhaire.lti.core.model.configuration.ToolConfiguration;

import java.util.Optional;

/**
 * This is the minimal Registry info on the environment. Its the context within which commands run and can get
 * Access to other components
 */
public interface ApplicationRegistry<R,M> {

    /**
     * Return the current client configuration resolver
     * This is a entity which allows tool to verify token etc is from some reliable source
     * The default implementation is a caller to redis where we have information on a deployed registered tool
     * And where to find the JWKS etc
     * @return     ClientRegistrationResolver
     */
    UniKeyResolver<Optional<ClientConfiguration>, String> clientRegistrationResolver();

    /**
     * Return the current tool configuration resolver
     * This is where most of the tool configuration is stored -  keys, secrets etc
     * @return     ToolConfigurationResolver
     */
    NoKeyResolver<Optional<ToolConfiguration>> toolConfigurationResolver();

    /**
     * command dispatcher... this is the entity that stores a mapping between a message type and its handler
     * command. It looks up the message type and delegates to a command to handle it. There is a default command
     * handler if no command has been registered. At the moment its a 1-1 mapping
     *
     * @return  CommandDispatcher
     */
    CommandDispatcher<R, ApplicationRegistry<R,M>, M> commandDispatcher();
}
