Class SourceContextImpl

    • Constructor Detail

      • SourceContextImpl

        public SourceContextImpl​(java.lang.String sourceName,
                                 boolean isLoadingType,
                                 java.lang.String[] profiles,
                                 java.lang.ClassLoader classLoader,
                                 ClockFactory clockFactory,
                                 ResourceSource... resourceSources)
        Initiate the raw SourceContext to seed other SourceContext instances.
        Parameters:
        sourceName - Name of source.
        isLoadingType - Indicates if loading type.
        profiles - Active profiles.
        classLoader - ClassLoader.
        clockFactory - ClockFactory.
        resourceSources - ResourceSource instances.
      • SourceContextImpl

        public SourceContextImpl​(java.lang.String sourceName,
                                 boolean isLoadingType,
                                 java.lang.String[] additionalProfiles,
                                 SourceContext delegate,
                                 SourceProperties sourceProperties)
        Initiate specific SourceContext with necessary SourceProperties.
        Parameters:
        sourceName - Name of source.
        isLoadingType - Indicates if loading type.
        additionalProfiles - Additional profiles.
        delegate - Delegate SourceContext.
        sourceProperties - SourceProperties.
    • Method Detail

      • getName

        public java.lang.String getName()
        Description copied from interface: SourceContext
        Obtains the name of the item being sourced.
        Specified by:
        getName in interface SourceContext
        Returns:
        Name of item being sourced.
      • isLoadingType

        public boolean isLoadingType()
        Description copied from interface: SourceContext

        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.

        Specified by:
        isLoadingType in interface SourceContext
        Returns:
        true if loading as a type.
      • getProfiles

        public java.util.List<java.lang.String> getProfiles()
        Description copied from interface: SourceContext
        Obtains the listing of active profiles.
        Specified by:
        getProfiles in interface SourceContext
        Returns:
        Active profiles.
      • loadOptionalClass

        public java.lang.Class<?> loadOptionalClass​(java.lang.String name)
        Description copied from interface: SourceContext
        Attempts to load the specified Class.
        Specified by:
        loadOptionalClass in interface SourceContext
        Parameters:
        name - Name of the Class.
        Returns:
        Class or null if the Class can not be found.
      • loadClass

        public java.lang.Class<?> loadClass​(java.lang.String name)
                                     throws UnknownClassError
        Description copied from interface: SourceContext
        Loads the Class.
        Specified by:
        loadClass in interface SourceContext
        Parameters:
        name - Name of the Class.
        Returns:
        Class.
        Throws:
        UnknownClassError - If Class is not available. Let this propagate as OfficeFloor will handle it.
      • getOptionalResource

        public java.io.InputStream getOptionalResource​(java.lang.String location)
        Description copied from interface: SourceContext
        Attempts to obtain the resource at the specified location.
        Specified by:
        getOptionalResource in interface SourceContext
        Parameters:
        location - Location of the resource.
        Returns:
        InputStream to the contents of the resource or null if the resource can not be found.
      • getResource

        public java.io.InputStream getResource​(java.lang.String location)
                                        throws UnknownResourceError
        Description copied from interface: SourceContext
        Obtains the resource.
        Specified by:
        getResource in interface SourceContext
        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.
      • loadOptionalService

        public <S,​F extends ServiceFactory<S>> S loadOptionalService​(java.lang.Class<F> serviceFactoryType)
                                                                    throws LoadServiceError
        Description copied from interface: SourceContext
        Optionally loads a single service.
        Specified by:
        loadOptionalService in interface SourceContext
        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.
      • getClock

        public <T> Clock<T> getClock​(java.util.function.Function<java.lang.Long,​T> translator)
        Description copied from interface: SourceContext
        Obtains the Clock.
        Specified by:
        getClock in interface SourceContext
        Parameters:
        translator - Translate the seconds since Epoch to "time" returned from the Clock.
        Returns:
        Clock.
      • getLogger

        public java.util.logging.Logger getLogger()
        Description copied from interface: SourceContext

        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.

        Specified by:
        getLogger in interface SourceContext
        Returns:
        Logger.
      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
        Description copied from interface: SourceContext

        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.

        Specified by:
        getClassLoader in interface SourceContext
        Returns:
        ClassLoader.