Package org.apache.camel.spi

Examples of org.apache.camel.spi.Language.createExpression()


     * given value on a specific exchange
     */
    protected void assertExpression(Exchange exchange, String languageName, String expressionText, Object expectedValue) {
        Language language = assertResolveLanguage(languageName);

        Expression expression = language.createExpression(expressionText);
        assertNotNull("No Expression could be created for text: " + expressionText + " language: " + language, expression);

        assertExpression(expression, exchange, expectedValue);
    }

View Full Code Here


    protected void assertExpressionResultInstanceOf(String expressionText, Class<?> expectedType) {
        // TODO [hz]: we should refactor TestSupport.assertExpression(Expression, Exchange, Object)
        // into 2 methods, a helper that returns the value and use that helper in assertExpression
        // Then use the helper here to get the value and move this method to LanguageTestSupport
        Language language = assertResolveLanguage(getLanguageName());
        Expression expression = language.createExpression(expressionText);
        assertNotNull("Cannot assert type when no type is provided", expectedType);
        assertNotNull("No Expression could be created for text: " + expressionText + " language: " + language, expression);
        Object answer = expression.evaluate(exchange, Object.class);
        assertIsInstanceOf(Animal.class, answer);
    }
View Full Code Here

        if (expression.contains("$")) {
            language = getCamelContext().resolveLanguage("file");
        } else {
            language = getCamelContext().resolveLanguage("constant");
        }
        return language.createExpression(expression);
    }

    /**
     * Creates the associated name of the done file based on the given file name.
     * <p/>
 
View Full Code Here

            // the header name can be an expression too, that should override
            // whatever configured on the endpoint
            if (SimpleLanguage.hasStartToken(name)) {
                log.trace("{} contains a Simple expression: {}", Exchange.FILE_NAME, name);
                Language language = getEndpoint().getCamelContext().resolveLanguage("file");
                expression = language.createExpression(name);
            }
        }
        if (expression != null) {
            log.trace("Filename evaluated as expression: {}", expression);
            name = expression.evaluate(exchange, String.class);
View Full Code Here

            if (name.indexOf("${") > -1) {
                if (log.isDebugEnabled()) {
                    log.debug(Exchange.FILE_NAME + " contains a FileLanguage expression: " + name);
                }
                Language language = getEndpoint().getCamelContext().resolveLanguage("file");
                expression = language.createExpression(name);
            }
        }
        if (expression != null) {
            if (log.isDebugEnabled()) {
                log.debug("Filename evaluated as expression: " + expression);
View Full Code Here

            if (SimpleLanguage.hasStartToken(name)) {
                if (log.isDebugEnabled()) {
                    log.debug(Exchange.FILE_NAME + " contains a Simple expression: " + name);
                }
                Language language = getEndpoint().getCamelContext().resolveLanguage("file");
                expression = language.createExpression(name);
            }
        }
        if (expression != null) {
            if (log.isDebugEnabled()) {
                log.debug("Filename evaluated as expression: " + expression);
View Full Code Here

        if (expression.contains("$")) {
            language = getCamelContext().resolveLanguage("file");
        } else {
            language = getCamelContext().resolveLanguage("constant");
        }
        return language.createExpression(expression);
    }

    /**
     * Creates the associated name of the done file based on the given file name.
     * <p/>
 
View Full Code Here

            // default strategy will move files in a .camel/ subfolder where the file was consumed
            GenericFileRenameProcessStrategy<File> strategy = new GenericFileRenameProcessStrategy<File>();
            strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
            // use context to lookup language to let it be loose coupled
            Language language = context.resolveLanguage("file");
            Expression expression = language.createExpression("${file:parent}/.camel/${file:onlyname}");
            strategy.setCommitRenamer(new GenericFileExpressionRenamer<File>(expression));
            return strategy;
        }
    }
View Full Code Here

        return params;
    }

    private Expression createFileLangugeExpression(String expression) {
        Language language = getCamelContext().resolveLanguage("file");
        return language.createExpression(expression);
    }
}
View Full Code Here

            public Object evaluate(Exchange exchange) {
                // resolve language using context to have a clear separation of packages
                // must call evalute to return the nested langauge evaluate when evaluating
                // stacked expressions
                Language language = exchange.getContext().resolveLanguage("simple");
                return language.createExpression(expression).evaluate(exchange, Object.class);
            }

            @Override
            public String toString() {
                return "simple(" + expression + ")";
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.