Class DestinationAccessor
java.lang.Object
com.sap.cloud.sdk.cloudplatform.connectivity.DestinationAccessor
Wrapper for an
DestinationLoader, offering platform agnostic access to destinations.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendDestinationLoader(DestinationLoader newLoader) Register anDestinationLoadercreated at runtime.static DestinationgetDestination(String destinationName) Loads the destination with the given name.static DestinationLoaderThe loader containing the platform specific logic to retrieve destinations.static voidprependDestinationLoader(DestinationLoader newLoader) Register anDestinationLoadercreated at runtime.static voidsetLoader(DestinationLoader loader) Sets the loader to be used for all future method invocations on thisDestinationAccessor.static io.vavr.control.Try<Destination>tryGetDestination(String destinationName) Loads the destination with the given name.
-
Method Details
-
setLoader
Sets the loader to be used for all future method invocations on thisDestinationAccessor.If
nullis provided this will fallback to the default loader, which has the following priority list:- Read the destination from the destinations environment variable
- Read the destination with the loader found via the
ServiceLoaderpattern
ServiceLoaderfinds multipleDestinationLoaderit will behave as if none was given, as no deterministic order of resolution could be identified. Use theDestinationLoaderChainto create your own priority.- Parameters:
loader- The new loader to be used. Ifnullis 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
Trycontaining either the destination or an exception describing what went wrong.
-
appendDestinationLoader
Register anDestinationLoadercreated at runtime. If thecurrent destination loaderis already aDestinationLoaderChainit 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 usesetLoader(null).- Parameters:
newLoader- The destination loader to register.- See Also:
-
prependDestinationLoader
Register anDestinationLoadercreated at runtime. If thecurrent destination loaderis already aDestinationLoaderChainit 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 usesetLoader(null).- Parameters:
newLoader- The destination loader to register.- See Also:
-
getLoader
The loader containing the platform specific logic to retrieve destinations.
-