当前位置: 首页>>代码示例>>Java>>正文


Java JaxbAnnotationIntrospector类代码示例

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


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

示例1: objectMapper

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
@Bean
public ObjectMapper objectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

    mapper.registerModule(new Ocpp12JacksonModule());
    mapper.registerModule(new Ocpp15JacksonModule());

    mapper.setAnnotationIntrospector(
            AnnotationIntrospector.pair(
                    new JacksonAnnotationIntrospector(),
                    new JaxbAnnotationIntrospector(mapper.getTypeFactory())
            )
    );
    return mapper;
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:17,代码来源:WebSocketConfiguration.java

示例2: Jackson2Parser

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
public Jackson2Parser(Settings settings, TypeProcessor typeProcessor, boolean useJaxbAnnotations) {
    super(settings, typeProcessor);
    if (settings.jackson2ModuleDiscovery) {
        objectMapper.registerModules(ObjectMapper.findModules(settings.classLoader));
    }
    for (Class<? extends Module> moduleClass : settings.jackson2Modules) {
        try {
            objectMapper.registerModule(moduleClass.newInstance());
        } catch (ReflectiveOperationException e) {
            throw new RuntimeException(String.format("Cannot instantiate Jackson2 module '%s'", moduleClass.getName()), e);
        }
    }
    if (useJaxbAnnotations) {
        AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(objectMapper.getTypeFactory());
        objectMapper.setAnnotationIntrospector(introspector);
    }
}
 
开发者ID:vojtechhabarta,项目名称:typescript-generator,代码行数:18,代码来源:Jackson2Parser.java

示例3: createJsonFactory

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
private JsonFactory createJsonFactory() {
    final ObjectMapper objectMapper = new ObjectMapper();

    objectMapper.setAnnotationIntrospector(
            new AnnotationIntrospectorPair(
                    new JacksonAnnotationIntrospector(),
                    new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())));

    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    objectMapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, true);

    final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    df.setTimeZone(TimeZone.getTimeZone("GMT"));
    objectMapper.setDateFormat(df);

    return objectMapper.getFactory();
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:18,代码来源:RdapResponseJsonTest.java

示例4: init

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
@PostConstruct
public void init() {
    objectMapper = new ObjectMapper()
            .setAnnotationIntrospector(
                    new AnnotationIntrospectorPair(
                            new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())
                            , new JacksonAnnotationIntrospector()
                    )
            )
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:12,代码来源:JsonTaskMapper.java

示例5: defaultObjectMapper

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
public static ObjectMapper defaultObjectMapper() {
    return new XmlMapper(new XmlFactory(new WstxInputFactory(), new WstxPrefixedOutputFactory()))
            .enable(SerializationFeature.INDENT_OUTPUT)
            .setSerializationInclusion(JsonInclude.Include.NON_NULL)
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
            .configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, true)
            .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
            .registerModule(new ParserModule())
            .setAnnotationIntrospector(AnnotationIntrospector.pair(
                    new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()),
                    new JacksonAnnotationIntrospector()));
}
 
开发者ID:carlanton,项目名称:mpd-tools,代码行数:13,代码来源:MPDParser.java

示例6: testSerializeJSON

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
@Test
public void testSerializeJSON() throws IOException {

	Person person = new Person();
	person.setId(12345L);
	person.setFirstName("Peter");
	person.setLastName("Walser");
	person.setGender(Gender.MALE);
	person.setDateOfBirth(LocalDate.of(1975, 12, 20));

	StringWriter buffer = new StringWriter();
	ObjectMapper mapper = new ObjectMapper();

	mapper.setAnnotationIntrospector(
			AnnotationIntrospector.pair(
					new JacksonAnnotationIntrospector(),
					new JaxbAnnotationIntrospector(mapper.getTypeFactory())
			)
	);
	mapper.writerWithDefaultPrettyPrinter().writeValue(buffer, person);

	String jsonString = buffer.toString();
	System.out.println(jsonString);

	Assert.assertTrue(jsonString.contains("\"id\" : 12345"));
	Assert.assertTrue(jsonString.contains("\"first_name\" : \"Peter\""));
	Assert.assertTrue(jsonString.contains("\"last_name\" : \"Walser\""));
	Assert.assertTrue(jsonString.contains("\"gender\" : \"MALE\""));
	Assert.assertTrue(jsonString.contains("\"birth_date\" : \"1975-12-20\""));

}
 
开发者ID:pwalser75,项目名称:jee-demo,代码行数:32,代码来源:PersonDTOTest.java

示例7: getGraphForJson

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
/**
 * Returns the graph for json.
 *
 * @param <T> the generic type
 * @param json the json
 * @param graphClass the graph class
 * @return the graph for json
 * @throws Exception the exception
 */
public static <T> T getGraphForJson(String json, Class<T> graphClass)
  throws Exception {
  InputStream in =
      new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8));
  ObjectMapper mapper = new ObjectMapper();
  AnnotationIntrospector introspector =
      new JaxbAnnotationIntrospector(mapper.getTypeFactory());
  mapper.setAnnotationIntrospector(introspector);
  return mapper.readValue(in, graphClass);

}
 
开发者ID:IHTSDO,项目名称:SNOMED-in-5-minutes,代码行数:21,代码来源:Utility.java

示例8: getJsonForGraph

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
/**
 * Returns the json for graph.
 *
 * @param object the object
 * @return the json for graph
 * @throws Exception the exception
 */
