• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JaxbDataFormat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: augmentJaxbDataFormatDefinition

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
/** Clones the passed JaxbDataFormat and then augments it with with Drools related namespaces
 * 
 * @param jaxbDataFormat
 * @return */
public static JaxbDataFormat augmentJaxbDataFormatDefinition(JaxbDataFormat jaxbDataFormat) {
    Set<String> set = new HashSet<String>();

    for (String clsName : DroolsJaxbHelperProviderImpl.JAXB_ANNOTATED_CMD) {
        set.add(clsName.substring(0, clsName.lastIndexOf('.')));
    }

    StringBuilder sb = new StringBuilder();
    String contextPath = jaxbDataFormat.getContextPath();
    if (contextPath != null) {
        sb.append(contextPath);
    }
    sb.append(":");
    for (String pkgName : set) {
        sb.append(pkgName);
        sb.append(':');
    }

    jaxbDataFormat.setContextPath(sb.toString());
    return jaxbDataFormat;
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:26,代码来源:KiePolicy.java


示例2: createRouteBuilder

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            JaxbDataFormat df = new JaxbDataFormat();
            df.setContextPath("org.apache.camel.example");
            df.setNamespacePrefixRef("myPrefix");

            from("direct:start")
                .marshal(df)
                .to("mock:result");

        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:JaxbMarshalNamespacePrefixMapperTest.java


示例3: configure

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
@Override
public void configure() throws Exception {
    JaxbDataFormat jaxb = new JaxbDataFormat();
    jaxb.setContextPath("com.ameliant.devoxx.model");

    from("jms:backend").id("stub.backend")
        .unmarshal(jaxb)
        .process(exchange -> {
            Message in = exchange.getIn();
            OrderQuery orderQuery = in.getBody(OrderQuery.class);
            String orderId = orderQuery.getOrderId();

            OrderDetails orderDetails = new OrderDetailsBuilder().buildOrderDetails(orderId);
            in.setBody(orderDetails);
        })
        .log("Stub replying with: ${body}")
        .marshal(jaxb);
}
 
开发者ID:jkorab,项目名称:camel-devoxx,代码行数:19,代码来源:BackendStubRoute.java


示例4: configure

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
/** configures camel-drools integration and defines 3 routes:
 * 1) testing route (connection to drools with JAXB command format)
 * 2) unmarshalling route (for unmarshalling command results)
 * 3) marshalling route (enables creating commands through API and converting to XML) */
private CamelContext configure(StatefulKnowledgeSession session) throws Exception {
    Context context = new JndiContext();
    context.bind("ksession", session);

    CamelContext camelContext = new DefaultCamelContext(context);
    camelContext.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            JaxbDataFormat jdf = new JaxbDataFormat();
            jdf.setContextPath("org.kie.camel.testdomain");
            jdf.setPrettyPrint(true);

            from("direct:test-session").policy(new KiePolicy()).unmarshal(jdf).to("kie://ksession").marshal(jdf);
            from("direct:unmarshall").policy(new KiePolicy()).unmarshal(jdf);
            from("direct:marshall").policy(new KiePolicy()).marshal(jdf);
        }
    });

    return camelContext;
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:25,代码来源:JaxbInsertTest.java


