Package org.apache.camel.builder.xml

Examples of org.apache.camel.builder.xml.Namespaces


        return ctx;
    }

    protected void injectNamespaces(Element element, Binder<Node> binder) {
        NodeList list = element.getChildNodes();
        Namespaces namespaces = null;
        int size = list.getLength();
        for (int i = 0; i < size; i++) {
            Node child = list.item(i);
            if (child instanceof Element) {
                Element childElement = (Element) child;
                Object object = binder.getJAXBNode(child);
                if (object instanceof NamespaceAware) {
                    NamespaceAware namespaceAware = (NamespaceAware) object;
                    if (namespaces == null) {
                        namespaces = new Namespaces(element);
                    }
                    namespaces.configure(namespaceAware);
                }
                injectNamespaces(childElement, binder);
            }
        }
    }
View Full Code Here


    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            Namespaces ns = new Namespaces("", "http:acme.com");
            @Override
            public void configure() throws Exception {
                // START SNIPPET: e1
                from("file:target/pair")
                        // split the order child tags, and inherit namespaces from the orders root tag
View Full Code Here

    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            Namespaces ns = new Namespaces("", "http:acme.com");
            @Override
            public void configure() throws Exception {
                // START SNIPPET: e1
                from("file:target/xtokenizer")
                    // split the order child tags, and inherit namespaces from the orders root tag
View Full Code Here

    }

    @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            Namespaces ns = new Namespaces("C", "urn:c");
            public void configure() {
                from("direct:start")
                    .split().xtokenize("//C:child", 'w', ns, 2)
                        .to("mock:result")
                    .end();
View Full Code Here

    }

    @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            Namespaces ns = new Namespaces("C", "urn:c");
            public void configure() {
                from("direct:start")
                    .split().xtokenize("//C:child", 'i', ns, 2)
                        .to("mock:result")
                    .end();
View Full Code Here

    }

    @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            Namespaces ns = new Namespaces("C", "urn:c");
            public void configure() {
                from("direct:start")
                    .split().xtokenize("//C:child", ns)
                        .to("mock:result")
                    .end();
View Full Code Here

    }

    @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            Namespaces ns = new Namespaces("C", "urn:c");
            public void configure() {
                from("direct:start")
                    .split().xtokenize("//C:child", 'w', ns)
                        .to("mock:result")
                    .end();
View Full Code Here

        }
    }

    protected void injectNamespaces(Element element, Binder<Node> binder) {
        NodeList list = element.getChildNodes();
        Namespaces namespaces = null;
        int size = list.getLength();
        for (int i = 0; i < size; i++) {
            Node child = list.item(i);
            if (child instanceof Element) {
                Element childElement = (Element) child;
                Object object = binder.getJAXBNode(child);
                if (object instanceof NamespaceAware) {
                    NamespaceAware namespaceAware = (NamespaceAware) object;
                    if (namespaces == null) {
                        namespaces = new Namespaces(element);
                    }
                    namespaces.configure(namespaceAware);
                }
                injectNamespaces(childElement, binder);
            }
        }
    }
View Full Code Here

        return true;
    }

    @Test
    public void testXmlEncryptionDecryption() throws Exception {
        final Namespaces namespaces = new Namespaces("c", "http://camelcookbook.org/schema/booksignings");
        final String cityExistsXPath = "exists(/c:booksignings/c:store/c:address/c:city)";

        context.getRouteDefinition("encrypt")
            .adviceWith(context, new AdviceWithRouteBuilder() {
                @Override
                public void configure() throws Exception {
                    interceptSendToEndpoint("direct:decrypt")
                        .when(namespaces.xpath(cityExistsXPath))
                            .to("mock:incorrectlyEncrypted");
                }
            });
        context.getRouteDefinition("decrypt")
            .adviceWith(context, new AdviceWithRouteBuilder() {
                @Override
                public void configure() throws Exception {
                    interceptSendToEndpoint("mock:out")
                        .when(namespaces.xpath(cityExistsXPath))
                            .to("mock:correctlyDecrypted");
                }
            });
        context.start();
View Full Code Here

        return true;
    }

    @Test
    public void testXmlEncryptionDecryption() throws Exception {
        final Namespaces namespaces = new Namespaces("c", "http://camelcookbook.org/schema/booksignings");
        final String cityExistsXPath = "exists(/c:booksignings/c:store/c:address/c:city)";

        context.getRouteDefinition("encrypt")
            .adviceWith(context, new AdviceWithRouteBuilder() {
                @Override
                public void configure() throws Exception {
                    interceptSendToEndpoint("direct:decrypt")
                        .when(namespaces.xpath(cityExistsXPath))
                            .to("mock:incorrectlyEncrypted");
                }
            });
        context.getRouteDefinition("decrypt")
            .adviceWith(context, new AdviceWithRouteBuilder() {
                @Override
                public void configure() throws Exception {
                    interceptSendToEndpoint("mock:out")
                        .when(namespaces.xpath(cityExistsXPath))
                            .to("mock:correctlyDecrypted");
                }
            });
        context.start();
View Full Code Here

TOP

Related Classes of org.apache.camel.builder.xml.Namespaces

Copyright © 2018 www.massapicom. 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.