/** * Jooby https://jooby.io * Apache License Version 2.0 https://jooby.io/LICENSE.txt * Copyright 2014 Edgar Espina */ package io.jooby; import io.jooby.exception.RegistryException; import javax.annotation.Nonnull; /** * Service locator pattern which may be provided by a dependency injection framework. * * @since 2.0.0 * @author edgar * @see ServiceRegistry */ public interface Registry { /** * Provides an instance of the given type. * * @param type Object type. * @param Object type. * @return Instance of this type. * @throws RegistryException If there was a runtime failure while providing an instance. */ @Nonnull T require(@Nonnull Class type) throws RegistryException; /** * Provides an instance of the given type where name matches it. * * @param type Object type. * @param name Object name. * @param Object type. * @return Instance of this type. * @throws RegistryException If there was a runtime failure while providing an instance. */ @Nonnull T require(@Nonnull Class type, @Nonnull String name) throws RegistryException; /** * Provides an instance of the given type. * * @param key Object key. * @param Object type. * @return Instance of this type. * @throws RegistryException If there was a runtime failure while providing an instance. */ @Nonnull T require(@Nonnull ServiceKey key) throws RegistryException; }