public void setExpression(ExpressionDefinition expression) { // favour using the helper to set the expression as it can unwrap some unwanted builders when using Java DSL if (expression instanceof Expression) { this.expression = ExpressionNodeHelper.toExpressionDefinition((Expression) expression); } else if (expression instanceof Predicate) { this.expression = ExpressionNodeHelper.toExpressionDefinition((Predicate) expression); } else { this.expression = expression; } }
private Expression createMaxRequestsPerPeriodExpression(RouteContext routeContext) { ExpressionDefinition expr = getExpression(); if (expr != null) { return expr.createExpression(routeContext); } return null; }
private Expression createAbsoluteTimeDelayExpression(RouteContext routeContext) { ExpressionDefinition expr = getExpression(); if (expr != null) { return expr.createExpression(routeContext); } return null; }
public Expression createExpression(RouteContext routeContext) { ExpressionDefinition expressionType = getExpressionType(); if (expressionType != null && expression == null) { expression = expressionType.createExpression(routeContext); } return expression; }
public Predicate createPredicate(RouteContext routeContext) { ExpressionDefinition expressionType = getExpressionType(); if (expressionType != null && getPredicate() == null) { setPredicate(expressionType.createPredicate(routeContext)); } return getPredicate(); }
public AggregateDefinition(ExpressionDefinition correlationExpression) { setExpression(correlationExpression); ExpressionSubElementDefinition cor = new ExpressionSubElementDefinition(); cor.setExpressionType(correlationExpression); setCorrelationExpression(cor); }
private void findLanguage(ExpressionDefinition expression, Set<String> languages) { if (expression != null) { String lang = expression.getLanguage(); if (lang != null && lang.length() > 0) { languages.add(lang); } } }
@Override public FilterProcessor createProcessor(RouteContext routeContext) throws Exception { setExpression(new ExpressionDefinition(createDedupe(routeContext))); return super.createProcessor(routeContext); }
private void expressionOptions(String k, ExpressionDefinition exp, Map<String, String> options) { // special for aggregate as it has naming clash if ("completionSizeExpression".equals(k)) { k = "completionSize"; } else if ("completionTimeoutExpression".equals(k)) { k = "completionTimeout"; } String text = exp.getExpression(); String lan = exp.getLanguage(); options.put(k, lan); if (text != null) { options.put(k + "_value", text); } // when using a language as an expression it can contain additional options which we // cannot build a nice UI in forge as forge is not that dynamic. So instead we have an extra // input field where we allow users to edit the values using a Camel multivalue uri style with // key=value&key2=value2 ... CollectionStringBuffer csb = new CollectionStringBuffer("&"); String json = getCamelCatalog().languageJSonSchema(lan); if (json != null) { List<Map<String, String>> data = JSonSchemaHelper.parseJsonSchema("properties", json, true); if (data != null) { for (Map<String, String> map : data) { String name = map.get("name"); // skip expression/id as we are not interested in those if (name != null && !"id".equals(name) && !"expression".equals(name)) { try { Object value = IntrospectionSupport.getProperty(exp, name); if (value != null) { text = value.toString(); csb.append(name + "=" + text); } } catch (Exception e) { // ignore } } } } if (!csb.isEmpty()) { String extra = csb.toString(); options.put(k + "_extra", extra); } } }
public static String getExpressionOrElse(ExpressionDefinition exp) { return getExpressionOrElse(exp, ""); }
public static String getExpressionOrElse(ExpressionDefinition exp, String defaultValue) { if (exp != null) { return Strings2.getOrElse(exp.getExpression(), defaultValue).trim(); } return defaultValue; }
/** * Optional expression to sort by something else than the message body */ @Override public void setExpression(ExpressionDefinition expression) { // override to include javadoc what the expression is used for super.setExpression(expression); }
public ExpressionNode(ExpressionDefinition expression) { this.expression = expression; }
public ExpressionDefinition getExpression() { return expression; }
/** * Expression to use for validation as a predicate. The expression should return either <tt>true</tt> or <tt>false</tt>. * If returning <tt>false</tt> the message is invalid and an exception is thrown. */ @Override public void setExpression(ExpressionDefinition expression) { // override to include javadoc what the expression is used for super.setExpression(expression); }
public WhenDefinition(ExpressionDefinition expression) { super(expression); }
/** * Expression used as the predicate to evaluate whether this when should trigger and route the message or not. */ @Override public void setExpression(ExpressionDefinition expression) { // override to include javadoc what the expression is used for super.setExpression(expression); }
/** * Expression to configure the maximum number of messages to throttle per request */ @Override public void setExpression(ExpressionDefinition expression) { // override to include javadoc what the expression is used for super.setExpression(expression); }
public SplitDefinition(ExpressionDefinition expression) { super(expression); }
/** * Expression of how to split the message body, such as as-is, using a tokenizer, or using an xpath. */ @Override public void setExpression(ExpressionDefinition expression) { // override to include javadoc what the expression is used for super.setExpression(expression); }
/** * Expression to define how long time to wait (in millis) */ @Override public void setExpression(ExpressionDefinition expression) { // override to include javadoc what the expression is used for super.setExpression(expression); }
/** * Expression that computes the endpoint uri to use as the resource endpoint to enrich from */ @Override public void setExpression(ExpressionDefinition expression) { // override to include javadoc what the expression is used for super.setExpression(expression); }
public SetHeaderDefinition(String headerName, ExpressionDefinition expression) { super(expression); setHeaderName(headerName); }
/** * Expression to return the value of the header */ @Override public void setExpression(ExpressionDefinition expression) { // override to include javadoc what the expression is used for super.setExpression(expression); }
public void setCorrelationExpression(Expression expression) { ExpressionDefinition def = ExpressionNodeHelper.toExpressionDefinition(expression); this.correlationExpression = new ExpressionSubElementDefinition(); this.correlationExpression.setExpressionType(def); }
public SetOutHeaderDefinition(String headerName, ExpressionDefinition expression) { super(expression); setHeaderName(headerName); }
/** * Expression used as the predicate to evaluate whether the message should be sent or not to the endpoint */ @Override public void setExpression(ExpressionDefinition expression) { // override to include javadoc what the expression is used for super.setExpression(expression); }
/** * Expression that returns the new fault body to use */ @Override public void setExpression(ExpressionDefinition expression) { super.setExpression(expression); }
public ExpressionDefinition getExpressionType() { return expressionType; }
public void setExpressionType(ExpressionDefinition expressionType) { this.expressionType = expressionType; }
public FilterDefinition(ExpressionDefinition expression) { super(expression); }
/** * Expression to determine if the message should be filtered or not. If the expression returns an empty value or <tt>false</tt> * then the message is filtered (dropped), otherwise the message is continued being routed. */ @Override public void setExpression(ExpressionDefinition expression) { // override to include javadoc what the expression is used for super.setExpression(expression); }
private Processor makeProcessorImpl(RouteContext routeContext) throws Exception { Processor processor = null; // allow any custom logic before we create the processor preCreateProcessor(); // resolve properties before we create the processor ProcessorDefinitionHelper.resolvePropertyPlaceholders(routeContext.getCamelContext(), this); // resolve constant fields (eg Exchange.FILE_NAME) ProcessorDefinitionHelper.resolveKnownConstantFields(this); // also resolve properties and constant fields on embedded expressions ProcessorDefinition<?> me = (ProcessorDefinition<?>) this; if (me instanceof ExpressionNode) { ExpressionNode exp = (ExpressionNode) me; ExpressionDefinition expressionDefinition = exp.getExpression(); if (expressionDefinition != null) { // resolve properties before we create the processor ProcessorDefinitionHelper.resolvePropertyPlaceholders(routeContext.getCamelContext(), expressionDefinition); // resolve constant fields (eg Exchange.FILE_NAME) ProcessorDefinitionHelper.resolveKnownConstantFields(expressionDefinition); } } // at first use custom factory if (routeContext.getCamelContext().getProcessorFactory() != null) { processor = routeContext.getCamelContext().getProcessorFactory().createProcessor(routeContext, this); } // fallback to default implementation if factory did not create the processor if (processor == null) { processor = createProcessor(routeContext); } // inject id if (processor instanceof IdAware) { String id = this.idOrCreate(routeContext.getCamelContext().getNodeIdFactory()); ((IdAware) processor).setId(id); } if (processor == null) { // no processor to make return null; } return wrapProcessor(routeContext, processor); }
public NoOutputExpressionNode(ExpressionDefinition expression) { super(expression); }
public ExpressionDefinition getExpression() { if (expression == null && correlationExpression != null) { expression = correlationExpression.getExpressionType(); } return expression; }
public void setExpression(ExpressionDefinition expression) { this.expression = expression; }
/** * Expression to use for re-ordering the messages, such as a header with a sequence number */ public void setExpression(ExpressionDefinition expression) { this.expression = expression; }