public interface JStachioExtensions
A container that will hold all resolved
JStachioExtension
s and consolidate them
to a single instances of various services.- Author:
- agentgt
- API Note
- While this interface looks similar to
JStachioExtension
it 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
Modifier and TypeInterfaceDescriptionstatic interface
A 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 JStachioExtensions
of()
Resolves extensions from theServiceLoader
withJStachioExtension
as the SPI.static JStachioExtensions
of
(Iterable<? extends JStachioExtension> extensions) Resolve from an iterable of extensions that usually come from some discovery mechanism like theServiceLoader
or a DI framework.static JStachioExtensions
of
(Stream<? extends JStachioExtension> extensions) Resolve from a stream of extensions that usually come from some discovery mechanism like theServiceLoader
or a DI framework.
-
Method Details
-
of
Resolve from an iterable of extensions that usually come from some discovery mechanism like theServiceLoader
or 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 theServiceLoader
or 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 theServiceLoader
withJStachioExtension
as the SPI.- Returns:
- jstachio extensions found by the ServiceLoader
-
getConfig
Composite Config where the first config that returns a nonnull forJStachioConfig.getProperty(String)
is used.- Returns:
- config
-
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
Composite Template finder where the first template finder that finds a template is used.- Returns:
- template finder
-
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
-