示例5: testJaxbMarshal

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
@Test
public void testJaxbMarshal() throws Exception {

    final JaxbDataFormat format = new JaxbDataFormat();
    format.setContextPath("org.wildfly.camel.test.jaxb.model");

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .marshal(format);
        }
    });

    camelctx.start();
    try (InputStream input = getClass().getResourceAsStream("/customer.xml")) {
        String expected = XMLUtils.compactXML(input);
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Customer customer = new Customer("John", "Doe");
        String result = producer.requestBody("direct:start", customer, String.class);
        Assert.assertEquals(expected, XMLUtils.compactXML(result));
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:27,代码来源:JAXBIntegrationTest.java


示例6: testJaxbUnmarshal

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
@Test
public void testJaxbUnmarshal() throws Exception {

    final JaxbDataFormat format = new JaxbDataFormat();
    format.setContextPath("org.wildfly.camel.test.jaxb.model");

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .unmarshal(format);
        }
    });

    camelctx.start();
    try (InputStream input = getClass().getResourceAsStream("/customer.xml")) {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Customer customer = producer.requestBody("direct:start", input, Customer.class);
        Assert.assertEquals("John", customer.getFirstName());
        Assert.assertEquals("Doe", customer.getLastName());
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:26,代码来源:JAXBIntegrationTest.java


示例7: createRouteBuilder

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() {
            PropertiesComponent pc = (PropertiesComponent) context.getComponent("properties");
            pc.setLocation("classpath:test.properties");

            JaxbDataFormat jaxb = new JaxbDataFormat(false);
            jaxb.setContextPath("se.kth.infosys.smx.alma.model");

            from("timer:once?repeatCount=1")
              .setHeader("almaUserId")
              .simple("[email protected]")
              .to("alma://apikey:{{alma.apikey}}@{{alma.host}}/users/read")
              .to("log:test1")
              .to("mock:result")

              .marshal(jaxb)
              .to("log:test2")
              .setHeader("first_name")
              .simple("Magnus")
              .to("xslt:replace-firstname.xslt")
              .unmarshal(jaxb)
              .to("alma://apikey:{{alma.apikey}}@{{alma.host}}/users/update")
              .to("mock:result2")

              .marshal(jaxb)
              .to("log:test3")
              .setHeader("first_name")
              .simple("properties:test.data.user.first_name")
              .to("xslt:replace-firstname.xslt")
              .unmarshal(jaxb)
              .to("alma://apikey:{{alma.apikey}}@{{alma.host}}/users/createOrUpdate")

              .to("mock:result3")
              .marshal(jaxb)
              .to("log:test4");
        }
    };
}
 
开发者ID:KTH,项目名称:camel-alma,代码行数:41,代码来源:AlmaUserTest.java


示例8: createRouteBuilder

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() {
            PropertiesComponent pc = (PropertiesComponent) context.getComponent("properties");
            pc.setLocation("classpath:test.properties");

            JaxbDataFormat jaxb = new JaxbDataFormat(false);
            jaxb.setContextPath("se.kth.infosys.smx.alma.model");

            from("timer:once?repeatCount=1")
              .setHeader("almaUserId")
              .simple("[email protected]")
              .to("alma://apikey:{{alma.apikey}}@{{alma.host}}/users/read")
              .to("log:test1")
              .to("mock:result")

              .removeHeader("almaUserId")
              .to("alma://apikey:{{alma.apikey}}@{{alma.host}}/users/read")
              .to("log:test2")
              .to("mock:result2")

              .marshal(jaxb)
              .to("log:test3");
        }
    };
}
 
开发者ID:KTH,项目名称:camel-alma,代码行数:28,代码来源:AlmaUserByUserTest.java


示例9: createRouteBuilder

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            JaxbDataFormat jaxb = new JaxbDataFormat(false);
            jaxb.setContextPath("org.apache.camel.component.spring.ws.jaxb");

            // request webservice
            from("direct:webservice-marshall")
                    .marshal(jaxb)
                    .to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuote&webServiceTemplate=#webServiceTemplate")
                    .convertBodyTo(String.class);

            // request webservice
            from("direct:webservice-marshall-unmarshall")
                    .marshal(jaxb)
                    .to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuote&webServiceTemplate=#webServiceTemplate")
                    .unmarshal(jaxb);

            // provide web service
            from("spring-ws:soapaction:http://www.stockquotes.edu/GetQuote?endpointMapping=#endpointMapping").process(
                    new StockQuoteResponseProcessor());
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:ConsumerMarshallingRouteTest.java


