This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch cjmamo-CAMEL-19985 in repository https://gitbox.apache.org/repos/asf/camel.git
commit e48414ad5ece73e6588c8144c196762f7c0281e7 Author: Claus Ibsen <[email protected]> AuthorDate: Mon Jun 3 10:59:29 2024 +0200 CAMEL-19985: Smooks component --- .../apache/camel/catalog/components}/smooks.json | 0 .../component/smooks/SmooksEndpointUriFactory.java | 6 +- .../org/apache/camel/component/smooks/smooks.json | 8 +- .../src/main/docs/smooks-component.adoc | 2 +- .../camel/component/smooks/SmooksComponent.java | 20 +- .../camel/component/smooks/SmooksEndpoint.java | 43 +- .../camel/component/smooks/SmooksProcessor.java | 133 ++-- .../smooks/converter/ResultConverter.java | 3 +- .../smooks/converter/SourceConverter.java | 4 +- .../apache/camel/component/smooks/Coordinate.java | 3 - .../component/smooks/SmooksComponentTest.java | 7 +- .../component/smooks/SmooksProcessorTest.java | 7 +- .../smooks/converter/ResultConverterTest.java | 6 +- .../smooks/converter/SourceConverterTest.java | 6 +- .../dsl/SmooksComponentBuilderFactory.java | 151 ++++ .../endpoint/dsl/SmooksEndpointBuilderFactory.java | 847 +++++++++++++++++++++ 16 files changed, 1108 insertions(+), 138 deletions(-) diff --git a/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/component/smooks/smooks.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smooks.json similarity index 100% copy from components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/component/smooks/smooks.json copy to catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smooks.json diff --git a/components/camel-smooks/src/generated/java/org/apache/camel/component/smooks/SmooksEndpointUriFactory.java b/components/camel-smooks/src/generated/java/org/apache/camel/component/smooks/SmooksEndpointUriFactory.java index a7552824dd9..781876531a3 100644 --- a/components/camel-smooks/src/generated/java/org/apache/camel/component/smooks/SmooksEndpointUriFactory.java +++ b/components/camel-smooks/src/generated/java/org/apache/camel/component/smooks/SmooksEndpointUriFactory.java @@ -17,7 +17,7 @@ import org.apache.camel.spi.EndpointUriFactory; @Generated("org.apache.camel.maven.packaging.GenerateEndpointUriFactoryMojo") public class SmooksEndpointUriFactory extends org.apache.camel.support.component.EndpointUriFactorySupport implements EndpointUriFactory { - private static final String BASE = "://smooks-config-path"; + private static final String BASE = ":smooksConfig"; private static final Set<String> PROPERTY_NAMES; private static final Set<String> SECRET_PROPERTY_NAMES; @@ -28,7 +28,6 @@ public class SmooksEndpointUriFactory extends org.apache.camel.support.component props.add("backoffIdleThreshold"); props.add("backoffMultiplier"); props.add("bridgeErrorHandler"); - props.add("database"); props.add("delay"); props.add("exceptionHandler"); props.add("exchangePattern"); @@ -42,6 +41,7 @@ public class SmooksEndpointUriFactory extends org.apache.camel.support.component props.add("scheduler"); props.add("schedulerProperties"); props.add("sendEmptyMessageWhenIdle"); + props.add("smooksConfig"); props.add("startScheduler"); props.add("timeUnit"); props.add("useFixedDelay"); @@ -64,7 +64,7 @@ public class SmooksEndpointUriFactory extends org.apache.camel.support.component Map<String, Object> copy = new HashMap<>(properties); - uri = buildPathParameter(syntax, uri, "database", null, true, copy); + uri = buildPathParameter(syntax, uri, "smooksConfig", null, true, copy); uri = buildQueryParameters(uri, copy, encode); return uri; } diff --git a/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/component/smooks/smooks.json b/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/component/smooks/smooks.json index cb677a24991..993bf295f63 100644 --- a/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/component/smooks/smooks.json +++ b/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/component/smooks/smooks.json @@ -3,10 +3,10 @@ "kind": "component", "name": "smooks", "title": "Smooks", - "description": "Applies fragment-based processing in Smooks to perform a variety of operations like transformation.", + "description": "EDI, XML, CSV, etc. based data transformation using Smooks.", "deprecated": false, "firstVersion": "4.7.0", - "label": "file", + "label": "transformation", "javaType": "org.apache.camel.component.smooks.SmooksComponent", "supportLevel": "Preview", "groupId": "org.apache.camel", @@ -14,7 +14,7 @@ "version": "4.7.0-SNAPSHOT", "scheme": "smooks", "extendsScheme": "", - "syntax": "smooks:\/\/smooks-config-path", + "syntax": "smooks:smooksConfig", "async": false, "api": false, "consumerOnly": false, @@ -28,7 +28,7 @@ "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] }, "properties": { - "database": { "index": 0, "kind": "path", "displayName": "Database", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "database name" }, + "smooksConfig": { "index": 0, "kind": "path", "displayName": "Smooks Config", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Smooks XML configuration file" }, "sendEmptyMessageWhenIdle": { "index": 1, "kind": "parameter", "displayName": "Send Empty Message When Idle", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead." }, "bridgeErrorHandler": { "index": 2, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming [...] "exceptionHandler": { "index": 3, "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By def [...] diff --git a/components/camel-smooks/src/main/docs/smooks-component.adoc b/components/camel-smooks/src/main/docs/smooks-component.adoc index d5d1a1056af..1a7f571a90d 100644 --- a/components/camel-smooks/src/main/docs/smooks-component.adoc +++ b/components/camel-smooks/src/main/docs/smooks-component.adoc @@ -2,7 +2,7 @@ :doctitle: Smooks :shortname: smooks :artifactid: camel-smooks -:description: Applies fragment-based processing in Smooks to perform a variety of operations like transformation. +:description: EDI, XML, CSV, etc. based data transformation using Smooks. :since: 4.7 :supportlevel: Preview :tabs-sync-option: diff --git a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksComponent.java b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksComponent.java index 42bcf7cf613..cf2406bebc1 100644 --- a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksComponent.java +++ b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksComponent.java @@ -22,25 +22,17 @@ import org.apache.camel.Endpoint; import org.apache.camel.spi.annotations.Component; import org.apache.camel.support.DefaultComponent; -/** - * Smook Camel Component. - * <p/> - * <p> - * Example usage: - * - * <pre> - * from("direct:a").to("smooks://edi-to-xml-smooks-config.xml") - * </pre> - * - * @author Christian Mueller - * @author Daniel Bevenius - */ @Component("smooks") public class SmooksComponent extends DefaultComponent { + protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { SmooksProcessor smooksProcessor = new SmooksProcessor(remaining, getCamelContext()); configureSmooksProcessor(smooksProcessor, uri, remaining, parameters); - return new SmooksEndpoint(uri, this, smooksProcessor); + + SmooksEndpoint endpoint = new SmooksEndpoint(uri, this, smooksProcessor); + endpoint.setSmooksConfig(remaining); + setProperties(endpoint, parameters); + return endpoint; } protected void configureSmooksProcessor(SmooksProcessor smooksProcessor, String uri, String remaining, diff --git a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java index 641d58f3d10..29e6df5b160 100644 --- a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java +++ b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java @@ -18,22 +18,21 @@ package org.apache.camel.component.smooks; import org.apache.camel.Category; import org.apache.camel.Component; -import org.apache.camel.Service; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriPath; import org.apache.camel.support.ProcessorEndpoint; -import org.smooks.api.SmooksException; +import org.apache.camel.support.service.ServiceHelper; /** - * Applies fragment-based processing in Smooks to perform a variety of operations like transformation. + * EDI, XML, CSV, etc. based data transformation using Smooks. */ -@UriEndpoint(firstVersion = "4.7.0", scheme = "smooks", title = "Smooks", syntax = "smooks://smooks-config-path", category = { Category.FILE }) -public class SmooksEndpoint extends ProcessorEndpoint implements Service { +@UriEndpoint(firstVersion = "4.7.0", scheme = "smooks", title = "Smooks", syntax = "smooks:smooksConfig", category = { Category.TRANSFORMATION }) +public class SmooksEndpoint extends ProcessorEndpoint { - @UriPath(description = "database name") - @Metadata(required = true) - private String database; + @UriPath(description = "Smooks XML configuration file") + @Metadata(required = true, supportFileReference = true) + private String smooksConfig; private final SmooksProcessor smooksProcessor; @@ -42,20 +41,24 @@ public class SmooksEndpoint extends ProcessorEndpoint implements Service { this.smooksProcessor = processor; } - public void start() { - try { - smooksProcessor.start(); - } catch (Exception e) { - throw new SmooksException(e.getMessage(), e); - } + public String getSmooksConfig() { + return smooksConfig; } - public void stop() { - try { - smooksProcessor.stop(); - } catch (Exception e) { - throw new SmooksException(e.getMessage(), e); - } + public void setSmooksConfig(String smooksConfig) { + this.smooksConfig = smooksConfig; + } + + @Override + protected void doStart() throws Exception { + super.doStart(); + ServiceHelper.startService(smooksProcessor); + } + + @Override + protected void doStop() throws Exception { + super.doStop(); + ServiceHelper.stopService(smooksProcessor); } } diff --git a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java index 3636f2f86a3..a6abc57aa1c 100644 --- a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java +++ b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java @@ -38,10 +38,12 @@ import org.apache.camel.CamelContextAware; import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.Processor; -import org.apache.camel.Service; import org.apache.camel.WrappedFile; import org.apache.camel.attachment.Attachment; import org.apache.camel.attachment.AttachmentMessage; +import org.apache.camel.support.ResourceHelper; +import org.apache.camel.support.service.ServiceSupport; +import org.apache.camel.util.IOHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.smooks.Smooks; @@ -57,24 +59,22 @@ import org.smooks.io.payload.Exports; /** * Smooks {@link Processor} for Camel. - * - * @author Christian Mueller - * @author Daniel Bevenius */ -public class SmooksProcessor implements Processor, Service, CamelContextAware { +public class SmooksProcessor extends ServiceSupport implements Processor, CamelContextAware { + public static final String SMOOKS_EXECUTION_CONTEXT = "CamelSmooksExecutionContext"; - public static final String CAMEL_CHARACTER_ENCODING = "CamelCharsetName"; - private static final Logger LOGGER = LoggerFactory.getLogger(SmooksProcessor.class); - public static final TypedKey<Exchange> EXCHANGE_TYPED_KEY = TypedKey.of(); + + private static final TypedKey<Exchange> EXCHANGE_TYPED_KEY = TypedKey.of(); + private static final Logger LOG = LoggerFactory.getLogger(SmooksProcessor.class); private Smooks smooks; private String configUri; private String reportPath; - private Set<VisitorAppender> visitorAppenders = new HashSet<>(); - private Map<String, Visitor> selectorVisitorMap = new HashMap<>(); + private final Set<VisitorAppender> visitorAppender = new HashSet<>(); + private final Map<String, Visitor> selectorVisitorMap = new HashMap<>(); private CamelContext camelContext; - private boolean attachmentsSupported = false; + private boolean attachmentsSupported; public SmooksProcessor(final CamelContext camelContext) { this.camelContext = camelContext; @@ -90,6 +90,14 @@ public class SmooksProcessor implements Processor, Service, CamelContextAware { this.configUri = configUri; } + public void setCamelContext(CamelContext camelContext) { + this.camelContext = camelContext; + } + + public CamelContext getCamelContext() { + return camelContext; + } + public void process(final Exchange exchange) { //forward headers exchange.getMessage().setHeaders(exchange.getIn().getHeaders()); @@ -104,25 +112,27 @@ public class SmooksProcessor implements Processor, Service, CamelContextAware { } final ExecutionContext executionContext = smooks.createExecutionContext(); - executionContext.put(EXCHANGE_TYPED_KEY, exchange); - String charsetName = (String) exchange.getProperty(CAMEL_CHARACTER_ENCODING); - if (charsetName != null) //if provided use the came character encoding - { - executionContext.setContentEncoding(charsetName); - } - exchange.getIn().setHeader(SMOOKS_EXECUTION_CONTEXT, executionContext); - setupSmooksReporting(executionContext); - - final Exports exports = smooks.getApplicationContext().getRegistry().lookup(new ExportsLookup()); - if (exports.hasExports()) { - final Result[] results = exports.createResults(); - smooks.filterSource(executionContext, getSource(exchange), results); - setResultOnBody(exports, results, exchange); - } else { - smooks.filterSource(executionContext, getSource(exchange)); + try { + executionContext.put(EXCHANGE_TYPED_KEY, exchange); + String charsetName = (String) exchange.getProperty(Exchange.CHARSET_NAME); + if (charsetName != null) { + // if provided use the came character encoding + executionContext.setContentEncoding(charsetName); + } + exchange.getIn().setHeader(SMOOKS_EXECUTION_CONTEXT, executionContext); + setupSmooksReporting(executionContext); + + final Exports exports = smooks.getApplicationContext().getRegistry().lookup(new ExportsLookup()); + if (exports.hasExports()) { + final Result[] results = exports.createResults(); + smooks.filterSource(executionContext, getSource(exchange), results); + setResultOnBody(exports, results, exchange); + } else { + smooks.filterSource(executionContext, getSource(exchange)); + } + } finally { + executionContext.remove(EXCHANGE_TYPED_KEY); } - - executionContext.remove(EXCHANGE_TYPED_KEY); } protected void setResultOnBody(final Exports exports, final Result[] results, final Exchange exchange) { @@ -141,7 +151,7 @@ public class SmooksProcessor implements Processor, Service, CamelContextAware { try { executionContext.getContentDeliveryRuntime().addExecutionEventListener(new HtmlReportGenerator(reportPath, executionContext.getApplicationContext())); } catch (final IOException e) { - LOGGER.info("Could not generate Smooks Report. The reportPath specified was [" + reportPath + "].", e); + LOG.warn("Cannot generate Smooks Report. The reportPath specified was [" + reportPath + "]. This exception is ignored.", e); } } } @@ -205,7 +215,7 @@ public class SmooksProcessor implements Processor, Service, CamelContextAware { * @return This instance. */ public SmooksProcessor addVisitor(VisitorAppender appender) { - visitorAppenders.add(appender); + visitorAppender.add(appender); return this; } @@ -213,19 +223,35 @@ public class SmooksProcessor implements Processor, Service, CamelContextAware { this.reportPath = reportPath; } + private Smooks createSmooks() { + final SmooksFactory smooksFactory = (SmooksFactory) camelContext.getRegistry().lookupByName(SmooksFactory.class.getName()); + return smooksFactory != null ? smooksFactory.createInstance() : new Smooks(); + } + + private void addAppender(Smooks smooks, Set<VisitorAppender> visitorAppenders) { + for (VisitorAppender appender : visitorAppenders) + smooks.addVisitors(appender); + } + + private void addVisitor(Smooks smooks, Map<String, Visitor> selectorVisitorMap) { + for (Entry<String, Visitor> entry : selectorVisitorMap.entrySet()) + smooks.addVisitor(entry.getValue(), entry.getKey()); + } + @Override - public void start() { + protected void doStart() throws Exception { try { if (smooks == null) { smooks = createSmooks(); if (configUri != null) { - smooks.addResourceConfigs(configUri); + InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, configUri); + smooks.addResourceConfigs(is); } smooks.getApplicationContext().getRegistry().registerObject(CamelContext.class, camelContext); } - addAppenders(smooks, visitorAppenders); - addVisitors(smooks, selectorVisitorMap); + addAppender(smooks, visitorAppender); + addVisitor(smooks, selectorVisitorMap); InputStream inputStream = null; try { @@ -239,53 +265,28 @@ public class SmooksProcessor implements Processor, Service, CamelContextAware { } } finally { if (!attachmentsSupported) { - LOGGER.warn("Attachments module could not be found: attachments will not be propagated"); + LOG.warn("Attachments module could not be found: attachments will not be propagated"); } if (inputStream != null) { inputStream.close(); } } - - LOGGER.info(this + " Started"); - } catch (SAXException | IOException e) { + } catch (Exception e) { throw new SmooksException(e.getMessage(), e); } } - private Smooks createSmooks() { - final SmooksFactory smooksFactory = (SmooksFactory) camelContext.getRegistry().lookupByName(SmooksFactory.class.getName()); - return smooksFactory != null ? smooksFactory.createInstance() : new Smooks(); - } - - private void addAppenders(Smooks smooks, Set<VisitorAppender> visitorAppenders) { - for (VisitorAppender appender : visitorAppenders) - smooks.addVisitors(appender); - } - - private void addVisitors(Smooks smooks, Map<String, Visitor> selectorVisitorMap) { - for (Entry<String, Visitor> entry : selectorVisitorMap.entrySet()) - smooks.addVisitor(entry.getValue(), entry.getKey()); - } - - public void stop() { + @Override + protected void doStop() throws Exception { if (smooks != null) { - smooks.close(); + IOHelper.close(smooks); smooks = null; } - LOGGER.info(this + " Stopped"); } @Override public String toString() { - return "SmooksProcessor [configUri=" + configUri + "]"; - } - - public void setCamelContext(CamelContext camelContext) { - this.camelContext = camelContext; - } - - public CamelContext getCamelContext() { - return camelContext; + return "SmooksProcessor[configUri=" + configUri + "]"; } } diff --git a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/converter/ResultConverter.java b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/converter/ResultConverter.java index 74d6d41376b..06897d8f8fb 100644 --- a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/converter/ResultConverter.java +++ b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/converter/ResultConverter.java @@ -37,11 +37,10 @@ import org.smooks.io.payload.StringResult; /** * ResultConverter converts from different {@link Result} types. - * - * @author Daniel Bevenius */ @Converter(generateLoader = true) public class ResultConverter { + public static final String SMOOKS_RESULT_KEY = "SmooksResultKeys"; private ResultConverter() { diff --git a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/converter/SourceConverter.java b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/converter/SourceConverter.java index 994d249fc3e..a411b4a784a 100644 --- a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/converter/SourceConverter.java +++ b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/converter/SourceConverter.java @@ -31,8 +31,6 @@ import org.smooks.io.payload.JavaSourceWithoutEventStream; /** * SourceConverter is a Camel {@link Converter} that converts from different * formats to {@link Source} instances. </p> - * - * @author Daniel Bevenius */ @Converter(generateLoader = true) public class SourceConverter { @@ -61,7 +59,7 @@ public class SourceConverter { @Converter public static Source toStreamSource(GenericFile<File> genericFile) { - return new StreamSource((File) genericFile.getBody()); + return new StreamSource(genericFile.getFile()); } } diff --git a/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/Coordinate.java b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/Coordinate.java index 742e96adc33..af4c1af02fd 100644 --- a/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/Coordinate.java +++ b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/Coordinate.java @@ -16,9 +16,6 @@ */ package org.apache.camel.component.smooks; -/** - * @author <a href="mailto:[email protected]">[email protected]</a> - */ public class Coordinate { private Integer x; diff --git a/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/SmooksComponentTest.java b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/SmooksComponentTest.java index ed87219c5c2..44fcc9b252e 100644 --- a/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/SmooksComponentTest.java +++ b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/SmooksComponentTest.java @@ -32,13 +32,8 @@ import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf; import static org.junit.jupiter.api.Assertions.assertFalse; -/** - * Unit test for {@link SmooksComponent}. - * - * @author Christian Mueller - * @author Daniel Bevenius - */ public class SmooksComponentTest extends CamelTestSupport { + @EndpointInject(value = "mock:result") private MockEndpoint mockEndpoint; diff --git a/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/SmooksProcessorTest.java b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/SmooksProcessorTest.java index 5cf61198854..82afff24154 100644 --- a/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/SmooksProcessorTest.java +++ b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/SmooksProcessorTest.java @@ -63,13 +63,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -/** - * Unit test for {@link SmooksProcessor}. - * - * @author Christian Mueller - * @author Daniel Bevenius - */ public class SmooksProcessorTest extends CamelTestSupport { + @EndpointInject(value = "mock:result") private MockEndpoint result; diff --git a/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/converter/ResultConverterTest.java b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/converter/ResultConverterTest.java index 408da4585d8..08d3e52cb9d 100644 --- a/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/converter/ResultConverterTest.java +++ b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/converter/ResultConverterTest.java @@ -29,12 +29,8 @@ import org.smooks.io.payload.StringResult; import static org.junit.jupiter.api.Assertions.assertEquals; -/** - * Unit test for {@link ResultConverter}. - * - * @author Daniel Bevenius - */ public class ResultConverterTest { + private TypeConverter typeConverter; @BeforeEach diff --git a/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/converter/SourceConverterTest.java b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/converter/SourceConverterTest.java index 92396a6ab8a..fdc52368d11 100644 --- a/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/converter/SourceConverterTest.java +++ b/components/camel-smooks/src/test/java/org/apache/camel/component/smooks/converter/SourceConverterTest.java @@ -28,12 +28,8 @@ import org.smooks.io.payload.JavaSourceWithoutEventStream; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -/** - * Unit test for {@link SourceConverter}. </p> - * - * @author Daniel Bevenius - */ public class SourceConverterTest { + private TypeConverter typeConverter; @BeforeEach diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SmooksComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SmooksComponentBuilderFactory.java new file mode 100644 index 00000000000..1e9b50ea171 --- /dev/null +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SmooksComponentBuilderFactory.java @@ -0,0 +1,151 @@ +/* Generated by camel build tools - do NOT edit this file! */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.builder.component.dsl; + +import javax.annotation.processing.Generated; +import org.apache.camel.Component; +import org.apache.camel.builder.component.AbstractComponentBuilder; +import org.apache.camel.builder.component.ComponentBuilder; +import org.apache.camel.component.smooks.SmooksComponent; + +/** + * Applies fragment-based processing in Smooks to perform a variety of + * operations like transformation. + * + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.ComponentDslMojo") +public interface SmooksComponentBuilderFactory { + + /** + * Smooks (camel-smooks) + * Applies fragment-based processing in Smooks to perform a variety of + * operations like transformation. + * + * Category: file + * Since: 4.7 + * Maven coordinates: org.apache.camel:camel-smooks + * + * @return the dsl builder + */ + static SmooksComponentBuilder smooks() { + return new SmooksComponentBuilderImpl(); + } + + /** + * Builder for the Smooks component. + */ + interface SmooksComponentBuilder extends ComponentBuilder<SmooksComponent> { + + + /** + * Allows for bridging the consumer to the Camel routing Error Handler, + * which mean any exceptions (if possible) occurred while the Camel + * consumer is trying to pickup incoming messages, or the likes, will + * now be processed as a message and handled by the routing Error + * Handler. Important: This is only possible if the 3rd party component + * allows Camel to be alerted if an exception was thrown. Some + * components handle this internally only, and therefore + * bridgeErrorHandler is not possible. In other situations we may + * improve the Camel component to hook into the 3rd party component and + * make this possible for future releases. By default the consumer will + * use the org.apache.camel.spi.ExceptionHandler to deal with + * exceptions, that will be logged at WARN or ERROR level and ignored. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: consumer + * + * @param bridgeErrorHandler the value to set + * @return the dsl builder + */ + default SmooksComponentBuilder bridgeErrorHandler(boolean bridgeErrorHandler) { + doSetProperty("bridgeErrorHandler", bridgeErrorHandler); + return this; + } + + + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: producer + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default SmooksComponentBuilder lazyStartProducer(boolean lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + + + /** + * Whether autowiring is enabled. This is used for automatic autowiring + * options (the option must be marked as autowired) by looking up in the + * registry to find if there is a single instance of matching type, + * which then gets configured on the component. This can be used for + * automatic configuring JDBC data sources, JMS connection factories, + * AWS Clients, etc. + * + * The option is a: <code>boolean</code> type. + * + * Default: true + * Group: advanced + * + * @param autowiredEnabled the value to set + * @return the dsl builder + */ + default SmooksComponentBuilder autowiredEnabled(boolean autowiredEnabled) { + doSetProperty("autowiredEnabled", autowiredEnabled); + return this; + } + } + + class SmooksComponentBuilderImpl + extends AbstractComponentBuilder<SmooksComponent> + implements SmooksComponentBuilder { + @Override + protected SmooksComponent buildConcreteComponent() { + return new SmooksComponent(); + } + @Override + protected boolean setPropertyOnComponent( + Component component, + String name, + Object value) { + switch (name) { + case "bridgeErrorHandler": ((SmooksComponent) component).setBridgeErrorHandler((boolean) value); return true; + case "lazyStartProducer": ((SmooksComponent) component).setLazyStartProducer((boolean) value); return true; + case "autowiredEnabled": ((SmooksComponent) component).setAutowiredEnabled((boolean) value); return true; + default: return false; + } + } + } +} \ No newline at end of file diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SmooksEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SmooksEndpointBuilderFactory.java new file mode 100644 index 00000000000..f1fef38d77a --- /dev/null +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SmooksEndpointBuilderFactory.java @@ -0,0 +1,847 @@ +/* Generated by camel build tools - do NOT edit this file! */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.builder.endpoint.dsl; + +import java.util.*; +import java.util.concurrent.*; +import java.util.function.*; +import java.util.stream.*; +import javax.annotation.processing.Generated; +import org.apache.camel.builder.EndpointConsumerBuilder; +import org.apache.camel.builder.EndpointProducerBuilder; +import org.apache.camel.builder.endpoint.AbstractEndpointBuilder; + +/** + * Applies fragment-based processing in Smooks to perform a variety of + * operations like transformation. + * + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointDslMojo") +public interface SmooksEndpointBuilderFactory { + + /** + * Builder for endpoint consumers for the Smooks component. + */ + public interface SmooksEndpointConsumerBuilder + extends + EndpointConsumerBuilder { + default AdvancedSmooksEndpointConsumerBuilder advanced() { + return (AdvancedSmooksEndpointConsumerBuilder) this; + } + /** + * If the polling consumer did not poll any files, you can enable this + * option to send an empty message (no body) instead. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: consumer + * + * @param sendEmptyMessageWhenIdle the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder sendEmptyMessageWhenIdle(boolean sendEmptyMessageWhenIdle) { + doSetProperty("sendEmptyMessageWhenIdle", sendEmptyMessageWhenIdle); + return this; + } + /** + * If the polling consumer did not poll any files, you can enable this + * option to send an empty message (no body) instead. + * + * The option will be converted to a <code>boolean</code> type. + * + * Default: false + * Group: consumer + * + * @param sendEmptyMessageWhenIdle the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder sendEmptyMessageWhenIdle(String sendEmptyMessageWhenIdle) { + doSetProperty("sendEmptyMessageWhenIdle", sendEmptyMessageWhenIdle); + return this; + } + /** + * The number of subsequent error polls (failed due some error) that + * should happen before the backoffMultipler should kick-in. + * + * The option is a: <code>int</code> type. + * + * Group: scheduler + * + * @param backoffErrorThreshold the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder backoffErrorThreshold(int backoffErrorThreshold) { + doSetProperty("backoffErrorThreshold", backoffErrorThreshold); + return this; + } + /** + * The number of subsequent error polls (failed due some error) that + * should happen before the backoffMultipler should kick-in. + * + * The option will be converted to a <code>int</code> type. + * + * Group: scheduler + * + * @param backoffErrorThreshold the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder backoffErrorThreshold(String backoffErrorThreshold) { + doSetProperty("backoffErrorThreshold", backoffErrorThreshold); + return this; + } + /** + * The number of subsequent idle polls that should happen before the + * backoffMultipler should kick-in. + * + * The option is a: <code>int</code> type. + * + * Group: scheduler + * + * @param backoffIdleThreshold the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder backoffIdleThreshold(int backoffIdleThreshold) { + doSetProperty("backoffIdleThreshold", backoffIdleThreshold); + return this; + } + /** + * The number of subsequent idle polls that should happen before the + * backoffMultipler should kick-in. + * + * The option will be converted to a <code>int</code> type. + * + * Group: scheduler + * + * @param backoffIdleThreshold the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder backoffIdleThreshold(String backoffIdleThreshold) { + doSetProperty("backoffIdleThreshold", backoffIdleThreshold); + return this; + } + /** + * To let the scheduled polling consumer backoff if there has been a + * number of subsequent idles/errors in a row. The multiplier is then + * the number of polls that will be skipped before the next actual + * attempt is happening again. When this option is in use then + * backoffIdleThreshold and/or backoffErrorThreshold must also be + * configured. + * + * The option is a: <code>int</code> type. + * + * Group: scheduler + * + * @param backoffMultiplier the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder backoffMultiplier(int backoffMultiplier) { + doSetProperty("backoffMultiplier", backoffMultiplier); + return this; + } + /** + * To let the scheduled polling consumer backoff if there has been a + * number of subsequent idles/errors in a row. The multiplier is then + * the number of polls that will be skipped before the next actual + * attempt is happening again. When this option is in use then + * backoffIdleThreshold and/or backoffErrorThreshold must also be + * configured. + * + * The option will be converted to a <code>int</code> type. + * + * Group: scheduler + * + * @param backoffMultiplier the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder backoffMultiplier(String backoffMultiplier) { + doSetProperty("backoffMultiplier", backoffMultiplier); + return this; + } + /** + * Milliseconds before the next poll. + * + * The option is a: <code>long</code> type. + * + * Default: 500 + * Group: scheduler + * + * @param delay the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder delay(long delay) { + doSetProperty("delay", delay); + return this; + } + /** + * Milliseconds before the next poll. + * + * The option will be converted to a <code>long</code> type. + * + * Default: 500 + * Group: scheduler + * + * @param delay the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder delay(String delay) { + doSetProperty("delay", delay); + return this; + } + /** + * If greedy is enabled, then the ScheduledPollConsumer will run + * immediately again, if the previous run polled 1 or more messages. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: scheduler + * + * @param greedy the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder greedy(boolean greedy) { + doSetProperty("greedy", greedy); + return this; + } + /** + * If greedy is enabled, then the ScheduledPollConsumer will run + * immediately again, if the previous run polled 1 or more messages. + * + * The option will be converted to a <code>boolean</code> type. + * + * Default: false + * Group: scheduler + * + * @param greedy the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder greedy(String greedy) { + doSetProperty("greedy", greedy); + return this; + } + /** + * Milliseconds before the first poll starts. + * + * The option is a: <code>long</code> type. + * + * Default: 1000 + * Group: scheduler + * + * @param initialDelay the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder initialDelay(long initialDelay) { + doSetProperty("initialDelay", initialDelay); + return this; + } + /** + * Milliseconds before the first poll starts. + * + * The option will be converted to a <code>long</code> type. + * + * Default: 1000 + * Group: scheduler + * + * @param initialDelay the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder initialDelay(String initialDelay) { + doSetProperty("initialDelay", initialDelay); + return this; + } + /** + * Specifies a maximum limit of number of fires. So if you set it to 1, + * the scheduler will only fire once. If you set it to 5, it will only + * fire five times. A value of zero or negative means fire forever. + * + * The option is a: <code>long</code> type. + * + * Default: 0 + * Group: scheduler + * + * @param repeatCount the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder repeatCount(long repeatCount) { + doSetProperty("repeatCount", repeatCount); + return this; + } + /** + * Specifies a maximum limit of number of fires. So if you set it to 1, + * the scheduler will only fire once. If you set it to 5, it will only + * fire five times. A value of zero or negative means fire forever. + * + * The option will be converted to a <code>long</code> type. + * + * Default: 0 + * Group: scheduler + * + * @param repeatCount the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder repeatCount(String repeatCount) { + doSetProperty("repeatCount", repeatCount); + return this; + } + /** + * The consumer logs a start/complete log line when it polls. This + * option allows you to configure the logging level for that. + * + * The option is a: <code>org.apache.camel.LoggingLevel</code> type. + * + * Default: TRACE + * Group: scheduler + * + * @param runLoggingLevel the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder runLoggingLevel(org.apache.camel.LoggingLevel runLoggingLevel) { + doSetProperty("runLoggingLevel", runLoggingLevel); + return this; + } + /** + * The consumer logs a start/complete log line when it polls. This + * option allows you to configure the logging level for that. + * + * The option will be converted to a + * <code>org.apache.camel.LoggingLevel</code> type. + * + * Default: TRACE + * Group: scheduler + * + * @param runLoggingLevel the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder runLoggingLevel(String runLoggingLevel) { + doSetProperty("runLoggingLevel", runLoggingLevel); + return this; + } + /** + * Allows for configuring a custom/shared thread pool to use for the + * consumer. By default each consumer has its own single threaded thread + * pool. + * + * The option is a: + * <code>java.util.concurrent.ScheduledExecutorService</code> type. + * + * Group: scheduler + * + * @param scheduledExecutorService the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder scheduledExecutorService(ScheduledExecutorService scheduledExecutorService) { + doSetProperty("scheduledExecutorService", scheduledExecutorService); + return this; + } + /** + * Allows for configuring a custom/shared thread pool to use for the + * consumer. By default each consumer has its own single threaded thread + * pool. + * + * The option will be converted to a + * <code>java.util.concurrent.ScheduledExecutorService</code> type. + * + * Group: scheduler + * + * @param scheduledExecutorService the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder scheduledExecutorService(String scheduledExecutorService) { + doSetProperty("scheduledExecutorService", scheduledExecutorService); + return this; + } + /** + * To use a cron scheduler from either camel-spring or camel-quartz + * component. Use value spring or quartz for built in scheduler. + * + * The option is a: <code>java.lang.Object</code> type. + * + * Default: none + * Group: scheduler + * + * @param scheduler the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder scheduler(Object scheduler) { + doSetProperty("scheduler", scheduler); + return this; + } + /** + * To use a cron scheduler from either camel-spring or camel-quartz + * component. Use value spring or quartz for built in scheduler. + * + * The option will be converted to a <code>java.lang.Object</code> type. + * + * Default: none + * Group: scheduler + * + * @param scheduler the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder scheduler(String scheduler) { + doSetProperty("scheduler", scheduler); + return this; + } + /** + * To configure additional properties when using a custom scheduler or + * any of the Quartz, Spring based scheduler. + * + * The option is a: <code>java.util.Map<java.lang.String, + * java.lang.Object></code> type. + * The option is multivalued, and you can use the + * schedulerProperties(String, Object) method to add a value (call the + * method multiple times to set more values). + * + * Group: scheduler + * + * @param key the option key + * @param value the option value + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder schedulerProperties(String key, Object value) { + doSetMultiValueProperty("schedulerProperties", "scheduler." + key, value); + return this; + } + /** + * To configure additional properties when using a custom scheduler or + * any of the Quartz, Spring based scheduler. + * + * The option is a: <code>java.util.Map<java.lang.String, + * java.lang.Object></code> type. + * The option is multivalued, and you can use the + * schedulerProperties(String, Object) method to add a value (call the + * method multiple times to set more values). + * + * Group: scheduler + * + * @param values the values + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder schedulerProperties(Map values) { + doSetMultiValueProperties("schedulerProperties", "scheduler.", values); + return this; + } + /** + * Whether the scheduler should be auto started. + * + * The option is a: <code>boolean</code> type. + * + * Default: true + * Group: scheduler + * + * @param startScheduler the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder startScheduler(boolean startScheduler) { + doSetProperty("startScheduler", startScheduler); + return this; + } + /** + * Whether the scheduler should be auto started. + * + * The option will be converted to a <code>boolean</code> type. + * + * Default: true + * Group: scheduler + * + * @param startScheduler the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder startScheduler(String startScheduler) { + doSetProperty("startScheduler", startScheduler); + return this; + } + /** + * Time unit for initialDelay and delay options. + * + * The option is a: <code>java.util.concurrent.TimeUnit</code> type. + * + * Default: MILLISECONDS + * Group: scheduler + * + * @param timeUnit the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder timeUnit(TimeUnit timeUnit) { + doSetProperty("timeUnit", timeUnit); + return this; + } + /** + * Time unit for initialDelay and delay options. + * + * The option will be converted to a + * <code>java.util.concurrent.TimeUnit</code> type. + * + * Default: MILLISECONDS + * Group: scheduler + * + * @param timeUnit the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder timeUnit(String timeUnit) { + doSetProperty("timeUnit", timeUnit); + return this; + } + /** + * Controls if fixed delay or fixed rate is used. See + * ScheduledExecutorService in JDK for details. + * + * The option is a: <code>boolean</code> type. + * + * Default: true + * Group: scheduler + * + * @param useFixedDelay the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder useFixedDelay(boolean useFixedDelay) { + doSetProperty("useFixedDelay", useFixedDelay); + return this; + } + /** + * Controls if fixed delay or fixed rate is used. See + * ScheduledExecutorService in JDK for details. + * + * The option will be converted to a <code>boolean</code> type. + * + * Default: true + * Group: scheduler + * + * @param useFixedDelay the value to set + * @return the dsl builder + */ + default SmooksEndpointConsumerBuilder useFixedDelay(String useFixedDelay) { + doSetProperty("useFixedDelay", useFixedDelay); + return this; + } + } + + /** + * Advanced builder for endpoint consumers for the Smooks component. + */ + public interface AdvancedSmooksEndpointConsumerBuilder + extends + EndpointConsumerBuilder { + default SmooksEndpointConsumerBuilder basic() { + return (SmooksEndpointConsumerBuilder) this; + } + /** + * Allows for bridging the consumer to the Camel routing Error Handler, + * which mean any exceptions (if possible) occurred while the Camel + * consumer is trying to pickup incoming messages, or the likes, will + * now be processed as a message and handled by the routing Error + * Handler. Important: This is only possible if the 3rd party component + * allows Camel to be alerted if an exception was thrown. Some + * components handle this internally only, and therefore + * bridgeErrorHandler is not possible. In other situations we may + * improve the Camel component to hook into the 3rd party component and + * make this possible for future releases. By default the consumer will + * use the org.apache.camel.spi.ExceptionHandler to deal with + * exceptions, that will be logged at WARN or ERROR level and ignored. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: consumer (advanced) + * + * @param bridgeErrorHandler the value to set + * @return the dsl builder + */ + default AdvancedSmooksEndpointConsumerBuilder bridgeErrorHandler(boolean bridgeErrorHandler) { + doSetProperty("bridgeErrorHandler", bridgeErrorHandler); + return this; + } + /** + * Allows for bridging the consumer to the Camel routing Error Handler, + * which mean any exceptions (if possible) occurred while the Camel + * consumer is trying to pickup incoming messages, or the likes, will + * now be processed as a message and handled by the routing Error + * Handler. Important: This is only possible if the 3rd party component + * allows Camel to be alerted if an exception was thrown. Some + * components handle this internally only, and therefore + * bridgeErrorHandler is not possible. In other situations we may + * improve the Camel component to hook into the 3rd party component and + * make this possible for future releases. By default the consumer will + * use the org.apache.camel.spi.ExceptionHandler to deal with + * exceptions, that will be logged at WARN or ERROR level and ignored. + * + * The option will be converted to a <code>boolean</code> type. + * + * Default: false + * Group: consumer (advanced) + * + * @param bridgeErrorHandler the value to set + * @return the dsl builder + */ + default AdvancedSmooksEndpointConsumerBuilder bridgeErrorHandler(String bridgeErrorHandler) { + doSetProperty("bridgeErrorHandler", bridgeErrorHandler); + return this; + } + /** + * To let the consumer use a custom ExceptionHandler. Notice if the + * option bridgeErrorHandler is enabled then this option is not in use. + * By default the consumer will deal with exceptions, that will be + * logged at WARN or ERROR level and ignored. + * + * The option is a: <code>org.apache.camel.spi.ExceptionHandler</code> + * type. + * + * Group: consumer (advanced) + * + * @param exceptionHandler the value to set + * @return the dsl builder + */ + default AdvancedSmooksEndpointConsumerBuilder exceptionHandler(org.apache.camel.spi.ExceptionHandler exceptionHandler) { + doSetProperty("exceptionHandler", exceptionHandler); + return this; + } + /** + * To let the consumer use a custom ExceptionHandler. Notice if the + * option bridgeErrorHandler is enabled then this option is not in use. + * By default the consumer will deal with exceptions, that will be + * logged at WARN or ERROR level and ignored. + * + * The option will be converted to a + * <code>org.apache.camel.spi.ExceptionHandler</code> type. + * + * Group: consumer (advanced) + * + * @param exceptionHandler the value to set + * @return the dsl builder + */ + default AdvancedSmooksEndpointConsumerBuilder exceptionHandler(String exceptionHandler) { + doSetProperty("exceptionHandler", exceptionHandler); + return this; + } + /** + * Sets the exchange pattern when the consumer creates an exchange. + * + * The option is a: <code>org.apache.camel.ExchangePattern</code> type. + * + * Group: consumer (advanced) + * + * @param exchangePattern the value to set + * @return the dsl builder + */ + default AdvancedSmooksEndpointConsumerBuilder exchangePattern(org.apache.camel.ExchangePattern exchangePattern) { + doSetProperty("exchangePattern", exchangePattern); + return this; + } + /** + * Sets the exchange pattern when the consumer creates an exchange. + * + * The option will be converted to a + * <code>org.apache.camel.ExchangePattern</code> type. + * + * Group: consumer (advanced) + * + * @param exchangePattern the value to set + * @return the dsl builder + */ + default AdvancedSmooksEndpointConsumerBuilder exchangePattern(String exchangePattern) { + doSetProperty("exchangePattern", exchangePattern); + return this; + } + /** + * A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing + * you to provide your custom implementation to control error handling + * usually occurred during the poll operation before an Exchange have + * been created and being routed in Camel. + * + * The option is a: + * <code>org.apache.camel.spi.PollingConsumerPollStrategy</code> type. + * + * Group: consumer (advanced) + * + * @param pollStrategy the value to set + * @return the dsl builder + */ + default AdvancedSmooksEndpointConsumerBuilder pollStrategy(org.apache.camel.spi.PollingConsumerPollStrategy pollStrategy) { + doSetProperty("pollStrategy", pollStrategy); + return this; + } + /** + * A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing + * you to provide your custom implementation to control error handling + * usually occurred during the poll operation before an Exchange have + * been created and being routed in Camel. + * + * The option will be converted to a + * <code>org.apache.camel.spi.PollingConsumerPollStrategy</code> type. + * + * Group: consumer (advanced) + * + * @param pollStrategy the value to set + * @return the dsl builder + */ + default AdvancedSmooksEndpointConsumerBuilder pollStrategy(String pollStrategy) { + doSetProperty("pollStrategy", pollStrategy); + return this; + } + } + + /** + * Builder for endpoint producers for the Smooks component. + */ + public interface SmooksEndpointProducerBuilder + extends + EndpointProducerBuilder { + default AdvancedSmooksEndpointProducerBuilder advanced() { + return (AdvancedSmooksEndpointProducerBuilder) this; + } + + } + + /** + * Advanced builder for endpoint producers for the Smooks component. + */ + public interface AdvancedSmooksEndpointProducerBuilder extends EndpointProducerBuilder { + default SmooksEndpointProducerBuilder basic() { + return (SmooksEndpointProducerBuilder) this; + } + + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: producer (advanced) + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AdvancedSmooksEndpointProducerBuilder lazyStartProducer(boolean lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option will be converted to a <code>boolean</code> type. + * + * Default: false + * Group: producer (advanced) + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AdvancedSmooksEndpointProducerBuilder lazyStartProducer(String lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + } + + /** + * Builder for endpoint for the Smooks component. + */ + public interface SmooksEndpointBuilder + extends + SmooksEndpointConsumerBuilder, + SmooksEndpointProducerBuilder { + default AdvancedSmooksEndpointBuilder advanced() { + return (AdvancedSmooksEndpointBuilder) this; + } + + } + + /** + * Advanced builder for endpoint for the Smooks component. + */ + public interface AdvancedSmooksEndpointBuilder + extends + AdvancedSmooksEndpointConsumerBuilder, + AdvancedSmooksEndpointProducerBuilder { + default SmooksEndpointBuilder basic() { + return (SmooksEndpointBuilder) this; + } + + } + + public interface SmooksBuilders { + /** + * Smooks (camel-smooks) + * Applies fragment-based processing in Smooks to perform a variety of + * operations like transformation. + * + * Category: file + * Since: 4.7 + * Maven coordinates: org.apache.camel:camel-smooks + * + * Syntax: <code>smooks://smooks-config-path</code> + * + * Path parameter: database (required) + * database name + * + * @param path smooks-config-path + * @return the dsl builder + */ + default SmooksEndpointBuilder smooks(String path) { + return SmooksEndpointBuilderFactory.endpointBuilder("smooks", path); + } + /** + * Smooks (camel-smooks) + * Applies fragment-based processing in Smooks to perform a variety of + * operations like transformation. + * + * Category: file + * Since: 4.7 + * Maven coordinates: org.apache.camel:camel-smooks + * + * Syntax: <code>smooks://smooks-config-path</code> + * + * Path parameter: database (required) + * database name + * + * @param componentName to use a custom component name for the endpoint + * instead of the default name + * @param path smooks-config-path + * @return the dsl builder + */ + default SmooksEndpointBuilder smooks(String componentName, String path) { + return SmooksEndpointBuilderFactory.endpointBuilder(componentName, path); + } + + } + static SmooksEndpointBuilder endpointBuilder(String componentName, String path) { + class SmooksEndpointBuilderImpl extends AbstractEndpointBuilder implements SmooksEndpointBuilder, AdvancedSmooksEndpointBuilder { + public SmooksEndpointBuilderImpl(String path) { + super(componentName, path); + } + } + return new SmooksEndpointBuilderImpl(path); + } +} \ No newline at end of file
