當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。