|
| 1 | +package org.springframework.integration.aws.config.xml; |
| 2 | + |
| 3 | +import org.springframework.beans.factory.support.AbstractBeanDefinition; |
| 4 | +import org.springframework.beans.factory.support.BeanDefinitionBuilder; |
| 5 | +import org.springframework.beans.factory.xml.ParserContext; |
| 6 | +import org.springframework.integration.aws.outbound.KplMessageHandler; |
| 7 | +import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; |
| 8 | +import org.w3c.dom.Element; |
| 9 | + |
| 10 | +import java.time.Duration; |
| 11 | + |
| 12 | +public class KplOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser { |
| 13 | + |
| 14 | + @Override |
| 15 | + protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { |
| 16 | + return XmlBeanDefinitionBuilder.newInstance(element, parserContext, KplMessageHandler.class) |
| 17 | + .addConstructorArgReference("kinesis-producer") |
| 18 | + .setPropertyIfAttributeDefined("async") |
| 19 | + .setPropertyIfAttributeDefined("output-channel", "outputChannelName") |
| 20 | + .setPropertyIfAttributeDefined("send-timeout") |
| 21 | + .setPropertyOrExpressionStringIfAttributeDefined("stream") |
| 22 | + .setPropertyOrExpressionStringIfAttributeDefined("partition-key") |
| 23 | + .setPropertyOrExpressionStringIfAttributeDefined("explicit-hash-key") |
| 24 | + .setPropertyIfAttributeDefined("sequence-number-expression", "sequenceNumberExpressionString") |
| 25 | + .setPropertyIfAttributeDefined("glue-schema-expression", "glueSchemaExpressionString") |
| 26 | + .setPropertyIfAttributeDefined("flush-duration", "flushDuration", this::duration) |
| 27 | + .setPropertyReferenceIfAttributeDefined("embedded-headers-mapper") |
| 28 | + .setPropertyReferenceIfAttributeDefined("message-converter") |
| 29 | + .build(); |
| 30 | + } |
| 31 | + |
| 32 | + private AbstractBeanDefinition duration(String millis) { |
| 33 | + return BeanDefinitionBuilder.genericBeanDefinition(Duration.class) |
| 34 | + .addConstructorArgValue(millis) |
| 35 | + .setFactoryMethod("ofMillis") |
| 36 | + .applyCustomizers(def -> def.setAutowireCandidate(false)) |
| 37 | + .getBeanDefinition(); |
| 38 | + } |
| 39 | +} |
0 commit comments