Class SpiHelper
java.lang.Object
io.opentelemetry.sdk.autoconfigure.internal.SpiHelper
This class is internal and is hence not for public use. Its APIs are unstable and can change at
any time.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ComponentLoader
private final Set
<AutoConfigureListener> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SpiHelper
create
(ComponentLoader componentLoader) Create aSpiHelper
which loads SPIs using thecomponentLoader
.static SpiHelper
create
(ClassLoader classLoader) Create aSpiHelper
which loads SPIs using theclassLoader
.Return the backing underlyingComponentLoader
.Return the set of SPIs loaded which implementAutoConfigureListener
.<T> List
<T> Load implementations of an SPI.<T> T
loadComponent
(Class<T> type, String name, StructuredConfigProperties config) Find a registeredComponentProvider
withComponentProvider.getType()
matchingtype
,ComponentProvider.getName()
matchingname
, and callComponentProvider.create(StructuredConfigProperties)
with the givenconfig
.<T,
S> NamedSpiManager <T> loadConfigurable
(Class<S> spiClass, Function<S, String> getName, BiFunction<S, ConfigProperties, T> getConfigurable, ConfigProperties config) Load implementations of an SPI which are configurable (i.e.loadOrdered
(Class<T> spiClass) Load implementations of an ordered SPI (i.e.private void
maybeAddListener
(Object object) static ComponentLoader
serviceComponentLoader
(ClassLoader classLoader) Create aComponentLoader
which loads using theclassLoader
.
-
Field Details
-
componentLoader
-
listeners
-
-
Constructor Details
-
SpiHelper
-
-
Method Details
-
create
Create aSpiHelper
which loads SPIs using theclassLoader
. -
create
Create aSpiHelper
which loads SPIs using thecomponentLoader
. -
serviceComponentLoader
Create aComponentLoader
which loads using theclassLoader
. -
getComponentLoader
Return the backing underlyingComponentLoader
. -
loadConfigurable
public <T,S> NamedSpiManager<T> loadConfigurable(Class<S> spiClass, Function<S, String> getName, BiFunction<S, ConfigProperties, T> getConfigurable, ConfigProperties config) Load implementations of an SPI which are configurable (i.e. they acceptConfigProperties
.- Type Parameters:
T
- the configurable typeS
- the SPI type- Parameters:
spiClass
- the SPI classgetName
- function returning the name of an SPI implementationgetConfigurable
- function returning a configured instanceconfig
- the configuration to pass to invocations of#getConfigurable
- Returns:
- a
NamedSpiManager
used to access configured instances of the SPI by name
-
loadComponent
Find a registeredComponentProvider
withComponentProvider.getType()
matchingtype
,ComponentProvider.getName()
matchingname
, and callComponentProvider.create(StructuredConfigProperties)
with the givenconfig
.- Throws:
ConfigurationException
- if no matching providers are found, or if multiple are found (i.e. conflict), or ifComponentProvider.create(StructuredConfigProperties)
throws
-
loadOrdered
Load implementations of an ordered SPI (i.e. implementsOrdered
).- Type Parameters:
T
- the SPI type- Parameters:
spiClass
- the SPI class- Returns:
- list of SPI implementations, in order
-
load
Load implementations of an SPI.- Type Parameters:
T
- the SPI type- Parameters:
spiClass
- the SPI class- Returns:
- list of SPI implementations
-
maybeAddListener
-
getListeners
Return the set of SPIs loaded which implementAutoConfigureListener
.
-