public interface JStachioExtensions
A container that will hold all resolved
JStachioExtensions and consolidate them
to a single instances of various services.- Author:
- agentgt
- API Note
- While this interface looks similar to
JStachioExtensionit is not an extension but rather an immutable bean like container. The methods are purposely java bean style (which is not the default in JStachio as JStachio prefers newer record like accessor method names) to support as many frameworks as possible.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA marker interface used for JStachio implementations that provide access to extensions. -
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends JStachioExtension>
Optional<T>findExtension(Class<T> c) Finds a specific implementation usingClass.isAssignableFrom(Class).Composite Config where the first config that returns a nonnull forJStachioConfig.getProperty(String)is used.The orignal contained extensions excluding the composites.Composite Filter where the ordering of the filter is based on a combination ofJStachioFilter.order()first and then the order in the iterable passed toof(Iterable).Composite Template finder where the first template finder that finds a template is used.static JStachioExtensionsof()Resolves extensions from theServiceLoaderwithJStachioExtensionas the SPI.static JStachioExtensionsof(Iterable<? extends JStachioExtension> extensions) Resolve from an iterable of extensions that usually come from some discovery mechanism like theServiceLoaderor a DI framework.static JStachioExtensionsof(Stream<? extends JStachioExtension> extensions) Resolve from a stream of extensions that usually come from some discovery mechanism like theServiceLoaderor a DI framework.
-
Method Details
-
of
Resolve from an iterable of extensions that usually come from some discovery mechanism like theServiceLoaderor a DI framework. The order of the extensions is important and primacy order takes precedence!- Parameters:
extensions- found extensions.- Returns:
- bean like container of services.
-
of
Resolve from a stream of extensions that usually come from some discovery mechanism like theServiceLoaderor a DI framework. The order of the extensions is important and primacy order takes precedence!- Parameters:
extensions- found extensions.- Returns:
- bean like container of services.
-
of
Resolves extensions from theServiceLoaderwithJStachioExtensionas the SPI.- Returns:
- jstachio extensions found by the ServiceLoader
-
getConfig
JStachioConfig getConfig()Composite Config where the first config that returns a nonnull forJStachioConfig.getProperty(String)is used.- Returns:
- config
-
getFilter
JStachioFilter getFilter()Composite Filter where the ordering of the filter is based on a combination ofJStachioFilter.order()first and then the order in the iterable passed toof(Iterable).- Returns:
- filter
-
getTemplateFinder
JStachioTemplateFinder getTemplateFinder()Composite Template finder where the first template finder that finds a template is used.- Returns:
- template finder
-
getExtensions
List<JStachioExtension> getExtensions()The orignal contained extensions excluding the composites.- Returns:
- found services
-
findExtension
Finds a specific implementation usingClass.isAssignableFrom(Class).- Type Parameters:
T- the implementation type- Parameters:
c- the implementation type.- Returns:
- an implementation if found
-