Class ExtensionManager

java.lang.Object
org.sentrysoftware.metricshub.engine.extension.ExtensionManager

public class ExtensionManager extends Object
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 Details

    • ExtensionManager

      public ExtensionManager()
  • Method Details

    • empty

      public static ExtensionManager 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 - Any Criterion implementation
      telemetryManager - TelemetryManager instance where the configurations are located.
      Returns:
      an Optional of an IProtocolExtension instance.
    • findExtensionByType

      public Optional<IProtocolExtension> findExtensionByType(String type)
      Finds the first protocol extension that supports the specified type.
      Parameters:
      type - The configuration type to match.
      Returns:
      An Optional describing the first matching extension, or an empty Optional if 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 - Any Source implementation
      telemetryManager - TelemetryManager instance where the configurations are located.
      Returns:
      an Optional of an IProtocolExtension instance.
    • 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 - TelemetryManager instance where the configurations are located.
      Returns:
      a List of IProtocolExtension instances.
    • 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 IConfiguration representing different types of protocol configurations, and the values are sets of classes extending Source, 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, an null value is returned.
      Parameters:
      configurationType - A String representing the type of configuration to be created. This is used to identify the appropriate protocol extension that can handle the specified configuration type.
      configurationJsonNode - A JsonNode containing the configuration data in JSON format. This data is used by the selected protocol extension to build the configuration object.
      decrypt - A UnaryOperator function that takes a char[] array and returns a char[] array. This function is intended to decrypt the configuration data if necessary before building the configuration object.
      Returns:
      An Optional of IConfiguration representing the constructed configuration object. Returns an empty Optional if 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

      public ConnectorStore aggregateExtensionConnectorStores()
      Aggregates connector stores from various provider extensions into a single ConnectorStore. This method initializes a new ConnectorStore and 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 ConnectorStore containing all connectors from various extensions combined into one store.
    • findSourceComputationExtension

      public Optional<ISourceComputationExtension> findSourceComputationExtension(Source source)
      Find the extension which satisfies the processing of the given source according to its type.
      Parameters:
      source - Any Source implementation
      Returns:
      an Optional of an ISourceComputationExtension instance.