Skip to content

Commit 2692e51

Browse files
authored
Java: Document Register Destinations API (#2159)
* register destinations API * .
1 parent 27aa176 commit 2692e51

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

docs-java/features/connectivity/004-http-destinations.mdx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,39 @@ It provides the following headers:
253253
- The `sap-language` header.
254254
- If the `DefaultHttpDestination` contains a property called `cloudsdk.dynamicSapLanguage` with value `true`, the `LocaleAccessor` will be used to determine the current locale.
255255
- Otherwise, if there is a `sap-language` property, its value will be used.
256+
257+
## About Registering Destinations at Runtime
258+
259+
Any destination built at runtime can be registered such that it will be available via `DestinationAccessor.getDestination()`.
260+
This is especially useful when [working in a local environment](running-locally).
261+
262+
You can create a destination manually and prepare a loader for it as follows:
263+
264+
```java
265+
customHttpDestination = DefaultHttpDestination.builder("http://url")
266+
.name("custom-destination")
267+
.build();
268+
269+
customLoader = new DefaultDestinationLoader()
270+
.registerDestination(customHttpDestination);
271+
272+
DestinationAccessor.prependDestinationLoader(loader);
273+
274+
// This will now return the custom destination
275+
DestinationAccessor.getDestination("custom-destination").asHttp();
276+
```
277+
278+
By default, the `DestinationAccessor` is using a `DestinationLoaderChain` that comprises multiple loaders.
279+
These are e.g. a loader to get destinations from the destination service and a loader that reads destinations from environment variables.
280+
281+
The above `prependDestinationLoader()` will add the provided loader at the start of such a chain.
282+
That means the new loader will take precedence over destinations in the destination service, in case both hold a destination with the same name.
283+
If instead a fallback behavior is desired, use `appendDestinationLoader()`.
284+
Note that this comes with a performance overhead, since the destination service will be queried first.
285+
286+
:::note Multitenancy
287+
288+
Please note that registering destinations is **not** tenant-aware.
289+
A registered destination will be available to all tenants.
290+
291+
:::

0 commit comments

Comments
 (0)