本文整理汇总了Java中org.apache.camel.component.jackson.JacksonDataFormat类的典型用法代码示例。如果您正苦于以下问题:Java JacksonDataFormat类的具体用法?Java JacksonDataFormat怎么用?Java JacksonDataFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JacksonDataFormat类属于org.apache.camel.component.jackson包,在下文中一共展示了JacksonDataFormat类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: configureJacksonDataFormat
import org.apache.camel.component.jackson.JacksonDataFormat; //导入依赖的package包/类
@Bean
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JacksonDataFormat.class)
public JacksonDataFormat configureJacksonDataFormat(
CamelContext camelContext,
JacksonDataFormatConfiguration configuration) throws Exception {
JacksonDataFormat dataformat = new JacksonDataFormat();
if (dataformat instanceof CamelContextAware) {
((CamelContextAware) dataformat).setCamelContext(camelContext);
}
Map<String, Object> parameters = new HashMap<>();
IntrospectionSupport.getProperties(configuration, parameters, null,
false);
IntrospectionSupport.setProperties(camelContext,
camelContext.getTypeConverter(), dataformat, parameters);
return dataformat;
}
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:JacksonDataFormatAutoConfiguration.java
示例2: init
import org.apache.camel.component.jackson.JacksonDataFormat; //导入依赖的package包/类
@Before
public void init()
{
ObjectMapper mapper = ObjectMapperFactory.createInstance();
dataFormat = new JacksonDataFormat(mapper, Object.class);
String expectedClassMapKey1 =
isClassMapKeySerializedWithPrefix() ? "class java.lang.Long" : "java.lang.Long";
expectedJson = "{" +
"\"@class\":\"" + SimplePojo.class.getCanonicalName() + "\"," +
"\"field1\":\"" + EXPECTED_FIELD1_VALUE + "\"," +
"\"field2\":" + EXPECTED_FIELD2_VALUE + "," +
"\"field3\":\"" + EXPECTED_FIELD3_VALUE + "\"," +
"\"field4\":{\"@class\":\"java.util.HashMap\"," +
"\"" + expectedClassMapKey1 + "\":\"" + EXPECTED_CLASS_MAP_VALUE1 + "\"}," +
"\"field5\":{\"@class\":\"java.util.HashMap\"," +
"\"" + EXPECTED_STRING_MAP_KEY1 + "\":\"" + EXPECTED_STRING_MAP_VALUE1 + "\"}" +
"}";
}
开发者ID:Alfresco,项目名称:gytheio,代码行数:21,代码来源:JacksonDataFormatTest.java
示例3: configure
import org.apache.camel.component.jackson.JacksonDataFormat; //导入依赖的package包/类
@Override
public void configure() throws Exception {
String s = null;
// Create an instance of JacksonDataFormat to convert to JSON to
// a {@link Notification} instance
JacksonDataFormat format = new JacksonDataFormat();
format.setUnmarshalType(Notification.class);
from(getFromUri())
.routeId(getRouteId())
.startupOrder(getStartUpOrder())
// .log(DEBUG,"headers: ${headers}")
// .log(DEBUG,"body: ${body}")
// .log(DEBUG,"body: ${body}")
// .log(DEBUG,"class: ${body.getClass.toString}")
// .process(new Processor() {
// public void process(Exchange exchange) throws Exception {
// HttpMessage msg = exchange.getIn(HttpMessage.class);
//
// InputStreamCache sis = msg.getBody(InputStreamCache.class);
//
// String s = exchange.getContext().getTypeConverter().convertTo(String.class, sis);
// LOG.debug("process body: " + s);
//
// Message newMessage = new DefaultMessage();
// newMessage.setHeaders(msg.getHeaders());
// newMessage.setBody(s);
// exchange.setIn(newMessage);
// }
// })
// .log(DEBUG,"BEFORE CLASS: ${body.getClass.toString}")
// .log(DEBUG,"BEFORE SIZE: ${body.length}")
// .log(DEBUG,"BEFORE BODY: ${body}")
// .unmarshal().string("UTF-8")
// .log(DEBUG,"AFTER CLASS: ${body.getClass.toString}")
// .log(DEBUG,"AFTER SIZE: ${body.length}")
// .log(DEBUG,"AFTER BODY: ${body}")
.unmarshal().json(JsonLibrary.Jackson,Notification.class)
.to(getToUri());
}
开发者ID:boundary,项目名称:boundary-event-sdk,代码行数:41,代码来源:WebHookRouteBuilder.java
示例4: createRouteBuilder
import org.apache.camel.component.jackson.JacksonDataFormat; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() {
JacksonDataFormat jdf = new JacksonDataFormat(TemperaturePojo.class);
from("direct:start")
.unmarshal(jdf)
.to("mock:result");
}
};
}
开发者ID:EdwardOst,项目名称:mdpnp,代码行数:12,代码来源:RtiJsonTest.java
示例5: initializeCamelEndpoint
import org.apache.camel.component.jackson.JacksonDataFormat; //导入依赖的package包/类
/**
* Initializes a Camel context and configures routes and object marshaling with the given
* brokerUrl, enpoint, and messageConsumer.
*
* @param brokerUrl
* @param endpoint
* @param messageConsumer
* @return the Gytheio message producer
* @throws Exception
*/
protected MessageProducer initializeCamelEndpoint(
final String brokerUrl, final String endpointSend, final String endpointReceive,
final MessageConsumer messageConsumer) throws Exception
{
CamelContext context = new DefaultCamelContext();
ConnectionFactory connectionFactory =
new ActiveMQConnectionFactory(brokerUrl);
JmsComponent component = AMQPComponent.jmsComponent();
component.setConnectionFactory(connectionFactory);
context.addComponent("amqp", component);
final DataFormat dataFormat = new JacksonDataFormat(
ObjectMapperFactory.createInstance(), Object.class);
if (messageConsumer != null)
{
context.addRoutes(new RouteBuilder() {
public void configure() {
from("amqp:" + endpointReceive).unmarshal(dataFormat).bean(messageConsumer, "onReceive");
}
});
}
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:benchmark.test").marshal(dataFormat).to("amqp:" + endpointSend);
}
});
CamelMessageProducer messageProducer = new CamelMessageProducer();
messageProducer.setProducer(context.createProducerTemplate());
messageProducer.setEndpoint("direct:benchmark.test");
context.start();
return messageProducer;
}
开发者ID:Alfresco,项目名称:gytheio,代码行数:49,代码来源:BenchmarkRunner.java
示例6: testJsonIgnore
import org.apache.camel.component.jackson.JacksonDataFormat; //导入依赖的package包/类
@Test
public void testJsonIgnore() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
JacksonDataFormat jacksonDataFormat = new JacksonDataFormat();
jacksonDataFormat.setPrettyPrint(false);
from("direct:start")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Organization organization = new Organization();
organization.setName("The Organization");
Employee employee = new Employee();
employee.setName("The Manager");
employee.setEmployeeNumber(12345);
employee.setOrganization(organization);
organization.setManager(employee);
exchange.getIn().setBody(employee);
}
})
.marshal(jacksonDataFormat);
}
});
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
String result = template.requestBody("direct:start", null, String.class);
Assert.assertEquals("{\"name\":\"The Manager\"}", result);
} finally {
camelctx.stop();
}
}
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:40,代码来源:JSONJacksonAnnotationsTest.java
示例7: testRestSwaggerJSON
import org.apache.camel.component.jackson.JacksonDataFormat; //导入依赖的package包/类
@Test
public void testRestSwaggerJSON() throws Exception {
JacksonDataFormat jacksonDataFormat = new JacksonDataFormat();
jacksonDataFormat.setUnmarshalType(Customer.class);
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:getCustomerById")
.to("customer:getCustomerById")
.convertBodyTo(String.class)
.unmarshal(jacksonDataFormat);
}
});
RestSwaggerComponent restSwaggerComponent = new RestSwaggerComponent();
restSwaggerComponent.setSpecificationUri(new URI("http://localhost:8080/api/swagger"));
restSwaggerComponent.setComponentName("undertow");
restSwaggerComponent.setConsumes(MediaType.APPLICATION_JSON);
restSwaggerComponent.setProduces(MediaType.APPLICATION_JSON);
camelctx.addComponent("customer", restSwaggerComponent);
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
Customer customer = template.requestBodyAndHeader("direct:getCustomerById", null, "id", 1, Customer.class);
Assert.assertNotNull(customer);
Assert.assertEquals(1, customer.getId());
} finally {
camelctx.stop();
}
}
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:35,代码来源:RestSwaggerIntegrationTest.java
示例8: configure
import org.apache.camel.component.jackson.JacksonDataFormat; //导入依赖的package包/类
@Override
public void configure() throws Exception {
DataFormat jsonDataFormat = new JacksonDataFormat();
from("cxfrs:bean:rsReportsServer?bindingStyle=SimpleConsumer")
.log("Executing ${header.operationName}")
.doTry()
.beanRef("authBean", "isLoggedIn")
.beanRef("authBean", "canAccessReport")
.recipientList(simple("direct:rs-${header.operationName}")).end()
.doCatch(AuthenticationException.class)
.log("Authentication failed ${header.operationName}")
.beanRef("authBean", "buildAuthFail")
.marshal(jsonDataFormat)
.doCatch(AuthorizationException.class)
.log("Report authorization failed ${header.operationName} ${header.reportId}")
.beanRef("reportBean", "noSuchReport")
.marshal(jsonDataFormat)
.end()
.routeId("cxfrsReportsInRouteId");
from("direct:rs-reportDetails")
.beanRef("reportBean", "getReportsDetailed")
.marshal().json(JsonLibrary.Jackson)
.routeId("rsReportDetailsRouteId");
from("direct:rs-runReport")
.beanRef("reportBean", "run")
.marshal().json(JsonLibrary.Jackson)
.routeId("rsRunReportRouteId");
from("direct:rs-detailsAndRunReport")
.beanRef("reportBean", "detailsAndRun")
.marshal().json(JsonLibrary.Jackson)
.routeId("rsDetailsAndRunReportRouteId");
from("direct:rs-exportReport")
.beanRef("reportBean", "export")
.routeId("rsExportReportRouteId");
}
开发者ID:base2Services,项目名称:kagura,代码行数:40,代码来源:ReportsRoutes.java
示例9: createRegistry
import org.apache.camel.component.jackson.JacksonDataFormat; //导入依赖的package包/类
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
jndi.bind("bla", new JacksonDataFormat());
return jndi;
}
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:RestRestletCustomDataFormatInvalidTest.java
注:本文中的org.apache.camel.component.jackson.JacksonDataFormat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论