This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-13947 in repository https://gitbox.apache.org/repos/asf/camel.git
commit e403b94acf0f9efc3519d5c352e04b2c7f33cdd1 Author: Claus Ibsen <[email protected]> AuthorDate: Wed Sep 25 22:11:52 2019 +0200 CAMEL-13947: PropertiesComponent should be a static service and resolved like other similar features. --- components/camel-properties/pom.xml | 4 + .../src/main/docs/properties-component.adoc | 4 +- .../component/properties/PropertiesEndpoint.java | 86 ----- components/readme.adoc | 6 +- .../builder/endpoint/EndpointBuilderFactory.java | 1 - .../dsl/PropertiesEndpointBuilderFactory.java | 411 --------------------- .../modules/ROOT/pages/properties-component.adoc | 4 +- .../example/cxf/httptojms/CamelCxfExample.java | 3 - .../example/cxf/jaxrs/CamelRouterBuilder.java | 3 - .../camel/example/ftp/MyFtpClientRouteBuilder.java | 4 +- .../camel/example/ftp/MyFtpServerRouteBuilder.java | 4 +- .../google/pubsub/MessageConsumerClient.java | 4 +- .../google/pubsub/MessagePublisherClient.java | 4 +- .../camel/example/kafka/MessageConsumerClient.java | 4 +- .../example/kafka/MessagePublisherClient.java | 4 +- .../splunk/SplunkPublishEventRouteBuilder.java | 4 +- .../splunk/SplunkSavedSearchRouteBuilder.java | 4 +- .../example/splunk/SplunkSearchRouteBuilder.java | 4 +- .../PropertiesComponentAutoConfiguration.java | 115 ++---- .../PropertiesComponentConfiguration.java | 29 +- 20 files changed, 59 insertions(+), 643 deletions(-) diff --git a/components/camel-properties/pom.xml b/components/camel-properties/pom.xml index 4b33700..c9245c9 100644 --- a/components/camel-properties/pom.xml +++ b/components/camel-properties/pom.xml @@ -32,6 +32,10 @@ <name>Camel :: Properties</name> <description>Camel Properties component</description> + <properties> + <firstVersion>2.3.0</firstVersion> + <label>core</label> + </properties> <dependencies> diff --git a/components/camel-properties/src/main/docs/properties-component.adoc b/components/camel-properties/src/main/docs/properties-component.adoc index 8fe3a5f..3580100 100644 --- a/components/camel-properties/src/main/docs/properties-component.adoc +++ b/components/camel-properties/src/main/docs/properties-component.adoc @@ -87,7 +87,7 @@ When using Spring Boot make sure to use the following Maven dependency to have s ---- -The component supports 12 options, which are listed below. +The component supports 10 options, which are listed below. @@ -95,9 +95,7 @@ The component supports 12 options, which are listed below. |=== | Name | Description | Default | Type | *camel.component.properties.auto-discover-properties-sources* | Whether to automatically discovery instances of PropertiesSource from registry and service factory. | true | Boolean -| *camel.component.properties.basic-property-binding* | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | Boolean | *camel.component.properties.default-fallback-enabled* | If false, the component does not attempt to find a default for the key by looking after the colon separator. | true | Boolean -| *camel.component.properties.enabled* | Whether to enable auto configuration of the properties component. This is enabled by default. | | Boolean | *camel.component.properties.encoding* | Encoding to use when loading properties file from the file system or classpath. If no encoding has been set, then the properties files is loaded using ISO-8859-1 encoding (latin-1) as documented by java.util.Properties#load(java.io.InputStream) | | String | *camel.component.properties.environment-variable-mode* | Sets the OS environment variables mode (0 = never, 1 = fallback, 2 = override). The default mode (override) is to use OS environment variables if present, and override any existing properties. OS environment variable mode is checked before JVM system property mode | 2 | Integer | *camel.component.properties.ignore-missing-location* | Whether to silently ignore if a location cannot be located, such as a properties file not found. | false | Boolean diff --git a/components/camel-properties/src/main/java/org/apache/camel/component/properties/PropertiesEndpoint.java b/components/camel-properties/src/main/java/org/apache/camel/component/properties/PropertiesEndpoint.java deleted file mode 100644 index c336e31..0000000 --- a/components/camel-properties/src/main/java/org/apache/camel/component/properties/PropertiesEndpoint.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.properties; - -import org.apache.camel.Component; -import org.apache.camel.Consumer; -import org.apache.camel.DelegateEndpoint; -import org.apache.camel.Endpoint; -import org.apache.camel.Processor; -import org.apache.camel.Producer; -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.UriEndpoint; -import org.apache.camel.spi.UriPath; -import org.apache.camel.support.DefaultEndpoint; - -/** - * The properties component is used for using property placeholders in endpoint uris. - */ -@UriEndpoint(firstVersion = "2.3.0", scheme = "properties", title = "Properties", syntax = "properties:key", label = "core,endpoint") -public class PropertiesEndpoint extends DefaultEndpoint implements DelegateEndpoint { - - private volatile Endpoint endpoint; - - @UriPath - @Metadata(required = true) - private String key; - - public PropertiesEndpoint(String endpointUri, Endpoint delegate, Component component) { - super(endpointUri, component); - this.endpoint = delegate; - } - - public String getKey() { - return key; - } - - /** - * Property key to use as placeholder - */ - public void setKey(String key) { - this.key = key; - } - - @Override - public Producer createProducer() throws Exception { - return endpoint.createProducer(); - } - - @Override - public Consumer createConsumer(Processor processor) throws Exception { - return endpoint.createConsumer(processor); - } - - @Override - public Endpoint getEndpoint() { - return endpoint; - } - - @Override - protected void doStart() throws Exception { - // add the endpoint as a service so Camel can manage the endpoint and enlist the endpoint in JMX etc. - getCamelContext().addService(endpoint); - super.doStart(); - } - - @Override - protected void doStop() throws Exception { - super.doStop(); - // noop - } - -} diff --git a/components/readme.adoc b/components/readme.adoc index 989e36b..324d5e2 100644 --- a/components/readme.adoc +++ b/components/readme.adoc @@ -682,7 +682,7 @@ Number of Components: 301 in 239 JAR artifacts (0 deprecated) | link:camel-printer/src/main/docs/lpr-component.adoc[Printer] (camel-printer) + `lpr:hostname:port/printername` | 2.1 | The printer component is used for sending messages to printers as print jobs. -| link:camel-properties/src/main/docs/properties-component.adoc[Properties] (camel-properties) + +| link:@@@ARTIFACTID@@@/src/main/docs/properties-component.adoc[Properties] (@@@ARTIFACTID@@@) + `properties:key` | 2.3 | The properties component is used for using property placeholders in endpoint uris. | link:camel-pubnub/src/main/docs/pubnub-component.adoc[PubNub] (camel-pubnub) + @@ -1065,7 +1065,7 @@ Number of Languages: 17 in 11 JAR artifacts (0 deprecated) == Miscellaneous Components // others: START -Number of Miscellaneous Components: 35 in 35 JAR artifacts (0 deprecated) +Number of Miscellaneous Components: 36 in 36 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -1093,6 +1093,8 @@ Number of Miscellaneous Components: 35 in 35 JAR artifacts (0 deprecated) | link:camel-opentracing/src/main/docs/opentracing.adoc[OpenTracing] (camel-opentracing) | 2.19 | Distributed tracing using OpenTracing +| link:camel-properties/src/main/docs/properties.adoc[Properties] (camel-properties) | | Camel Properties component + | link:camel-reactive-executor-vertx/src/main/docs/reactive-executor-vertx.adoc[Reactive Executor Vertx] (camel-reactive-executor-vertx) | 3.0 | Reactive Executor for camel-core using Vert X | link:camel-reactor/src/main/docs/reactor.adoc[Reactor] (camel-reactor) | 2.20 | Reactor based back-end for Camel's reactive streams component diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java index 7cf2bea..75b83d2 100644 --- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java @@ -238,7 +238,6 @@ public interface EndpointBuilderFactory extends PdfEndpointBuilderFactory, PgEventEndpointBuilderFactory, PrinterEndpointBuilderFactory, - PropertiesEndpointBuilderFactory, PubNubEndpointBuilderFactory, PulsarEndpointBuilderFactory, QuartzEndpointBuilderFactory, diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/PropertiesEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/PropertiesEndpointBuilderFactory.java deleted file mode 100644 index 099018a..0000000 --- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/PropertiesEndpointBuilderFactory.java +++ /dev/null @@ -1,411 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.builder.endpoint.dsl; - -import javax.annotation.Generated; -import org.apache.camel.ExchangePattern; -import org.apache.camel.builder.EndpointConsumerBuilder; -import org.apache.camel.builder.EndpointProducerBuilder; -import org.apache.camel.builder.endpoint.AbstractEndpointBuilder; -import org.apache.camel.spi.ExceptionHandler; - -/** - * The properties component is used for using property placeholders in endpoint - * uris. - * - * Generated by camel-package-maven-plugin - do not edit this file! - */ -@Generated("org.apache.camel.maven.packaging.EndpointDslMojo") -public interface PropertiesEndpointBuilderFactory { - - - /** - * Builder for endpoint consumers for the Properties component. - */ - public interface PropertiesEndpointConsumerBuilder - extends - EndpointConsumerBuilder { - default AdvancedPropertiesEndpointConsumerBuilder advanced() { - return (AdvancedPropertiesEndpointConsumerBuilder) this; - } - /** - * 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. - * - * The option is a: <code>boolean</code> type. - * - * Group: consumer - */ - default PropertiesEndpointConsumerBuilder bridgeErrorHandler( - boolean bridgeErrorHandler) { - doSetProperty("bridgeErrorHandler", bridgeErrorHandler); - return this; - } - /** - * 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. - * - * The option will be converted to a <code>boolean</code> type. - * - * Group: consumer - */ - default PropertiesEndpointConsumerBuilder bridgeErrorHandler( - String bridgeErrorHandler) { - doSetProperty("bridgeErrorHandler", bridgeErrorHandler); - return this; - } - } - - /** - * Advanced builder for endpoint consumers for the Properties component. - */ - public interface AdvancedPropertiesEndpointConsumerBuilder - extends - EndpointConsumerBuilder { - default PropertiesEndpointConsumerBuilder basic() { - return (PropertiesEndpointConsumerBuilder) this; - } - /** - * To let the consumer use a custom ExceptionHandler. Notice if the - * option bridgeErrorHandler is enabled then this option is not in use. - * By default the consumer will deal with exceptions, that will be - * logged at WARN or ERROR level and ignored. - * - * The option is a: <code>org.apache.camel.spi.ExceptionHandler</code> - * type. - * - * Group: consumer (advanced) - */ - default AdvancedPropertiesEndpointConsumerBuilder exceptionHandler( - ExceptionHandler exceptionHandler) { - doSetProperty("exceptionHandler", exceptionHandler); - return this; - } - /** - * To let the consumer use a custom ExceptionHandler. Notice if the - * option bridgeErrorHandler is enabled then this option is not in use. - * By default the consumer will deal with exceptions, that will be - * logged at WARN or ERROR level and ignored. - * - * The option will be converted to a - * <code>org.apache.camel.spi.ExceptionHandler</code> type. - * - * Group: consumer (advanced) - */ - default AdvancedPropertiesEndpointConsumerBuilder exceptionHandler( - String exceptionHandler) { - doSetProperty("exceptionHandler", exceptionHandler); - return this; - } - /** - * Sets the exchange pattern when the consumer creates an exchange. - * - * The option is a: <code>org.apache.camel.ExchangePattern</code> type. - * - * Group: consumer (advanced) - */ - default AdvancedPropertiesEndpointConsumerBuilder exchangePattern( - ExchangePattern exchangePattern) { - doSetProperty("exchangePattern", exchangePattern); - return this; - } - /** - * Sets the exchange pattern when the consumer creates an exchange. - * - * The option will be converted to a - * <code>org.apache.camel.ExchangePattern</code> type. - * - * Group: consumer (advanced) - */ - default AdvancedPropertiesEndpointConsumerBuilder exchangePattern( - String exchangePattern) { - doSetProperty("exchangePattern", exchangePattern); - return this; - } - /** - * Whether the endpoint should use basic property binding (Camel 2.x) or - * the newer property binding with additional capabilities. - * - * The option is a: <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointConsumerBuilder basicPropertyBinding( - boolean basicPropertyBinding) { - doSetProperty("basicPropertyBinding", basicPropertyBinding); - return this; - } - /** - * Whether the endpoint should use basic property binding (Camel 2.x) or - * the newer property binding with additional capabilities. - * - * The option will be converted to a <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointConsumerBuilder basicPropertyBinding( - String basicPropertyBinding) { - doSetProperty("basicPropertyBinding", basicPropertyBinding); - return this; - } - /** - * Sets whether synchronous processing should be strictly used, or Camel - * is allowed to use asynchronous processing (if supported). - * - * The option is a: <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointConsumerBuilder synchronous( - boolean synchronous) { - doSetProperty("synchronous", synchronous); - return this; - } - /** - * Sets whether synchronous processing should be strictly used, or Camel - * is allowed to use asynchronous processing (if supported). - * - * The option will be converted to a <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointConsumerBuilder synchronous( - String synchronous) { - doSetProperty("synchronous", synchronous); - return this; - } - } - - /** - * Builder for endpoint producers for the Properties component. - */ - public interface PropertiesEndpointProducerBuilder - extends - EndpointProducerBuilder { - default AdvancedPropertiesEndpointProducerBuilder advanced() { - return (AdvancedPropertiesEndpointProducerBuilder) this; - } - /** - * Whether the producer should be started lazy (on the first message). - * By starting lazy you can use this to allow CamelContext and routes to - * startup in situations where a producer may otherwise fail during - * starting and cause the route to fail being started. By deferring this - * startup to be lazy then the startup failure can be handled during - * routing messages via Camel's routing error handlers. Beware that when - * the first message is processed then creating and starting the - * producer may take a little time and prolong the total processing time - * of the processing. - * - * The option is a: <code>boolean</code> type. - * - * Group: producer - */ - default PropertiesEndpointProducerBuilder lazyStartProducer( - boolean lazyStartProducer) { - doSetProperty("lazyStartProducer", lazyStartProducer); - return this; - } - /** - * Whether the producer should be started lazy (on the first message). - * By starting lazy you can use this to allow CamelContext and routes to - * startup in situations where a producer may otherwise fail during - * starting and cause the route to fail being started. By deferring this - * startup to be lazy then the startup failure can be handled during - * routing messages via Camel's routing error handlers. Beware that when - * the first message is processed then creating and starting the - * producer may take a little time and prolong the total processing time - * of the processing. - * - * The option will be converted to a <code>boolean</code> type. - * - * Group: producer - */ - default PropertiesEndpointProducerBuilder lazyStartProducer( - String lazyStartProducer) { - doSetProperty("lazyStartProducer", lazyStartProducer); - return this; - } - } - - /** - * Advanced builder for endpoint producers for the Properties component. - */ - public interface AdvancedPropertiesEndpointProducerBuilder - extends - EndpointProducerBuilder { - default PropertiesEndpointProducerBuilder basic() { - return (PropertiesEndpointProducerBuilder) this; - } - /** - * Whether the endpoint should use basic property binding (Camel 2.x) or - * the newer property binding with additional capabilities. - * - * The option is a: <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointProducerBuilder basicPropertyBinding( - boolean basicPropertyBinding) { - doSetProperty("basicPropertyBinding", basicPropertyBinding); - return this; - } - /** - * Whether the endpoint should use basic property binding (Camel 2.x) or - * the newer property binding with additional capabilities. - * - * The option will be converted to a <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointProducerBuilder basicPropertyBinding( - String basicPropertyBinding) { - doSetProperty("basicPropertyBinding", basicPropertyBinding); - return this; - } - /** - * Sets whether synchronous processing should be strictly used, or Camel - * is allowed to use asynchronous processing (if supported). - * - * The option is a: <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointProducerBuilder synchronous( - boolean synchronous) { - doSetProperty("synchronous", synchronous); - return this; - } - /** - * Sets whether synchronous processing should be strictly used, or Camel - * is allowed to use asynchronous processing (if supported). - * - * The option will be converted to a <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointProducerBuilder synchronous( - String synchronous) { - doSetProperty("synchronous", synchronous); - return this; - } - } - - /** - * Builder for endpoint for the Properties component. - */ - public interface PropertiesEndpointBuilder - extends - PropertiesEndpointConsumerBuilder, PropertiesEndpointProducerBuilder { - default AdvancedPropertiesEndpointBuilder advanced() { - return (AdvancedPropertiesEndpointBuilder) this; - } - } - - /** - * Advanced builder for endpoint for the Properties component. - */ - public interface AdvancedPropertiesEndpointBuilder - extends - AdvancedPropertiesEndpointConsumerBuilder, AdvancedPropertiesEndpointProducerBuilder { - default PropertiesEndpointBuilder basic() { - return (PropertiesEndpointBuilder) this; - } - /** - * Whether the endpoint should use basic property binding (Camel 2.x) or - * the newer property binding with additional capabilities. - * - * The option is a: <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointBuilder basicPropertyBinding( - boolean basicPropertyBinding) { - doSetProperty("basicPropertyBinding", basicPropertyBinding); - return this; - } - /** - * Whether the endpoint should use basic property binding (Camel 2.x) or - * the newer property binding with additional capabilities. - * - * The option will be converted to a <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointBuilder basicPropertyBinding( - String basicPropertyBinding) { - doSetProperty("basicPropertyBinding", basicPropertyBinding); - return this; - } - /** - * Sets whether synchronous processing should be strictly used, or Camel - * is allowed to use asynchronous processing (if supported). - * - * The option is a: <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointBuilder synchronous( - boolean synchronous) { - doSetProperty("synchronous", synchronous); - return this; - } - /** - * Sets whether synchronous processing should be strictly used, or Camel - * is allowed to use asynchronous processing (if supported). - * - * The option will be converted to a <code>boolean</code> type. - * - * Group: advanced - */ - default AdvancedPropertiesEndpointBuilder synchronous(String synchronous) { - doSetProperty("synchronous", synchronous); - return this; - } - } - /** - * Properties (camel-properties) - * The properties component is used for using property placeholders in - * endpoint uris. - * - * Category: core,endpoint - * Available as of version: 2.3 - * Maven coordinates: org.apache.camel:camel-properties - * - * Syntax: <code>properties:key</code> - * - * Path parameter: key (required) - * Property key to use as placeholder - */ - default PropertiesEndpointBuilder properties(String path) { - class PropertiesEndpointBuilderImpl extends AbstractEndpointBuilder implements PropertiesEndpointBuilder, AdvancedPropertiesEndpointBuilder { - public PropertiesEndpointBuilderImpl(String path) { - super("properties", path); - } - } - return new PropertiesEndpointBuilderImpl(path); - } -} \ No newline at end of file diff --git a/docs/components/modules/ROOT/pages/properties-component.adoc b/docs/components/modules/ROOT/pages/properties-component.adoc index 34f6450..d160a2a 100644 --- a/docs/components/modules/ROOT/pages/properties-component.adoc +++ b/docs/components/modules/ROOT/pages/properties-component.adoc @@ -88,7 +88,7 @@ When using Spring Boot make sure to use the following Maven dependency to have s ---- -The component supports 12 options, which are listed below. +The component supports 10 options, which are listed below. @@ -96,9 +96,7 @@ The component supports 12 options, which are listed below. |=== | Name | Description | Default | Type | *camel.component.properties.auto-discover-properties-sources* | Whether to automatically discovery instances of PropertiesSource from registry and service factory. | true | Boolean -| *camel.component.properties.basic-property-binding* | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | Boolean | *camel.component.properties.default-fallback-enabled* | If false, the component does not attempt to find a default for the key by looking after the colon separator. | true | Boolean -| *camel.component.properties.enabled* | Whether to enable auto configuration of the properties component. This is enabled by default. | | Boolean | *camel.component.properties.encoding* | Encoding to use when loading properties file from the file system or classpath. If no encoding has been set, then the properties files is loaded using ISO-8859-1 encoding (latin-1) as documented by java.util.Properties#load(java.io.InputStream) | | String | *camel.component.properties.environment-variable-mode* | Sets the OS environment variables mode (0 = never, 1 = fallback, 2 = override). The default mode (override) is to use OS environment variables if present, and override any existing properties. OS environment variable mode is checked before JVM system property mode | 2 | Integer | *camel.component.properties.ignore-missing-location* | Whether to silently ignore if a location cannot be located, such as a properties file not found. | false | Boolean diff --git a/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/httptojms/CamelCxfExample.java b/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/httptojms/CamelCxfExample.java index c2080d4..f261012 100644 --- a/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/httptojms/CamelCxfExample.java +++ b/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/httptojms/CamelCxfExample.java @@ -20,7 +20,6 @@ import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.cxf.CxfComponent; import org.apache.camel.component.cxf.CxfEndpoint; -import org.apache.camel.component.properties.PropertiesComponent; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.test.AvailablePortFinder; import org.apache.hello_world_soap_http.Greeter; @@ -73,8 +72,6 @@ public final class CamelCxfExample { // START SNIPPET: e1 CamelContext context = new DefaultCamelContext(); // END SNIPPET: e1 - PropertiesComponent pc = new PropertiesComponent(); - context.addComponent("properties", pc); // Set up the JMS broker and the CXF SOAP over JMS server // START SNIPPET: e2 JmsBroker broker = new JmsBroker(); diff --git a/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/CamelRouterBuilder.java b/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/CamelRouterBuilder.java index c3a2e49..c83f36e 100644 --- a/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/CamelRouterBuilder.java +++ b/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/CamelRouterBuilder.java @@ -24,7 +24,6 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.cxf.common.message.CxfConstants; -import org.apache.camel.component.properties.PropertiesComponent; import org.apache.camel.example.cxf.jaxrs.resources.Book; import org.apache.camel.example.cxf.jaxrs.resources.BookStore; import org.apache.camel.example.cxf.jaxrs.resources.BookStoreImpl; @@ -44,8 +43,6 @@ public class CamelRouterBuilder extends RouteBuilder { System.setProperty("restEndpointPort", "9002"); CamelContext context = new DefaultCamelContext(); - PropertiesComponent pc = new PropertiesComponent(); - context.addComponent("properties", pc); context.start(); context.addRoutes(new CamelRouterBuilder()); Thread.sleep(1000); diff --git a/examples/camel-example-ftp/src/main/java/org/apache/camel/example/ftp/MyFtpClientRouteBuilder.java b/examples/camel-example-ftp/src/main/java/org/apache/camel/example/ftp/MyFtpClientRouteBuilder.java index 5b0accb..18dc528 100644 --- a/examples/camel-example-ftp/src/main/java/org/apache/camel/example/ftp/MyFtpClientRouteBuilder.java +++ b/examples/camel-example-ftp/src/main/java/org/apache/camel/example/ftp/MyFtpClientRouteBuilder.java @@ -17,7 +17,6 @@ package org.apache.camel.example.ftp; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.properties.PropertiesComponent; /** * Client route @@ -27,8 +26,7 @@ public class MyFtpClientRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { // configure properties component - PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class); - pc.setLocation("classpath:ftp.properties"); + getContext().getPropertiesComponent().setLocation("classpath:ftp.properties"); // lets shutdown faster in case of in-flight messages stack up getContext().getShutdownStrategy().setTimeout(10); diff --git a/examples/camel-example-ftp/src/main/java/org/apache/camel/example/ftp/MyFtpServerRouteBuilder.java b/examples/camel-example-ftp/src/main/java/org/apache/camel/example/ftp/MyFtpServerRouteBuilder.java index ea6e680..f7e4260 100644 --- a/examples/camel-example-ftp/src/main/java/org/apache/camel/example/ftp/MyFtpServerRouteBuilder.java +++ b/examples/camel-example-ftp/src/main/java/org/apache/camel/example/ftp/MyFtpServerRouteBuilder.java @@ -17,7 +17,6 @@ package org.apache.camel.example.ftp; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.properties.PropertiesComponent; /** * Server route @@ -27,8 +26,7 @@ public class MyFtpServerRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { // configure properties component - PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class); - pc.setLocation("classpath:ftp.properties"); + getContext().getPropertiesComponent().setLocation("classpath:ftp.properties"); // lets shutdown faster in case of in-flight messages stack up getContext().getShutdownStrategy().setTimeout(10); diff --git a/examples/camel-example-google-pubsub/src/main/java/org/apache/camel/example/google/pubsub/MessageConsumerClient.java b/examples/camel-example-google-pubsub/src/main/java/org/apache/camel/example/google/pubsub/MessageConsumerClient.java index 3fed846..5c542ef 100644 --- a/examples/camel-example-google-pubsub/src/main/java/org/apache/camel/example/google/pubsub/MessageConsumerClient.java +++ b/examples/camel-example-google-pubsub/src/main/java/org/apache/camel/example/google/pubsub/MessageConsumerClient.java @@ -19,7 +19,6 @@ package org.apache.camel.example.google.pubsub; import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.google.pubsub.GooglePubsubComponent; -import org.apache.camel.component.properties.PropertiesComponent; import org.apache.camel.impl.DefaultCamelContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,8 +44,7 @@ public final class MessageConsumerClient { camelContext.addRoutes(new RouteBuilder() { public void configure() { - PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class); - pc.setLocation("classpath:example.properties"); + camelContext.getPropertiesComponent().setLocation("classpath:example.properties"); log.info("About to start route: Google Pubsub -> Log "); diff --git a/examples/camel-example-google-pubsub/src/main/java/org/apache/camel/example/google/pubsub/MessagePublisherClient.java b/examples/camel-example-google-pubsub/src/main/java/org/apache/camel/example/google/pubsub/MessagePublisherClient.java index 53cca38..b29a18e 100644 --- a/examples/camel-example-google-pubsub/src/main/java/org/apache/camel/example/google/pubsub/MessagePublisherClient.java +++ b/examples/camel-example-google-pubsub/src/main/java/org/apache/camel/example/google/pubsub/MessagePublisherClient.java @@ -24,7 +24,6 @@ import org.apache.camel.CamelContext; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.google.pubsub.GooglePubsubComponent; -import org.apache.camel.component.properties.PropertiesComponent; import org.apache.camel.impl.DefaultCamelContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,8 +47,7 @@ public final class MessagePublisherClient { camelContext.addRoutes(new RouteBuilder() { public void configure() { - PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class); - pc.setLocation("classpath:example.properties"); + camelContext.getPropertiesComponent().setLocation("classpath:example.properties"); // setup google pubsub component GooglePubsubComponent googlePubsub = PubsubUtil.createComponent(); diff --git a/examples/camel-example-kafka/src/main/java/org/apache/camel/example/kafka/MessageConsumerClient.java b/examples/camel-example-kafka/src/main/java/org/apache/camel/example/kafka/MessageConsumerClient.java index 5d9fb74..69c5dff 100644 --- a/examples/camel-example-kafka/src/main/java/org/apache/camel/example/kafka/MessageConsumerClient.java +++ b/examples/camel-example-kafka/src/main/java/org/apache/camel/example/kafka/MessageConsumerClient.java @@ -18,7 +18,6 @@ package org.apache.camel.example.kafka; import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.properties.PropertiesComponent; import org.apache.camel.impl.DefaultCamelContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,8 +39,7 @@ public final class MessageConsumerClient { camelContext.addRoutes(new RouteBuilder() { public void configure() { - PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class); - pc.setLocation("classpath:application.properties"); + camelContext.getPropertiesComponent().setLocation("classpath:application.properties"); log.info("About to start route: Kafka Server -> Log "); diff --git a/examples/camel-example-kafka/src/main/java/org/apache/camel/example/kafka/MessagePublisherClient.java b/examples/camel-example-kafka/src/main/java/org/apache/camel/example/kafka/MessagePublisherClient.java index 6168984..27864d9 100644 --- a/examples/camel-example-kafka/src/main/java/org/apache/camel/example/kafka/MessagePublisherClient.java +++ b/examples/camel-example-kafka/src/main/java/org/apache/camel/example/kafka/MessagePublisherClient.java @@ -25,7 +25,6 @@ import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.kafka.KafkaComponent; import org.apache.camel.component.kafka.KafkaConstants; -import org.apache.camel.component.properties.PropertiesComponent; import org.apache.camel.impl.DefaultCamelContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,8 +47,7 @@ public final class MessagePublisherClient { camelContext.addRoutes(new RouteBuilder() { public void configure() { - PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class); - pc.setLocation("classpath:application.properties"); + camelContext.getPropertiesComponent().setLocation("classpath:application.properties"); // setup kafka component with the brokers KafkaComponent kafka = new KafkaComponent(); diff --git a/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkPublishEventRouteBuilder.java b/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkPublishEventRouteBuilder.java index c29282a..ebf0d33 100644 --- a/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkPublishEventRouteBuilder.java +++ b/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkPublishEventRouteBuilder.java @@ -17,7 +17,6 @@ package org.apache.camel.example.splunk; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.properties.PropertiesComponent; import org.apache.camel.component.splunk.event.SplunkEvent; public class SplunkPublishEventRouteBuilder extends RouteBuilder { @@ -27,8 +26,7 @@ public class SplunkPublishEventRouteBuilder extends RouteBuilder { log.info("About to start route: direct --> Splunk Server"); // configure properties component - PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class); - pc.setLocation("classpath:application.properties"); + getContext().getPropertiesComponent().setLocation("classpath:application.properties"); from("direct:start") .convertBodyTo(SplunkEvent.class) diff --git a/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkSavedSearchRouteBuilder.java b/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkSavedSearchRouteBuilder.java index a74a3f3..2f59ab3 100644 --- a/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkSavedSearchRouteBuilder.java +++ b/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkSavedSearchRouteBuilder.java @@ -17,7 +17,6 @@ package org.apache.camel.example.splunk; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.properties.PropertiesComponent; public class SplunkSavedSearchRouteBuilder extends RouteBuilder { @@ -26,8 +25,7 @@ public class SplunkSavedSearchRouteBuilder extends RouteBuilder { log.info("About to setup Splunk 'saved-search' route:Splunk Server --> log{results}"); // configure properties component - PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class); - pc.setLocation("classpath:application.properties"); + getContext().getPropertiesComponent().setLocation("classpath:application.properties"); from("splunk://savedsearch?host={{splunk.host}}&port={{splunk.port}}&delay=10s" + "&username={{splunk.username}}&password={{splunk.password}}&initEarliestTime=08/17/13 08:35:46:456" diff --git a/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchRouteBuilder.java b/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchRouteBuilder.java index c7fc835..50e489a 100644 --- a/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchRouteBuilder.java +++ b/examples/camel-example-splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchRouteBuilder.java @@ -17,7 +17,6 @@ package org.apache.camel.example.splunk; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.properties.PropertiesComponent; public class SplunkSearchRouteBuilder extends RouteBuilder { @@ -27,8 +26,7 @@ public class SplunkSearchRouteBuilder extends RouteBuilder { log.info("About to setup Splunk search route: Splunk Server --> log{results}"); // configure properties component - PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class); - pc.setLocation("classpath:application.properties"); + getContext().getPropertiesComponent().setLocation("classpath:application.properties"); from("splunk://normal?host={{splunk.host}}&port={{splunk.port}}&delay=10s" + "&username={{splunk.username}}&password={{splunk.password}}&initEarliestTime=08/17/13 08:35:46:456" diff --git a/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentAutoConfiguration.java index 3ab556f..c44f0cea 100644 --- a/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentAutoConfiguration.java @@ -16,27 +16,15 @@ */ package org.apache.camel.component.properties.springboot; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.annotation.Generated; +import java.util.Properties; + import org.apache.camel.CamelContext; import org.apache.camel.component.properties.PropertiesComponent; -import org.apache.camel.spi.ComponentCustomizer; -import org.apache.camel.spi.HasId; +import org.apache.camel.component.properties.PropertiesParser; import org.apache.camel.spring.boot.CamelAutoConfiguration; -import org.apache.camel.spring.boot.ComponentConfigurationProperties; -import org.apache.camel.spring.boot.util.CamelPropertiesHelper; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; -import org.apache.camel.spring.boot.util.GroupCondition; -import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; -import org.apache.camel.support.IntrospectionSupport; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.ApplicationContext; @@ -45,83 +33,56 @@ import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; -/** - * Generated by camel-package-maven-plugin - do not edit this file! - */ -@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @Configuration -@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class, - PropertiesComponentAutoConfiguration.GroupConditions.class}) +@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class}) @AutoConfigureAfter(CamelAutoConfiguration.class) -@EnableConfigurationProperties({ComponentConfigurationProperties.class, - PropertiesComponentConfiguration.class}) +@EnableConfigurationProperties({PropertiesComponentConfiguration.class}) public class PropertiesComponentAutoConfiguration { - private static final Logger LOGGER = LoggerFactory - .getLogger(PropertiesComponentAutoConfiguration.class); @Autowired private ApplicationContext applicationContext; @Autowired private CamelContext camelContext; - @Autowired - private PropertiesComponentConfiguration configuration; - @Autowired(required = false) - private List<ComponentCustomizer<PropertiesComponent>> customizers; - - static class GroupConditions extends GroupCondition { - public GroupConditions() { - super("camel.component", "camel.component.properties"); - } - } @Lazy @Bean(name = "properties-component") @ConditionalOnMissingBean(PropertiesComponent.class) - public PropertiesComponent configurePropertiesComponent() throws Exception { + public PropertiesComponent configurePropertiesComponent(PropertiesComponentConfiguration configuration) throws Exception { PropertiesComponent component = new PropertiesComponent(); component.setCamelContext(camelContext); - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - for (Map.Entry<String, Object> entry : parameters.entrySet()) { - Object value = entry.getValue(); - Class<?> paramClass = value.getClass(); - if (paramClass.getName().endsWith("NestedConfiguration")) { - Class nestedClass = null; - try { - nestedClass = (Class) paramClass.getDeclaredField( - "CAMEL_NESTED_CLASS").get(null); - HashMap<String, Object> nestedParameters = new HashMap<>(); - IntrospectionSupport.getProperties(value, nestedParameters, - null, false); - Object nestedProperty = nestedClass.newInstance(); - CamelPropertiesHelper.setCamelProperties(camelContext, - nestedProperty, nestedParameters, false); - entry.setValue(nestedProperty); - } catch (NoSuchFieldException e) { - } - } + + if (configuration.getAutoDiscoverPropertiesSources() != null) { + component.setAutoDiscoverPropertiesSources(configuration.getAutoDiscoverPropertiesSources()); + } + if (configuration.getDefaultFallbackEnabled() != null) { + component.setDefaultFallbackEnabled(configuration.getDefaultFallbackEnabled()); + } + if (configuration.getEncoding() != null) { + component.setEncoding(configuration.getEncoding()); + } + if (configuration.getEnvironmentVariableMode() != null) { + component.setEnvironmentVariableMode(configuration.getEnvironmentVariableMode()); + } + if (configuration.getSystemPropertiesMode() != null) { + component.setSystemPropertiesMode(configuration.getSystemPropertiesMode()); + } + if (configuration.getIgnoreMissingLocation() != null) { + component.setIgnoreMissingLocation(configuration.getIgnoreMissingLocation()); + } + if (configuration.getLocation() != null) { + component.setLocation(configuration.getLocation()); + } + if (configuration.getInitialProperties() != null) { + Properties prop = camelContext.getRegistry().lookupByNameAndType(configuration.getInitialProperties(), Properties.class); + component.setInitialProperties(prop); + } + if (configuration.getOverrideProperties() != null) { + Properties prop = camelContext.getRegistry().lookupByNameAndType(configuration.getOverrideProperties(), Properties.class); + component.setOverrideProperties(prop); } - CamelPropertiesHelper.setCamelProperties(camelContext, component, - parameters, false); - if (ObjectHelper.isNotEmpty(customizers)) { - for (ComponentCustomizer<PropertiesComponent> customizer : customizers) { - boolean useCustomizer = (customizer instanceof HasId) - ? HierarchicalPropertiesEvaluator.evaluate( - applicationContext.getEnvironment(), - "camel.component.customizer", - "camel.component.properties.customizer", - ((HasId) customizer).getId()) - : HierarchicalPropertiesEvaluator.evaluate( - applicationContext.getEnvironment(), - "camel.component.customizer", - "camel.component.properties.customizer"); - if (useCustomizer) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); - } - } + if (configuration.getPropertiesParser() != null) { + PropertiesParser parser = camelContext.getRegistry().lookupByNameAndType(configuration.getPropertiesParser(), PropertiesParser.class); + component.setPropertiesParser(parser); } return component; } diff --git a/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java index ad7ad86..905f716 100644 --- a/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java @@ -16,28 +16,15 @@ */ package org.apache.camel.component.properties.springboot; -import javax.annotation.Generated; -import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** - * The properties component is used for using property placeholders in endpoint - * uris. - * - * Generated by camel-package-maven-plugin - do not edit this file! + * The properties component is used for using property placeholders in endpoint uris. */ -@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.properties") -public class PropertiesComponentConfiguration - extends - ComponentConfigurationPropertiesCommon { +public class PropertiesComponentConfiguration { /** - * Whether to enable auto configuration of the properties component. This is - * enabled by default. - */ - private Boolean enabled; - /** * A list of locations to load properties. You can use comma to separate * multiple locations. This option will override any default locations and * only use the locations from this option. @@ -95,11 +82,6 @@ public class PropertiesComponentConfiguration * registry and service factory. */ private Boolean autoDiscoverPropertiesSources = true; - /** - * Whether the component should use basic property binding (Camel 2.x) or - * the newer property binding with additional capabilities - */ - private Boolean basicPropertyBinding = false; public String getLocation() { return location; @@ -182,11 +164,4 @@ public class PropertiesComponentConfiguration this.autoDiscoverPropertiesSources = autoDiscoverPropertiesSources; } - public Boolean getBasicPropertyBinding() { - return basicPropertyBinding; - } - - public void setBasicPropertyBinding(Boolean basicPropertyBinding) { - this.basicPropertyBinding = basicPropertyBinding; - } } \ No newline at end of file