public static String getJsonForGraph(Object object) throws Exception {
  ObjectMapper mapper = new ObjectMapper();
  AnnotationIntrospector introspector =
      new JaxbAnnotationIntrospector(mapper.getTypeFactory());
  mapper.setAnnotationIntrospector(introspector);
  return mapper.writeValueAsString(object);
}
 
开发者ID:IHTSDO,项目名称:SNOMED-in-5-minutes,代码行数:15,代码来源:Utility.java

示例9: Allure1Plugin

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
public Allure1Plugin() {
    final SimpleModule module = new XmlParserModule()
            .addDeserializer(ru.yandex.qatools.allure.model.Status.class, new StatusDeserializer());
    xmlMapper = new XmlMapper()
            .configure(USE_WRAPPER_NAME_AS_PROPERTY_NAME, true)
            .setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()))
            .registerModule(module);
}
 
开发者ID:allure-framework,项目名称:allure2,代码行数:9,代码来源:Allure1Plugin.java

示例10: configureMessageConverters

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
	Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder = new Jackson2ObjectMapperBuilder()
			.annotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()))
			.indentOutput(true);
	converters.add(new StringHttpMessageConverter());
	converters.add(new MappingJackson2HttpMessageConverter());
	converters.add(new MappingJackson2XmlHttpMessageConverter(
			jacksonObjectMapperBuilder
				.createXmlMapper(true)
				.build()));
}
 
开发者ID:samolisov,项目名称:spring-4x-demos,代码行数:13,代码来源:ApplicationConfig.java

示例11: addJaxbAnnotationIntrospector

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
private void addJaxbAnnotationIntrospector(ObjectMapper objectMapper) {
	JaxbAnnotationIntrospector jaxbAnnotationIntrospector = new JaxbAnnotationIntrospector(
			objectMapper.getTypeFactory());
	objectMapper.setAnnotationIntrospectors(
			createPair(objectMapper.getSerializationConfig(),
					jaxbAnnotationIntrospector),
			createPair(objectMapper.getDeserializationConfig(),
					jaxbAnnotationIntrospector));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:JerseyAutoConfiguration.java

示例12: configureMapperForSerialization

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
private ObjectMapper configureMapperForSerialization(){
	ObjectMapper mapper = new ObjectMapper();
	mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
	mapper.setSerializationInclusion(Include.NON_NULL);
	mapper.registerModule(createSerializerModule());
	mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
	return mapper;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:9,代码来源:JsonLexicalProcessor.java

示例13: createMapper

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
public static ObjectMapper createMapper() {
    return new ObjectMapper()
            .configure(USE_WRAPPER_NAME_AS_PROPERTY_NAME, true)
            .setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()))
            .setSerializationInclusion(NON_NULL)
            .configure(INDENT_OUTPUT, Boolean.getBoolean(INDENT_OUTPUT_PROPERTY_NAME))
            .registerModule(new SimpleModule()
                    .addDeserializer(Status.class, new StatusDeserializer())
                    .addDeserializer(Stage.class, new StageDeserializer())
            );
}
 
开发者ID:allure-framework,项目名称:allure2-model,代码行数:12,代码来源:Allure2ModelJackson.java

示例14: createRESTClientProxy

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
@Override
protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) {
    List providers = new ArrayList();
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()));

    JacksonJaxbJsonProvider jsonProvider
            = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS);
    providers.add(jsonProvider);
    T t = JAXRSClientFactory.create(apiUrl, proxy, providers, true);
    Client client = (Client) t;
    client.header("User-Agent", getImplementationName() + "=" + getVersion());
    return t;
}
 
开发者ID:gopaycommunity,项目名称:gopay-java-api,代码行数:16,代码来源:CXFGPConnector.java

示例15: ApiHttpClient

import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
public ApiHttpClient(final String channelAccessToken) {

        RequestConfig requestConfig = RequestConfig.custom()
                .setConnectionRequestTimeout(timeoutInMillis)
                .setConnectTimeout(timeoutInMillis)
                .build();

        CloseableHttpAsyncClient asyncClient = HttpAsyncClientBuilder.create()
                .setDefaultRequestConfig(requestConfig)
                .addInterceptorLast((HttpRequest httpRequest, HttpContext httpContext) -> {
                    httpRequest.addHeader("X-Line-ChannelToken", channelAccessToken);
                    httpRequest.addHeader("Content-Type", "application/json; charser=UTF-8");
                    httpRequest.removeHeaders("Accept");
                    httpRequest.addHeader("Accept", "application/json; charset=UTF-8");
                })
                .setMaxConnTotal(maxConnections)
                .setMaxConnPerRoute(maxConnections)
                .disableCookieManagement()
                .build();

        asyncRestTemplate = new AsyncRestTemplate(new HttpComponentsAsyncClientHttpRequestFactory(asyncClient));
        asyncRestTemplate.setErrorHandler(new ApiResponseErrorHandler());

        httpHeaders = new HttpHeaders();
        httpHeaders.set("X-Line-ChannelToken", channelAccessToken);
        httpHeaders.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
        List<MediaType> list = new ArrayList<>();
        list.add(new MediaType("application", "json", Charset.forName("UTF-8")));
        httpHeaders.setAccept(list);

        objectMapper = new ObjectMapper();
        objectMapper.configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, true);
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
        objectMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()));
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    }
 
开发者ID:line,项目名称:bc-quick-start-guide,代码行数:38,代码来源:ApiHttpClient.java


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