Class SpiHelper
- java.lang.Object
-
- io.opentelemetry.sdk.autoconfigure.internal.SpiHelper
-
public final class SpiHelper extends java.lang.ObjectThis 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 Modifier and Type Class Description private static classSpiHelper.ServiceLoaderComponentLoader
-
Field Summary
Fields Modifier and Type Field Description private ComponentLoadercomponentLoaderprivate java.util.Set<AutoConfigureListener>listeners
-
Constructor Summary
Constructors Modifier Constructor Description privateSpiHelper(ComponentLoader componentLoader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SpiHelpercreate(ComponentLoader componentLoader)Create aSpiHelperwhich loads SPIs using thecomponentLoader.static SpiHelpercreate(java.lang.ClassLoader classLoader)Create aSpiHelperwhich loads SPIs using theclassLoader.ComponentLoadergetComponentLoader()Return the backing underlyingComponentLoader.java.util.Set<AutoConfigureListener>getListeners()Return the set of SPIs loaded which implementAutoConfigureListener.<T> java.util.List<T>load(java.lang.Class<T> spiClass)Load implementations of an SPI.<T> TloadComponent(java.lang.Class<T> type, java.lang.String name, StructuredConfigProperties config)Find a registeredComponentProviderwithComponentProvider.getType()matchingtype,ComponentProvider.getName()matchingname, and callComponentProvider.create(StructuredConfigProperties)with the givenconfig.<T,S>
NamedSpiManager<T>loadConfigurable(java.lang.Class<S> spiClass, java.util.function.Function<S,java.lang.String> getName, java.util.function.BiFunction<S,ConfigProperties,T> getConfigurable, ConfigProperties config)Load implementations of an SPI which are configurable (i.e.<T extends Ordered>
java.util.List<T>loadOrdered(java.lang.Class<T> spiClass)Load implementations of an ordered SPI (i.e.private voidmaybeAddListener(java.lang.Object object)static ComponentLoaderserviceComponentLoader(java.lang.ClassLoader classLoader)Create aComponentLoaderwhich loads using theclassLoader.
-
-
-
Field Detail
-
componentLoader
private final ComponentLoader componentLoader
-
listeners
private final java.util.Set<AutoConfigureListener> listeners
-
-
Constructor Detail
-
SpiHelper
private SpiHelper(ComponentLoader componentLoader)
-
-
Method Detail
-
create
public static SpiHelper create(java.lang.ClassLoader classLoader)
Create aSpiHelperwhich loads SPIs using theclassLoader.
-
create
public static SpiHelper create(ComponentLoader componentLoader)
Create aSpiHelperwhich loads SPIs using thecomponentLoader.
-
serviceComponentLoader
public static ComponentLoader serviceComponentLoader(java.lang.ClassLoader classLoader)
Create aComponentLoaderwhich loads using theclassLoader.
-
getComponentLoader
public ComponentLoader getComponentLoader()
Return the backing underlyingComponentLoader.
-
loadConfigurable
public <T,S> NamedSpiManager<T> loadConfigurable(java.lang.Class<S> spiClass, java.util.function.Function<S,java.lang.String> getName, java.util.function.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
NamedSpiManagerused to access configured instances of the SPI by name
-
loadComponent
public <T> T loadComponent(java.lang.Class<T> type, java.lang.String name, StructuredConfigProperties config)Find a registeredComponentProviderwithComponentProvider.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
public <T extends Ordered> java.util.List<T> loadOrdered(java.lang.Class<T> spiClass)
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
public <T> java.util.List<T> load(java.lang.Class<T> spiClass)
Load implementations of an SPI.- Type Parameters:
T- the SPI type- Parameters:
spiClass- the SPI class- Returns:
- list of SPI implementations
-
maybeAddListener
private void maybeAddListener(java.lang.Object object)
-
getListeners
public java.util.Set<AutoConfigureListener> getListeners()
Return the set of SPIs loaded which implementAutoConfigureListener.
-
-