This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5133ca3e38b523f170a094fcd54729d96c371b17 Author: Guillaume Nodet <gno...@gmail.com> AuthorDate: Fri Feb 7 08:41:01 2020 +0100 [CAMEL-14516] Components should use the endpoint configurer when possible --- .../component/activemq/ActiveMQComponent.java | 18 ++++ .../apache/camel/component/amqp/AMQPComponent.java | 11 +++ .../java/org/apache/camel/coap/CoAPComponent.java | 4 +- .../apache/camel/component/cxf/CxfComponent.java | 10 +- .../component/directvm/DirectVmComponent.java | 1 - .../component/disruptor/DisruptorComponent.java | 2 +- .../component/facebook/FacebookComponent.java | 2 +- .../camel/component/file/GenericFileComponent.java | 1 - .../file/remote/SftpEndpointConfigurer.java | 3 + .../apache/camel/component/file/remote/sftp.json | 2 + .../camel-ftp/src/main/docs/sftp-component.adoc | 4 +- .../camel/component/file/remote/FtpComponent.java | 16 +++ .../camel/component/file/remote/SftpEndpoint.java | 2 +- .../apache/camel/component/hdfs/HdfsComponent.java | 2 +- components/camel-hipchat/pom.xml | 5 + .../camel/component/hipchat/HipchatComponent.java | 2 +- .../hipchat/HipchatComponentConsumerTest.java | 8 +- .../hipchat/HipchatComponentMultipleUsersTest.java | 8 +- .../hipchat/HipchatComponentProducerTest.java | 8 +- .../component/hipchat/HipchatTestComponent.java | 48 +++++++++ .../HipchatXmlDefinedComponentProducerTest.java | 8 +- .../apache/camel/component/http/HttpComponent.java | 8 +- .../apache/camel/component/irc/IrcComponent.java | 2 +- .../camel/component/ironmq/IronMQComponent.java | 8 +- .../component/ironmq/IronMQBatchConsumerTest.java | 1 + .../ironmq/IronMQBatchDeleteConsumerTest.java | 1 + .../component/ironmq/IronMQBatchProducerTest.java | 1 + .../ironmq/IronMQComponentConfigurationTest.java | 7 +- .../component/ironmq/IronMQComponentTest.java | 1 + .../ironmq/IronMQPreserveHeadersTest.java | 1 + .../camel/component/jetty/JettyHttpComponent.java | 2 +- .../apache/camel/component/jms/JmsComponent.java | 2 +- .../camel/component/kafka/KafkaComponent.java | 2 - .../component/kafka/BaseEmbeddedKafkaTest.java | 1 + .../camel/component/kafka/KafkaEndpointTest.java | 4 +- .../camel/component/kafka/KafkaProducerTest.java | 1 + .../camel/component/lucene/LuceneComponent.java | 2 +- .../apache/camel/component/mail/MailComponent.java | 1 - .../camel/component/mail/MailComponentTest.java | 2 + .../component/netty/http/NettyHttpComponent.java | 10 +- .../camel/component/netty/NettyComponent.java | 2 +- .../olingo2/AbstractOlingo2TestSupport.java | 1 + .../camel/component/olingo4/Olingo4Component.java | 5 +- .../platform/http/PlatformHttpComponent.java | 2 +- .../camel/component/printer/PrinterComponent.java | 4 +- .../rest/openapi/RestOpenApiEndpoint.java | 7 +- .../apache/camel/component/rest/RestEndpoint.java | 10 ++ .../apache/camel/component/seda/SedaComponent.java | 2 +- .../camel/component/servlet/ServletComponent.java | 2 +- .../apache/camel/component/sip/SipComponent.java | 2 +- .../camel/component/sparkrest/SparkComponent.java | 2 +- .../component/springldap/SpringLdapComponent.java | 2 +- .../component/springldap/SpringLdapEndpoint.java | 5 +- .../apache/camel/component/ssh/SshComponent.java | 2 +- .../component/undertow/UndertowComponent.java | 10 +- .../component/wordpress/WordpressComponent.java | 30 ++---- .../wordpress/WordpressComponentTest.java | 1 + .../XmlSignatureComponentConfigurer.java | 31 ------ .../XmlSignatureEndpointConfigurer.java | 95 ------------------ .../apache/camel/configurer/xmlsecurity-component | 2 - .../apache/camel/configurer/xmlsecurity-endpoint | 2 - .../xmlsecurity/XmlSignatureComponent.java | 4 +- .../xmlsecurity/XmlSignatureEndpoint.java | 4 +- .../component/xmlsecurity/XmlSignerEndpoint.java | 2 +- .../component/xmlsecurity/XmlVerifierEndpoint.java | 2 +- .../processor/XmlSignatureConfiguration.java | 13 +-- .../processor/XmlSignatureProcessor.java | 15 ++- .../processor/XmlSignerConfiguration.java | 109 --------------------- .../xmlsecurity/processor/XmlSignerProcessor.java | 4 +- .../processor/XmlVerifierConfiguration.java | 90 ----------------- .../processor/XmlVerifierProcessor.java | 4 +- .../component/xmlsecurity/XmlSignatureTest.java | 4 +- .../camel/component/yammer/YammerComponent.java | 3 - .../camel/component/yammer/YammerEndpoint.java | 1 + .../org/apache/camel/support/DefaultComponent.java | 31 ++++-- .../org/apache/camel/support/DefaultEndpoint.java | 8 +- .../camel/support/PropertyBindingSupport.java | 8 +- .../camel/support/RestProducerFactoryHelper.java | 4 +- .../support/component/AbstractApiComponent.java | 5 +- .../support/component/AbstractApiEndpoint.java | 13 +-- 80 files changed, 273 insertions(+), 492 deletions(-) diff --git a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java index 0d994d4..48cf5c4 100644 --- a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java +++ b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java @@ -22,10 +22,13 @@ import java.util.concurrent.CopyOnWriteArrayList; import org.apache.activemq.Service; import org.apache.camel.CamelContext; +import org.apache.camel.Endpoint; import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.jms.JmsComponent; +import org.apache.camel.component.jms.JmsEndpoint; import org.apache.camel.component.jms.JmsConfiguration; import org.apache.camel.spi.annotations.Component; +import org.apache.camel.support.component.PropertyConfigurerSupport; import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.PropertiesHelper; import org.apache.camel.util.URISupport; @@ -129,6 +132,21 @@ public class ActiveMQComponent extends JmsComponent { } } + @Override + protected void setProperties(Endpoint bean, Map<String, Object> parameters) throws Exception { + Object useSingleConnection = parameters.remove("useSingleConnection"); + if (useSingleConnection != null) { + ((ActiveMQConfiguration) ((JmsEndpoint) bean).getConfiguration()) + .setUseSingleConnection(PropertyConfigurerSupport.property(getCamelContext(), boolean.class, useSingleConnection)); + } + Object usePooledConnection = parameters.remove("usePooledConnection"); + if (usePooledConnection != null) { + ((ActiveMQConfiguration) ((JmsEndpoint) bean).getConfiguration()) + .setUsePooledConnection(PropertyConfigurerSupport.property(getCamelContext(), boolean.class, usePooledConnection)); + } + super.setProperties(bean, parameters); + } + protected void addPooledConnectionFactoryService(Service pooledConnectionFactoryService) { pooledConnectionFactoryServiceList.add(pooledConnectionFactoryService); } diff --git a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java index f255ce4..25ece36 100644 --- a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java +++ b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java @@ -27,6 +27,7 @@ import org.apache.camel.component.jms.JmsComponent; import org.apache.camel.component.jms.JmsConfiguration; import org.apache.camel.component.jms.JmsEndpoint; import org.apache.camel.spi.annotations.Component; +import org.apache.camel.support.component.PropertyConfigurerSupport; import org.apache.qpid.jms.JmsConnectionFactory; /** @@ -115,4 +116,14 @@ public class AMQPComponent extends JmsComponent { } } + @Override + protected void setProperties(Endpoint bean, Map<String, Object> parameters) throws Exception { + Object includeAmqpAnnotations = parameters.remove("includeAmqpAnnotations"); + if (includeAmqpAnnotations != null) { + ((AMQPConfiguration) ((JmsEndpoint) bean).getConfiguration()) + .setIncludeAmqpAnnotations(PropertyConfigurerSupport.property(getCamelContext(), boolean.class, includeAmqpAnnotations)); + } + super.setProperties(bean, parameters); + } + } diff --git a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java index 34e2653..cb4a5bb 100644 --- a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java +++ b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java @@ -136,7 +136,7 @@ public class CoAPComponent extends DefaultComponent implements RestConsumerFacto RestConfiguration config = configuration; if (config == null) { - config = getCamelContext().getRestConfiguration("coap", true); + config = camelContext.getRestConfiguration("coap", true); } if (config.isEnableCORS()) { @@ -187,7 +187,7 @@ public class CoAPComponent extends DefaultComponent implements RestConsumerFacto } CoAPEndpoint endpoint = camelContext.getEndpoint(url, CoAPEndpoint.class); - setProperties(camelContext, endpoint, parameters); + setProperties(endpoint, parameters); // configure consumer properties Consumer consumer = endpoint.createConsumer(processor); diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java index b1066d9..12af269 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java @@ -105,20 +105,14 @@ public class CxfComponent extends HeaderFilterStrategyComponent implements SSLCo } result = createCxfSpringEndpoint(beanId); - // need to check the CamelContext value - if (getCamelContext().equals(result.getCamelContext())) { - result.setCamelContext(getCamelContext()); - } result.setBeanId(beanId); } else { // endpoint URI does not specify a bean result = createCxfEndpoint(remaining); } - - if (result.getCamelContext() == null) { - result.setCamelContext(getCamelContext()); - } + result.setComponent(this); + result.setCamelContext(getCamelContext()); setEndpointHeaderFilterStrategy(result); setProperties(result, parameters); diff --git a/components/camel-directvm/src/main/java/org/apache/camel/component/directvm/DirectVmComponent.java b/components/camel-directvm/src/main/java/org/apache/camel/component/directvm/DirectVmComponent.java index b9bc4ea..995f14d 100644 --- a/components/camel-directvm/src/main/java/org/apache/camel/component/directvm/DirectVmComponent.java +++ b/components/camel-directvm/src/main/java/org/apache/camel/component/directvm/DirectVmComponent.java @@ -72,7 +72,6 @@ public class DirectVmComponent extends DefaultComponent { answer.setBlock(block); answer.setTimeout(timeout); answer.setPropagateProperties(propagateProperties); - answer.configureProperties(parameters); setProperties(answer, parameters); return answer; } diff --git a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorComponent.java b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorComponent.java index 5717fd7..6c9d6be 100644 --- a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorComponent.java +++ b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorComponent.java @@ -105,7 +105,7 @@ public class DisruptorComponent extends DefaultComponent { answer.setBlockWhenFull(blockWhenFull); answer.setWaitStrategy(waitStrategy); answer.setProducerType(producerType); - answer.configureProperties(parameters); + setProperties(answer, parameters); return answer; } diff --git a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookComponent.java b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookComponent.java index d3ff7a0..f9302d6 100644 --- a/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookComponent.java +++ b/components/camel-facebook/src/main/java/org/apache/camel/component/facebook/FacebookComponent.java @@ -65,7 +65,7 @@ public class FacebookComponent extends DefaultComponent { setProperties(endpoint, parameters); // configure endpoint properties - endpoint.configureProperties(parameters); + setProperties(endpoint, parameters); // validate parameters validateParameters(uri, parameters, null); diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileComponent.java b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileComponent.java index 6ffaae4..4413432 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileComponent.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileComponent.java @@ -65,7 +65,6 @@ public abstract class GenericFileComponent<T> extends DefaultComponent { Comparator<Exchange> comparator = createSortByComparator(it); endpoint.setSortBy(comparator); } - setProperties(endpoint.getConfiguration(), parameters); setProperties(endpoint, parameters); afterPropertiesSet(endpoint); diff --git a/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/SftpEndpointConfigurer.java b/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/SftpEndpointConfigurer.java index 0a6ab57..ebd96e8 100644 --- a/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/SftpEndpointConfigurer.java +++ b/components/camel-ftp/src/generated/java/org/apache/camel/component/file/remote/SftpEndpointConfigurer.java @@ -15,6 +15,7 @@ public class SftpEndpointConfigurer extends PropertyConfigurerSupport implements public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { SftpEndpoint target = (SftpEndpoint) obj; switch (ignoreCase ? name.toLowerCase() : name) { + case "binary": target.getConfiguration().setBinary(property(camelContext, boolean.class, value)); return true; case "charset": target.setCharset(property(camelContext, java.lang.String.class, value)); return true; case "disconnect": target.setDisconnect(property(camelContext, boolean.class, value)); return true; case "donefilename": @@ -23,6 +24,8 @@ public class SftpEndpointConfigurer extends PropertyConfigurerSupport implements case "fileName": target.setFileName(property(camelContext, java.lang.String.class, value)); return true; case "jschlogginglevel": case "jschLoggingLevel": target.getConfiguration().setJschLoggingLevel(property(camelContext, org.apache.camel.LoggingLevel.class, value)); return true; + case "passivemode": + case "passiveMode": target.getConfiguration().setPassiveMode(property(camelContext, boolean.class, value)); return true; case "separator": target.getConfiguration().setSeparator(property(camelContext, org.apache.camel.component.file.remote.RemoteFileConfiguration.PathSeparator.class, value)); return true; case "fastexistscheck": case "fastExistsCheck": target.setFastExistsCheck(property(camelContext, boolean.class, value)); return true; diff --git a/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/sftp.json b/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/sftp.json index 1f00df7..827d180 100644 --- a/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/sftp.json +++ b/components/camel-ftp/src/generated/resources/org/apache/camel/component/file/remote/sftp.json @@ -27,11 +27,13 @@ "host": { "kind": "path", "displayName": "Host", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.file.remote.SftpConfiguration", "configurationField": "configuration", "description": "Hostname of the FTP server" }, "port": { "kind": "path", "displayName": "Port", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.SftpConfiguration", "configurationField": "configuration", "description": "Port of the FTP server" }, "directoryName": { "kind": "path", "displayName": "Directory Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.file.remote.SftpConfiguration", "configurationField": "configuration", "description": "The starting directory" }, + "binary": { "kind": "parameter", "displayName": "Binary", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.file.remote.SftpConfiguration", "configurationField": "configuration", "description": "Specifies the file transfer mode, BINARY or ASCII. Default is ASCII (false)." }, "charset": { "kind": "parameter", "displayName": "Charset", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "This option is used to specify the encoding of the file. You can use this on the consumer, to specify the encodings of the files, which allow Camel to know the charset it should load the file content in case the file content is being accessed. Likewise when writing a file, [...] "disconnect": { "kind": "parameter", "displayName": "Disconnect", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether or not to disconnect from remote FTP server right after use. Disconnect will only disconnect the current connection to the FTP server. If you have a consumer which you want to stop, then you need to stop the consumer\/route instead." }, "doneFileName": { "kind": "parameter", "displayName": "Done File Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "Producer: If provided, then Camel will write a 2nd done file when the original file has been written. The done file will be empty. This option configures what file name to use. Either you can specify a fixed name. Or you can use dynamic placeholders. The done f [...] "fileName": { "kind": "parameter", "displayName": "File Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "Use Expression such as File Language to dynamically set the filename. For consumers, it's used as a filename filter. For producers, it's used to evaluate the filename to write. If an expression is set, it take precedence over the CamelFileName header. (Note: The header [...] "jschLoggingLevel": { "kind": "parameter", "displayName": "Jsch Logging Level", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.LoggingLevel", "enum": [ "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF" ], "deprecated": false, "secret": false, "defaultValue": "WARN", "configurationClass": "org.apache.camel.component.file.remote.SftpConfiguration", "configurationField": "configuration", "description": "The logging level to use for JSCH [...] + "passiveMode": { "kind": "parameter", "displayName": "Passive Mode", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.file.remote.SftpConfiguration", "configurationField": "configuration", "description": "Sets passive mode connections. Default is active mode connections." }, "separator": { "kind": "parameter", "displayName": "Separator", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.file.remote.RemoteFileConfiguration.PathSeparator", "enum": [ "UNIX", "Windows", "Auto" ], "deprecated": false, "secret": false, "defaultValue": "UNIX", "configurationClass": "org.apache.camel.component.file.remote.SftpConfiguration", "configurationField": "configuration", "description": "Sets the path separator t [...] "fastExistsCheck": { "kind": "parameter", "displayName": "Fast Exists Check", "group": "common (advanced)", "label": "common,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If set this option to be true, camel-ftp will use the list file directly to check if the file exists. Since some FTP server may not support to list the file directly, if the option is false, camel-ftp will use the [...] "bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled b [...] diff --git a/components/camel-ftp/src/main/docs/sftp-component.adoc b/components/camel-ftp/src/main/docs/sftp-component.adoc index 657880b..6086f49 100644 --- a/components/camel-ftp/src/main/docs/sftp-component.adoc +++ b/components/camel-ftp/src/main/docs/sftp-component.adoc @@ -65,17 +65,19 @@ with the following path and query parameters: |=== -=== Query Parameters (118 parameters): +=== Query Parameters (120 parameters): [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type +| *binary* (common) | Specifies the file transfer mode, BINARY or ASCII. Default is ASCII (false). | false | boolean | *charset* (common) | This option is used to specify the encoding of the file. You can use this on the consumer, to specify the encodings of the files, which allow Camel to know the charset it should load the file content in case the file content is being accessed. Likewise when writing a file, you can use this option to specify which charset to write the file as well. Do mind that when writing the file Camel may have to read the message content into memory to be able to convert the dat [...] | *disconnect* (common) | Whether or not to disconnect from remote FTP server right after use. Disconnect will only disconnect the current connection to the FTP server. If you have a consumer which you want to stop, then you need to stop the consumer/route instead. | false | boolean | *doneFileName* (common) | Producer: If provided, then Camel will write a 2nd done file when the original file has been written. The done file will be empty. This option configures what file name to use. Either you can specify a fixed name. Or you can use dynamic placeholders. The done file will always be written in the same folder as the original file. Consumer: If provided, Camel will only consume files if a done file exists. This option configures what file name to use. Either you ca [...] | *fileName* (common) | Use Expression such as File Language to dynamically set the filename. For consumers, it's used as a filename filter. For producers, it's used to evaluate the filename to write. If an expression is set, it take precedence over the CamelFileName header. (Note: The header itself can also be an Expression). The expression options support both String and Expression types. If the expression is a String type, it is always evaluated using the File Language. If the express [...] | *jschLoggingLevel* (common) | The logging level to use for JSCH activity logging. As JSCH is verbose at by default at INFO level the threshold is WARN by default. The value can be one of: TRACE, DEBUG, INFO, WARN, ERROR, OFF | WARN | LoggingLevel +| *passiveMode* (common) | Sets passive mode connections. Default is active mode connections. | false | boolean | *separator* (common) | Sets the path separator to be used. UNIX = Uses unix style path separator Windows = Uses windows style path separator Auto = (is default) Use existing path separator in file name. The value can be one of: UNIX, Windows, Auto | UNIX | PathSeparator | *fastExistsCheck* (common) | If set this option to be true, camel-\ftp will use the list file directly to check if the file exists. Since some FTP server may not support to list the file directly, if the option is false, camel-\ftp will use the old way to list the directory and check if the file exists. This option also influences readLock=changed to control whether it performs a fast check to update file information or not. This can be used to speed up the process if the FTP server ha [...] | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. 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. | false | boolean diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java index 126a104..e78bfd0 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java @@ -20,10 +20,13 @@ import java.net.URI; import java.util.Map; import org.apache.camel.CamelContext; +import org.apache.camel.Endpoint; import org.apache.camel.component.file.FileProcessStrategy; import org.apache.camel.component.file.GenericFileEndpoint; import org.apache.camel.component.file.remote.strategy.FtpProcessStrategyFactory; import org.apache.camel.spi.annotations.Component; +import org.apache.camel.support.EndpointHelper; +import org.apache.camel.support.component.PropertyConfigurerSupport; import org.apache.camel.util.PropertiesHelper; import org.apache.commons.net.ftp.FTPFile; @@ -99,6 +102,19 @@ public class FtpComponent extends RemoteFileComponent<FTPFile> { } @Override + protected void setProperties(Endpoint endpoint, Map<String, Object> parameters) throws Exception { + Object siteCommand = parameters.remove("siteCommand"); + if (siteCommand != null) { + String cmd = PropertyConfigurerSupport.property(getCamelContext(), String.class, siteCommand); + if (EndpointHelper.isReferenceParameter(cmd)) { + cmd = EndpointHelper.resolveReferenceParameter(getCamelContext(), cmd, String.class); + } + ((FtpEndpoint) endpoint).getConfiguration().setSiteCommand(cmd); + } + super.setProperties(endpoint, parameters); + } + + @Override protected void afterPropertiesSet(GenericFileEndpoint<FTPFile> endpoint) throws Exception { // noop } diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java index 7fb9290..85a29a1 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java @@ -29,7 +29,7 @@ import org.apache.camel.spi.UriParam; * from SFTP servers. */ @UriEndpoint(firstVersion = "1.1.0", scheme = "sftp", extendsScheme = "file", title = "SFTP", syntax = "sftp:host:port/directoryName", label = "file", - excludeProperties = "appendChars,binary,passiveMode,bufferSize,siteCommand," + excludeProperties = "appendChars,bufferSize,siteCommand," + "directoryMustExist,extendedAttributes,probeContentType,startingDirectoryMustExist," + "startingDirectoryMustHaveAccess,chmodDirectory,forceWrites,copyAndDeleteOnRenameFail," + "renameUsingCopy") diff --git a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java index 35b9c3b..2cbbd76 100644 --- a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java +++ b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java @@ -41,7 +41,7 @@ public class HdfsComponent extends DefaultComponent { @Override protected final Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { HdfsEndpoint hdfsEndpoint = new HdfsEndpoint(uri, this); - setProperties(hdfsEndpoint.getConfig(), parameters); + setProperties(hdfsEndpoint, parameters); return hdfsEndpoint; } diff --git a/components/camel-hipchat/pom.xml b/components/camel-hipchat/pom.xml index eb88412..2751500 100644 --- a/components/camel-hipchat/pom.xml +++ b/components/camel-hipchat/pom.xml @@ -89,6 +89,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-xml-jaxb</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <scope>test</scope> diff --git a/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatComponent.java b/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatComponent.java index c2e5772..b97c5f6 100644 --- a/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatComponent.java +++ b/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatComponent.java @@ -50,7 +50,7 @@ public class HipchatComponent extends DefaultComponent { @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { HipchatEndpoint endpoint = getHipchatEndpoint(uri); - setProperties(endpoint.getConfiguration(), parameters); + setProperties(endpoint, parameters); if (endpoint.getConfiguration().getAuthToken() == null) { throw new HipchatException("OAuth 2 auth token must be specified"); } diff --git a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentConsumerTest.java b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentConsumerTest.java index 4e190c1..5cfb696 100644 --- a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentConsumerTest.java +++ b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentConsumerTest.java @@ -187,12 +187,8 @@ public class HipchatComponentConsumerTest extends CamelTestSupport { @Override protected CamelContext createCamelContext() throws Exception { final CamelContext context = super.createCamelContext(); - HipchatComponent component = new HipchatComponent(context) { - @Override - protected HipchatEndpoint getHipchatEndpoint(String uri) { - return new HipchatEPSuccessTestSupport(uri, this, null, closeableHttpResponse); - } - }; + HipchatComponent component = new HipchatTestComponent(context, closeableHttpResponse); + component.init(); context.addComponent("hipchat", component); return context; } diff --git a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentMultipleUsersTest.java b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentMultipleUsersTest.java index a144b1d..a2b3e09 100644 --- a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentMultipleUsersTest.java +++ b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentMultipleUsersTest.java @@ -113,12 +113,8 @@ public class HipchatComponentMultipleUsersTest extends CamelTestSupport { @Override protected CamelContext createCamelContext() throws Exception { final CamelContext context = super.createCamelContext(); - HipchatComponent component = new HipchatComponent(context) { - @Override - protected HipchatEndpoint getHipchatEndpoint(String uri) { - return new HipchatEPSuccessTestSupport(uri, this, null, closeableHttpResponse); - } - }; + HipchatComponent component = new HipchatTestComponent(context, closeableHttpResponse); + component.init(); context.addComponent("hipchat", component); return context; } diff --git a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentProducerTest.java b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentProducerTest.java index bce2b81..19d802a 100644 --- a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentProducerTest.java +++ b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatComponentProducerTest.java @@ -182,12 +182,8 @@ public class HipchatComponentProducerTest extends CamelTestSupport { @Override protected CamelContext createCamelContext() throws Exception { final CamelContext context = super.createCamelContext(); - HipchatComponent component = new HipchatComponent(context) { - @Override - protected HipchatEndpoint getHipchatEndpoint(String uri) { - return new HipchatEPSuccessTestSupport(uri, this, callback, null); - } - }; + HipchatComponent component = new HipchatTestComponent(context, callback); + component.init(); context.addComponent("hipchat", component); return context; } diff --git a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatTestComponent.java b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatTestComponent.java new file mode 100644 index 0000000..c999545 --- /dev/null +++ b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatTestComponent.java @@ -0,0 +1,48 @@ +/* + * 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.component.hipchat; + +import org.apache.camel.CamelContext; +import org.apache.camel.component.hipchat.HipchatComponentProducerTest.PostCallback; +import org.apache.camel.spi.annotations.Component; +import org.apache.http.client.methods.CloseableHttpResponse; + +@Component("hipchat") +public class HipchatTestComponent extends HipchatComponent { + + PostCallback callback; + CloseableHttpResponse closeableHttpResponse; + + public HipchatTestComponent(CamelContext context) { + super(context); + } + + public HipchatTestComponent(CamelContext context, CloseableHttpResponse closeableHttpResponse) { + super(context); + this.closeableHttpResponse = closeableHttpResponse; + } + + public HipchatTestComponent(CamelContext context, PostCallback callback) { + super(context); + this.callback = callback; + } + + @Override + protected HipchatEndpoint getHipchatEndpoint(String uri) { + return new HipchatEPSuccessTestSupport(uri, this, callback, closeableHttpResponse); + } +} diff --git a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatXmlDefinedComponentProducerTest.java b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatXmlDefinedComponentProducerTest.java index b4fa560..ddf13a7 100644 --- a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatXmlDefinedComponentProducerTest.java +++ b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/HipchatXmlDefinedComponentProducerTest.java @@ -48,12 +48,8 @@ public class HipchatXmlDefinedComponentProducerTest extends CamelTestSupport { @Override protected CamelContext createCamelContext() throws Exception { final CamelContext context = super.createCamelContext(); - HipchatComponent component = new HipchatComponent(context) { - @Override - protected HipchatEndpoint getHipchatEndpoint(String uri) { - return new HipchatEPSuccessTestSupport(uri, this, null, null); - } - }; + HipchatComponent component = new HipchatTestComponent(context); + component.init(); context.addComponent("hipchat", component); // This test is all about ensuring the endpoint is configured correctly when using the XML DSL so this diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java index 471d17d..d1de045 100644 --- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java +++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java @@ -452,15 +452,15 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa url = url + "?" + query; } + parameters = parameters != null ? new HashMap<>(parameters) : new HashMap<String, Object>(); + // there are cases where we might end up here without component being created beforehand // we need to abide by the component properties specified in the parameters when creating // the component, one such case is when we switch from "http" to "https" component name - RestProducerFactoryHelper.setupComponentFor(url, camelContext, (Map<String, Object>) parameters.get("component")); + RestProducerFactoryHelper.setupComponentFor(url, camelContext, (Map<String, Object>) parameters.remove("component")); HttpEndpoint endpoint = camelContext.getEndpoint(url, HttpEndpoint.class); - if (parameters != null && !parameters.isEmpty()) { - setProperties(camelContext, endpoint, parameters); - } + setProperties(endpoint, parameters); String path = uriTemplate != null ? uriTemplate : basePath; endpoint.setHeaderFilterStrategy(new HttpRestHeaderFilterStrategy(path, queryParameters)); diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java index 9376297..3f50ceb 100644 --- a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java +++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java @@ -54,7 +54,7 @@ public class IrcComponent extends DefaultComponent implements SSLContextParamete config.configure(uri); IrcEndpoint endpoint = new IrcEndpoint(uri, this, config); - setProperties(endpoint.getConfiguration(), parameters); + setProperties(endpoint, parameters); return endpoint; } diff --git a/components/camel-ironmq/src/main/java/org/apache/camel/component/ironmq/IronMQComponent.java b/components/camel-ironmq/src/main/java/org/apache/camel/component/ironmq/IronMQComponent.java index e566a22..1ecef6a 100644 --- a/components/camel-ironmq/src/main/java/org/apache/camel/component/ironmq/IronMQComponent.java +++ b/components/camel-ironmq/src/main/java/org/apache/camel/component/ironmq/IronMQComponent.java @@ -38,20 +38,18 @@ public class IronMQComponent extends DefaultComponent { @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - IronMQConfiguration ironMQConfiguration = new IronMQConfiguration(); - setProperties(ironMQConfiguration, parameters); if (remaining == null || remaining.trim().length() == 0) { throw new IllegalArgumentException("Queue name must be specified."); } + IronMQConfiguration ironMQConfiguration = new IronMQConfiguration(); + Endpoint endpoint = new IronMQEndpoint(uri, this, ironMQConfiguration); ironMQConfiguration.setQueueName(remaining); - + setProperties(endpoint, parameters); if (ironMQConfiguration.getClient() == null && (ironMQConfiguration.getProjectId() == null || ironMQConfiguration.getToken() == null)) { throw new IllegalArgumentException("Client or project and token must be specified."); } - Endpoint endpoint = new IronMQEndpoint(uri, this, ironMQConfiguration); - setProperties(endpoint, parameters); return endpoint; } } diff --git a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchConsumerTest.java b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchConsumerTest.java index 581c52d..27cbc28 100644 --- a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchConsumerTest.java +++ b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchConsumerTest.java @@ -63,6 +63,7 @@ public class IronMQBatchConsumerTest extends CamelTestSupport { CamelContext context = super.createCamelContext(); IronMQComponent component = new IronMQComponent(context); + component.init(); Map<String, Object> parameters = new HashMap<>(); parameters.put("projectId", "dummy"); parameters.put("token", "dummy"); diff --git a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchDeleteConsumerTest.java b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchDeleteConsumerTest.java index e0f1810..4be3621 100644 --- a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchDeleteConsumerTest.java +++ b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchDeleteConsumerTest.java @@ -65,6 +65,7 @@ public class IronMQBatchDeleteConsumerTest extends CamelTestSupport { CamelContext context = super.createCamelContext(); IronMQComponent component = new IronMQComponent(context); + component.init(); Map<String, Object> parameters = new HashMap<>(); parameters.put("projectId", "dummy"); parameters.put("token", "dummy"); diff --git a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchProducerTest.java b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchProducerTest.java index dcca8e6..00deb32 100644 --- a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchProducerTest.java +++ b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQBatchProducerTest.java @@ -56,6 +56,7 @@ public class IronMQBatchProducerTest extends CamelTestSupport { protected CamelContext createCamelContext() throws Exception { CamelContext context = super.createCamelContext(); IronMQComponent component = new IronMQComponent(context); + component.init(); Map<String, Object> parameters = new HashMap<>(); parameters.put("projectId", "dummy"); parameters.put("token", "dummy"); diff --git a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQComponentConfigurationTest.java b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQComponentConfigurationTest.java index f7de536..1797891 100644 --- a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQComponentConfigurationTest.java +++ b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQComponentConfigurationTest.java @@ -24,6 +24,7 @@ public class IronMQComponentConfigurationTest extends CamelTestSupport { @Test public void createEndpointWithMinimalConfiguration() throws Exception { IronMQComponent component = new IronMQComponent(context); + component.init(); IronMQEndpoint endpoint = (IronMQEndpoint)component.createEndpoint("ironmq://TestQueue?projectId=xxx&token=yyy"); assertEquals("TestQueue", endpoint.getConfiguration().getQueueName()); @@ -40,7 +41,7 @@ public class IronMQComponentConfigurationTest extends CamelTestSupport { @Test public void createEndpointWithMinimalConfigurationAndIronMQCloud() throws Exception { IronMQComponent component = new IronMQComponent(context); - + component.init(); IronMQEndpoint endpoint = (IronMQEndpoint)component.createEndpoint("ironmq://TestQueue?projectId=xxx&token=yyy&ironMQCloud=https://iron.foo"); assertEquals("TestQueue", endpoint.getConfiguration().getQueueName()); @@ -55,6 +56,7 @@ public class IronMQComponentConfigurationTest extends CamelTestSupport { @Test public void createEndpointWithMaximalConfiguration() throws Exception { IronMQComponent component = new IronMQComponent(context); + component.init(); IronMQEndpoint endpoint = (IronMQEndpoint)component .createEndpoint("ironmq://TestQueue?projectId=xxx&token=yyy&timeout=120&visibilityDelay=5&maxMessagesPerPoll=20&preserveHeaders=true&wait=30" + "&ironMQCloud=https://iron.foo&batchDelete=true"); @@ -73,6 +75,7 @@ public class IronMQComponentConfigurationTest extends CamelTestSupport { @Test public void createEndpointWithPollConsumerConfiguration() throws Exception { IronMQComponent component = new IronMQComponent(context); + component.init(); IronMQEndpoint endpoint = (IronMQEndpoint)component .createEndpoint("ironmq://TestQueue?projectId=xxx&token=yyy&initialDelay=200&delay=400&timeout=120&maxMessagesPerPoll=20"); IronMQConsumer consumer = (IronMQConsumer)endpoint.createConsumer(null); @@ -85,12 +88,14 @@ public class IronMQComponentConfigurationTest extends CamelTestSupport { @Test(expected = IllegalArgumentException.class) public void createEndpointWithoutTokenConfiguration() throws Exception { IronMQComponent component = new IronMQComponent(context); + component.init(); component.createEndpoint("ironmq://testqueue?projectId=yyy"); } @Test(expected = IllegalArgumentException.class) public void createEndpointWithoutProjectIdConfiguration() throws Exception { IronMQComponent component = new IronMQComponent(context); + component.init(); component.createEndpoint("ironmq://MyQueue?token=xxx"); } } diff --git a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQComponentTest.java b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQComponentTest.java index d6c0100..939622d 100644 --- a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQComponentTest.java +++ b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQComponentTest.java @@ -95,6 +95,7 @@ public class IronMQComponentTest extends CamelTestSupport { protected CamelContext createCamelContext() throws Exception { CamelContext context = super.createCamelContext(); IronMQComponent component = new IronMQComponent(context); + component.init(); Map<String, Object> parameters = new HashMap<>(); parameters.put("projectId", "dummy"); parameters.put("token", "dummy"); diff --git a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQPreserveHeadersTest.java b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQPreserveHeadersTest.java index 62f08a8..1102200 100644 --- a/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQPreserveHeadersTest.java +++ b/components/camel-ironmq/src/test/java/org/apache/camel/component/ironmq/IronMQPreserveHeadersTest.java @@ -48,6 +48,7 @@ public class IronMQPreserveHeadersTest extends CamelTestSupport { protected CamelContext createCamelContext() throws Exception { CamelContext context = super.createCamelContext(); IronMQComponent component = new IronMQComponent(context); + component.init(); endpoint = (IronMQEndpoint)component.createEndpoint("ironmq://TestQueue?projectId=xxx&token=yyy&preserveHeaders=true"); endpoint.setClient(new IronMQClientMock("dummy", "dummy")); context.addComponent("ironmq", component); diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java index e940dad..eac20722 100644 --- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java @@ -1093,7 +1093,7 @@ public abstract class JettyHttpComponent extends HttpCommonComponent implements String url = RestComponentHelper.createRestConsumerUrl("jetty", scheme, host, port, path, map); JettyHttpEndpoint endpoint = camelContext.getEndpoint(url, JettyHttpEndpoint.class); - setProperties(camelContext, endpoint, parameters); + setProperties(endpoint, parameters); if (!map.containsKey("httpBindingRef")) { // use the rest binding, if not using a custom http binding diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java index a9d37ae..4e65d9d 100644 --- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java +++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java @@ -1376,7 +1376,7 @@ public class JmsComponent extends HeaderFilterStrategyComponent { } endpoint.setHeaderFilterStrategy(getHeaderFilterStrategy()); - setProperties(endpoint.getConfiguration(), parameters); + setProperties(endpoint, parameters); return endpoint; } diff --git a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaComponent.java b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaComponent.java index 4778cec..e6d53da 100644 --- a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaComponent.java +++ b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaComponent.java @@ -16,7 +16,6 @@ */ package org.apache.camel.component.kafka; -import java.util.HashMap; import java.util.Map; import java.util.concurrent.ExecutorService; @@ -73,7 +72,6 @@ public class KafkaComponent extends DefaultComponent implements SSLContextParame // brokers can be configured on either component or endpoint level // and the consumer and produce is aware of this and act accordingly - setProperties(endpoint.getConfiguration(), params); setProperties(endpoint, params); if (endpoint.getConfiguration().getSslContextParameters() == null) { diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/BaseEmbeddedKafkaTest.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/BaseEmbeddedKafkaTest.java index 249ae59..ba04b21 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/BaseEmbeddedKafkaTest.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/BaseEmbeddedKafkaTest.java @@ -71,6 +71,7 @@ public class BaseEmbeddedKafkaTest extends CamelTestSupport { context.getPropertiesComponent().setLocation("ref:prop"); KafkaComponent kafka = new KafkaComponent(context); + kafka.init(); kafka.setBrokers("localhost:" + getKafkaPort()); context.addComponent("kafka", kafka); diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaEndpointTest.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaEndpointTest.java index 6b4246a..4928eeb 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaEndpointTest.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaEndpointTest.java @@ -44,7 +44,9 @@ public class KafkaEndpointTest { @Before public void setup() { - endpoint = new KafkaEndpoint("kafka:mytopic?brokers=localhost", new KafkaComponent(new DefaultCamelContext())); + KafkaComponent kafka = new KafkaComponent(new DefaultCamelContext()); + kafka.init(); + endpoint = new KafkaEndpoint("kafka:mytopic?brokers=localhost", kafka); } @Test diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaProducerTest.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaProducerTest.java index a982e72..db854f1 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaProducerTest.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaProducerTest.java @@ -73,6 +73,7 @@ public class KafkaProducerTest { public KafkaProducerTest() throws Exception { KafkaComponent kafka = new KafkaComponent(new DefaultCamelContext()); kafka.setBrokers("broker1:1234,broker2:4567"); + kafka.init(); endpoint = kafka.createEndpoint("kafka:sometopic", "sometopic", new HashMap()); producer = new KafkaProducer(endpoint); diff --git a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneComponent.java b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneComponent.java index d859207..71b79cb 100644 --- a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneComponent.java +++ b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneComponent.java @@ -45,7 +45,7 @@ public class LuceneComponent extends DefaultComponent { throws Exception { config.parseURI(new URI(uri), parameters, this); LuceneEndpoint luceneEndpoint = new LuceneEndpoint(uri, this, config); - setProperties(luceneEndpoint.getConfig(), parameters); + setProperties(luceneEndpoint, parameters); return luceneEndpoint; } diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java index 9d78a9d..3a72a9a 100644 --- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java +++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java @@ -110,7 +110,6 @@ public class MailComponent extends HeaderFilterStrategyComponent implements SSLC endpoint.setContentTypeResolver(contentTypeResolver); setEndpointHeaderFilterStrategy(endpoint); - setProperties(endpoint.getConfiguration(), parameters); setProperties(endpoint, parameters); // sanity check that we know the mail server diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java index 9b93421..13b244a 100644 --- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java +++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java @@ -256,6 +256,7 @@ public class MailComponentTest extends CamelTestSupport { public void testMailComponentCtr() throws Exception { MailComponent comp = new MailComponent(); comp.setCamelContext(context); + comp.init(); assertNotNull(comp.getConfiguration()); assertNull(comp.getContentTypeResolver()); @@ -270,6 +271,7 @@ public class MailComponentTest extends CamelTestSupport { @Test public void testMailComponentCtrCamelContext() throws Exception { MailComponent comp = new MailComponent(context); + comp.init(); assertNotNull(comp.getConfiguration()); assertNull(comp.getContentTypeResolver()); diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java index 5d7bbd9..3fb0272 100644 --- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java +++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java @@ -393,7 +393,7 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt String url = RestComponentHelper.createRestConsumerUrl("netty-http", scheme, host, port, path, map); NettyHttpEndpoint endpoint = camelContext.getEndpoint(url, NettyHttpEndpoint.class); - setProperties(camelContext, endpoint, parameters); + setProperties(endpoint, parameters); // configure consumer properties Consumer consumer = endpoint.createConsumer(processor); @@ -449,15 +449,15 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt url = url + "?" + query; } + parameters = parameters != null ? new HashMap<>(parameters) : new HashMap<String, Object>(); + // there are cases where we might end up here without component being created beforehand // we need to abide by the component properties specified in the parameters when creating // the component - RestProducerFactoryHelper.setupComponentFor(url, camelContext, (Map<String, Object>) parameters.get("component")); + RestProducerFactoryHelper.setupComponentFor(url, camelContext, (Map<String, Object>) parameters.remove("component")); NettyHttpEndpoint endpoint = camelContext.getEndpoint(url, NettyHttpEndpoint.class); - if (parameters != null && !parameters.isEmpty()) { - setProperties(camelContext, endpoint, parameters); - } + setProperties(endpoint, parameters); String path = uriTemplate != null ? uriTemplate : basePath; endpoint.setHeaderFilterStrategy(new NettyHttpRestHeaderFilterStrategy(path, queryParameters)); diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java index 5c87b62..b1f82ab 100644 --- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java +++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java @@ -106,7 +106,7 @@ public class NettyComponent extends DefaultComponent implements SSLContextParame config.validateConfiguration(); NettyEndpoint nettyEndpoint = new NettyEndpoint(uri, this, config); - setProperties(nettyEndpoint.getConfiguration(), parameters); + setProperties(nettyEndpoint, parameters); return nettyEndpoint; } diff --git a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2TestSupport.java b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2TestSupport.java index c36fe76..392f527 100644 --- a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2TestSupport.java +++ b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2TestSupport.java @@ -61,6 +61,7 @@ public class AbstractOlingo2TestSupport extends CamelTestSupport { // add OlingoComponent to Camel context final Olingo2Component component = new Olingo2Component(context); + component.init(); component.setConfiguration(configuration); context.addComponent("olingo2", component); diff --git a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Component.java b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Component.java index a0601e8..78371f3 100644 --- a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Component.java +++ b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Component.java @@ -82,11 +82,8 @@ public class Olingo4Component extends AbstractApiComponent<Olingo4ApiName, Oling final Olingo4Configuration endpointConfiguration = createEndpointConfiguration(Olingo4ApiName.DEFAULT); final Endpoint endpoint = createEndpoint(uri, methodName, Olingo4ApiName.DEFAULT, endpointConfiguration); - // set endpoint property inBody - setProperties(endpoint, parameters); - // configure endpoint properties and initialize state - endpoint.configureProperties(parameters); + setProperties(endpoint, parameters); return endpoint; } diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java index d860d5a..47229bd 100644 --- a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java +++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java @@ -125,7 +125,7 @@ public class PlatformHttpComponent extends DefaultComponent implements RestConsu String url = RestComponentHelper.createRestConsumerUrl("platform-http", path, map); PlatformHttpEndpoint endpoint = camelContext.getEndpoint(url, PlatformHttpEndpoint.class); - setProperties(camelContext, endpoint, parameters); + setProperties(endpoint, parameters); endpoint.setConsumes(consumes); endpoint.setProduces(produces); diff --git a/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterComponent.java b/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterComponent.java index 872ea43..8a95d4d 100644 --- a/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterComponent.java +++ b/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterComponent.java @@ -36,7 +36,7 @@ public class PrinterComponent extends DefaultComponent { config.parseURI(new URI(uri)); PrinterEndpoint printerEndpoint = new PrinterEndpoint(uri, this, config); - setProperties(printerEndpoint.getConfig(), parameters); - return new PrinterEndpoint(uri, this, config); + setProperties(printerEndpoint, parameters); + return printerEndpoint; } } diff --git a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java index f566e25..9bcdfa2 100644 --- a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java +++ b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java @@ -324,11 +324,8 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { Map<String, Object> params = determineEndpointParameters(openapi, operation); boolean hasHost = params.containsKey("host"); - if (endpoint instanceof DefaultEndpoint) { - // let the rest endpoint configure itself - DefaultEndpoint de = (DefaultEndpoint) endpoint; - de.setProperties(endpoint, params); - } + // let the rest endpoint configure itself + endpoint.configureProperties(params); // if there is a host then we should use this hardcoded host instead of any Header that may have an existing // Host header from some other HTTP input, and if so then lets remove it diff --git a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java index cfab1b7..018100d 100644 --- a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java +++ b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java @@ -36,6 +36,7 @@ import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriPath; import org.apache.camel.support.DefaultEndpoint; +import org.apache.camel.support.component.PropertyConfigurerSupport; import org.apache.camel.util.HostUtils; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -96,6 +97,15 @@ public class RestEndpoint extends DefaultEndpoint { } @Override + public void configureProperties(Map<String, Object> options) { + Object parameters = options.remove("parameters"); + if (parameters != null) { + setParameters(PropertyConfigurerSupport.property(getCamelContext(), Map.class, parameters)); + } + super.configureProperties(options); + } + + @Override public RestComponent getComponent() { return (RestComponent) super.getComponent(); } diff --git a/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaComponent.java b/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaComponent.java index cb0cf98..de3239c 100644 --- a/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaComponent.java +++ b/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaComponent.java @@ -224,9 +224,9 @@ public class SedaComponent extends DefaultComponent { answer.setOfferTimeout(offerTimeout); answer.setBlockWhenFull(blockWhenFull); answer.setDiscardWhenFull(discardWhenFull); - answer.configureProperties(parameters); answer.setConcurrentConsumers(consumers); answer.setLimitConcurrentConsumers(limitConcurrentConsumers); + setProperties(answer, parameters); return answer; } diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java index 6e84abb..e37320a 100644 --- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java +++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java @@ -299,7 +299,7 @@ public class ServletComponent extends HttpCommonComponent implements RestConsume String url = RestComponentHelper.createRestConsumerUrl("servlet", path, map); ServletEndpoint endpoint = camelContext.getEndpoint(url, ServletEndpoint.class); - setProperties(camelContext, endpoint, parameters); + setProperties(endpoint, parameters); if (!map.containsKey("httpBinding")) { // use the rest binding, if not using a custom http binding diff --git a/components/camel-sip/src/main/java/org/apache/camel/component/sip/SipComponent.java b/components/camel-sip/src/main/java/org/apache/camel/component/sip/SipComponent.java index 6733e6c..fb7bbfd 100644 --- a/components/camel-sip/src/main/java/org/apache/camel/component/sip/SipComponent.java +++ b/components/camel-sip/src/main/java/org/apache/camel/component/sip/SipComponent.java @@ -35,7 +35,7 @@ public class SipComponent extends DefaultComponent { config.initialize(new URI(uri), parameters, this); SipEndpoint sipEndpoint = new SipEndpoint(uri, this, config); - setProperties(sipEndpoint.getConfiguration(), parameters); + setProperties(sipEndpoint, parameters); return sipEndpoint; } } \ No newline at end of file diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java index 386e497..6c7b694 100644 --- a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java +++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java @@ -344,7 +344,7 @@ public class SparkComponent extends DefaultComponent implements RestConsumerFact // get the endpoint SparkEndpoint endpoint = camelContext.getEndpoint(url, SparkEndpoint.class); - setProperties(camelContext, endpoint, parameters); + setProperties(endpoint, parameters); // configure consumer properties Consumer consumer = endpoint.createConsumer(processor); diff --git a/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapComponent.java b/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapComponent.java index e59f6bc..31dc1ae 100644 --- a/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapComponent.java +++ b/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapComponent.java @@ -49,7 +49,7 @@ public class SpringLdapComponent extends DefaultComponent { Registry registry = camelContext.getRegistry(); LdapTemplate ldapTemplate = registry.lookupByNameAndType(remaining, LdapTemplate.class); - Endpoint endpoint = new SpringLdapEndpoint(remaining, ldapTemplate); + Endpoint endpoint = new SpringLdapEndpoint(uri, this, remaining, ldapTemplate); setProperties(endpoint, parameters); return endpoint; } diff --git a/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapEndpoint.java b/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapEndpoint.java index 7c6ad09..9d30942 100644 --- a/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapEndpoint.java +++ b/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapEndpoint.java @@ -49,10 +49,13 @@ public class SpringLdapEndpoint extends DefaultEndpoint { /** * Initializes the SpringLdapEndpoint using the provided template * + * @param endpointUri the full URI used to create this endpoint + * @param component the component that created this endpoint * @param templateName name of the LDAP template * @param ldapTemplate LDAP template, see org.springframework.ldap.core.LdapTemplate */ - public SpringLdapEndpoint(String templateName, LdapTemplate ldapTemplate) { + public SpringLdapEndpoint(String endpointUri, SpringLdapComponent component, String templateName, LdapTemplate ldapTemplate) { + super(endpointUri, component); this.templateName = templateName; this.ldapTemplate = ldapTemplate; } diff --git a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java index 35e267b..95e3195 100644 --- a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java +++ b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java @@ -43,7 +43,7 @@ public class SshComponent extends DefaultComponent { newConfig.configure(u); SshEndpoint endpoint = new SshEndpoint(uri, this, newConfig); - setProperties(endpoint.getConfiguration(), parameters); + setProperties(endpoint, parameters); return endpoint; } diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java index 5291f58..bfd7616 100644 --- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java +++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java @@ -221,7 +221,7 @@ public class UndertowComponent extends DefaultComponent implements RestConsumerF String url = RestComponentHelper.createRestConsumerUrl(getComponentName(), scheme, host, port, path, map); UndertowEndpoint endpoint = camelContext.getEndpoint(url, UndertowEndpoint.class); - setProperties(camelContext, endpoint, parameters); + setProperties(endpoint, parameters); if (!map.containsKey("undertowHttpBinding")) { // use the rest binding, if not using a custom http binding @@ -278,15 +278,15 @@ public class UndertowComponent extends DefaultComponent implements RestConsumerF url = url + "?" + query; } + parameters = parameters != null ? new HashMap<>(parameters) : new HashMap<String, Object>(); + // there are cases where we might end up here without component being created beforehand // we need to abide by the component properties specified in the parameters when creating // the component - RestProducerFactoryHelper.setupComponentFor(url, camelContext, (Map<String, Object>) parameters.get("component")); + RestProducerFactoryHelper.setupComponentFor(url, camelContext, (Map<String, Object>) parameters.remove("component")); UndertowEndpoint endpoint = camelContext.getEndpoint(url, UndertowEndpoint.class); - if (parameters != null && !parameters.isEmpty()) { - setProperties(camelContext, endpoint, parameters); - } + setProperties(endpoint, parameters); String path = uriTemplate != null ? uriTemplate : basePath; endpoint.setHeaderFilterStrategy(new UndertowRestHeaderFilterStrategy(path, queryParameters)); diff --git a/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressComponent.java b/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressComponent.java index 87c5b25..0ee13d8 100644 --- a/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressComponent.java +++ b/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressComponent.java @@ -62,14 +62,17 @@ public class WordpressComponent extends DefaultComponent { @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - final WordpressComponentConfiguration endpointConfiguration = this.copyComponentProperties(); - - WordpressEndpoint endpoint = new WordpressEndpoint(uri, this, endpointConfiguration); + if (configuration != null) { + Map<String, Object> properties = new HashMap<>(); + BeanIntrospection beanIntrospection = getCamelContext().adapt(ExtendedCamelContext.class).getBeanIntrospection(); + beanIntrospection.getProperties(configuration, properties, null, false); + properties.forEach(parameters::putIfAbsent); + } + WordpressComponentConfiguration config = new WordpressComponentConfiguration(); + WordpressEndpoint endpoint = new WordpressEndpoint(uri, this, config); + discoverOperations(endpoint, remaining); setProperties(endpoint, parameters); - - this.discoverOperations(endpoint, remaining); - endpoint.configureProperties(parameters); - + setProperties(config, parameters); return endpoint; } @@ -81,17 +84,4 @@ public class WordpressComponent extends DefaultComponent { } } - private WordpressComponentConfiguration copyComponentProperties() throws Exception { - Map<String, Object> componentProperties = new HashMap<>(); - - if (configuration != null) { - BeanIntrospection beanIntrospection = getCamelContext().adapt(ExtendedCamelContext.class).getBeanIntrospection(); - beanIntrospection.getProperties(configuration, componentProperties, null, false); - } - - // create endpoint configuration with component properties - WordpressComponentConfiguration config = new WordpressComponentConfiguration(); - PropertyBindingSupport.bindProperties(getCamelContext(), config, componentProperties); - return config; - } } diff --git a/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/WordpressComponentTest.java b/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/WordpressComponentTest.java index 3ba998e..ac3e69b 100644 --- a/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/WordpressComponentTest.java +++ b/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/WordpressComponentTest.java @@ -36,6 +36,7 @@ public class WordpressComponentTest extends CamelTestSupport { @Test public void testParseUriPropertiesCriteria() throws Exception { final WordpressComponent component = new WordpressComponent(context); + component.init(); final WordpressEndpoint endpoint = (WordpressEndpoint)component .createEndpoint("wordpress:post?apiVersion=2&url=http://mysite.com/&criteria.search=test&criteria.page=1&criteria.perPage=10&criteria.orderBy=author&criteria.categories=camel,dozer,json"); diff --git a/components/camel-xmlsecurity/src/generated/java/org/apache/camel/component/xmlsecurity/XmlSignatureComponentConfigurer.java b/components/camel-xmlsecurity/src/generated/java/org/apache/camel/component/xmlsecurity/XmlSignatureComponentConfigurer.java deleted file mode 100644 index c7ab035..0000000 --- a/components/camel-xmlsecurity/src/generated/java/org/apache/camel/component/xmlsecurity/XmlSignatureComponentConfigurer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* Generated by camel build tools - do NOT edit this file! */ -package org.apache.camel.component.xmlsecurity; - -import org.apache.camel.CamelContext; -import org.apache.camel.spi.GeneratedPropertyConfigurer; -import org.apache.camel.support.component.PropertyConfigurerSupport; - -/** - * Generated by camel build tools - do NOT edit this file! - */ -@SuppressWarnings("unchecked") -public class XmlSignatureComponentConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer { - - @Override - public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { - XmlSignatureComponent target = (XmlSignatureComponent) obj; - switch (ignoreCase ? name.toLowerCase() : name) { - case "signerconfiguration": - case "signerConfiguration": target.setSignerConfiguration(property(camelContext, org.apache.camel.component.xmlsecurity.processor.XmlSignerConfiguration.class, value)); return true; - case "verifierconfiguration": - case "verifierConfiguration": target.setVerifierConfiguration(property(camelContext, org.apache.camel.component.xmlsecurity.processor.XmlVerifierConfiguration.class, value)); return true; - case "basicpropertybinding": - case "basicPropertyBinding": target.setBasicPropertyBinding(property(camelContext, boolean.class, value)); return true; - case "lazystartproducer": - case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; - default: return false; - } - } - -} - diff --git a/components/camel-xmlsecurity/src/generated/java/org/apache/camel/component/xmlsecurity/XmlSignatureEndpointConfigurer.java b/components/camel-xmlsecurity/src/generated/java/org/apache/camel/component/xmlsecurity/XmlSignatureEndpointConfigurer.java deleted file mode 100644 index 503c843..0000000 --- a/components/camel-xmlsecurity/src/generated/java/org/apache/camel/component/xmlsecurity/XmlSignatureEndpointConfigurer.java +++ /dev/null @@ -1,95 +0,0 @@ -/* Generated by camel build tools - do NOT edit this file! */ -package org.apache.camel.component.xmlsecurity; - -import org.apache.camel.CamelContext; -import org.apache.camel.spi.GeneratedPropertyConfigurer; -import org.apache.camel.support.component.PropertyConfigurerSupport; - -/** - * Generated by camel build tools - do NOT edit this file! - */ -@SuppressWarnings("unchecked") -public class XmlSignatureEndpointConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer { - - @Override - public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { - XmlSignatureEndpoint target = (XmlSignatureEndpoint) obj; - switch (ignoreCase ? name.toLowerCase() : name) { - case "baseuri": - case "baseUri": target.getSignerConfiguration().setBaseUri(property(camelContext, java.lang.String.class, value)); return true; - case "clearheaders": - case "clearHeaders": target.getSignerConfiguration().setClearHeaders(property(camelContext, java.lang.Boolean.class, value)); return true; - case "cryptocontextproperties": - case "cryptoContextProperties": target.getSignerConfiguration().setCryptoContextProperties(property(camelContext, java.util.Map.class, value)); return true; - case "disallowdoctypedecl": - case "disallowDoctypeDecl": target.getSignerConfiguration().setDisallowDoctypeDecl(property(camelContext, java.lang.Boolean.class, value)); return true; - case "omitxmldeclaration": - case "omitXmlDeclaration": target.getSignerConfiguration().setOmitXmlDeclaration(property(camelContext, java.lang.Boolean.class, value)); return true; - case "outputxmlencoding": - case "outputXmlEncoding": target.getSignerConfiguration().setOutputXmlEncoding(property(camelContext, java.lang.String.class, value)); return true; - case "schemaresourceuri": - case "schemaResourceUri": target.getSignerConfiguration().setSchemaResourceUri(property(camelContext, java.lang.String.class, value)); return true; - case "lazystartproducer": - case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; - case "basicpropertybinding": - case "basicPropertyBinding": target.setBasicPropertyBinding(property(camelContext, boolean.class, value)); return true; - case "synchronous": target.setSynchronous(property(camelContext, boolean.class, value)); return true; - case "uridereferencer": - case "uriDereferencer": target.getSignerConfiguration().setUriDereferencer(property(camelContext, javax.xml.crypto.URIDereferencer.class, value)); return true; - case "addkeyinforeference": - case "addKeyInfoReference": target.getSignerConfiguration().setAddKeyInfoReference(property(camelContext, java.lang.Boolean.class, value)); return true; - case "canonicalizationmethod": - case "canonicalizationMethod": target.getSignerConfiguration().setCanonicalizationMethod(property(camelContext, javax.xml.crypto.AlgorithmMethod.class, value)); return true; - case "contentobjectid": - case "contentObjectId": target.getSignerConfiguration().setContentObjectId(property(camelContext, java.lang.String.class, value)); return true; - case "contentreferencetype": - case "contentReferenceType": target.getSignerConfiguration().setContentReferenceType(property(camelContext, java.lang.String.class, value)); return true; - case "contentreferenceuri": - case "contentReferenceUri": target.getSignerConfiguration().setContentReferenceUri(property(camelContext, java.lang.String.class, value)); return true; - case "digestalgorithm": - case "digestAlgorithm": target.getSignerConfiguration().setDigestAlgorithm(property(camelContext, java.lang.String.class, value)); return true; - case "keyaccessor": - case "keyAccessor": target.getSignerConfiguration().setKeyAccessor(property(camelContext, org.apache.camel.component.xmlsecurity.api.KeyAccessor.class, value)); return true; - case "parentlocalname": - case "parentLocalName": target.getSignerConfiguration().setParentLocalName(property(camelContext, java.lang.String.class, value)); return true; - case "parentnamespace": - case "parentNamespace": target.getSignerConfiguration().setParentNamespace(property(camelContext, java.lang.String.class, value)); return true; - case "parentxpath": - case "parentXpath": target.getSignerConfiguration().setParentXpath(property(camelContext, javax.xml.crypto.dsig.spec.XPathFilterParameterSpec.class, value)); return true; - case "plaintext": - case "plainText": target.getSignerConfiguration().setPlainText(property(camelContext, java.lang.Boolean.class, value)); return true; - case "plaintextencoding": - case "plainTextEncoding": target.getSignerConfiguration().setPlainTextEncoding(property(camelContext, java.lang.String.class, value)); return true; - case "prefixforxmlsignaturenamespace": - case "prefixForXmlSignatureNamespace": target.getSignerConfiguration().setPrefixForXmlSignatureNamespace(property(camelContext, java.lang.String.class, value)); return true; - case "properties": target.getSignerConfiguration().setProperties(property(camelContext, org.apache.camel.component.xmlsecurity.api.XmlSignatureProperties.class, value)); return true; - case "signaturealgorithm": - case "signatureAlgorithm": target.getSignerConfiguration().setSignatureAlgorithm(property(camelContext, java.lang.String.class, value)); return true; - case "signatureid": - case "signatureId": target.getSignerConfiguration().setSignatureId(property(camelContext, java.lang.String.class, value)); return true; - case "transformmethods": - case "transformMethods": target.getSignerConfiguration().setTransformMethods(property(camelContext, java.util.List.class, value)); return true; - case "xpathstoidattributes": - case "xpathsToIdAttributes": target.getSignerConfiguration().setXpathsToIdAttributes(property(camelContext, java.util.List.class, value)); return true; - case "keyselector": - case "keySelector": target.getVerifierConfiguration().setKeySelector(property(camelContext, javax.xml.crypto.KeySelector.class, value)); return true; - case "outputnodesearch": - case "outputNodeSearch": target.getVerifierConfiguration().setOutputNodeSearch(property(camelContext, java.lang.String.class, value)); return true; - case "outputnodesearchtype": - case "outputNodeSearchType": target.getVerifierConfiguration().setOutputNodeSearchType(property(camelContext, java.lang.String.class, value)); return true; - case "removesignatureelements": - case "removeSignatureElements": target.getVerifierConfiguration().setRemoveSignatureElements(property(camelContext, java.lang.Boolean.class, value)); return true; - case "securevalidation": - case "secureValidation": target.getVerifierConfiguration().setSecureValidation(property(camelContext, java.lang.Boolean.class, value)); return true; - case "validationfailedhandler": - case "validationFailedHandler": target.getVerifierConfiguration().setValidationFailedHandler(property(camelContext, org.apache.camel.component.xmlsecurity.api.ValidationFailedHandler.class, value)); return true; - case "xmlsignature2message": - case "xmlSignature2Message": target.getVerifierConfiguration().setXmlSignature2Message(property(camelContext, org.apache.camel.component.xmlsecurity.api.XmlSignature2Message.class, value)); return true; - case "xmlsignaturechecker": - case "xmlSignatureChecker": target.getVerifierConfiguration().setXmlSignatureChecker(property(camelContext, org.apache.camel.component.xmlsecurity.api.XmlSignatureChecker.class, value)); return true; - default: return false; - } - } - -} - diff --git a/components/camel-xmlsecurity/src/generated/resources/META-INF/services/org/apache/camel/configurer/xmlsecurity-component b/components/camel-xmlsecurity/src/generated/resources/META-INF/services/org/apache/camel/configurer/xmlsecurity-component deleted file mode 100644 index ee20a42..0000000 --- a/components/camel-xmlsecurity/src/generated/resources/META-INF/services/org/apache/camel/configurer/xmlsecurity-component +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -class=org.apache.camel.component.xmlsecurity.XmlSignatureComponentConfigurer diff --git a/components/camel-xmlsecurity/src/generated/resources/META-INF/services/org/apache/camel/configurer/xmlsecurity-endpoint b/components/camel-xmlsecurity/src/generated/resources/META-INF/services/org/apache/camel/configurer/xmlsecurity-endpoint deleted file mode 100644 index 0a44d5c..0000000 --- a/components/camel-xmlsecurity/src/generated/resources/META-INF/services/org/apache/camel/configurer/xmlsecurity-endpoint +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -class=org.apache.camel.component.xmlsecurity.XmlSignatureEndpointConfigurer diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignatureComponent.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignatureComponent.java index 01b45a7..9808b16 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignatureComponent.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignatureComponent.java @@ -80,10 +80,10 @@ public class XmlSignatureComponent extends DefaultComponent { ) ); } - setProperties(endpoint.getConfiguration(), parameters); - endpoint.getConfiguration().setCamelContext(getCamelContext()); endpoint.setCommand(XmlCommand.valueOf(scheme)); endpoint.setName(name); + setProperties(endpoint, parameters); + setProperties(endpoint.getConfiguration(), parameters); return endpoint; } diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignatureEndpoint.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignatureEndpoint.java index f493b9c..aff9c96 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignatureEndpoint.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignatureEndpoint.java @@ -35,7 +35,9 @@ import org.apache.camel.support.DefaultEndpoint; /** * Used to sign and verify exchanges using the XML signature specification. */ -@UriEndpoint(firstVersion = "2.12.0", scheme = "xmlsecurity", title = "XML Security", syntax = "xmlsecurity:command:name", producerOnly = true, label = "security,transformation") +@UriEndpoint(firstVersion = "2.12.0", scheme = "xmlsecurity", title = "XML Security", + syntax = "xmlsecurity:command:name", producerOnly = true, label = "security,transformation", + generateConfigurer = false) public abstract class XmlSignatureEndpoint extends DefaultEndpoint { @UriPath @Metadata(required = true) diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignerEndpoint.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignerEndpoint.java index 37201c0..6df8a84 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignerEndpoint.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlSignerEndpoint.java @@ -38,7 +38,7 @@ public class XmlSignerEndpoint extends XmlSignatureEndpoint { @Override Processor createProcessor() { - return new XmlSignerProcessor(getConfiguration()); + return new XmlSignerProcessor(getCamelContext(), getConfiguration()); } @Override diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlVerifierEndpoint.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlVerifierEndpoint.java index 109b448..62d6389 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlVerifierEndpoint.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/XmlVerifierEndpoint.java @@ -37,7 +37,7 @@ public class XmlVerifierEndpoint extends XmlSignatureEndpoint { @Override Processor createProcessor() { - return new XmlVerifierProcessor(getConfiguration()); + return new XmlVerifierProcessor(getCamelContext(), getConfiguration()); } @Override diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureConfiguration.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureConfiguration.java index 3b7846c..95623bd 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureConfiguration.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureConfiguration.java @@ -30,9 +30,8 @@ import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @UriParams -public abstract class XmlSignatureConfiguration implements Cloneable, CamelContextAware { +public abstract class XmlSignatureConfiguration implements Cloneable { - private CamelContext context; @UriParam(label = "common") private String baseUri; @UriParam(label = "common") @@ -53,16 +52,6 @@ public abstract class XmlSignatureConfiguration implements Cloneable, CamelConte public XmlSignatureConfiguration() { } - @Override - public CamelContext getCamelContext() { - return context; - } - - @Override - public void setCamelContext(CamelContext camelContext) { - this.context = camelContext; - } - public URIDereferencer getUriDereferencer() { return uriDereferencer; } diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureProcessor.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureProcessor.java index 84c0c10..2d3cf2e 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureProcessor.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureProcessor.java @@ -28,6 +28,7 @@ import javax.xml.validation.SchemaFactory; import org.xml.sax.SAXException; +import org.apache.camel.CamelContext; import org.apache.camel.Message; import org.apache.camel.Processor; import org.apache.camel.component.validator.DefaultLSResourceResolver; @@ -54,6 +55,16 @@ public abstract class XmlSignatureProcessor implements Processor { } } + protected final CamelContext context; + + public XmlSignatureProcessor(CamelContext context) { + this.context = context; + } + + public CamelContext getCamelContext() { + return context; + } + public abstract XmlSignatureConfiguration getConfiguration(); void setUriDereferencerAndBaseUri(XMLCryptoContext context) { @@ -102,7 +113,7 @@ public abstract class XmlSignatureProcessor implements Processor { if (schemaResourceUri == null || schemaResourceUri.isEmpty()) { return null; } - InputStream is = ResourceHelper.resolveResourceAsInputStream(getConfiguration().getCamelContext().getClassResolver(), + InputStream is = ResourceHelper.resolveResourceAsInputStream(getCamelContext().getClassResolver(), schemaResourceUri); if (is == null) { throw new XmlSignatureException( @@ -118,7 +129,7 @@ public abstract class XmlSignatureProcessor implements Processor { } SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); schemaFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); - schemaFactory.setResourceResolver(new DefaultLSResourceResolver(getConfiguration().getCamelContext(), getConfiguration() + schemaFactory.setResourceResolver(new DefaultLSResourceResolver(getCamelContext(), getConfiguration() .getSchemaResourceUri())); LOG.debug("Instantiating schema for validation"); return schemaFactory.newSchema(new BytesSource(bytes)); diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignerConfiguration.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignerConfiguration.java index c8949ed..f0f566f 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignerConfiguration.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignerConfiguration.java @@ -25,7 +25,6 @@ import javax.xml.crypto.dsig.CanonicalizationMethod; import javax.xml.crypto.dsig.keyinfo.KeyInfo; import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; -import org.apache.camel.CamelContext; import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.xmlsecurity.api.KeyAccessor; import org.apache.camel.component.xmlsecurity.api.XmlSignatureConstants; @@ -45,13 +44,10 @@ public class XmlSignerConfiguration extends XmlSignatureConfiguration { @UriParam(label = "sign") private List<AlgorithmMethod> transformMethods = Collections.singletonList(XmlSignatureHelper .getCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE)); - private String transformMethodsName; @UriParam(label = "sign") private KeyAccessor keyAccessor; - private String keyAccessorName; @UriParam(label = "sign", defaultValue = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315") private AlgorithmMethod canonicalizationMethod = new XmlSignatureTransform(CanonicalizationMethod.INCLUSIVE); - private String canonicalizationMethodName; @UriParam(label = "sign", defaultValue = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256") private String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"; @UriParam(label = "sign") @@ -78,7 +74,6 @@ public class XmlSignerConfiguration extends XmlSignatureConfiguration { private String plainTextEncoding = "UTF-8"; @UriParam(label = "sign") private XmlSignatureProperties properties; - private String propertiesName; public XmlSignerConfiguration() { } @@ -91,16 +86,6 @@ public class XmlSignerConfiguration extends XmlSignatureConfiguration { } } - @Override - public void setCamelContext(CamelContext camelContext) { - super.setCamelContext(camelContext); - // try to retrieve the references once the context is available. - setTransformMethods(transformMethodsName); - setCanonicalizationMethod(canonicalizationMethodName); - setKeyAccessor(keyAccessorName); - setProperties(propertiesName); - } - public KeyAccessor getKeyAccessor() { return keyAccessor; } @@ -114,21 +99,6 @@ public class XmlSignerConfiguration extends XmlSignatureConfiguration { this.keyAccessor = keyAccessor; } - /** - * Sets the reference name for a KeyAccessor that can be found in the registry. - */ - public void setKeyAccessor(String keyAccessorName) { - if (getCamelContext() != null && keyAccessorName != null) { - KeyAccessor accessor = getCamelContext().getRegistry().lookupByNameAndType(keyAccessorName, KeyAccessor.class); - if (accessor != null) { - setKeyAccessor(accessor); - } - } - if (keyAccessorName != null) { - this.keyAccessorName = keyAccessorName; - } - } - public AlgorithmMethod getCanonicalizationMethod() { return canonicalizationMethod; } @@ -142,21 +112,6 @@ public class XmlSignerConfiguration extends XmlSignatureConfiguration { this.canonicalizationMethod = canonicalizationMethod; } - /** - * Sets the reference name for a AlgorithmMethod that can be found in the registry. - */ - public void setCanonicalizationMethod(String canonicalizationMethodName) { - if (getCamelContext() != null && canonicalizationMethodName != null) { - AlgorithmMethod method = getCamelContext().getRegistry().lookupByNameAndType(canonicalizationMethodName, AlgorithmMethod.class); - if (method != null) { - setCanonicalizationMethod(method); - } - } - if (canonicalizationMethodName != null) { - this.canonicalizationMethodName = canonicalizationMethodName; - } - } - public List<AlgorithmMethod> getTransformMethods() { return transformMethods; } @@ -170,22 +125,6 @@ public class XmlSignerConfiguration extends XmlSignatureConfiguration { this.transformMethods = transformMethods; } - /** - * Sets the reference name for a List<AlgorithmMethod> that can be found in the registry. - */ - public void setTransformMethods(String transformMethodsName) { - if (getCamelContext() != null && transformMethodsName != null) { - @SuppressWarnings("unchecked") - List<AlgorithmMethod> list = getCamelContext().getRegistry().lookupByNameAndType(transformMethodsName, List.class); - if (list != null) { - setTransformMethods(list); - } - } - if (transformMethodsName != null) { - this.transformMethodsName = transformMethodsName; - } - } - public String getSignatureAlgorithm() { return signatureAlgorithm; } @@ -386,54 +325,6 @@ public class XmlSignerConfiguration extends XmlSignatureConfiguration { this.properties = properties; } - /** - * Sets the reference name for a XmlSignatureProperties that can be found in the registry. - */ - public void setProperties(String propertiesName) { - if (getCamelContext() != null && propertiesName != null) { - XmlSignatureProperties props = getCamelContext().getRegistry() - .lookupByNameAndType(propertiesName, XmlSignatureProperties.class); - if (props != null) { - setProperties(props); - } - } - if (propertiesName != null) { - this.propertiesName = propertiesName; - } - } - - public String getKeyAccessorName() { - return keyAccessorName; - } - - public void setKeyAccessorName(String keyAccessorName) { - this.keyAccessorName = keyAccessorName; - } - - public String getCanonicalizationMethodName() { - return canonicalizationMethodName; - } - - public void setCanonicalizationMethodName(String canonicalizationMethodName) { - this.canonicalizationMethodName = canonicalizationMethodName; - } - - public String getTransformMethodsName() { - return transformMethodsName; - } - - public void setTransformMethodsName(String transformMethodsName) { - this.transformMethodsName = transformMethodsName; - } - - public String getPropertiesName() { - return propertiesName; - } - - public void setPropertiesName(String propertiesName) { - this.propertiesName = propertiesName; - } - public List<XPathFilterParameterSpec> getXpathsToIdAttributes() { return xpathsToIdAttributes; } diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignerProcessor.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignerProcessor.java index 0e6cbe7..606245f 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignerProcessor.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignerProcessor.java @@ -64,6 +64,7 @@ import org.w3c.dom.NodeList; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; +import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.component.xmlsecurity.api.KeyAccessor; @@ -197,7 +198,8 @@ public class XmlSignerProcessor extends XmlSignatureProcessor { private final XmlSignerConfiguration config; - public XmlSignerProcessor(XmlSignerConfiguration config) { + public XmlSignerProcessor(CamelContext context, XmlSignerConfiguration config) { + super(context); this.config = config; } diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlVerifierConfiguration.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlVerifierConfiguration.java index e64f5ed..6976b54 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlVerifierConfiguration.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlVerifierConfiguration.java @@ -18,7 +18,6 @@ package org.apache.camel.component.xmlsecurity.processor; import javax.xml.crypto.KeySelector; -import org.apache.camel.CamelContext; import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.xmlsecurity.api.DefaultValidationFailedHandler; import org.apache.camel.component.xmlsecurity.api.DefaultXmlSignature2Message; @@ -33,16 +32,12 @@ public class XmlVerifierConfiguration extends XmlSignatureConfiguration { @UriParam(label = "verify") private KeySelector keySelector; - private String keySelectorName; @UriParam(label = "verify") private XmlSignatureChecker xmlSignatureChecker; - private String xmlSignatureCheckerName; @UriParam(label = "verify") private XmlSignature2Message xmlSignature2Message = new DefaultXmlSignature2Message(); - private String xmlSignature2MessageName; @UriParam(label = "verify") private ValidationFailedHandler validationFailedHandler = new DefaultValidationFailedHandler(); - private String validationFailedHandlerName; @UriParam(label = "verify", javaType = "java.lang.String") private Object outputNodeSearch; @UriParam(label = "verify", defaultValue = DefaultXmlSignature2Message.OUTPUT_NODE_SEARCH_TYPE_DEFAULT) @@ -63,15 +58,6 @@ public class XmlVerifierConfiguration extends XmlSignatureConfiguration { } } - @Override - public void setCamelContext(CamelContext camelContext) { - super.setCamelContext(camelContext); - setKeySelector(keySelectorName); - setXmlSignatureChecker(xmlSignatureCheckerName); - setXmlSignature2Message(xmlSignature2MessageName); - setValidationFailedHandler(validationFailedHandlerName); - } - /** * Provides the key for validating the XML signature. */ @@ -83,22 +69,6 @@ public class XmlVerifierConfiguration extends XmlSignatureConfiguration { return keySelector; } - /** - * Sets the reference name for a KeySelector that can be found in the registry. - */ - public void setKeySelector(String keySelectorName) { - if (getCamelContext() != null && keySelectorName != null) { - KeySelector selector = getCamelContext().getRegistry() - .lookupByNameAndType(keySelectorName, KeySelector.class); - if (selector != null) { - setKeySelector(selector); - } - } - if (keySelectorName != null) { - this.keySelectorName = keySelectorName; - } - } - public XmlSignatureChecker getXmlSignatureChecker() { return xmlSignatureChecker; } @@ -111,23 +81,6 @@ public class XmlVerifierConfiguration extends XmlSignatureConfiguration { this.xmlSignatureChecker = xmlSignatureChecker; } - /** - * Sets the reference name for a application checker that can be found in the registry. - */ - public void setXmlSignatureChecker(String xmlSignatureCheckerName) { - if (getCamelContext() != null && xmlSignatureCheckerName != null) { - XmlSignatureChecker checker = getCamelContext().getRegistry() - .lookupByNameAndType(xmlSignatureCheckerName, - XmlSignatureChecker.class); - if (checker != null) { - setXmlSignatureChecker(checker); - } - } - if (xmlSignatureCheckerName != null) { - this.xmlSignatureCheckerName = xmlSignatureCheckerName; - } - } - public XmlSignature2Message getXmlSignature2Message() { return xmlSignature2Message; } @@ -151,24 +104,6 @@ public class XmlVerifierConfiguration extends XmlSignatureConfiguration { this.xmlSignature2Message = xmlSignature2Message; } - /** - * Sets the reference name for the to-message instance that can be found in - * the registry. - */ - public void setXmlSignature2Message(String xmlSignature2Message) { - if (getCamelContext() != null && xmlSignature2Message != null) { - XmlSignature2Message maper = getCamelContext().getRegistry() - .lookupByNameAndType(xmlSignature2Message, - XmlSignature2Message.class); - if (maper != null) { - setXmlSignature2Message(maper); - } - } - if (xmlSignature2Message != null) { - this.xmlSignature2MessageName = xmlSignature2Message; - } - } - public ValidationFailedHandler getValidationFailedHandler() { return validationFailedHandler; } @@ -184,20 +119,6 @@ public class XmlVerifierConfiguration extends XmlSignatureConfiguration { this.validationFailedHandler = validationFailedHandler; } - public void setValidationFailedHandler(String validationFailedHandlerName) { - if (getCamelContext() != null && validationFailedHandlerName != null) { - ValidationFailedHandler vailFailedHandler = getCamelContext() - .getRegistry().lookupByNameAndType(validationFailedHandlerName, - ValidationFailedHandler.class); - if (vailFailedHandler != null) { - setValidationFailedHandler(vailFailedHandler); - } - } - if (validationFailedHandlerName != null) { - this.validationFailedHandlerName = validationFailedHandlerName; - } - } - public Object getOutputNodeSearch() { return outputNodeSearch; } @@ -256,15 +177,4 @@ public class XmlVerifierConfiguration extends XmlSignatureConfiguration { this.secureValidation = secureValidation; } - public String getValidationFailedHandlerName() { - return validationFailedHandlerName; - } - - /** - * Name of handler to - * @param validationFailedHandlerName - */ - public void setValidationFailedHandlerName(String validationFailedHandlerName) { - this.validationFailedHandlerName = validationFailedHandlerName; - } } diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlVerifierProcessor.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlVerifierProcessor.java index ac430e4..dc42c5a 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlVerifierProcessor.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlVerifierProcessor.java @@ -44,6 +44,7 @@ import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.component.xmlsecurity.api.ValidationFailedHandler; @@ -68,7 +69,8 @@ public class XmlVerifierProcessor extends XmlSignatureProcessor { private final XmlVerifierConfiguration config; - public XmlVerifierProcessor(XmlVerifierConfiguration config) { + public XmlVerifierProcessor(CamelContext context, XmlVerifierConfiguration config) { + super(context); this.config = config; } diff --git a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java index 663843a..6816769 100644 --- a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java +++ b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java @@ -297,7 +297,7 @@ public class XmlSignatureTest extends CamelTestSupport { public void configure() throws Exception { // START SNIPPET: validationFailedHandler from("direct:validationFailedHandler") - .to("xmlsecurity:verify:validationFailedHandler?keySelector=#selectorKeyValue&validationFailedHandler=validationFailedHandlerIgnoreManifestFailures") + .to("xmlsecurity:verify:validationFailedHandler?keySelector=#selectorKeyValue&validationFailedHandler=#validationFailedHandlerIgnoreManifestFailures") .to("mock:result"); // END SNIPPET: validationFailedHandler } @@ -734,7 +734,7 @@ public class XmlSignatureTest extends CamelTestSupport { public void testVerifySignatureInvalidValueException() throws Exception { MockEndpoint mock = setupExceptionMock(); setUpKeys("DSA", 512); - context.getEndpoint("xmlsecurity:verify:verifyexceptions?keySelector=#selector", XmlVerifierEndpoint.class).setKeySelector( + context.getEndpoint("xmlsecurity:verify:verifyexceptions", XmlVerifierEndpoint.class).setKeySelector( KeySelector.singletonKeySelector(keyPair.getPublic())); // payload needs DSA key InputStream payload = XmlSignatureTest.class diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java index df29c06..ad3954d 100644 --- a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java +++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java @@ -53,9 +53,6 @@ public class YammerComponent extends DefaultComponent { endpointConfig.setFunction(remaining); endpointConfig.setFunctionType(YammerFunctionType.fromUri(remaining)); - // and then override from parameters - setProperties(endpointConfig, parameters); - Endpoint endpoint = new YammerEndpoint(uri, this, endpointConfig); setProperties(endpoint, parameters); return endpoint; diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java index 4f08173..41ffc24 100644 --- a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java +++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java @@ -40,6 +40,7 @@ public class YammerEndpoint extends ScheduledPollEndpoint { } public YammerEndpoint(String uri, YammerComponent yammerComponent, YammerConfiguration config) { + super(uri, yammerComponent); this.setConfig(config); } diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java index 78a5390..27dd8a6 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java @@ -169,10 +169,7 @@ public abstract class DefaultComponent extends ServiceSupport implements Compone } // configure remainder of the parameters - endpoint.configureProperties(parameters); - if (useIntrospectionOnEndpoint()) { - setProperties(endpoint, parameters); - } + setProperties(endpoint, parameters); // if endpoint is strict (not lenient) and we have unknown parameters configured then // fail if there are parameters that could not be set, then they are probably misspell or not supported at all @@ -258,10 +255,7 @@ public abstract class DefaultComponent extends ServiceSupport implements Compone } // configure remainder of the parameters - endpoint.configureProperties(parameters); - if (useIntrospectionOnEndpoint()) { - setProperties(endpoint, parameters); - } + setProperties(endpoint, parameters); // if endpoint is strict (not lenient) and we have unknown parameters configured then // fail if there are parameters that could not be set, then they are probably misspell or not supported at all @@ -473,6 +467,23 @@ public abstract class DefaultComponent extends ServiceSupport implements Compone throws Exception; /** + * Configure an endpoint using the given parameters. + * In the usual cases, this is the only call needed after having created the endpoint + * in the {@link #createEndpoint(String, String, Map)} method's implementation. + * + * This method will call the {@link Endpoint#configureProperties(Map)} method which + * should delegate the the endpoint's {@link GeneratedPropertyConfigurer} instance. + * In some rare cases, you need to override this method to explicitely set parameters + * in case a simple generated configurer can not be used. + * + * @param endpoint the endpoint + * @param parameters properties to set + */ + protected void setProperties(Endpoint endpoint, Map<String, Object> parameters) throws Exception { + endpoint.configureProperties(parameters); + } + + /** * Sets the bean properties on the given bean * * @param bean the bean @@ -501,13 +512,15 @@ public abstract class DefaultComponent extends ServiceSupport implements Compone .withPlaceholder(false).withNesting(false).withDeepNesting(false).withReference(false) .bind(camelContext, bean, parameters); } else { - PropertyConfigurer configurer = null; + PropertyConfigurer configurer; if (bean instanceof Component) { configurer = getComponentPropertyConfigurer(); } else if (bean instanceof Endpoint) { configurer = getEndpointPropertyConfigurer(); } else if (bean instanceof PropertyConfigurerAware) { configurer = ((PropertyConfigurerAware) bean).getPropertyConfigurer(bean); + } else { + configurer = null; } // use advanced binding PropertyBindingSupport.build().withConfigurer(configurer).bind(camelContext, bean, parameters); diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java index f247f27..e748853 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java @@ -208,6 +208,10 @@ public abstract class DefaultEndpoint extends ServiceSupport implements Endpoint return component; } + public void setComponent(Component component) { + this.component = component; + } + @Override public void setCamelContext(CamelContext camelContext) { this.camelContext = camelContext; @@ -394,7 +398,7 @@ public abstract class DefaultEndpoint extends ServiceSupport implements Endpoint @Override public void configureProperties(Map<String, Object> options) { - // noop + setProperties(this, options); } /** @@ -405,7 +409,7 @@ public abstract class DefaultEndpoint extends ServiceSupport implements Endpoint * @param bean the bean * @param parameters properties to set */ - public void setProperties(Object bean, Map<String, Object> parameters) throws Exception { + public void setProperties(Object bean, Map<String, Object> parameters) { if (parameters == null || parameters.isEmpty()) { return; } diff --git a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java index 66e1b06..e01aa7d 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java @@ -225,7 +225,8 @@ public final class PropertyBindingSupport { org.apache.camel.util.ObjectHelper.notNull(target, "target"); org.apache.camel.util.ObjectHelper.notNull(properties, "properties"); - return doBindProperties(camelContext, target, properties, optionPrefix, ignoreCase, removeParameters, mandatory, + return doBindProperties(camelContext, target, removeParameters ? properties : new HashMap<>(properties), + optionPrefix, ignoreCase, true, mandatory, nesting, deepNesting, fluentBuilder, allowPrivateSetter, reference, placeholder, configurer); } @@ -247,7 +248,8 @@ public final class PropertyBindingSupport { org.apache.camel.util.ObjectHelper.notNull(obj, "target"); org.apache.camel.util.ObjectHelper.notNull(prop, "properties"); - return doBindProperties(context, obj, prop, optionPrefix, ignoreCase, removeParameters, mandatory, + return doBindProperties(context, obj, removeParameters ? prop : new HashMap<>(prop), + optionPrefix, ignoreCase, true, mandatory, nesting, deepNesting, fluentBuilder, allowPrivateSetter, reference, placeholder, configurer); } @@ -269,7 +271,7 @@ public final class PropertyBindingSupport { Map<String, Object> properties = new HashMap<>(1); properties.put(key, value); - return doBindProperties(camelContext, target, properties, optionPrefix, ignoreCase, removeParameters, mandatory, + return doBindProperties(camelContext, target, properties, optionPrefix, ignoreCase, true, mandatory, nesting, deepNesting, fluentBuilder, allowPrivateSetter, reference, placeholder, configurer); } diff --git a/core/camel-support/src/main/java/org/apache/camel/support/RestProducerFactoryHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/RestProducerFactoryHelper.java index 2b4c764..b1b13bd 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/RestProducerFactoryHelper.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/RestProducerFactoryHelper.java @@ -74,7 +74,9 @@ public final class RestProducerFactoryHelper { // component was not added to the context we can configure it final Component newlyCreated = camelContext.getComponent(componentName, true, false); - PropertyBindingSupport.build().withRemoveParameters(false).bind(camelContext, newlyCreated, componentProperties); + PropertyBindingSupport.build().withRemoveParameters(false) + .withConfigurer(newlyCreated.getComponentPropertyConfigurer()) + .bind(camelContext, newlyCreated, componentProperties); ServiceHelper.startService(newlyCreated); return newlyCreated; diff --git a/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiComponent.java b/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiComponent.java index e0bbe4d..4bcbfa2 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiComponent.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiComponent.java @@ -83,11 +83,8 @@ public abstract class AbstractApiComponent<E extends Enum<E> & ApiName, T, S ext final T endpointConfiguration = createEndpointConfiguration(apiName); final Endpoint endpoint = createEndpoint(uri, methodName, apiName, endpointConfiguration); - // set endpoint property inBody - setProperties(endpoint, parameters); - // configure endpoint properties and initialize state - endpoint.configureProperties(parameters); + setProperties(endpoint, parameters); return endpoint; } catch (InvocationTargetException e) { diff --git a/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiEndpoint.java b/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiEndpoint.java index 46d4bec..e69a946 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiEndpoint.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiEndpoint.java @@ -98,14 +98,11 @@ public abstract class AbstractApiEndpoint<E extends ApiName, T> @Override public void configureProperties(Map<String, Object> options) { super.configureProperties(options); - - // set configuration properties first - try { - T configuration = getConfiguration(); - setProperties(configuration, options); - } catch (Exception e) { - throw new IllegalArgumentException(e); - } + // TODO: this is not very clean as it does not leverage the endpoint + // TODO: configurer, but the generated configurer currently does not + // TODO: support configuration inheritance, so only basic options + // TODO: are supported. This should be fixed. + setProperties(getConfiguration(), options); // validate and initialize state initState();