示例10: createRouteBuilder

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    routeBuilder = new RouteBuilder() {
        public void configure() throws Exception {
            JaxbDataFormat def = new JaxbDataFormat();
            def.setPrettyPrint(true);
            // TODO does not work: def.setContextPath( "org.drools.camel.testdomain:org.drools.pipeline.camel" );
            def.setContextPath("org.kie.pipeline.camel");

            from("direct:test-with-session").policy(new KiePolicy()).unmarshal(def).to("kie:ksession1").marshal(def);
            from("direct:test-no-session").policy(new KiePolicy()).unmarshal(def).to("kie:dynamic").marshal(def);
        }
    };
    return routeBuilder;
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:16,代码来源:CamelEndpointWithJaxbTest.java


示例11: createRouteBuilder

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    routeBuilder = new RouteBuilder() {
        public void configure() throws Exception {
            JaxbDataFormat def = new JaxbDataFormat();
            def.setPrettyPrint(true);
            def.setContextPath("org.kie.pipeline.camel");

            from("direct:test-with-session").policy(new KiePolicy()).unmarshal(def).to("kie:ksession1").marshal(def);
        }
    };
    return routeBuilder;
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:14,代码来源:CamelEndpointWithJaxbXSDModelTest.java


示例12: createRouteBuilder

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    routeBuilder = new RouteBuilder() {
        public void configure() throws Exception {
            JaxbDataFormat def = new JaxbDataFormat();
            def.setPrettyPrint(true);
            // TODO does not work: def.setContextPath( "org.drools.camel.testdomain:org.drools.pipeline.camel" );
            def.setContextPath("org.kie.pipeline.camel");

            from("direct:test-with-session").policy(new KiePolicy()).unmarshal(def).to("kie:ksession1").marshal(def);
        }
    };
    return routeBuilder;
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:15,代码来源:CamelEndpointWithJaxWrapperCollectionTest.java


示例13: createRouteBuilder

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() throws Exception {
            JaxbDataFormat jaxbDf = new JaxbDataFormat();
            jaxbDf.setContextPath("org.kie.camel.testdomain");

            from("direct:exec").policy(new KiePolicy()).unmarshal(dataformat).to("kie://ksession1").marshal(dataformat);
            from("direct:execWithLookup").policy(new KiePolicy()).unmarshal(dataformat).to("kie://dynamic").marshal(dataformat);
            from("direct:unmarshal").policy(new KiePolicy()).unmarshal(dataformat);
            from("direct:marshal").policy(new KiePolicy()).marshal(dataformat);
            from("direct:to-xstream").policy(new KiePolicy()).unmarshal(dataformat).marshal("xstream");
            from("direct:to-jaxb").policy(new KiePolicy()).unmarshal(dataformat).marshal(jaxbDf);
        }
    };
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:16,代码来源:BatchTest.java


示例14: configure

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
@Override
public void configure() throws Exception {
    /**
     * Configure JAXB so that it can discover model classes.
     */
    JaxbDataFormat jaxbDataFormat = new JaxbDataFormat();
    jaxbDataFormat.setContextPath(Order.class.getPackage().getName());

    /**
     * Configure a simple dead letter strategy. Whenever an IllegalStateException
     * is encountered this takes care of rolling back the JMS and JPA transactions. The
     * problem message is sent to the WildFly dead letter JMS queue (DLQ).
     */
    onException(IllegalStateException.class)
        .maximumRedeliveries(1)
        .handled(true)
        .to("jms:queue:DLQ")
        .markRollbackOnly();

    /**
     * This route generates a random order every 15 seconds
     */
    from("timer:order?period=15s&delay=0")
        .bean("orderGenerator", "generateOrder")
        .setHeader(Exchange.FILE_NAME).method("orderGenerator", "generateFileName")
        .to("file://{{jboss.server.data.dir}}/orders");

    /**
     * This route consumes XML files from JBOSS_HOME/standalone/data/orders and sends
     * the file content to JMS destination OrdersQueue.
     */
    from("file:{{jboss.server.data.dir}}/orders")
        .transacted()
            .convertBodyTo(String.class)
            .to("jms:queue:OrdersQueue");

    /**
     * This route consumes messages from JMS destination OrdersQueue, unmarshalls the XML
     * message body using JAXB to an Order entity object. The order is then sent to the JPA
     * endpoint for persisting within an in-memory database.
     *
     * Whenever an order quantity greater than 10 is encountered, the route throws an IllegalStateException
     * which forces the JMS / JPA transaction to be rolled back and the message to be delivered to the dead letter
     * queue.
     */
    from("jms:queue:OrdersQueue")
        .unmarshal(jaxbDataFormat)
        .to("jpa:Order")
            .choice()
            .when(simple("${body.quantity} > 10"))
                .log("Order quantity is greater than 10 - rolling back transaction!")
                .throwException(new IllegalStateException("Invalid quantity"))
            .otherwise()
                .log("Order processed successfully");

}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel-examples,代码行数:57,代码来源:JmsRouteBuilder.java


