Interface ServiceLocator

All Known Implementing Classes:
FilteredServiceLocator, GuiceServiceLocator

public interface ServiceLocator
Used to access instances which would otherwise be provided using the javax.getInstance annotations javax.injext.Inject and javax.injext.Named. Created by patricktwohig on 8/27/15.
  • Method Details

    • getInstance

      default <T> T getInstance(Class<T> tClass)
      Gets the type of service, unnamed.
      Type Parameters:
      T - the type ot getInstance
      Parameters:
      tClass - the type to getInstance
      Returns:
      an injected instance of the supplied Class<T>
    • getInstance

      default <T> T getInstance(Class<T> tClass, String named)
      Gets the type of the service with the specific name.
      Type Parameters:
      T -
      Parameters:
      tClass - the type
      named - the name as represented by the javax.injext.Named annotation
      Returns:
      the object representing the requested type.
    • getInstance

      default <T> T getInstance(ElementServiceKey<T> serviceKey)
      Gets the type of the service with the specific name.
      Type Parameters:
      T - the type
      Parameters:
      serviceKey - the ElementServiceKey
      Returns:
      the object representing the requested type.
    • findInstance

      default <T> Optional<Supplier<T>> findInstance(Class<T> tClass)
      Finds the Supplier to the supplied instance. This does not load the instance until the returned Supplier is called, therefore avoiding expensive loading operations if just checking for the existence of the service.
      Type Parameters:
      T - the type to request
      Parameters:
      tClass - the type to fine
      Returns:
      an Optional of Supplier to the object
    • findInstance

      default <T> Optional<Supplier<T>> findInstance(Class<T> tClass, String named)
      Finds the Supplier to the supplied instance. This does not load the instance until the returned Supplier is called, therefore avoiding expensive loading operations if just checking for the existence of the service.
      Type Parameters:
      T - the type to request
      Parameters:
      tClass - the type to fine
      named - the name of the service
      Returns:
      an Optional of Supplier to the object
    • findInstance

      <T> Optional<Supplier<T>> findInstance(ElementServiceKey<T> key)
      Gets the service using the ElementServiceKey.
      Type Parameters:
      T - the type to request
      Parameters:
      key - the key
      Returns:
      an Optional of Supplier to the object