@Beta public class SimpleCachingServiceBindingLoaderWrapper extends Object implements ServiceBindingLoader
ServiceBindingLoader
interface that wraps another ServiceBindingLoader
instance and caches the result for a certain amount of time.Modifier and Type | Class and Description |
---|---|
static class |
SimpleCachingServiceBindingLoaderWrapper.SimpleCachingServiceBindingLoaderWrapperBuilder |
Modifier and Type | Field and Description |
---|---|
static Duration |
DEFAULT_CACHE_DURATION
The default caching duration.
|
static Supplier<LocalDateTime> |
DEFAULT_CURRENT_DATE_TIME_SUPPLIER
The default
Supplier to get the current LocalDateTime from. |
Modifier | Constructor and Description |
---|---|
protected |
SimpleCachingServiceBindingLoaderWrapper(ServiceBindingLoader serviceBindingLoader,
Duration cacheDuration,
Supplier<LocalDateTime> currentDateTimeSupplier)
Constructs a new instance of the
SimpleCachingServiceBindingLoaderWrapper class. |
Modifier and Type | Method and Description |
---|---|
static SimpleCachingServiceBindingLoaderWrapper.SimpleCachingServiceBindingLoaderWrapperBuilder |
builder() |
void |
invalidateCache()
Invalidates the cached service bindings so that the wrapped
ServiceBindingLoader will be called the next
time load() is invoked. |
Map<String,com.google.gson.JsonArray> |
load()
Loads all existing service bindings for the current application.
|
@Nonnull public static final Duration DEFAULT_CACHE_DURATION
@Nonnull public static final Supplier<LocalDateTime> DEFAULT_CURRENT_DATE_TIME_SUPPLIER
Supplier
to get the current LocalDateTime
from.protected SimpleCachingServiceBindingLoaderWrapper(@Nonnull ServiceBindingLoader serviceBindingLoader, @Nullable Duration cacheDuration, @Nullable Supplier<LocalDateTime> currentDateTimeSupplier)
SimpleCachingServiceBindingLoaderWrapper
class.serviceBindingLoader
- The ServiceBindingLoader
instance that should be wrapped.cacheDuration
- The caching duration. null
, the DEFAULT_CACHE_DURATION
will be used.currentDateTimeSupplier
- The supplier to obtain the current LocalDateTime
from. null
, the DEFAULT_CURRENT_DATE_TIME_SUPPLIER
will be used.@Nonnull public Map<String,com.google.gson.JsonArray> load()
ServiceBindingLoader
Exception
.load
in interface ServiceBindingLoader
Map
of service bindings, where keys are the name of the service type (e.g. "xsuaa") and each
entry (JsonArray
) contains a list of individual service bindings that belong to the specific
service type.public void invalidateCache()
ServiceBindingLoader
will be called the next
time load()
is invoked.@Nonnull public static SimpleCachingServiceBindingLoaderWrapper.SimpleCachingServiceBindingLoaderWrapperBuilder builder()
Copyright © 2021 SAP SE. All rights reserved.