java.lang.Object
io.helidon.integrations.oci.sdk.runtime.OciExtension

public final class OciExtension extends Object
This class enables configuration access for integration to the Oracle Cloud Infrastructure Java SDK. It is intended for non-Helidon MP, non-CDI usage scenarios. For usages that involve Helidon MP and CDI please refer to io.helidon.integrations.oci.sdk.cdi.OciExtension instead. This integration will follow the same terminology and usage pattern as specified for Helidon MP integration. The implementation strategy, however, is different between the two. Please take a moment to familiarize yourself to the terminology and general approach before continuing further.

This module enables the injection of any service interface, service client, service client builder, asynchronous service interface, asynchronous service client, or asynchronous service client builder from the Oracle Cloud Infrastructure Java SDK.

Additionally, this module enables the injection of the AbstractAuthenticationDetailsProvider, which allows the corresponding service client to authenticate with the service.

In all cases, user-supplied configuration will be preferred over any default configuration. Please refer to ociConfig() for details.

Basic Usage

To use this extension, make sure it is on your project's runtime classpath. Also be sure the helidon-integrations-oci-processor is on your APT/compile-time classpath. To inject a service interface named com.oracle.bmc.cloudexample.CloudExample (or an analogous asynchronous service interface), you will also need to ensure that its containing artifact is on your compile classpath (e.g. oci-java-sdk-cloudexample-$VERSION.jar, where $VERSION should be replaced by a suitable version number).

Advanced Usage

In the course of providing injection support for a service interface or an asynchronous service interface, this extension will create service client builder and asynchronous service client builder instances by invoking the static builder() method that is present on all OCI service client classes, and will then provide those instances as regular Injection/Injectable services. The resulting service client or asynchronous service client will be built by that builder's build(AbstractAuthenticationDetailsProvider) method and will itself be provided as a service instance.

A user may wish to customize this builder so that the resulting service client or asynchronous service client reflects the customization. She has two options:

  1. She may provide her own instance with the service client builder type (or asynchronous client builder type). In this case, the user should supply an overriding (i.e., higher weighted) service provider implementation than the one provided by OciAuthenticationDetailsProvider.
  2. She may customize the service client builder (or asynchronous service client builder) supplied by this OciAuthenticationDetailsProvider. To do this, she must supply a custom configuration via ociConfig().

Configuration

This extension uses the OciConfig for configuration. Refer to it for details.
See Also:
  • Method Details

    • configuredAuthenticationDetailsProvider

      public static Class<? extends com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider> configuredAuthenticationDetailsProvider(boolean verifyIsAvailable)
      The configured authentication provider strategy type name. Note, however, that the authentication strategy returned may not necessarily be available. The configured authentication provider merely returns what is configured via "auth-strategy" and/or "auth-strategies". In order to additionally check if the provider is available, the verifyIsAvailable argument should be true.
      Parameters:
      verifyIsAvailable - flag to indicate whether the provider should be checked for availability
      Returns:
      the configured authentication type name
    • ociConfig

      public static OciConfig ociConfig()
      Returns the global OciConfig bean that is currently defined in the bootstrap environment.

      The implementation will first look for an oci.yaml file, and if found will use that file to establish the global oci-specific bootstrap ConfigSource.

      If the implementation is unable to find this file, then a fallback mechanism will be used to find it in the configuration found in the InjectionServices.globalBootstrap(), using a top-level attribute key named "oci".

      The final fallback mechanism will use an auto authentication strategy - see OciConfigBlueprint for details.

      Returns:
      the bootstrap oci config bean
      See Also:
      • OciConfigBlueprint
      • ociConfigSupplier
    • ociAuthenticationProvider

      public static Supplier<? extends com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider> ociAuthenticationProvider()
      The supplier for the globally configured OCI authentication provider.
      Returns:
      the supplier for the globally configured authentication provider
      See Also:
    • configSupplier

      public static Supplier<Config> configSupplier()
      The supplier for the raw config-backed by the OCI config source(s).
      Returns:
      the supplier for the raw config-backed by the OCI config source(s)
      See Also:
    • configSupplier

      public static void configSupplier(Supplier<Config> configSupplier)
      Establishes the supplier for the raw config-backed by the OCI config source(s). Setting this will override the usage of the DEFAULT_OCI_GLOBAL_CONFIG_FILE as the backing configuration file.
      Parameters:
      configSupplier - the config supplier
      See Also:
    • fallbackConfigSupplier

      public static void fallbackConfigSupplier(Supplier<Config> configSupplier)
      Establishes the fallback config supplier used only when the DEFAULT_OCI_GLOBAL_CONFIG_FILE is not physically present, and there has been no config supplier explicitly established via configSupplier(Supplier).

      This method is typically used when running in CDI in order to allow for the fallback of using microprofile configuration.

      Parameters:
      configSupplier - the fallback config supplier
      See Also:
    • isSufficientlyConfigured

      public static boolean isSufficientlyConfigured(Config config)
      Returns true if the given config is sufficiently configured in order to identity an OCI authentication strategy. If false then OciAuthenticationDetailsProvider.AuthStrategy.AUTO will be applied.
      Parameters:
      config - the config
      Returns:
      true if the given config can be used to identify an OCI authentication strategy