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 void
appendDestinationLoader
(DestinationLoader newLoader) Register anDestinationLoader
created at runtime.static Destination
getDestination
(String destinationName) Loads the destination with the given name.static DestinationLoader
The loader containing the platform specific logic to retrieve destinations.static void
prependDestinationLoader
(DestinationLoader newLoader) Register anDestinationLoader
created at runtime.static void
setLoader
(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
null
is 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
ServiceLoader
pattern
ServiceLoader
finds multipleDestinationLoader
it will behave as if none was given, as no deterministic order of resolution could be identified. Use theDestinationLoaderChain
to create your own priority.- Parameters:
loader
- The new loader to be used. Ifnull
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
Register anDestinationLoader
created at runtime. If thecurrent destination loader
is already aDestinationLoaderChain
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 usesetLoader(null)
.- Parameters:
newLoader
- The destination loader to register.- See Also:
-
prependDestinationLoader
Register anDestinationLoader
created at runtime. If thecurrent destination loader
is already aDestinationLoaderChain
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 usesetLoader(null)
.- Parameters:
newLoader
- The destination loader to register.- See Also:
-
getLoader
The loader containing the platform specific logic to retrieve destinations.
-