Interface SourceContext

All Superinterfaces:
SourceProperties
All Known Subinterfaces:
AdministrationSourceContext, ExecutiveContext, ExecutiveSourceContext, GovernanceSourceContext, HttpSecuritySourceContext, ManagedFunctionSourceContext, ManagedObjectPoolSourceContext, ManagedObjectSourceContext<F>, OfficeExtensionContext, OfficeFloorExtensionContext, OfficeFloorSourceContext, OfficeSourceContext, SectionSourceContext, ServiceContext, SupplierSourceContext, TeamSourceContext, WoofTemplateExtensionChangeContext, WoofTemplateExtensionSourceContext
All Known Implementing Classes:
ConfigurationSourceContextImpl, ExecutiveContextImpl, ExecutiveSourceContextImpl, ManagedFunctionSourceContextImpl, ManagedObjectPoolSourceContextImpl, ManagedObjectSourceContextImpl, OfficeFloorSourceContextImpl, OfficeSourceContextImpl, SectionSourceContextImpl, SourceContextImpl, SupplierSourceContextImpl, TeamSourceContextWrapper

public interface SourceContext extends SourceProperties
Generic context for a source.
Author:
Daniel Sagenschneider
  • Method Details

    • getName

      String getName()
      Obtains the name of the item being sourced.
      Returns:
      Name of item being sourced.
    • isLoadingType

      boolean isLoadingType()

      Indicates if just loading as a type.

      When loading as a type the configuration provided is disregarded. This allows sources to know when to load singleton configuration that will take effect.

      Whether this is true or false the resulting type should be the same.

      Returns:
      true if loading as a type.
    • getProfiles

      List<String> getProfiles()
      Obtains the listing of active profiles.
      Returns:
      Active profiles.
    • loadOptionalClass

      Class<?> loadOptionalClass(String name)
      Attempts to load the specified Class.
      Parameters:
      name - Name of the Class.
      Returns:
      Class or null if the Class can not be found.
    • loadClass

      Class<?> loadClass(String name) throws UnknownClassError
      Loads the Class.
      Parameters:
      name - Name of the Class.
      Returns:
      Class.
      Throws:
      UnknownClassError - If Class is not available. Let this propagate as OfficeFloor will handle it.
    • getOptionalResource

      InputStream getOptionalResource(String location)
      Attempts to obtain the resource at the specified location.
      Parameters:
      location - Location of the resource.
      Returns:
      InputStream to the contents of the resource or null if the resource can not be found.
    • getResource

      InputStream getResource(String location) throws UnknownResourceError
      Obtains the resource.
      Parameters:
      location - Location of the resource.
      Returns:
      InputStream to the contents of the resource.
      Throws:
      UnknownResourceError - If resource is not found. Let this propagate as OfficeFloor will handle it.
    • loadService

      <S, F extends ServiceFactory<S>> S loadService(F serviceFactory) throws LoadServiceError
      Loads the specific service.
      Type Parameters:
      S - Service type
      F - ServiceFactory type to create service.
      Parameters:
      serviceFactory - ServiceFactory.
      Returns:
      Service.
      Throws:
      LoadServiceError - If fails to load the service.
    • loadService

      <S, F extends ServiceFactory<S>, D extends F> S loadService(Class<F> serviceFactoryType, D defaultServiceFactory) throws UnknownServiceError, LoadServiceError
      Loads a single service.
      Type Parameters:
      S - Service type
      F - ServiceFactory type to create service.
      D - Default ServiceFactory type.
      Parameters:
      serviceFactoryType - Type of ServiceFactory.
      defaultServiceFactory - Default ServiceFactory implementation. May be null to indicate no default service (one must be configured).
      Returns:
      Service.
      Throws:
      UnknownServiceError - If service is not configured and no default provided. Will also be thrown if more than one service is configured.
      LoadServiceError - If fails to load the service.
    • loadOptionalService

      <S, F extends ServiceFactory<S>> S loadOptionalService(Class<F> serviceFactoryType) throws LoadServiceError
      Optionally loads a single service.
      Type Parameters:
      S - Service type
      F - ServiceFactory type to create service.
      Parameters:
      serviceFactoryType - Type of ServiceFactory.
      Returns:
      Service or null if no service configured.
      Throws:
      LoadServiceError - If fails to load the service or ServiceLoader finds more than one service configured.
    • loadServices

      <S, F extends ServiceFactory<S>, D extends F> Iterable<S> loadServices(Class<F> serviceFactoryType, D defaultServiceFactory) throws UnknownServiceError, LoadServiceError
      Loads multiple services.
      Type Parameters:
      S - Service type
      F - ServiceFactory type to create service.
      D - Default ServiceFactory type.
      Parameters:
      serviceFactoryType - Type of ServiceFactory.
      defaultServiceFactory - Default ServiceFactory implementation. May be null to indicate no default service.
      Returns:
      Iterable over the services. The Iterable may also throw LoadServiceError if fails to create next service.
      Throws:
      UnknownServiceError - If no services are configured and no default provided.
      LoadServiceError - If fails to load a service.
    • loadOptionalServices

      <S, F extends ServiceFactory<S>> Iterable<S> loadOptionalServices(Class<F> serviceFactoryType) throws LoadServiceError
      Optionally loads multiple services.
      Type Parameters:
      S - Service type
      F - ServiceFactory type to create service.
      Parameters:
      serviceFactoryType - Type of ServiceFactory.
      Returns:
      Iterable over the services. May be no entries available. The Iterable may also throw LoadServiceError if fails to create next service.
      Throws:
      LoadServiceError - If fails to load a service.
    • getClassLoader

      ClassLoader getClassLoader()

      Obtains the ClassLoader.

      This is only provided in specific cases where a ClassLoader is required (such as creating a Proxy). The other methods of this interface should be used in preference to the returned ClassLoader.

      Returns:
      ClassLoader.
    • getLogger

      Logger getLogger()

      Obtains the Logger.

      The Logger is named specific to the source. This is especially the case for re-use of Class within sources, as would not be able to differentiate.

      Returns:
      Logger.
    • getClock

      <T> Clock<T> getClock(Function<Long,T> translator)
      Obtains the Clock.
      Type Parameters:
      T - Type of time.
      Parameters:
      translator - Translate the seconds since Epoch to "time" returned from the Clock.
      Returns:
      Clock.