Java 类org.apache.camel.model.language.ExpressionDefinition 实例源码

项目:Camel    文件:ExpressionNode.java   
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;
    }
}
项目:Camel    文件:ThrottleDefinition.java   
private Expression createMaxRequestsPerPeriodExpression(RouteContext routeContext) {
    ExpressionDefinition expr = getExpression();
    if (expr != null) {
        return expr.createExpression(routeContext);
    }
    return null;
}
项目:Camel    文件:DelayDefinition.java   
private Expression createAbsoluteTimeDelayExpression(RouteContext routeContext) {
    ExpressionDefinition expr = getExpression();
    if (expr != null) {
        return expr.createExpression(routeContext);
    }
    return null;
}
项目:Camel    文件:ExpressionSubElementDefinition.java   
public Expression createExpression(RouteContext routeContext) {
    ExpressionDefinition expressionType = getExpressionType();
    if (expressionType != null && expression == null) {
        expression = expressionType.createExpression(routeContext);
    }
    return expression;
}
项目:Camel    文件:ExpressionSubElementDefinition.java   
public Predicate createPredicate(RouteContext routeContext) {
    ExpressionDefinition expressionType = getExpressionType();
    if (expressionType != null && getPredicate() == null) {
        setPredicate(expressionType.createPredicate(routeContext));
    }
    return getPredicate();
}
项目:Camel    文件:AggregateDefinition.java   
public AggregateDefinition(ExpressionDefinition correlationExpression) {
    setExpression(correlationExpression);

    ExpressionSubElementDefinition cor = new ExpressionSubElementDefinition();
    cor.setExpressionType(correlationExpression);
    setCorrelationExpression(cor);
}
项目:Camel    文件:CamelNamespaceHandler.java   
private void findLanguage(ExpressionDefinition expression, Set<String> languages) {
    if (expression != null) {
        String lang = expression.getLanguage();
        if (lang != null && lang.length() > 0) {
            languages.add(lang);
        }
    }
}
项目:ipf-flow-manager    文件:DedupeDefinition.java   
@Override
public FilterProcessor createProcessor(RouteContext routeContext) throws Exception {
    setExpression(new ExpressionDefinition(createDedupe(routeContext)));
    return super.createProcessor(routeContext);
}
项目:fabric8-forge    文件:CamelEditNodeXmlCommand.java   
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);
        }
    }
}
项目:fabric8-forge    文件:Expressions.java   
public static String getExpressionOrElse(ExpressionDefinition exp) {
    return getExpressionOrElse(exp, "");
}
项目:fabric8-forge    文件:Expressions.java   
public static String getExpressionOrElse(ExpressionDefinition exp, String defaultValue) {
    if (exp != null) {
        return Strings2.getOrElse(exp.getExpression(), defaultValue).trim();
    }
    return defaultValue;
}
项目:Camel    文件:SortDefinition.java   
/**
 * 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);
}
项目:Camel    文件:ExpressionNode.java   
public ExpressionNode(ExpressionDefinition expression) {
    this.expression = expression;
}
项目:Camel    文件:ExpressionNode.java   
public ExpressionDefinition getExpression() {
    return expression;
}
项目:Camel    文件:ValidateDefinition.java   
/**
 * 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);
}
项目:Camel    文件:WhenDefinition.java   
public WhenDefinition(ExpressionDefinition expression) {
    super(expression);
}
项目:Camel    文件:WhenDefinition.java   
/**
 * 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);
}
项目:Camel    文件:ThrottleDefinition.java   
/**
 * 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);
}
项目:Camel    文件:SplitDefinition.java   
public SplitDefinition(ExpressionDefinition expression) {
    super(expression);
}
项目:Camel    文件:SplitDefinition.java   
/**
 * 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);
}
项目:Camel    文件:DelayDefinition.java   
/**
 * 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);
}
项目:Camel    文件:PollEnrichDefinition.java   
/**
 * 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);
}
项目:Camel    文件:SetHeaderDefinition.java   
public SetHeaderDefinition(String headerName, ExpressionDefinition expression) {
    super(expression);
    setHeaderName(headerName);
}
项目:Camel    文件:SetHeaderDefinition.java   
/**
 * 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);
}
项目:Camel    文件:EnrichDefinition.java   
/**
 * 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);
}
项目:Camel    文件:StickyLoadBalancerDefinition.java   
public void setCorrelationExpression(Expression expression) {
    ExpressionDefinition def = ExpressionNodeHelper.toExpressionDefinition(expression);
    this.correlationExpression = new ExpressionSubElementDefinition();
    this.correlationExpression.setExpressionType(def);
}
项目:Camel    文件:SetOutHeaderDefinition.java   
public SetOutHeaderDefinition(String headerName, ExpressionDefinition expression) {
    super(expression);
    setHeaderName(headerName);
}
项目:Camel    文件:SetOutHeaderDefinition.java   
/**
 * 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);
}
项目:Camel    文件:WhenSkipSendToEndpointDefinition.java   
/**
 * 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);
}
项目:Camel    文件:SetFaultBodyDefinition.java   
/**
 * Expression that returns the new fault body to use
 */
@Override
public void setExpression(ExpressionDefinition expression) {
    super.setExpression(expression);
}
项目:Camel    文件:ExpressionSubElementDefinition.java   
public ExpressionDefinition getExpressionType() {
    return expressionType;
}
项目:Camel    文件:ExpressionSubElementDefinition.java   
public void setExpressionType(ExpressionDefinition expressionType) {
    this.expressionType = expressionType;
}
项目:Camel    文件:FilterDefinition.java   
public FilterDefinition(ExpressionDefinition expression) {
    super(expression);
}
项目:Camel    文件:FilterDefinition.java   
/**
 * 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);
}
项目:Camel    文件:ProcessorDefinition.java   
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);
}
项目:Camel    文件:NoOutputExpressionNode.java   
public NoOutputExpressionNode(ExpressionDefinition expression) {
    super(expression);
}
项目:Camel    文件:AggregateDefinition.java   
public ExpressionDefinition getExpression() {
    if (expression == null && correlationExpression != null) {
        expression = correlationExpression.getExpressionType();            
    }
    return expression;
}
项目:Camel    文件:AggregateDefinition.java   
public void setExpression(ExpressionDefinition expression) {
    this.expression = expression;
}
项目:Camel    文件:ResequenceDefinition.java   
public ExpressionDefinition getExpression() {
    return expression;
}
项目:Camel    文件:ResequenceDefinition.java   
/**
 * Expression to use for re-ordering the messages, such as a header with a sequence number
 */
public void setExpression(ExpressionDefinition expression) {
    this.expression = expression;
}