INT-4520 Make IntegrationGraphServer customizable (#2608)

* INT-4520 Make IntegrationGraphServer customizable

JIRA: https://jira.spring.io/browse/INT-4520

* * Polishing according PR comments
This commit is contained in:
Artem Bilan
2018-10-24 15:02:52 -04:00
committed by Gary Russell
parent 495dfe6437
commit 90ac259da7
5 changed files with 267 additions and 111 deletions

View File

@@ -82,7 +82,7 @@ or from an `AbstractReplyProducingMessageHandler` to a `MessageChannel`.
For convenience and to let you determine a link's purpose, the model includes the `type` attribute.
The possible types are:
* `input`: Identifes the direction from `MessageChannel` to the endpoint, `inputChannel`, or `requestChannel` property
* `input`: Identifies the direction from `MessageChannel` to the endpoint, `inputChannel`, or `requestChannel` property
* `output`: The direction from the `MessageHandler`, `MessageProducer`, or `SourcePollingChannelAdapter` to the `MessageChannel` through an `outputChannel` or `replyChannel` property
* `error`: From `MessageHandler` on `PollingConsumer` or `MessageProducer` or `SourcePollingChannelAdapter` to the `MessageChannel` through an `errorChannel` property;
* `discard`: From `DiscardingMessageHandler` (such as `MessageFilter`) to the `MessageChannel` through an `errorChannel` property.
@@ -147,6 +147,25 @@ It is also used in the `links` element to represent a relationship (connection)
The `input` and `output` attributes are for the `inputChannel` and `outputChannel` properties of the `AbstractEndpoint`, `MessageHandler`, `SourcePollingChannelAdapter`, or `MessageProducerSupport`.
See the next section for more information.
Starting with version 5.1, the `IntegrationGraphServer` accepts a `Function<NamedComponent, Map<String, Object>> additionalPropertiesCallback` for population of additional properties on the `IntegrationNode` for a particular `NamedComponent`.
For example you can expose the `SmartLifecycle` `autoStartup` and `running` properties into the target graph:
====
[source,java]
----
server.setAdditionalPropertiesCallback(namedComponent -> {
Map<String, Object> properties = null;
if (namedComponent instanceof SmartLifecycle) {
SmartLifecycle smartLifecycle = (SmartLifecycle) namedComponent;
properties = new HashMap<>();
properties.put("auto-startup", smartLifecycle.isAutoStartup());
properties.put("running", smartLifecycle.isRunning());
}
return properties;
});
----
====
==== Graph Runtime Model
Spring Integration components have various levels of complexity.

View File

@@ -210,3 +210,9 @@ e.g. `org.springframework.integration:type=MessageChannel,` `name="input#foo.myG
It is now simpler to customize the standard Micrometer meters created by the framework.
See <<micrometer-integration>> for more information.
[[x51.-integration-graph]]
=== Integration Graph Customization
It is now possible to add additional properties to the `IntegrationNode` s via `Function<NamedComponent, Map<String, Object>> additionalPropertiesCallback` on the `IntegrationGraphServer`.
See <<<<integration-graph>>>> for more information.