You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2021/02/20 11:25:16 UTC
[camel] branch master updated: core: improve expression definition
to ease the integration with DSLs
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 693a058 core: improve expression definition to ease the integration with DSLs
693a058 is described below
commit 693a058400ed2aa0dc6748cf79e31ec90e1a1ffe
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Sat Feb 20 09:43:20 2021 +0100
core: improve expression definition to ease the integration with DSLs
---
.../model/ExpressionSubElementDefinition.java | 8 +++++-
.../org/apache/camel/model/HasExpressionType.java | 29 ++++++++++++++++++++++
.../camel/model/language/ExpressionDefinition.java | 22 +++++++++-------
3 files changed, 49 insertions(+), 10 deletions(-)
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/ExpressionSubElementDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/ExpressionSubElementDefinition.java
index 3bb97af..85c21ca 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/ExpressionSubElementDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/ExpressionSubElementDefinition.java
@@ -30,13 +30,17 @@ import org.apache.camel.model.language.ExpressionDefinition;
*/
@XmlRootElement(name = "expression") // must be named expression
@XmlAccessorType(XmlAccessType.FIELD)
-public class ExpressionSubElementDefinition {
+public class ExpressionSubElementDefinition implements HasExpressionType {
@XmlElementRef
private ExpressionDefinition expressionType;
public ExpressionSubElementDefinition() {
}
+ public ExpressionSubElementDefinition(ExpressionDefinition expressionType) {
+ this.expressionType = expressionType;
+ }
+
public ExpressionSubElementDefinition(Expression expression) {
this.expressionType = new ExpressionDefinition(expression);
}
@@ -45,10 +49,12 @@ public class ExpressionSubElementDefinition {
this.expressionType = new ExpressionDefinition(predicate);
}
+ @Override
public ExpressionDefinition getExpressionType() {
return expressionType;
}
+ @Override
public void setExpressionType(ExpressionDefinition expressionType) {
this.expressionType = expressionType;
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/HasExpressionType.java b/core/camel-core-model/src/main/java/org/apache/camel/model/HasExpressionType.java
new file mode 100644
index 0000000..39a8a9c
--- /dev/null
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/HasExpressionType.java
@@ -0,0 +1,29 @@
+/*
+ * 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 org.apache.camel.model.language.ExpressionDefinition;
+
+/**
+ * Marker interface to mark a {@link ProcessorDefinition} that supports expressions.
+ */
+public interface HasExpressionType {
+
+ ExpressionDefinition getExpressionType();
+
+ void setExpressionType(ExpressionDefinition expressionType);
+}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
index cc84a74..c22db57 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
@@ -34,6 +34,7 @@ import org.apache.camel.Expression;
import org.apache.camel.ExpressionFactory;
import org.apache.camel.Predicate;
import org.apache.camel.PredicateFactory;
+import org.apache.camel.model.HasExpressionType;
import org.apache.camel.model.ModelCamelContext;
import org.apache.camel.spi.ExpressionFactoryAware;
import org.apache.camel.spi.Metadata;
@@ -49,7 +50,8 @@ import org.apache.camel.util.ObjectHelper;
@XmlAccessorType(XmlAccessType.FIELD)
@SuppressWarnings("rawtypes")
public class ExpressionDefinition
- implements Expression, Predicate, ExpressionFactory, ExpressionFactoryAware, PredicateFactory, PredicateFactoryAware {
+ implements Expression, Predicate, ExpressionFactory, ExpressionFactoryAware, PredicateFactory, PredicateFactoryAware,
+ HasExpressionType {
@XmlAttribute
@XmlID
private String id;
@@ -149,10 +151,20 @@ public class ExpressionDefinition
this.expressionValue = expressionValue;
}
+ @Override
public ExpressionDefinition getExpressionType() {
return expressionType;
}
+ /**
+ * Allows derived classes and DSLs to set a lazily created expressionType instance such as if using the
+ * {@link org.apache.camel.builder.ExpressionClause}
+ */
+ @Override
+ public void setExpressionType(ExpressionDefinition expressionType) {
+ this.expressionType = expressionType;
+ }
+
public String getTrim() {
return trim;
}
@@ -181,14 +193,6 @@ public class ExpressionDefinition
return exp != null ? exp : "";
}
- /**
- * Allows derived classes to set a lazily created expressionType instance such as if using the
- * {@link org.apache.camel.builder.ExpressionClause}
- */
- protected void setExpressionType(ExpressionDefinition expressionType) {
- this.expressionType = expressionType;
- }
-
//
// ExpressionFactory
//