CAMEL-8316: Rename property language to exchangeProperty to avoid ambiguity, confusion and clash with properties as a general term.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/07691e98 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/07691e98 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/07691e98 Branch: refs/heads/master Commit: 07691e9801a599a0d301cbcf7ab40eeeb8c71ddb Parents: c211ed2 Author: Claus Ibsen <[email protected]> Authored: Thu Feb 5 10:08:10 2015 +0100 Committer: Claus Ibsen <[email protected]> Committed: Thu Feb 5 15:51:23 2015 +0100 ---------------------------------------------------------------------- .../java/org/apache/camel/ExchangeProperty.java | 36 +++++++++++ .../main/java/org/apache/camel/Property.java | 4 +- .../java/org/apache/camel/builder/Builder.java | 16 ++++- .../apache/camel/builder/BuilderSupport.java | 17 ++++- .../apache/camel/builder/ExpressionBuilder.java | 23 ++++++- .../camel/builder/ExpressionClauseSupport.java | 14 +++- .../apache/camel/component/bean/BeanInfo.java | 6 +- .../property/ExchangePropertyLanguage.java | 54 ++++++++++++++++ .../language/property/PropertyLanguage.java | 46 -------------- .../apache/camel/language/property/package.html | 2 +- .../simple/ast/SimpleFunctionExpression.java | 2 +- .../camel/model/PropertiesDefinition.java | 64 +++++++++++++++++++ .../apache/camel/model/PropertyDefinition.java | 62 ++++++++++++++++++ .../model/config/PropertiesDefinition.java | 64 ------------------- .../camel/model/config/PropertyDefinition.java | 62 ------------------ .../language/ExchangePropertyExpression.java | 45 +++++++++++++ .../camel/model/language/HeaderExpression.java | 2 +- .../model/language/PropertyExpression.java | 45 ------------- .../java/org/apache/camel/util/URISupport.java | 19 ++++++ .../org/apache/camel/language/exchangeProperty | 18 ++++++ .../services/org/apache/camel/language/property | 18 ------ .../org/apache/camel/model/config/jaxb.index | 2 - .../resources/org/apache/camel/model/jaxb.index | 2 + .../org/apache/camel/model/language/jaxb.index | 2 +- .../org/apache/camel/language/PropertyTest.java | 4 +- .../org/apache/camel/util/URISupportTest.java | 20 ++++-- .../blueprint/CamelContextFactoryBean.java | 2 +- .../xml/AbstractCamelContextFactoryBean.java | 2 +- .../xml/AbstractCamelEndpointFactoryBean.java | 67 +++++++++++++++++--- .../camel/spring/CamelContextFactoryBean.java | 2 +- ...potentConsumerNoSkipDuplicateFilterTest.java | 2 +- ...mpotentConsumerNoSkipDuplicateFilterTest.xml | 2 +- ...recipientListWithStringDelimitedProperty.xml | 2 +- 33 files changed, 453 insertions(+), 275 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/ExchangeProperty.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/ExchangeProperty.java b/camel-core/src/main/java/org/apache/camel/ExchangeProperty.java new file mode 100644 index 0000000..7f7e37c --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/ExchangeProperty.java @@ -0,0 +1,36 @@ +/** + * 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; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marks a parameter as being an injection point of a property of an {@link org.apache.camel.Exchange} + * + * @see org.apache.camel.Exchange#getProperty(String) + * @version + */ +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Target({ElementType.PARAMETER }) +public @interface ExchangeProperty { + String value(); +} http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/Property.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/Property.java b/camel-core/src/main/java/org/apache/camel/Property.java index 10657d6..a304e6f 100644 --- a/camel-core/src/main/java/org/apache/camel/Property.java +++ b/camel-core/src/main/java/org/apache/camel/Property.java @@ -26,11 +26,13 @@ import java.lang.annotation.Target; * Marks a parameter as being an injection point of a property of an {@link Exchange} * * @see Exchange#getProperty(String) - * @version + * @version + * @deprecated use {@link org.apache.camel.ExchangeProperty} instead */ @Retention(RetentionPolicy.RUNTIME) @Documented @Target({ElementType.PARAMETER }) +@Deprecated public @interface Property { String value(); } http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/builder/Builder.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/builder/Builder.java b/camel-core/src/main/java/org/apache/camel/builder/Builder.java index 850fc04..ed0d932 100644 --- a/camel-core/src/main/java/org/apache/camel/builder/Builder.java +++ b/camel-core/src/main/java/org/apache/camel/builder/Builder.java @@ -123,13 +123,23 @@ public final class Builder { /** * Returns a predicate and value builder for properties on an exchange + * + * @deprecated use {@link #exchangeProperty(String)} instead */ + @Deprecated public static ValueBuilder property(String name) { - Expression expression = ExpressionBuilder.propertyExpression(name); - return new ValueBuilder(expression); - } + return exchangeProperty(name); + } /** + * Returns a predicate and value builder for properties on an exchange + */ + public static ValueBuilder exchangeProperty(String name) { + Expression expression = ExpressionBuilder.exchangePropertyExpression(name); + return new ValueBuilder(expression); + } + + /** * Returns a predicate and value builder for the inbound body on an exchange */ public static ValueBuilder body() { http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java b/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java index 81b1101..e8713c5 100644 --- a/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java +++ b/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java @@ -27,9 +27,9 @@ import org.apache.camel.LoggingLevel; import org.apache.camel.NoSuchEndpointException; import org.apache.camel.builder.xml.XPathBuilder; import org.apache.camel.model.ModelCamelContext; +import org.apache.camel.model.language.ExchangePropertyExpression; import org.apache.camel.model.language.HeaderExpression; import org.apache.camel.model.language.MethodCallExpression; -import org.apache.camel.model.language.PropertyExpression; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,14 +63,25 @@ public abstract class BuilderSupport { } /** - * Returns a value builder for the given property + * + * Returns a value builder for the given exchange property + * @deprecated use {@link #exchangeProperty(String)} instead */ + @Deprecated public ValueBuilder property(String name) { - PropertyExpression expression = new PropertyExpression(name); + ExchangePropertyExpression expression = new ExchangePropertyExpression(name); return new ValueBuilder(expression); } /** + * Returns a value builder for the given exchange property + */ + public ValueBuilder exchangeProperty(String name) { + ExchangePropertyExpression expression = new ExchangePropertyExpression(name); + return new ValueBuilder(expression); + } + + /** * Returns a predicate and value builder for the inbound body on an exchange */ public ValueBuilder body() { http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java index 91c226c..a5539e2 100644 --- a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java +++ b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java @@ -525,7 +525,9 @@ public final class ExpressionBuilder { * * @param propertyName the name of the property the expression will return * @return an expression object which will return the property value + * @deprecated use {@link #exchangePropertyExpression(String)} instead */ + @Deprecated public static Expression propertyExpression(final String propertyName) { return new ExpressionAdapter() { public Object evaluate(Exchange exchange) { @@ -534,12 +536,31 @@ public final class ExpressionBuilder { @Override public String toString() { - return "property(" + propertyName + ")"; + return "exchangeProperty(" + propertyName + ")"; } }; } /** + * Returns an expression for the property value of exchange with the given name + * + * @param propertyName the name of the property the expression will return + * @return an expression object which will return the property value + */ + public static Expression exchangePropertyExpression(final String propertyName) { + return new ExpressionAdapter() { + public Object evaluate(Exchange exchange) { + return exchange.getProperty(propertyName); + } + + @Override + public String toString() { + return "exchangeProperty(" + propertyName + ")"; + } + }; + } + + /** * Returns an expression for the property value of exchange with the given name invoking methods defined * in a simple OGNL notation * http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java b/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java index 838d869..d0fa176 100644 --- a/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java +++ b/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java @@ -23,6 +23,7 @@ import org.apache.camel.Expression; import org.apache.camel.builder.xml.Namespaces; import org.apache.camel.model.language.ConstantExpression; import org.apache.camel.model.language.ELExpression; +import org.apache.camel.model.language.ExchangePropertyExpression; import org.apache.camel.model.language.ExpressionDefinition; import org.apache.camel.model.language.GroovyExpression; import org.apache.camel.model.language.HeaderExpression; @@ -34,7 +35,6 @@ import org.apache.camel.model.language.MethodCallExpression; import org.apache.camel.model.language.MvelExpression; import org.apache.camel.model.language.OgnlExpression; import org.apache.camel.model.language.PhpExpression; -import org.apache.camel.model.language.PropertyExpression; import org.apache.camel.model.language.PythonExpression; import org.apache.camel.model.language.RefExpression; import org.apache.camel.model.language.RubyExpression; @@ -184,9 +184,19 @@ public class ExpressionClauseSupport<T> { /** * An expression of an exchange property of the given name + * + * @deprecated use {@link #exchangeProperty(String)} instead */ + @Deprecated public T property(String name) { - return expression(new PropertyExpression(name)); + return expression(new ExchangePropertyExpression(name)); + } + + /** + * An expression of an exchange property of the given name + */ + public T exchangeProperty(String name) { + return expression(new ExchangePropertyExpression(name)); } /** http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java index fb9c533..c478d8b 100644 --- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java +++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java @@ -37,6 +37,7 @@ import org.apache.camel.Body; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.ExchangeException; +import org.apache.camel.ExchangeProperty; import org.apache.camel.Expression; import org.apache.camel.Handler; import org.apache.camel.Header; @@ -894,7 +895,10 @@ public class BeanInfo { return ExpressionBuilder.attachmentsExpression(); } else if (annotation instanceof Property) { Property propertyAnnotation = (Property)annotation; - return ExpressionBuilder.propertyExpression(propertyAnnotation.value()); + return ExpressionBuilder.exchangePropertyExpression(propertyAnnotation.value()); + } else if (annotation instanceof ExchangeProperty) { + ExchangeProperty propertyAnnotation = (ExchangeProperty)annotation; + return ExpressionBuilder.exchangePropertyExpression(propertyAnnotation.value()); } else if (annotation instanceof Properties) { return ExpressionBuilder.propertiesExpression(); } else if (annotation instanceof Header) { http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/language/property/ExchangePropertyLanguage.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/language/property/ExchangePropertyLanguage.java b/camel-core/src/main/java/org/apache/camel/language/property/ExchangePropertyLanguage.java new file mode 100644 index 0000000..cc29cd8 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/language/property/ExchangePropertyLanguage.java @@ -0,0 +1,54 @@ +/** + * 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.language.property; + +import org.apache.camel.Expression; +import org.apache.camel.IsSingleton; +import org.apache.camel.Predicate; +import org.apache.camel.builder.ExpressionBuilder; +import org.apache.camel.spi.Language; +import org.apache.camel.util.ExpressionToPredicateAdapter; + +/** + * A language for exchange property expressions. + */ +public class ExchangePropertyLanguage implements Language, IsSingleton { + + /** + * @deprecated use {@link #exchangeProperty(String)} instead + */ + @Deprecated + public static Expression property(String propertyName) { + return exchangeProperty(propertyName); + } + + public static Expression exchangeProperty(String propertyName) { + return ExpressionBuilder.exchangePropertyExpression(propertyName); + } + + public Predicate createPredicate(String expression) { + return ExpressionToPredicateAdapter.toPredicate(createExpression(expression)); + } + + public Expression createExpression(String expression) { + return ExchangePropertyLanguage.exchangeProperty(expression); + } + + public boolean isSingleton() { + return true; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/language/property/PropertyLanguage.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/language/property/PropertyLanguage.java b/camel-core/src/main/java/org/apache/camel/language/property/PropertyLanguage.java deleted file mode 100644 index 39a9723..0000000 --- a/camel-core/src/main/java/org/apache/camel/language/property/PropertyLanguage.java +++ /dev/null @@ -1,46 +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.language.property; - -import org.apache.camel.Expression; -import org.apache.camel.IsSingleton; -import org.apache.camel.Predicate; -import org.apache.camel.builder.ExpressionBuilder; -import org.apache.camel.spi.Language; -import org.apache.camel.util.ExpressionToPredicateAdapter; - -/** - * A language for property expressions. - */ -public class PropertyLanguage implements Language, IsSingleton { - - public static Expression property(String propertyName) { - return ExpressionBuilder.propertyExpression(propertyName); - } - - public Predicate createPredicate(String expression) { - return ExpressionToPredicateAdapter.toPredicate(createExpression(expression)); - } - - public Expression createExpression(String expression) { - return PropertyLanguage.property(expression); - } - - public boolean isSingleton() { - return true; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/language/property/package.html ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/language/property/package.html b/camel-core/src/main/java/org/apache/camel/language/property/package.html index 7fd9217..2899f70 100644 --- a/camel-core/src/main/java/org/apache/camel/language/property/package.html +++ b/camel-core/src/main/java/org/apache/camel/language/property/package.html @@ -19,7 +19,7 @@ </head> <body> -Camel <a href="http://camel.apache.org/header.html">Property</a> language. +Camel <a href="http://camel.apache.org/property.html">Exchange Property</a> language. </body> </html> http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java b/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java index d63e854..8ea75a1 100644 --- a/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java +++ b/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java @@ -111,7 +111,7 @@ public class SimpleFunctionExpression extends LiteralExpression { return ExpressionBuilder.propertyOgnlExpression(remainder); } else { // regular property - return ExpressionBuilder.propertyExpression(remainder); + return ExpressionBuilder.exchangePropertyExpression(remainder); } } http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/model/PropertiesDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/PropertiesDefinition.java b/camel-core/src/main/java/org/apache/camel/model/PropertiesDefinition.java new file mode 100644 index 0000000..1ad1095 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/PropertiesDefinition.java @@ -0,0 +1,64 @@ +/** + * 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.model; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.camel.spi.Metadata; + +/** + * A series of key value pair + */ +@Metadata(label = "configuration") +@XmlRootElement(name = "properties") +@XmlAccessorType(XmlAccessType.FIELD) +public class PropertiesDefinition { + @XmlElement(name = "property") + private List<PropertyDefinition> properties; + + public PropertiesDefinition() { + } + + /** + * A series of properties as key value pairs + */ + public void setProperties(List<PropertyDefinition> properties) { + this.properties = properties; + } + + public List<PropertyDefinition> getProperties() { + return properties; + } + + /*** + * @return A Map of the contained DataFormatType's indexed by id. + */ + public Map<String, String> asMap() { + Map<String, String> propertiesAsMap = new HashMap<String, String>(); + for (PropertyDefinition propertyType : getProperties()) { + propertiesAsMap.put(propertyType.getKey(), propertyType.getValue()); + } + return propertiesAsMap; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/model/PropertyDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/PropertyDefinition.java b/camel-core/src/main/java/org/apache/camel/model/PropertyDefinition.java new file mode 100644 index 0000000..7f4b02b --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/PropertyDefinition.java @@ -0,0 +1,62 @@ +/** + * 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.model; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.camel.spi.Metadata; + +/** + * A key value pair + */ +@Metadata(label = "configuration") +@XmlRootElement(name = "property") +@XmlAccessorType(XmlAccessType.FIELD) +public class PropertyDefinition { + @XmlAttribute(required = true) + String key; + @XmlAttribute(required = true) + String value; + + public PropertyDefinition() { + } + + /** + * Property key + */ + public void setKey(String key) { + this.key = key; + } + + public String getKey() { + return key; + } + + /** + * Property value + */ + public void setValue(String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/model/config/PropertiesDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/config/PropertiesDefinition.java b/camel-core/src/main/java/org/apache/camel/model/config/PropertiesDefinition.java deleted file mode 100644 index 1195044..0000000 --- a/camel-core/src/main/java/org/apache/camel/model/config/PropertiesDefinition.java +++ /dev/null @@ -1,64 +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.model.config; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.apache.camel.spi.Metadata; - -/** - * A series of key value pair - */ -@Metadata(label = "configuration,resequence") -@XmlRootElement(name = "properties") -@XmlAccessorType(XmlAccessType.FIELD) -public class PropertiesDefinition { - @XmlElement(name = "property") - private List<PropertyDefinition> properties; - - public PropertiesDefinition() { - } - - /** - * A series of properties as key value pairs - */ - public void setProperties(List<PropertyDefinition> properties) { - this.properties = properties; - } - - public List<PropertyDefinition> getProperties() { - return properties; - } - - /*** - * @return A Map of the contained DataFormatType's indexed by id. - */ - public Map<String, String> asMap() { - Map<String, String> propertiesAsMap = new HashMap<String, String>(); - for (PropertyDefinition propertyType : getProperties()) { - propertiesAsMap.put(propertyType.getKey(), propertyType.getValue()); - } - return propertiesAsMap; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/model/config/PropertyDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/config/PropertyDefinition.java b/camel-core/src/main/java/org/apache/camel/model/config/PropertyDefinition.java deleted file mode 100644 index 858ea2d..0000000 --- a/camel-core/src/main/java/org/apache/camel/model/config/PropertyDefinition.java +++ /dev/null @@ -1,62 +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.model.config; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -import org.apache.camel.spi.Metadata; - -/** - * A key value pair - */ -@Metadata(label = "configuration,resequence") -@XmlRootElement(name = "property") -@XmlAccessorType(XmlAccessType.FIELD) -public class PropertyDefinition { - @XmlAttribute(required = true) - String key; - @XmlAttribute(required = true) - String value; - - public PropertyDefinition() { - } - - /** - * Property key - */ - public void setKey(String key) { - this.key = key; - } - - public String getKey() { - return key; - } - - /** - * Property value - */ - public void setValue(String value) { - this.value = value; - } - - public String getValue() { - return value; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/model/language/ExchangePropertyExpression.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/language/ExchangePropertyExpression.java b/camel-core/src/main/java/org/apache/camel/model/language/ExchangePropertyExpression.java new file mode 100644 index 0000000..f40bd8f --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/language/ExchangePropertyExpression.java @@ -0,0 +1,45 @@ +/** + * 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.model.language; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.camel.spi.Metadata; + +/** + * An expression which extracts the named exchange property + * + * @version + */ +@Metadata(label = "language") +@XmlRootElement(name = "exchangeProperty") +@XmlAccessorType(XmlAccessType.FIELD) +public class ExchangePropertyExpression extends ExpressionDefinition { + + public ExchangePropertyExpression() { + } + + public ExchangePropertyExpression(String expression) { + super(expression); + } + + public String getLanguage() { + return "exchangeProperty"; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/model/language/HeaderExpression.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/language/HeaderExpression.java b/camel-core/src/main/java/org/apache/camel/model/language/HeaderExpression.java index a23a9a1..14e52cd 100644 --- a/camel-core/src/main/java/org/apache/camel/model/language/HeaderExpression.java +++ b/camel-core/src/main/java/org/apache/camel/model/language/HeaderExpression.java @@ -23,7 +23,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.camel.spi.Metadata; /** - * An expression which extracts the named header + * An expression which extracts the named exchange header * * @version */ http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/model/language/PropertyExpression.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/language/PropertyExpression.java b/camel-core/src/main/java/org/apache/camel/model/language/PropertyExpression.java deleted file mode 100644 index 96a5cdd..0000000 --- a/camel-core/src/main/java/org/apache/camel/model/language/PropertyExpression.java +++ /dev/null @@ -1,45 +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.model.language; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; - -import org.apache.camel.spi.Metadata; - -/** - * An expression which extracts the named exchange property - * - * @version - */ -@Metadata(label = "language") -@XmlRootElement(name = "property") -@XmlAccessorType(XmlAccessType.FIELD) -public class PropertyExpression extends ExpressionDefinition { - - public PropertyExpression() { - } - - public PropertyExpression(String expression) { - super(expression); - } - - public String getLanguage() { - return "property"; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/java/org/apache/camel/util/URISupport.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/util/URISupport.java b/camel-core/src/main/java/org/apache/camel/util/URISupport.java index 894f2ab..48f59ef 100644 --- a/camel-core/src/main/java/org/apache/camel/util/URISupport.java +++ b/camel-core/src/main/java/org/apache/camel/util/URISupport.java @@ -454,6 +454,25 @@ public final class URISupport { } /** + * Appends the given parameters to the given URI. + * <p/> + * It keeps the original parameters and if a new parameter is already defined in + * {@code originalURI}, it will be replaced by its value in {@code newParameters}. + * + * @param originalURI the original URI + * @param newParameters the parameters to add + * @return the URI with all the parameters + * @throws URISyntaxException is thrown if the uri syntax is invalid + * @throws UnsupportedEncodingException is thrown if encoding error + */ + public static String appendParametersToURI(String originalURI, Map<String, Object> newParameters) throws URISyntaxException, UnsupportedEncodingException { + URI uri = new URI(normalizeUri(originalURI)); + Map<String, Object> parameters = parseParameters(uri); + parameters.putAll(newParameters); + return createRemainingURI(uri, parameters).toString(); + } + + /** * Normalizes the uri by reordering the parameters so they are sorted and thus * we can use the uris for endpoint matching. * <p/> http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/exchangeProperty ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/exchangeProperty b/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/exchangeProperty new file mode 100644 index 0000000..27c64b2 --- /dev/null +++ b/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/exchangeProperty @@ -0,0 +1,18 @@ +# +# 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. +# + +class=org.apache.camel.language.property.ExchangePropertyLanguage http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/property ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/property b/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/property deleted file mode 100644 index bba6172..0000000 --- a/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/property +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.language.property.PropertyLanguage http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/resources/org/apache/camel/model/config/jaxb.index ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/org/apache/camel/model/config/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/config/jaxb.index index f9db197..8bd139d 100644 --- a/camel-core/src/main/resources/org/apache/camel/model/config/jaxb.index +++ b/camel-core/src/main/resources/org/apache/camel/model/config/jaxb.index @@ -15,7 +15,5 @@ ## limitations under the License. ## ------------------------------------------------------------------------ BatchResequencerConfig -PropertiesDefinition -PropertyDefinition ResequencerConfig StreamResequencerConfig http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/resources/org/apache/camel/model/jaxb.index ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index index 7e47451..fc79da2 100644 --- a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index +++ b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index @@ -53,6 +53,8 @@ PipelineDefinition PolicyDefinition PollEnrichDefinition ProcessDefinition +PropertiesDefinition +PropertyDefinition RecipientListDefinition RedeliveryPolicyDefinition RemoveHeaderDefinition http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/main/resources/org/apache/camel/model/language/jaxb.index ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/org/apache/camel/model/language/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/language/jaxb.index index e6b574b..7be5bd8 100644 --- a/camel-core/src/main/resources/org/apache/camel/model/language/jaxb.index +++ b/camel-core/src/main/resources/org/apache/camel/model/language/jaxb.index @@ -16,6 +16,7 @@ ## ------------------------------------------------------------------------ ConstantExpression ELExpression +ExchangePropertyExpression ExpressionDefinition GroovyExpression HeaderExpression @@ -27,7 +28,6 @@ MethodCallExpression MvelExpression OgnlExpression PhpExpression -PropertyExpression PythonExpression RefExpression RubyExpression http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/test/java/org/apache/camel/language/PropertyTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/language/PropertyTest.java b/camel-core/src/test/java/org/apache/camel/language/PropertyTest.java index 0162bf3..1537eb1 100644 --- a/camel-core/src/test/java/org/apache/camel/language/PropertyTest.java +++ b/camel-core/src/test/java/org/apache/camel/language/PropertyTest.java @@ -18,7 +18,7 @@ package org.apache.camel.language; import org.apache.camel.Exchange; import org.apache.camel.LanguageTestSupport; -import org.apache.camel.language.property.PropertyLanguage; +import org.apache.camel.language.property.ExchangePropertyLanguage; public class PropertyTest extends LanguageTestSupport { @@ -35,7 +35,7 @@ public class PropertyTest extends LanguageTestSupport { } public void testSingleton() { - PropertyLanguage prop = new PropertyLanguage(); + ExchangePropertyLanguage prop = new ExchangePropertyLanguage(); assertTrue(prop.isSingleton()); } http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java b/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java index cdefcec..8f25f8b 100644 --- a/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java +++ b/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java @@ -48,12 +48,11 @@ public class URISupportTest extends ContextTestSupport { out1 = URISupport.normalizeUri("seda:foo?concurrentConsumer=2"); out2 = URISupport.normalizeUri("seda:foo"); assertNotSame(out1, out2); - + out1 = URISupport.normalizeUri("foo:?test=1"); out2 = URISupport.normalizeUri("foo://?test=1"); assertEquals("foo://?test=1", out2); assertEquals(out1, out2); - } public void testNormalizeEndpointUriNoParam() throws Exception { @@ -94,9 +93,9 @@ public class URISupportTest extends ContextTestSupport { assertEquals(out1, out2); assertTrue("Should have //", out1.startsWith("http://")); assertTrue("Should have //", out2.startsWith("http://")); - + } - + public void testNormalizeIPv6HttpEndpoint() throws Exception { String result = URISupport.normalizeUri("http://[2a00:8a00:6000:40::1413]:30300/test"); assertEquals("http://[2a00:8a00:6000:40::1413]:30300/test", result); @@ -219,13 +218,13 @@ public class URISupportTest extends ContextTestSupport { String expected = "jt400://GEORGE:xxxxxx@LIVERPOOL/QSYS.LIB/BEATLES.LIB/PENNYLANE.DTAQ"; assertEquals(expected, URISupport.sanitizeUri(uri)); } - + public void testSanitizePathWithUserInfo() { String path = "GEORGE:HARRISON@LIVERPOOL/QSYS.LIB/BEATLES.LIB/PENNYLANE.PGM"; String expected = "GEORGE:xxxxxx@LIVERPOOL/QSYS.LIB/BEATLES.LIB/PENNYLANE.PGM"; assertEquals(expected, URISupport.sanitizePath(path)); } - + public void testSanitizePathWithoutSensitiveInfoIsUnchanged() { String path = "myhost:8080/mypath"; assertEquals(path, URISupport.sanitizePath(path)); @@ -295,4 +294,13 @@ public class URISupportTest extends ContextTestSupport { assertEquals("somechat", map.get("serviceName")); } + public void testAppendParameterToUriAndReplaceExistingOne() throws Exception { + Map<String, Object> newParameters = new HashMap<String, Object>(); + newParameters.put("foo", "456"); + newParameters.put("bar", "yes"); + String newUri = URISupport.appendParametersToURI("stub:foo?foo=123", newParameters); + + assertEquals("stub://foo?foo=456&bar=yes", newUri); + } + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java ---------------------------------------------------------------------- diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java index 56f1fba..b8500cd 100644 --- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java +++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java @@ -48,12 +48,12 @@ import org.apache.camel.model.InterceptSendToEndpointDefinition; import org.apache.camel.model.OnCompletionDefinition; import org.apache.camel.model.OnExceptionDefinition; import org.apache.camel.model.PackageScanDefinition; +import org.apache.camel.model.PropertiesDefinition; import org.apache.camel.model.RestContextRefDefinition; import org.apache.camel.model.RouteBuilderDefinition; import org.apache.camel.model.RouteContextRefDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.ThreadPoolProfileDefinition; -import org.apache.camel.model.config.PropertiesDefinition; import org.apache.camel.model.dataformat.DataFormatsDefinition; import org.apache.camel.model.rest.RestConfigurationDefinition; import org.apache.camel.model.rest.RestDefinition; http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java ---------------------------------------------------------------------- diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java index 28d0e08..9d807cc 100644 --- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java +++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java @@ -53,6 +53,7 @@ import org.apache.camel.model.ModelCamelContext; import org.apache.camel.model.OnCompletionDefinition; import org.apache.camel.model.OnExceptionDefinition; import org.apache.camel.model.PackageScanDefinition; +import org.apache.camel.model.PropertiesDefinition; import org.apache.camel.model.RestContextRefDefinition; import org.apache.camel.model.RouteBuilderDefinition; import org.apache.camel.model.RouteContainer; @@ -60,7 +61,6 @@ import org.apache.camel.model.RouteContextRefDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.RouteDefinitionHelper; import org.apache.camel.model.ThreadPoolProfileDefinition; -import org.apache.camel.model.config.PropertiesDefinition; import org.apache.camel.model.dataformat.DataFormatsDefinition; import org.apache.camel.model.rest.RestConfigurationDefinition; import org.apache.camel.model.rest.RestContainer; http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java ---------------------------------------------------------------------- diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java index 3ab4540..8f445c5 100644 --- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java +++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java @@ -16,35 +16,44 @@ */ package org.apache.camel.core.xml; +import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlTransient; import org.apache.camel.Endpoint; import org.apache.camel.ExchangePattern; import org.apache.camel.NoSuchEndpointException; - -import static org.apache.camel.util.ObjectHelper.notNull; +import org.apache.camel.model.PropertyDefinition; +import org.apache.camel.util.URISupport; @XmlAccessorType(XmlAccessType.FIELD) public abstract class AbstractCamelEndpointFactoryBean extends AbstractCamelFactoryBean<Endpoint> { @XmlAttribute(required = false) @Deprecated private Boolean singleton; - @XmlAttribute + @XmlAttribute(required = true) private String uri; @XmlAttribute + @Deprecated private ExchangePattern pattern; + @XmlElement(name = "property") + private List<PropertyDefinition> properties; @XmlTransient private Endpoint endpoint; public Endpoint getObject() throws Exception { if (endpoint == null || !endpoint.isSingleton()) { - notNull(uri, "uri"); - endpoint = getCamelContext().getEndpoint(uri); + String target = createUri(); + endpoint = getCamelContext().getEndpoint(target); if (endpoint == null) { - throw new NoSuchEndpointException(uri); + throw new NoSuchEndpointException(target); } } return endpoint; @@ -54,24 +63,64 @@ public abstract class AbstractCamelEndpointFactoryBean extends AbstractCamelFact return Endpoint.class; } + @Deprecated + public Boolean getSingleton() { + return singleton; + } + + @Deprecated + public void setSingleton(Boolean singleton) { + this.singleton = singleton; + } + public String getUri() { return uri; } /** - * Sets the URI to use to resolve the endpoint - * - * @param uri the URI used to set the endpoint + * Sets the URI to use to resolve the endpoint. + * <p/> + * Notice that additional options can be configured using a series of property. */ public void setUri(String uri) { this.uri = uri; } + @Deprecated public ExchangePattern getPattern() { return pattern; } + /** + * Sets the exchange pattern of the endpoint + * + * @deprecated set the pattern in the uri + */ public void setPattern(ExchangePattern pattern) { this.pattern = pattern; } + + public List<PropertyDefinition> getProperties() { + return properties; + } + + /** + * To configure additional endpoint options using a XML style which is similar as configuring Spring or Blueprint beans. + */ + public void setProperties(List<PropertyDefinition> properties) { + this.properties = properties; + } + + private String createUri() throws UnsupportedEncodingException, URISyntaxException { + if (properties == null || properties.isEmpty()) { + return uri; + } else { + Map<String, Object> map = new LinkedHashMap<String, Object>(); + for (PropertyDefinition property : properties) { + map.put(property.getKey(), property.getValue()); + } + return URISupport.appendParametersToURI(uri, map); + } + } + } http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java index 0a39e2a..ef02740 100644 --- a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java +++ b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java @@ -46,12 +46,12 @@ import org.apache.camel.model.InterceptSendToEndpointDefinition; import org.apache.camel.model.OnCompletionDefinition; import org.apache.camel.model.OnExceptionDefinition; import org.apache.camel.model.PackageScanDefinition; +import org.apache.camel.model.PropertiesDefinition; import org.apache.camel.model.RestContextRefDefinition; import org.apache.camel.model.RouteBuilderDefinition; import org.apache.camel.model.RouteContextRefDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.ThreadPoolProfileDefinition; -import org.apache.camel.model.config.PropertiesDefinition; import org.apache.camel.model.dataformat.DataFormatsDefinition; import org.apache.camel.model.rest.RestConfigurationDefinition; import org.apache.camel.model.rest.RestDefinition; http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringIdempotentConsumerNoSkipDuplicateFilterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringIdempotentConsumerNoSkipDuplicateFilterTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringIdempotentConsumerNoSkipDuplicateFilterTest.java index 37d34d4..4a7e84b 100644 --- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringIdempotentConsumerNoSkipDuplicateFilterTest.java +++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringIdempotentConsumerNoSkipDuplicateFilterTest.java @@ -39,7 +39,7 @@ public class SpringIdempotentConsumerNoSkipDuplicateFilterTest extends SpringTes mock.expectedBodiesReceived("one", "two", "three"); getMockEndpoint("mock:duplicate").expectedBodiesReceived("one", "two", "one"); - getMockEndpoint("mock:duplicate").allMessages().property(Exchange.DUPLICATE_MESSAGE).isEqualTo(Boolean.TRUE); + getMockEndpoint("mock:duplicate").allMessages().exchangeProperty(Exchange.DUPLICATE_MESSAGE).isEqualTo(Boolean.TRUE); sendMessage("1", "one"); sendMessage("2", "two"); http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringIdempotentConsumerNoSkipDuplicateFilterTest.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringIdempotentConsumerNoSkipDuplicateFilterTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringIdempotentConsumerNoSkipDuplicateFilterTest.xml index 3506828..24d1445 100644 --- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringIdempotentConsumerNoSkipDuplicateFilterTest.xml +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringIdempotentConsumerNoSkipDuplicateFilterTest.xml @@ -37,7 +37,7 @@ <!-- we will to handle duplicate messages using a filter --> <filter> <!-- the filter will only react on duplicate messages, if this property is set on the Exchange --> - <property>CamelDuplicateMessage</property> + <exchangeProperty>CamelDuplicateMessage</exchangeProperty> <!-- and send the message to this mock, due its part of an unit test --> <!-- but you can of course do anything as its part of the route --> <to uri="mock:duplicate"/> http://git-wip-us.apache.org/repos/asf/camel/blob/07691e98/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithStringDelimitedProperty.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithStringDelimitedProperty.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithStringDelimitedProperty.xml index 0714725..1491860 100644 --- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithStringDelimitedProperty.xml +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithStringDelimitedProperty.xml @@ -30,7 +30,7 @@ <route> <from uri="direct:a" /> <recipientList> - <property>myProperty</property> + <exchangeProperty>myProperty</exchangeProperty> </recipientList> </route> <!-- END SNIPPET: e1 -->
