I am developing a simple processor to verify the existence of mandatory properties in a route. I need to add that list on the route definition before calling the processor.
<route id="test1">
<from uri="/v1/test1" />
<setProperty propertyName="mandatoryProperties">
<simple resultType="java.util.List">${[A,B,C]}</simple>
</setProperty>
<bean ref="propertiesProcessor" />
</route>
My Processor is:
@Component
public class MandatoryPropertiesProcessor {
@Handler
public void process(final Exchange exchange, final @Properties Map properties, final @ExchangeProperty("mandatoryProperties") List<String> mandatoryProperties) {
List<String> missingPropertiesList = new ArrayList<>();
if (!CollectionUtils.isEmpty(mandatoryProperties)) {
for (String mandatoryProperty : mandatoryProperties) {
if (!properties.containsKey(mandatoryProperty)) {
missingPropertiesList.add(mandatoryProperty);
}
}
}
exchange.setProperty(MISSING_PROPERTIES, missingPropertiesList);
}
}
when i try to call this route i get:
Caused by: org.apache.camel.language.simple.types.SimpleParserException: Unknown function: ["A","B","C"]
at org.apache.camel.language.simple.ast.SimpleFunctionExpression.createSimpleExpression(SimpleFunctionExpression.java:216)
at org.apache.camel.language.simple.ast.SimpleFunctionExpression.createExpression(SimpleFunctionExpression.java:40)
at org.apache.camel.language.simple.ast.SimpleFunctionStart.doCreateLiteralExpression(SimpleFunctionStart.java:58)
at org.apache.camel.language.simple.ast.SimpleFunctionStart.createExpression(SimpleFunctionStart.java:48)
at org.apache.camel.language.simple.SimpleExpressionParser.createExpressions(SimpleExpressionParser.java:163)
at org.apache.camel.language.simple.SimpleExpressionParser.doParseExpression(SimpleExpressionParser.java:86)
at org.apache.camel.language.simple.SimpleExpressionParser.parseExpression(SimpleExpressionParser.java:53)
Is possible to achieve this in XML?