Class OAuth2ServiceBindingDestinationLoader
java.lang.Object
com.sap.cloud.sdk.cloudplatform.connectivity.OAuth2ServiceBindingDestinationLoader
- All Implemented Interfaces:
ServiceBindingDestinationLoader
public class OAuth2ServiceBindingDestinationLoader
extends Object
implements ServiceBindingDestinationLoader
An implementation of the
ServiceBindingDestinationLoader
interface that is capable of producing OAuth2 based
HttpDestination
instances.
This class will automatically be picked up by the service loader pattern.
- Since:
- 4.16.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
registerPropertySupplier
(com.sap.cloud.environment.servicebinding.api.ServiceIdentifier service, Function<ServiceBindingDestinationOptions, OAuth2PropertySupplier> propertySupplier) Adds the givenOAuth2PropertySupplier
to handle matchingServiceBindingDestinationOptions
according to the providedServiceIdentifier
.static void
registerPropertySupplier
(Predicate<ServiceBindingDestinationOptions> optionsMatcher, Function<ServiceBindingDestinationOptions, OAuth2PropertySupplier> propertySupplier) Adds the givenOAuth2PropertySupplier
to handle matchingServiceBindingDestinationOptions
.io.vavr.control.Try<HttpDestination>
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.sap.cloud.sdk.cloudplatform.connectivity.ServiceBindingDestinationLoader
getDestination
-
Constructor Details
-
OAuth2ServiceBindingDestinationLoader
public OAuth2ServiceBindingDestinationLoader()Default constructor. This will use the static default resolvers which can be modified viaregisterPropertySupplier(Predicate, Function)
.
-
-
Method Details
-
registerPropertySupplier
public static void registerPropertySupplier(@Nonnull com.sap.cloud.environment.servicebinding.api.ServiceIdentifier service, @Nonnull Function<ServiceBindingDestinationOptions, OAuth2PropertySupplier> propertySupplier) Adds the givenOAuth2PropertySupplier
to handle matchingServiceBindingDestinationOptions
according to the providedServiceIdentifier
. The provided supplier will be checked with higher priority than previously registered suppliers.Note: The order of registering suppliers is important. Therefore, the given
propertySupplier
will be prepended to the list of all registered property suppliers. The first supplier that matches the given options will be used.- Parameters:
service
- Theservice
that can be handled by the given property supplier.propertySupplier
- TheOAuth2PropertySupplier
capable of parsing bindings for the given service.- See Also:
-
registerPropertySupplier
public static void registerPropertySupplier(@Nonnull Predicate<ServiceBindingDestinationOptions> optionsMatcher, @Nonnull Function<ServiceBindingDestinationOptions, OAuth2PropertySupplier> propertySupplier) Adds the givenOAuth2PropertySupplier
to handle matchingServiceBindingDestinationOptions
. The provided matcher/supplier combination will be checked with higher priority than previously registered suppliers.Note: The order of registering suppliers is important. Therefore, the given
propertySupplier
will be prepended to the list of all registered property suppliers. The first supplier that matches the given options will be used.- Parameters:
optionsMatcher
- ThePredicate
to determine wether theServiceBindingDestinationOptions
can be handled by the given property supplier.propertySupplier
- TheOAuth2PropertySupplier
capable of parsing bindings for the given service.- Since:
- 4.23.0
-
tryGetDestination
@Nonnull public io.vavr.control.Try<HttpDestination> tryGetDestination(@Nonnull ServiceBindingDestinationOptions options) Description copied from interface:ServiceBindingDestinationLoader
- Specified by:
tryGetDestination
in interfaceServiceBindingDestinationLoader
- Parameters:
options
- TheServiceBindingDestinationOptions
that contain further context information about how the transformation process should be done.- Returns:
- Either a
Try.success(Object)
if the transformation succeeded,Try.failure(Throwable)
otherwise.In case of a
Try.failure(Throwable)
, the cause will either be aDestinationAccessException
or aDestinationNotFoundException
.
-