Class DestinationAccessor

java.lang.Object
com.sap.cloud.sdk.cloudplatform.connectivity.DestinationAccessor

public final class DestinationAccessor extends Object
Wrapper for an DestinationLoader, offering platform agnostic access to destinations.
  • Method Details

    • setLoader

      public static void setLoader(@Nullable DestinationLoader loader)
      Sets the loader to be used for all future method invocations on this DestinationAccessor.

      If null is provided this will fallback to the default loader, which has the following priority list:

      1. Read the destination from the destinations environment variable
      2. Read the destination with the loader found via the ServiceLoader pattern
      If the ServiceLoader finds multiple DestinationLoader it will behave as if none was given, as no deterministic order of resolution could be identified. Use the DestinationLoaderChain to create your own priority.
      Parameters:
      loader - The new loader to be used. If null is provided the default loader will be used instead.
    • getDestination

      @Nonnull public static Destination getDestination(@Nonnull String destinationName) throws DestinationAccessException
      Loads the destination with the given name.
      Parameters:
      destinationName - The name of the destination to search for.
      Returns:
      The loaded destination.
      Throws:
      DestinationNotFoundException - In case the destination could not be found.
      DestinationAccessException - More details in case something else went wrong.
    • tryGetDestination

      @Nonnull public static io.vavr.control.Try<Destination> tryGetDestination(@Nonnull String destinationName)
      Loads the destination with the given name.
      Parameters:
      destinationName - The name of the destination to search for.
      Returns:
      A Try containing either the destination or an exception describing what went wrong.
    • appendDestinationLoader

      public static void appendDestinationLoader(@Nonnull DestinationLoader newLoader)
      Register an DestinationLoader created at runtime. If the current destination loader is already a DestinationLoaderChain it will be added to the end of this chain. Otherwise a new chain will be created with the current and the new loader. To reset the loader of this accessor use setLoader(null).
      Parameters:
      newLoader - The destination loader to register.
      See Also:
    • prependDestinationLoader

      public static void prependDestinationLoader(@Nonnull DestinationLoader newLoader)
      Register an DestinationLoader created at runtime. If the current destination loader is already a DestinationLoaderChain it will be added at the beginning of this chain. Otherwise a new chain will be created with the new and the current loader. To reset the loader of this accessor use setLoader(null).
      Parameters:
      newLoader - The destination loader to register.
      See Also:
    • getLoader

      @Nonnull public static DestinationLoader getLoader()
      The loader containing the platform specific logic to retrieve destinations.