Java 类org.apache.camel.builder.SimpleBuilder 实例源码

项目:Camel    文件:SimpleExpression.java   
@Override
public Expression createExpression(CamelContext camelContext) {
    if (resultType == null && resultTypeName != null) {
        try {
            resultType = camelContext.getClassResolver().resolveMandatoryClass(resultTypeName);
        } catch (ClassNotFoundException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }
    }

    String exp = getExpression();
    // should be true by default
    boolean isTrim = getTrim() == null || getTrim();
    if (exp != null && isTrim) {
        exp = exp.trim();
    }

    SimpleBuilder answer = new SimpleBuilder(exp);
    answer.setResultType(resultType);
    return answer;
}
项目:Camel    文件:SimpleWithPropertiesTest.java   
/**
 * A property from the property component in a expression 
 * is processed when the expression is evaluated with exchange
 * See https://issues.apache.org/jira/browse/CAMEL-4843
 * Now camel doesn't support the properties expression of {{test}}
 */
@Test
public void testProperty() throws Exception {
    System.setProperty("test", "testValue");
    PropertiesComponent pc = new PropertiesComponent();
    CamelContext context = new DefaultCamelContext();
    context.addComponent("properties", pc);

    // try to setup the property
    Exchange exchange = new DefaultExchange(context);
    String result = SimpleBuilder.simple("${properties:test}").evaluate(exchange, String.class);
    Assert.assertEquals("testValue", result);
    System.clearProperty("test");
}
项目:camelinaction2    文件:MyProcessor.java   
public void process(Exchange exchange) throws Exception {
    SimpleBuilder simple = new SimpleBuilder(
                                   "${body} contains 'Camel'");
    if (!simple.matches(exchange)) {
        throw new Exception("This is NOT a Camel message");
    }
}
项目:camel-cookbook-examples    文件:MockReplyRouteTest.java   
@Test
public void testReplyingFromMockByExpression() throws InterruptedException {
    mockReplying.returnReplyBody(SimpleBuilder.simple("Hello ${body}"));
    mockOut.expectedBodiesReceived("Hello Camel");

    in.sendBody("Camel");

    assertMockEndpointsSatisfied();
}
项目:camel-cookbook-examples    文件:SimplePredicateWrapper.java   
public void setSimplePredicate(String expression) {
    this.predicate = SimpleBuilder.simple(expression, Boolean.class);
}
项目:morc    文件:MorcMethods.java   
/**
 * @param expression A regular expression to evaluate against the message body
 */
default Predicate regex(String expression) {
    return new SimpleBuilder("${body} regex '" + expression + "'");
}