• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java NamespacePrefix类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.camel.language.NamespacePrefix的典型用法代码示例。如果您正苦于以下问题:Java NamespacePrefix类的具体用法?Java NamespacePrefix怎么用?Java NamespacePrefix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

NamespacePrefix类属于org.apache.camel.language包,在下文中一共展示了NamespacePrefix类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createExpression

点赞 3

import org.apache.camel.language.NamespacePrefix; //导入依赖的package包/类
@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;
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:26,
代码来源:XPathAnnotationExpressionFactory.java

示例2: getRegion

点赞 2

import org.apache.camel.language.NamespacePrefix; //导入依赖的package包/类
/**
 * Get the region code that corresponds to the given country code.
 *
 * This method can be used as a plain Java method. However, when it is used inside a Camel route, the @XPath annotation will
 * evaluate the XPath expression and use the result as the method parameter. In this case, it will fetch the country code
 * from the order XML message. So, the method will determine the region code for the country that is in the XML message.
 *
 * @param country the country code
 * @return the region code
 */
public String getRegion(@XPath(value = "/order:order/order:customer/order:country",
    namespaces = @NamespacePrefix(prefix = "order", uri = "http://org.jboss.fuse.quickstarts/examples/order/v7")) String country) {
    if (country.equals("AU")) {
        return APAC;
    } else if (country.equals("US")) {
        return AMER;
    } else {
        return EMEA;
    }
}
 

开发者ID:jboss-fuse,
项目名称:fuse-karaf,
代码行数:21,
代码来源:RegionSupport.java

示例3: validateOrderDate

点赞 2

import org.apache.camel.language.NamespacePrefix; //导入依赖的package包/类
/**
 * Validate the order date - orders should only be place from Monday to Saturday.
 * <p/>
 * This method can be used as a plain Java method, but when it is used inside a Camel route, the @XPath annotation will kick
 * in, evaluating the XPath expression and using the result as the method parameter. In this case, it will fetch the order
 * date from the order XML message.
 *
 * @param date the order date
 * @throws OrderValidationException when the order date is a Sunday
 */
public void validateOrderDate(
    @XPath(value = "/order:order/order:date",
        namespaces = @NamespacePrefix(prefix = "order", uri = "http://org.jboss.fuse.quickstarts/examples/order/v7")) String date) throws OrderValidationException {
    final Calendar calendar = new GregorianCalendar();
    try {
        calendar.setTime(DATE_FORMAT.parse(date));
        if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
            LOGGER.warn("Order validation failure: order date " + date + " should not be a Sunday");
            throw new OrderValidationException("Order date should not be a Sunday: " + date);
        }
    } catch (ParseException e) {
        throw new OrderValidationException("Invalid order date: " + date);
    }
}
 

开发者ID:jboss-fuse,
项目名称:fuse-karaf,
代码行数:25,
代码来源:OrderService.java

示例4: createExpression

点赞 2

import org.apache.camel.language.NamespacePrefix; //导入依赖的package包/类
@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;
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:30,
代码来源:XQueryAnnotationExpressionFactory.java

示例5: handleIncomingOrder

点赞 2

import org.apache.camel.language.NamespacePrefix; //导入依赖的package包/类
public Document handleIncomingOrder(@Body Document xml,
                                    @XPath(value = "/c:order/@customerId", 
                                           namespaces = @NamespacePrefix(
                                               prefix = "c",
                                               uri = "http://camelinaction.com/order")) int customerId,
                                    @Bean(ref = "guid", method = "generate") int orderId) {

    Attr attr = xml.createAttribute("orderId");
    attr.setValue("" + orderId);

    Node node = xml.getElementsByTagName("order").item(0);
    node.getAttributes().setNamedItem(attr);

    return xml;
}
 

开发者ID:camelinaction,
项目名称:camelinaction2,
代码行数:16,
代码来源:XmlOrderNamespaceService.java

示例6: getExpressionNameSpacePrefix

点赞 2

import org.apache.camel.language.NamespacePrefix; //导入依赖的package包/类
protected NamespacePrefix[] getExpressionNameSpacePrefix(Annotation annotation) {
    return (NamespacePrefix[]) getAnnotationObjectValue(annotation, "namespaces");
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:4,
代码来源:XPathAnnotationExpressionFactory.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)