Class ExtensionManager
java.lang.Object
org.sentrysoftware.metricshub.engine.extension.ExtensionManager
Manages and aggregates various types of extensions used within MetricsHub.
This class acts as a central point for accessing and managing protocol
extensions, strategy provider extensions, connector store provider
extensions and source computation extensions.
The ExtensionManager is designed to be flexible and extensible,
supporting various types of extensions that can be added or removed as
needed. It uses the Builder pattern to simplify instantiation and setup.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAggregates connector stores from various provider extensions into a singleConnectorStore.buildConfigurationFromJsonNode(String configurationType, com.fasterxml.jackson.databind.JsonNode configurationJsonNode, UnaryOperator<char[]> decrypt) Constructs a configuration object from a given JSON node based on the specified configuration type.static ExtensionManagerempty()Create a new empty instance of the Extension Manager.Find a mapping between configuration classes and their corresponding sets of source classes.findCriterionExtension(Criterion criterion, TelemetryManager telemetryManager) Find the extension which satisfies the processing of the given criterion according to the user's configuration.findExtensionByType(String type) Finds the first protocol extension that supports the specified type.findProtocolCheckExtensions(@NonNull TelemetryManager telemetryManager) Find the extensions that satisfy the protocol check according to the user's configuration.findSourceComputationExtension(Source source) Find the extension which satisfies the processing of the given source according to its type.findSourceExtension(Source source, TelemetryManager telemetryManager) Find the extension which satisfies the processing of the given source according to the user's configuration.
-
Constructor Details
-
ExtensionManager
public ExtensionManager()
-
-
Method Details
-
empty
Create a new empty instance of the Extension Manager.- Returns:
- a new instance of
ExtensionManager.
-
findCriterionExtension
public Optional<IProtocolExtension> findCriterionExtension(Criterion criterion, TelemetryManager telemetryManager) Find the extension which satisfies the processing of the given criterion according to the user's configuration.- Parameters:
criterion- AnyCriterionimplementationtelemetryManager-TelemetryManagerinstance where the configurations are located.- Returns:
- an
Optionalof anIProtocolExtensioninstance.
-
findExtensionByType
Finds the first protocol extension that supports the specified type.- Parameters:
type- The configuration type to match.- Returns:
- An
Optionaldescribing the first matching extension, or an emptyOptionalif none match.
-
findSourceExtension
public Optional<IProtocolExtension> findSourceExtension(Source source, TelemetryManager telemetryManager) Find the extension which satisfies the processing of the given source according to the user's configuration.- Parameters:
source- AnySourceimplementationtelemetryManager-TelemetryManagerinstance where the configurations are located.- Returns:
- an
Optionalof anIProtocolExtensioninstance.
-
findProtocolCheckExtensions
public List<IProtocolExtension> findProtocolCheckExtensions(@NonNull @NonNull TelemetryManager telemetryManager) Find the extensions that satisfy the protocol check according to the user's configuration.- Parameters:
telemetryManager-TelemetryManagerinstance where the configurations are located.- Returns:
- a
ListofIProtocolExtensioninstances.
-
findConfigurationToSourceMapping
public Map<Class<? extends IConfiguration>,Set<Class<? extends Source>>> findConfigurationToSourceMapping()Find a mapping between configuration classes and their corresponding sets of source classes.- Returns:
- A map where the keys are classes extending
IConfigurationrepresenting different types of protocol configurations, and the values are sets of classes extendingSource, indicating the sources that are compatible and can be utilized with each configuration type for data exchange operations.
-
buildConfigurationFromJsonNode
public Optional<IConfiguration> buildConfigurationFromJsonNode(String configurationType, com.fasterxml.jackson.databind.JsonNode configurationJsonNode, UnaryOperator<char[]> decrypt) throws InvalidConfigurationException Constructs a configuration object from a given JSON node based on the specified configuration type. This method iterates over a collection of protocol extensions to find the first extension that supports the specified configuration type. It then uses this extension to build a configuration object from the provided JSON node. If no suitable extension is found, annullvalue is returned.- Parameters:
configurationType- AStringrepresenting the type of configuration to be created. This is used to identify the appropriate protocol extension that can handle the specified configuration type.configurationJsonNode- AJsonNodecontaining the configuration data in JSON format. This data is used by the selected protocol extension to build the configuration object.decrypt- AUnaryOperatorfunction that takes achar[]array and returns achar[]array. This function is intended to decrypt the configuration data if necessary before building the configuration object.- Returns:
- An
OptionalofIConfigurationrepresenting the constructed configuration object. Returns an emptyOptionalif no suitable protocol extension is found or if the configuration object cannot be created for any reason. - Throws:
InvalidConfigurationException- If the given configuration JSON node is invalid.
-
aggregateExtensionConnectorStores
Aggregates connector stores from various provider extensions into a singleConnectorStore. This method initializes a newConnectorStoreand iteratively loads data from each registered connector store provider extension. All connectors from each extension are added to the newly created store. This centralized store can be used to manage or interpret connectors across different extensions efficiently, providing a unified view of all connectors available in MetricsHub.- Returns:
- A
ConnectorStorecontaining all connectors from various extensions combined into one store.
-
findSourceComputationExtension
Find the extension which satisfies the processing of the given source according to its type.- Parameters:
source- AnySourceimplementation- Returns:
- an
Optionalof anISourceComputationExtensioninstance.
-