示例15: jaxb

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
/**
 * Uses the JAXB data format
 */
public T jaxb() {
    return dataFormat(new JaxbDataFormat());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:DataFormatClause.java


示例16: getDataFormat

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
protected JaxbDataFormat getDataFormat(Class<?> xmlClass) {
    JaxbDataFormat dataFormat = new JaxbDataFormat(false);
    dataFormat.setContextPath(xmlClass.getPackage().getName());
    dataFormat.setSchema("classpath:org/cleverbus/core/camel/jaxb/mock.xsd");
    return dataFormat;
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:7,代码来源:JaxbElementParseFailTest.java


示例17: jaxb

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
/**
 * Creates a JAXB data format for marshalling and unmarshalling the specified class
 * to/from its native XML representation.
 * <p/>
 * If rootQName is provided, this data format will work with classes that are not root elements
 * (not annotated with {@link XmlRootElement}).
 *
 * @param xmlClass  the class that this data format will be able to marshal and unmarshal
 * @param rootQName the QName (optional) of the root element in XML,
 *                  which is necessary for marshalling classes without XmlRootElement to XML
 * @return the Camel {@link DataFormatDefinition} instance for use in routes
 */
public static JaxbDataFormat jaxb(Class<?> xmlClass, @Nullable QName rootQName) {
    JaxbDataFormat dataFormat = jaxb(xmlClass);
    // partial marshaling - class without @XmlRootElement
    if (rootQName != null) {
        dataFormat.setFragment(true);
        dataFormat.setPartClass(xmlClass.getName());
        dataFormat.setPartNamespace(rootQName.toString());
    }
    return dataFormat;
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:23,代码来源:JaxbDataFormatHelper.java


示例18: jaxbFragment

import org.apache.camel.model.dataformat.JaxbDataFormat; //导入依赖的package包/类
/**
 * Creates a JAXB data format for <strong>unmarshalling</strong> (only)
 * the specified class to/from its native XML representation.
 * Unlike data format returned by {@link #jaxb(Class)},
 * this data format works with classes that are not root elements
 * (e.g., not annotated with {@link XmlRootElement}).
 *
 * @param xmlClass the class that this data format will be able to marshal and unmarshal
 * @return the Camel {@link DataFormatDefinition} instance for use in routes
 * @see #jaxbFragment(Class, String) for marshalling fragments (as this one can only unmarshal)
 */
public static JaxbDataFormat jaxbFragment(Class<?> xmlClass) {
    JaxbDataFormat jaxbIn = jaxb(xmlClass);
    // partial unmarshaling - class without @XmlRootElement
    jaxbIn.setFragment(true);
    jaxbIn.setPartClass(xmlClass.getName());
    return jaxbIn;
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:19,代码来源:JaxbDataFormatHelper.java



注:本文中的org.apache.camel.model.dataformat.JaxbDataFormat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RuleStore类代码示例发布时间:2022-05-23
下一篇:
Java MetricsExecutorImpl类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap