Lets reuse the header filter from the base component instead
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bba84aa2 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bba84aa2 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bba84aa2 Branch: refs/heads/master Commit: bba84aa2416fc45cde917e7710ef9906f44b82f2 Parents: 8c0f3c3 Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Dec 21 19:58:07 2016 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Dec 21 19:58:07 2016 +0100 ---------------------------------------------------------------------- .../SjmsBatchComponentConfiguration.java | 17 +++++++++++ .../springboot/SjmsComponentConfiguration.java | 30 ++++++++++---------- .../src/main/docs/sjms-batch-component.adoc | 3 +- .../src/main/docs/sjms-component.adoc | 2 +- .../camel/component/sjms/SjmsComponent.java | 25 +++------------- .../sjms/batch/SjmsBatchComponent.java | 4 +-- 6 files changed, 41 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/bba84aa2/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/batch/springboot/SjmsBatchComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/batch/springboot/SjmsBatchComponentConfiguration.java b/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/batch/springboot/SjmsBatchComponentConfiguration.java index b611055..c1dc1a9 100644 --- a/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/batch/springboot/SjmsBatchComponentConfiguration.java +++ b/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/batch/springboot/SjmsBatchComponentConfiguration.java @@ -17,7 +17,9 @@ package org.apache.camel.component.sjms.batch.springboot; import javax.jms.ConnectionFactory; +import org.apache.camel.spi.HeaderFilterStrategy; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * The sjms-batch component is a specialized for highly performant transactional @@ -32,6 +34,12 @@ public class SjmsBatchComponentConfiguration { * A ConnectionFactory is required to enable the SjmsBatchComponent. */ private ConnectionFactory connectionFactory; + /** + * To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter + * header to and from Camel message. + */ + @NestedConfigurationProperty + private HeaderFilterStrategy headerFilterStrategy; public ConnectionFactory getConnectionFactory() { return connectionFactory; @@ -40,4 +48,13 @@ public class SjmsBatchComponentConfiguration { public void setConnectionFactory(ConnectionFactory connectionFactory) { this.connectionFactory = connectionFactory; } + + public HeaderFilterStrategy getHeaderFilterStrategy() { + return headerFilterStrategy; + } + + public void setHeaderFilterStrategy( + HeaderFilterStrategy headerFilterStrategy) { + this.headerFilterStrategy = headerFilterStrategy; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bba84aa2/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentConfiguration.java b/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentConfiguration.java index 0035ed3..daba7f4 100644 --- a/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentConfiguration.java +++ b/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentConfiguration.java @@ -41,12 +41,6 @@ public class SjmsComponentConfiguration { */ private ConnectionFactory connectionFactory; /** - * To use a custom HeaderFilterStrategy to filter header to and from Camel - * message. - */ - @NestedConfigurationProperty - private HeaderFilterStrategy headerFilterStrategy; - /** * A ConnectionResource is an interface that allows for customization and * container control of the ConnectionFactory. See Plugable Connection * Resource Management for further details. @@ -92,6 +86,12 @@ public class SjmsComponentConfiguration { */ @NestedConfigurationProperty private MessageCreatedStrategy messageCreatedStrategy; + /** + * To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter + * header to and from Camel message. + */ + @NestedConfigurationProperty + private HeaderFilterStrategy headerFilterStrategy; public ConnectionFactory getConnectionFactory() { return connectionFactory; @@ -101,15 +101,6 @@ public class SjmsComponentConfiguration { this.connectionFactory = connectionFactory; } - public HeaderFilterStrategy getHeaderFilterStrategy() { - return headerFilterStrategy; - } - - public void setHeaderFilterStrategy( - HeaderFilterStrategy headerFilterStrategy) { - this.headerFilterStrategy = headerFilterStrategy; - } - public ConnectionResource getConnectionResource() { return connectionResource; } @@ -171,6 +162,15 @@ public class SjmsComponentConfiguration { this.messageCreatedStrategy = messageCreatedStrategy; } + public HeaderFilterStrategy getHeaderFilterStrategy() { + return headerFilterStrategy; + } + + public void setHeaderFilterStrategy( + HeaderFilterStrategy headerFilterStrategy) { + this.headerFilterStrategy = headerFilterStrategy; + } + public static class TimedTaskManagerNestedConfiguration { public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.sjms.taskmanager.TimedTaskManager.class; } http://git-wip-us.apache.org/repos/asf/camel/blob/bba84aa2/components/camel-sjms/src/main/docs/sjms-batch-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/main/docs/sjms-batch-component.adoc b/components/camel-sjms/src/main/docs/sjms-batch-component.adoc index ba4bee4..6f8715e 100644 --- a/components/camel-sjms/src/main/docs/sjms-batch-component.adoc +++ b/components/camel-sjms/src/main/docs/sjms-batch-component.adoc @@ -117,7 +117,7 @@ Component Options and Configurations // component options: START -The Simple JMS Batch component supports 1 options which are listed below. +The Simple JMS Batch component supports 2 options which are listed below. @@ -126,6 +126,7 @@ The Simple JMS Batch component supports 1 options which are listed below. |======================================================================= | Name | Java Type | Description | connectionFactory | ConnectionFactory | A ConnectionFactory is required to enable the SjmsBatchComponent. +| headerFilterStrategy | HeaderFilterStrategy | To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message. |======================================================================= {% endraw %} // component options: END http://git-wip-us.apache.org/repos/asf/camel/blob/bba84aa2/components/camel-sjms/src/main/docs/sjms-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/main/docs/sjms-component.adoc b/components/camel-sjms/src/main/docs/sjms-component.adoc index 89cf99f..7a55fb9 100644 --- a/components/camel-sjms/src/main/docs/sjms-component.adoc +++ b/components/camel-sjms/src/main/docs/sjms-component.adoc @@ -113,7 +113,6 @@ The Simple JMS component supports 9 options which are listed below. |======================================================================= | Name | Java Type | Description | connectionFactory | ConnectionFactory | A ConnectionFactory is required to enable the SjmsComponent. It can be set directly or set set as part of a ConnectionResource. -| headerFilterStrategy | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message. | connectionResource | ConnectionResource | A ConnectionResource is an interface that allows for customization and container control of the ConnectionFactory. See Plugable Connection Resource Management for further details. | connectionCount | Integer | The maximum number of connections available to endpoints started under this component | jmsKeyFormatStrategy | JmsKeyFormatStrategy | Pluggable strategy for encoding and decoding JMS keys so they can be compliant with the JMS specification. Camel provides one implementation out of the box: default. The default strategy will safely marshal dots and hyphens (. and -). Can be used for JMS brokers which do not care whether JMS header keys contain illegal characters. You can provide your own implementation of the org.apache.camel.component.jms.JmsKeyFormatStrategy and refer to it using the notation. @@ -121,6 +120,7 @@ The Simple JMS component supports 9 options which are listed below. | destinationCreationStrategy | DestinationCreationStrategy | To use a custom DestinationCreationStrategy. | timedTaskManager | TimedTaskManager | To use a custom TimedTaskManager | messageCreatedStrategy | MessageCreatedStrategy | To use the given MessageCreatedStrategy which are invoked when Camel creates new instances of javax.jms.Message objects when Camel is sending a JMS message. +| headerFilterStrategy | HeaderFilterStrategy | To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message. |======================================================================= {% endraw %} // component options: END http://git-wip-us.apache.org/repos/asf/camel/blob/bba84aa2/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsComponent.java b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsComponent.java index 97797c9..01918a1 100644 --- a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsComponent.java +++ b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsComponent.java @@ -29,15 +29,13 @@ import org.apache.camel.component.sjms.jms.DestinationCreationStrategy; import org.apache.camel.component.sjms.jms.JmsKeyFormatStrategy; import org.apache.camel.component.sjms.jms.MessageCreatedStrategy; import org.apache.camel.component.sjms.taskmanager.TimedTaskManager; -import org.apache.camel.impl.UriEndpointComponent; -import org.apache.camel.spi.HeaderFilterStrategy; -import org.apache.camel.spi.HeaderFilterStrategyAware; +import org.apache.camel.impl.HeaderFilterStrategyComponent; import org.apache.camel.spi.Metadata; /** * The <a href="http://camel.apache.org/sjms">Simple JMS</a> component. */ -public class SjmsComponent extends UriEndpointComponent implements HeaderFilterStrategyAware { +public class SjmsComponent extends HeaderFilterStrategyComponent { private ExecutorService asyncStartStopExecutorService; @@ -46,8 +44,6 @@ public class SjmsComponent extends UriEndpointComponent implements HeaderFilterS @Metadata(label = "advanced") private ConnectionResource connectionResource; @Metadata(label = "advanced") - private HeaderFilterStrategy headerFilterStrategy = new SjmsHeaderFilterStrategy(); - @Metadata(label = "advanced") private JmsKeyFormatStrategy jmsKeyFormatStrategy = new DefaultJmsKeyFormatStrategy(); @Metadata(defaultValue = "1") private Integer connectionCount = 1; @@ -78,8 +74,8 @@ public class SjmsComponent extends UriEndpointComponent implements HeaderFilterS if (destinationCreationStrategy != null) { endpoint.setDestinationCreationStrategy(destinationCreationStrategy); } - if (headerFilterStrategy != null) { - endpoint.setHeaderFilterStrategy(headerFilterStrategy); + if (getHeaderFilterStrategy() != null) { + endpoint.setHeaderFilterStrategy(getHeaderFilterStrategy()); } if (messageCreatedStrategy != null) { endpoint.setMessageCreatedStrategy(messageCreatedStrategy); @@ -154,19 +150,6 @@ public class SjmsComponent extends UriEndpointComponent implements HeaderFilterS return connectionFactory; } - @Override - public HeaderFilterStrategy getHeaderFilterStrategy() { - return this.headerFilterStrategy; - } - - /** - * To use a custom HeaderFilterStrategy to filter header to and from Camel message. - */ - @Override - public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) { - this.headerFilterStrategy = headerFilterStrategy; - } - /** * A ConnectionResource is an interface that allows for customization and container control of the ConnectionFactory. * See Plugable Connection Resource Management for further details. http://git-wip-us.apache.org/repos/asf/camel/blob/bba84aa2/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchComponent.java b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchComponent.java index 4403a68..9f2cf27 100644 --- a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchComponent.java +++ b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchComponent.java @@ -20,11 +20,11 @@ import java.util.Map; import javax.jms.ConnectionFactory; import org.apache.camel.Endpoint; -import org.apache.camel.impl.UriEndpointComponent; +import org.apache.camel.impl.HeaderFilterStrategyComponent; import org.apache.camel.spi.Metadata; import org.apache.camel.util.ObjectHelper; -public class SjmsBatchComponent extends UriEndpointComponent { +public class SjmsBatchComponent extends HeaderFilterStrategyComponent { @Metadata(label = "advanced") private ConnectionFactory connectionFactory;