Java 类org.apache.camel.language.LanguageAnnotation 实例源码

项目:Camel    文件:XPathAnnotationExpressionFactory.java   
@Override
public Expression createExpression(CamelContext camelContext, Annotation annotation, LanguageAnnotation languageAnnotation, Class<?> expressionReturnType) {
    String xpath = getExpressionFromAnnotation(annotation);

    Class<?> resultType = getResultType(annotation);
    if (resultType.equals(Object.class)) {
        resultType = expressionReturnType;
    }

    XPathBuilder builder = XPathBuilder.xpath(xpath, resultType);        
    NamespacePrefix[] namespaces = getExpressionNameSpacePrefix(annotation);
    if (namespaces != null) {
        for (NamespacePrefix namespacePrefix : namespaces) {
            builder = builder.namespace(namespacePrefix.prefix(), namespacePrefix.uri());
        }
    }

    // Set the header name that we want the XPathBuilder to apply the XPath expression to
    String headerName = getHeaderName(annotation);
    if (ObjectHelper.isNotEmpty(headerName)) {
        builder.setHeaderName(headerName);
    }

    return builder;
}
项目:Camel    文件:JsonPathAnnotationExpressionFactory.java   
@Override
public Expression createExpression(CamelContext camelContext, Annotation annotation,
                                   LanguageAnnotation languageAnnotation, Class<?> expressionReturnType) {

    String expression = getExpressionFromAnnotation(annotation);
    JsonPathExpression answer = new JsonPathExpression(expression);

    if (expressionReturnType != null) {
        answer.setResultType(expressionReturnType);
    }

    if (annotation instanceof JsonPath) {
        JsonPath jsonPathAnnotation = (JsonPath) annotation;

        answer.setSuppressExceptions(jsonPathAnnotation.suppressExceptions());

        Option[] options = jsonPathAnnotation.options();
        answer.setOptions(options);
    }

    answer.init();
    return answer;
}
项目:Camel    文件:BeanAnnotationExpressionFactory.java   
@Override
public Expression createExpression(CamelContext camelContext, Annotation annotation, LanguageAnnotation languageAnnotation, Class<?> expressionReturnType) {
    String beanName = getFromAnnotation(annotation, "ref");
    String method = getFromAnnotation(annotation, "method");

    // ref is mandatory
    ObjectHelper.notEmpty(beanName, "ref", annotation);

    // method is optional but provide it as null to the bean expression
    if (ObjectHelper.isEmpty(method)) {
        method = null;
    }

    return new BeanExpression(beanName, method);
}
项目:Camel    文件:XQueryAnnotationExpressionFactory.java   
@Override
public Expression createExpression(CamelContext camelContext, Annotation annotation,
                                   LanguageAnnotation languageAnnotation, Class<?> expressionReturnType) {
    String xQuery = getExpressionFromAnnotation(annotation);
    XQueryBuilder builder = XQueryBuilder.xquery(xQuery);
    if (annotation instanceof XQuery) {
        XQuery xQueryAnnotation = (XQuery)annotation;
        builder.setStripsAllWhiteSpace(xQueryAnnotation.stripsAllWhiteSpace());
        if (ObjectHelper.isNotEmpty(xQueryAnnotation.headerName())) {
            builder.setHeaderName(xQueryAnnotation.headerName());
        }
        NamespacePrefix[] namespaces = xQueryAnnotation.namespaces();
        if (namespaces != null) {
            for (NamespacePrefix namespacePrefix : namespaces) {
                builder = builder.namespace(namespacePrefix.prefix(), namespacePrefix.uri());
            }
        }
    }
    if (expressionReturnType.isAssignableFrom(String.class)) {
        builder.setResultsFormat(ResultFormat.String);
    } else if (expressionReturnType.isAssignableFrom(Collection.class)) {
        builder.setResultsFormat(ResultFormat.List);
    } else if (expressionReturnType.isAssignableFrom(Node.class)) {
        builder.setResultsFormat(ResultFormat.DOM);
    } else if (expressionReturnType.isAssignableFrom(byte[].class)) {
        builder.setResultsFormat(ResultFormat.Bytes);
    }
    return builder;
}
项目:Camel    文件:AnnotationExpressionFactory.java   
Expression createExpression(CamelContext camelContext, Annotation annotation, LanguageAnnotation languageAnnotation, Class<?> expressionReturnType);