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

项目:camelinaction2    文件:PartnerServiceBean.java   
public Map toMap(@XPath("partner/@id") int partnerId,
                 @XPath("partner/date/text()") String date,
                 @XPath("partner/code/text()") int statusCode,
                 @XPath("partner/time/text()") long responseTime) {

    if (partnerId <= 0) {
        throw new IllegalArgumentException("PartnerId is invalid, was " + partnerId);
    }

    Map map = new HashMap();
    map.put("id", partnerId);
    map.put("date", date);
    map.put("code", statusCode);
    map.put("time", responseTime);
    return map;
}
项目:camelinaction    文件:PartnerServiceBean.java   
public String toSql(@XPath("partner/@id") int partnerId,
                    @XPath("partner/date/text()") String date,
                    @XPath("partner/code/text()") int statusCode,
                    @XPath("partner/time/text()") long responseTime) {

    if (partnerId <= 0) {
        throw new IllegalArgumentException("PartnerId is invalid, was " + partnerId);
    }

    StringBuilder sb = new StringBuilder();
    sb.append("INSERT INTO PARTNER_METRIC (partner_id, time_occurred, status_code, perf_time) VALUES (");
    sb.append("'").append(partnerId).append("', ");
    sb.append("'").append(date).append("', ");
    sb.append("'").append(statusCode).append("', ");
    sb.append("'").append(responseTime).append("') ");

    return sb.toString();
}
项目:fuse-karaf    文件:RegionSupport.java   
/**
 * 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;
    }
}
项目:fuse-karaf    文件:OrderService.java   
/**
 * 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);
    }
}
项目:boteco    文件:StatusRssProcessor.java   
@Handler
public void process(@XPath("//title") String title,
                    @XPath("//description") String description,
                    @XPath("//pubDate") String pubDate,
                    @XPath("//link") String link) {
  ZonedDateTime published = ZonedDateTime.parse(pubDate, DateTimeFormatter.RFC_1123_DATE_TIME);
  if (ChronoUnit.MINUTES.between(published,
      ZonedDateTime.now()) <= threshold) {
    bus.broadcast(parser.parse(description, title, link))
        .as("status.redhat");
  }
}
项目:Camel    文件:DistributeRecordsBean.java   
@Consume(uri = "activemq:personnel.records")
@RecipientList
public String[] route(@XPath("/person/city/text()") String city) {
    if (city.equals("London")) {
        LOG.info("Person is from EMEA region");
        return new String[] {"file:target/messages/emea/hr_pickup", 
                             "file:target/messages/emea/finance_pickup"};
    } else {
        LOG.info("Person is from AMER region");
        return new String[] {"file:target/messages/amer/hr_pickup",
                             "file:target/messages/amer/finance_pickup"};
    }
}
项目:Camel    文件:StockService.java   
public String transform(@XPath("/stock/symbol/text()") String symbol, @XPath("/stock/value/text()") String value) {
    Integer hits = stat.get(symbol);
    if (hits == null) {
        hits = 1;
    } else {
        hits++;
    }
    stat.put(symbol, hits);

    return symbol + "@" + hits;
}
项目:Camel    文件:ClaimCheckTest.java   
public void checkLuggage(Exchange exchange, @Body String body, @XPath("/order/@custId") String custId) {   
    // store the message body into the data store, using the custId as the claim check
    dataStore.put(custId, body);
    // add the claim check as a header
    exchange.getIn().setHeader("claimCheck", custId);
    // remove the body from the message
    exchange.getIn().setBody(null);
}
项目:Camel    文件:BeanWithXPathInjectionUsingHeaderValueTest.java   
@Handler
public void handler(@XPath("//response/text()") String response,
                    @XPath(headerName = "invoiceDetails", value = "//invoice/person/name/text()") String userName,
                    @XPath(headerName = "invoiceDetails", value = "//invoice/person/date", resultType = String.class) String date) {
    this.response = response;
    this.userName = userName;
    this.date = date;
}
项目:Camel    文件:MyVendor.java   
public void getQuote(@XPath("/quote_request/@item") String item, Exchange exchange) throws Exception {
    if ("beer".equals(item)) {
        exchange.getIn().setBody(beerPrice);
        quoteAggregator.send(exchange);
    } else {
        throw new Exception("No quote available for " + item);
    }
}
项目:camelinaction2    文件:OrderToSqlBean.java   
public String toSql(@XPath("order/@name") String name,
                    @XPath("order/@amount") int amount,
                    @XPath("order/@customer") String customer,
                    @Headers Map<String, Object> outHeaders) {
    outHeaders.put("partName", name);
    outHeaders.put("quantity", amount);
    outHeaders.put("customer", customer);
    return "insert into incoming_orders (part_name, quantity, customer) values (:?partName, :?quantity, :?customer)";
}
项目:camelinaction2    文件:ValidatorBean.java   
public void validate(@XPath("/order/@name") String partName, Exchange exchange) {
    // only motors are valid parts in this simple test bean
    if ("motor".equals(partName)) {
        exchange.getOut().setBody("Valid");
    } else {
        exchange.getOut().setBody("Invalid");
    }
}
项目:camelinaction2    文件:XmlOrderService.java   
public Document handleIncomingOrder(@Body Document xml,
                                    @XPath("/order/@customerId") 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;
}
项目:camelinaction2    文件:XmlOrderNamespaceService.java   
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;
}
项目:camelinaction2    文件:PartnerServiceBean.java   
public Map toMap(@XPath("partner/@id") int partnerId,
                 @XPath("partner/date/text()") String date,
                 @XPath("partner/code/text()") int statusCode,
                 @XPath("partner/time/text()") long responseTime) {

    Map map = new HashMap();
    map.put("id", partnerId);
    map.put("date", date);
    map.put("code", statusCode);
    map.put("time", responseTime);
    return map;
}
项目:camelinaction2    文件:PartnerServiceBean.java   
public Map toMap(@XPath("partner/@id") int partnerId,
                    @XPath("partner/date/text()") String date,
                    @XPath("partner/code/text()") int statusCode,
                    @XPath("partner/time/text()") long responseTime) {

    Map map = new HashMap();
    map.put("id", partnerId);
    map.put("date", date);
    map.put("code", statusCode);
    map.put("time", responseTime);
    return map;
}
项目:camelinaction2    文件:PartnerServiceBean.java   
public Map toMap(@XPath("partner/@id") int partnerId,
                 @XPath("partner/date/text()") String date,
                 @XPath("partner/code/text()") int statusCode,
                 @XPath("partner/time/text()") long responseTime) {

    Map map = new HashMap();
    map.put("id", partnerId);
    map.put("date", date);
    map.put("code", statusCode);
    map.put("time", responseTime);
    return map;
}
项目:camelinaction2    文件:AnnotatedRecipientList.java   
@RecipientList
public String[] route(@XPath("/order/@customer") String customer) {
    if (isGoldCustomer(customer)) {
        return new String[] {"jms:accounting", "jms:production"};
    } else {
        return new String[] {"jms:accounting"};
    }
}
项目:camelinaction2    文件:RecipientsBean.java   
public String[] recipients(@XPath("/order/@customer") String customer) {
    if (isGoldCustomer(customer)) {
        return new String[] {"jms:accounting", "jms:production"};
    } else {
        return new String[] {"jms:accounting"};
    }
}
项目:camelinaction    文件:OrderToSqlBean.java   
public String toSql(@XPath("order/@name") String name,
                    @XPath("order/@amount") int amount,
                    @XPath("order/@customer") String customer) {

    StringBuilder sb = new StringBuilder();
    sb.append("insert into incoming_orders (part_name, quantity, customer) values (");
    sb.append("'").append(name).append("', ");
    sb.append("'").append(amount).append("', ");
    sb.append("'").append(customer).append("') ");
    System.out.println(sb.toString());
    return sb.toString();
}
项目:camelinaction    文件:ValidatorBean.java   
public void validate(@XPath("/order/@name") String partName, Exchange exchange) {
    // only motors are valid parts in this simple test bean
    if ("motor".equals(partName)) {
        exchange.getOut().setBody("Valid");
    } else {
        exchange.getOut().setBody("Invalid");
    }
}
项目:camelinaction    文件:XmlOrderService.java   
public Document handleIncomingOrder(@Body Document xml,
                                    @XPath("/order/@customerId") 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;
}
项目:camelinaction    文件:XmlOrderNamespaceService.java   
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;
}
项目:camelinaction    文件:RecipientListBean.java   
@RecipientList
public String[] route(@XPath("/order/@customer") String customer) {
    if (isGoldCustomer(customer)) {
        return new String[] {"jms:accounting", "jms:production"};
    } else {
        return new String[] {"jms:accounting"};
    }
}
项目:camelinaction    文件:PartnerServiceBean.java   
public String toSql(@XPath("partner/@id") int partnerId,
                    @XPath("partner/date/text()") String date,
                    @XPath("partner/code/text()") int statusCode,
                    @XPath("partner/time/text()") long responsTime) {

    StringBuilder sb = new StringBuilder();
    sb.append("INSERT INTO PARTNER_METRIC (partner_id, time_occurred, status_code, perf_time) VALUES (");
    sb.append("'").append(partnerId).append("', ");
    sb.append("'").append(date).append("', ");
    sb.append("'").append(statusCode).append("', ");
    sb.append("'").append(responsTime).append("') ");

    return sb.toString();
}
项目:t4f-data    文件:OrderToSqlBean.java   
public String toSql(@XPath("order/@name") String name,
                    @XPath("order/@amount") int amount,
                    @XPath("order/@customer") String customer) {

    StringBuilder sb = new StringBuilder();
    sb.append("insert into incoming_orders (part_name, quantity, customer) values (");
    sb.append("'").append(name).append("', ");
    sb.append("'").append(amount).append("', ");
    sb.append("'").append(customer).append("') ");
    System.out.println(sb.toString());
    return sb.toString();
}
项目:t4f-data    文件:XmlOrderService.java   
public Document handleIncomingOrder(@Body Document xml,
                                    @XPath("/order/@customerId") 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;
}
项目:t4f-data    文件:XmlOrderNamespaceService.java   
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;
}
项目:t4f-data    文件:OrderToSqlBean.java   
public String toSql(@XPath("order/@name") String name,
                        @XPath("order/@amount") int amount,
                        @XPath("order/@customer") String customer) {

        StringBuilder sb = new StringBuilder();
        sb.append("insert into incoming_orders (part_name, quantity, customer) values (");
        sb.append("'").append(name).append("', ");
        sb.append("'").append(amount).append("', ");
        sb.append("'").append(customer).append("') ");
System.out.println(sb.toString());
        return sb.toString();
    }
项目:t4f-data    文件:ValidatorBean.java   
public void validate(@XPath("/order/@name") String partName, Exchange exchange) {
    // only motors are valid parts in this simple test bean
    if ("motor".equals(partName)) {
        exchange.getOut().setBody("Valid");
    } else {
        exchange.getOut().setBody("Invalid");
    }
}
项目:t4f-data    文件:PartnerServiceBean.java   
public String toSql(@XPath("partner/@id") int partnerId,
                    @XPath("partner/date/text()") String date,
                    @XPath("partner/code/text()") int statusCode,
                    @XPath("partner/time/text()") long responsTime) {

    StringBuilder sb = new StringBuilder();
    sb.append("INSERT INTO PARTNER_METRIC (partner_id, time_occurred, status_code, perf_time) VALUES (");
    sb.append("'").append(partnerId).append("', ");
    sb.append("'").append(date).append("', ");
    sb.append("'").append(statusCode).append("', ");
    sb.append("'").append(responsTime).append("') ");

    return sb.toString();
}
项目:t4f-data    文件:XmlOrderService.java   
public Document handleIncomingOrder(@Body Document xml,
                                    @XPath("/order/@customerId") 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;
}
项目:t4f-data    文件:RecipientListBean.java   
@RecipientList
public String[] route(@XPath("/order/@customer") String customer) {
    if (isGoldCustomer(customer)) {
        return new String[] {"jms:accounting", "jms:production"};
    } else {
        return new String[] {"jms:accounting"};
    }
}
项目:t4f-data    文件:ValidatorBean.java   
public void validate(@XPath("/order/@name") String partName, Exchange exchange) {
    // only motors are valid parts in this simple test bean
    if ("motor".equals(partName)) {
        exchange.getOut().setBody("Valid");
    } else {
        exchange.getOut().setBody("Invalid");
    }
}
项目:camel-springboot    文件:RestEndpoints.java   
public static List<String> getCityNamesFromXML(@XPath("//NewDataSet/Table/City/text()") NodeList nodeList) {
    return IntStream.range(0, nodeList.getLength()).mapToObj(nodeList::item).map(n->n.getNodeValue()).collect(Collectors.toList());
}
项目:Camel    文件:MyNormalizer.java   
public void employeeToPerson(Exchange exchange, @XPath("/employee/name/text()") String name) {
    exchange.getOut().setBody(createPerson(name));            
}
项目:Camel    文件:MyNormalizer.java   
public void customerToPerson(Exchange exchange, @XPath("/customer/@name") String name) {
    exchange.getOut().setBody(createPerson(name));
}
项目:Camel    文件:BeanOgnMethodWithXPathInjectionTest.java   
public String read(String body, @XPath("/soap:Envelope/soap:Body/foo/text()") String foo) {
    this.foo = foo;
    this.body = body;
    LOG.info("read() method called on " + this);
    return foo;
}
项目:Camel    文件:BeanWithXPathInjectionTest.java   
public void read(String body, @XPath("/soap:Envelope/soap:Body/foo/text()") String foo) {
    this.foo = foo;
    this.body = body;
    LOG.info("read() method called on " + this);
}
项目:Camel    文件:BeanWithXPathInjectionUsingResultTypeTest.java   
public void read(@XPath("//a/b/text()") String ab,
                 @XPath(value = "concat('a',//a/b)", resultType = String.class) String abText) {
    this.ab = ab;
    this.abText = abText;
}