Package net.officefloor.frame.api.source
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,WoofTemplateChangeContext,WoofTemplateExtensionChangeContext,WoofTemplateExtensionSourceContext
- All Known Implementing Classes:
ConfigurationSourceContextImpl,ExecutiveContextImpl,ExecutiveSourceContextImpl,ManagedFunctionSourceContextImpl,ManagedObjectPoolSourceContextImpl,ManagedObjectSourceContextImpl,OfficeFloorSourceContextImpl,OfficeSourceContextImpl,SectionSourceContextImpl,SourceContextImpl,SupplierSourceContextImpl,TeamSourceContextWrapper,WoofTemplateChangeContextImpl,WoofTemplateExtensionChangeContextImpl
public interface SourceContext extends SourceProperties
Generic context for a source.- Author:
- Daniel Sagenschneider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.ClassLoadergetClassLoader()Obtains theClassLoader.<T> Clock<T>getClock(java.util.function.Function<java.lang.Long,T> translator)Obtains theClock.java.util.logging.LoggergetLogger()Obtains theLogger.java.lang.StringgetName()Obtains the name of the item being sourced.java.io.InputStreamgetOptionalResource(java.lang.String location)Attempts to obtain the resource at the specified location.java.util.List<java.lang.String>getProfiles()Obtains the listing of active profiles.java.io.InputStreamgetResource(java.lang.String location)Obtains the resource.booleanisLoadingType()Indicates if just loading as a type.java.lang.Class<?>loadClass(java.lang.String name)Loads theClass.java.lang.Class<?>loadOptionalClass(java.lang.String name)Attempts to load the specifiedClass.<S,F extends ServiceFactory<S>>
SloadOptionalService(java.lang.Class<F> serviceFactoryType)Optionally loads a single service.<S,F extends ServiceFactory<S>>
java.lang.Iterable<S>loadOptionalServices(java.lang.Class<F> serviceFactoryType)Optionally loads multiple services.<S,F extends ServiceFactory<S>>
SloadService(F serviceFactory)Loads the specific service.<S,F extends ServiceFactory<S>,D extends F>
SloadService(java.lang.Class<F> serviceFactoryType, D defaultServiceFactory)Loads a single service.<S,F extends ServiceFactory<S>,D extends F>
java.lang.Iterable<S>loadServices(java.lang.Class<F> serviceFactoryType, D defaultServiceFactory)Loads multiple services.-
Methods inherited from interface net.officefloor.frame.api.source.SourceProperties
getProperties, getProperty, getProperty, getPropertyNames
-
-
-
-
Method Detail
-
getName
java.lang.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
trueorfalsethe resulting type should be the same.- Returns:
trueif loading as a type.
-
getProfiles
java.util.List<java.lang.String> getProfiles()
Obtains the listing of active profiles.- Returns:
- Active profiles.
-
loadOptionalClass
java.lang.Class<?> loadOptionalClass(java.lang.String name)
Attempts to load the specifiedClass.- Parameters:
name- Name of theClass.- Returns:
Classornullif theClasscan not be found.
-
loadClass
java.lang.Class<?> loadClass(java.lang.String name) throws UnknownClassErrorLoads theClass.- Parameters:
name- Name of theClass.- Returns:
Class.- Throws:
UnknownClassError- IfClassis not available. Let this propagate as OfficeFloor will handle it.
-
getOptionalResource
java.io.InputStream getOptionalResource(java.lang.String location)
Attempts to obtain the resource at the specified location.- Parameters:
location- Location of the resource.- Returns:
InputStreamto the contents of the resource ornullif the resource can not be found.
-
getResource
java.io.InputStream getResource(java.lang.String location) throws UnknownResourceErrorObtains the resource.- Parameters:
location- Location of the resource.- Returns:
InputStreamto 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 typeF-ServiceFactorytype 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(java.lang.Class<F> serviceFactoryType, D defaultServiceFactory) throws UnknownServiceError, LoadServiceError
Loads a single service.- Type Parameters:
S- Service typeF-ServiceFactorytype to create service.D- DefaultServiceFactorytype.- Parameters:
serviceFactoryType- Type ofServiceFactory.defaultServiceFactory- DefaultServiceFactoryimplementation. May benullto 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(java.lang.Class<F> serviceFactoryType) throws LoadServiceError
Optionally loads a single service.- Type Parameters:
S- Service typeF-ServiceFactorytype to create service.- Parameters:
serviceFactoryType- Type ofServiceFactory.- Returns:
- Service or
nullif no service configured. - Throws:
LoadServiceError- If fails to load the service orServiceLoaderfinds more than one service configured.
-
loadServices
<S,F extends ServiceFactory<S>,D extends F> java.lang.Iterable<S> loadServices(java.lang.Class<F> serviceFactoryType, D defaultServiceFactory) throws UnknownServiceError, LoadServiceError
Loads multiple services.- Type Parameters:
S- Service typeF-ServiceFactorytype to create service.D- DefaultServiceFactorytype.- Parameters:
serviceFactoryType- Type ofServiceFactory.defaultServiceFactory- DefaultServiceFactoryimplementation. May benullto indicate no default service.- Returns:
Iterableover the services. TheIterablemay also throwLoadServiceErrorif 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>> java.lang.Iterable<S> loadOptionalServices(java.lang.Class<F> serviceFactoryType) throws LoadServiceError
Optionally loads multiple services.- Type Parameters:
S- Service typeF-ServiceFactorytype to create service.- Parameters:
serviceFactoryType- Type ofServiceFactory.- Returns:
Iterableover the services. May be no entries available. TheIterablemay also throwLoadServiceErrorif fails to create next service.- Throws:
LoadServiceError- If fails to load a service.
-
getClassLoader
java.lang.ClassLoader getClassLoader()
Obtains the
ClassLoader.This is only provided in specific cases where a
ClassLoaderis required (such as creating aProxy). The other methods of this interface should be used in preference to the returnedClassLoader.- Returns:
ClassLoader.
-
getLogger
java.util.logging.Logger getLogger()
Obtains the
Logger.The
Loggeris named specific to the source. This is especially the case for re-use ofClasswithin sources, as would not be able to differentiate.- Returns:
Logger.
-
-