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

Java JaxbAnnotationIntrospector类代码示例

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

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



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

示例1: CustomObjectMapper

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
   public CustomObjectMapper()
{
	super();
	this.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	this.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
	this.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
	
	this.setSerializationInclusion(JsonSerialize.Inclusion.NON_DEFAULT); 
	this.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
	this.setSerializationInclusion(JsonSerialize.Inclusion.NON_EMPTY);

	final AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
	
	// make deserializer use JAXB annotations (only)
	this.setAnnotationIntrospector(introspector);
	
	// TODO leverage NamingStrategy to make reponse attributes more Java-like
	//this.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
 
开发者ID:SAP,项目名称:SAP-cloud-dqm-sample-java,代码行数:23,代码来源:CustomObjectMapper.java


示例2: JsonModelSerializer

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
public JsonModelSerializer(boolean doNullValues, Class<T> serializedType) {
		super();
		objectMapper = new ObjectMapper();
		AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
		// make serializer use JAXB annotations (only)
		SerializationConfig sc = objectMapper.getSerializationConfig().withAnnotationIntrospector(introspector);
		sc.with(SerializationConfig.Feature.INDENT_OUTPUT);
		
		if (!doNullValues) {
			sc.without(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES);
			sc.without(SerializationConfig.Feature.WRITE_EMPTY_JSON_ARRAYS);
			sc = sc.withSerializationInclusion(Inclusion.NON_EMPTY);
		}
		
		objectMapper.setSerializationConfig(sc);
//		if (!doNullValues) {
//			objectMapper.setSerializationInclusion(Inclusion.NON_EMPTY);
//		}
	}
 
开发者ID:ina-foss,项目名称:amalia-model,代码行数:20,代码来源:JsonModelSerializer.java


示例3: buildJson

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
private String buildJson(Object object) {

        ObjectMapper mapper = new ObjectMapper();
        SerializationConfig serializationConfig = mapper.getSerializationConfig();
        serializationConfig = serializationConfig.withSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
        AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
        mapper.setSerializationConfig(serializationConfig);
        mapper.setAnnotationIntrospector(introspector);

        try {
            return mapper.writeValueAsString(object);
        } catch (IOException e) {
            log.warn("Can't marshal search criteria.");
            throw new RuntimeException("Failed inFolder build criteria json.", e);
        }
    }
 
开发者ID:Jaspersoft,项目名称:jrs-rest-java-client,代码行数:17,代码来源:BatchJobsOperationsAdapter.java


示例4: main

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
public static void main(String[] args) throws JsonMappingException {
	ObjectMapper jsonMapper = new ObjectMapper();
    AnnotationIntrospector introspector = new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(), 
    		new JacksonAnnotationIntrospector());
    jsonMapper.setAnnotationIntrospector(introspector);
    JsonSchema schema = jsonMapper.generateJsonSchema(Testi.class);
    if(Testi.class.getAnnotation(XmlRootElement.class)!=null
    		&& !Testi.class.getAnnotation(XmlRootElement.class).name().equals("##default"))
    	schema.getSchemaNode().put("name", Testi.class.getAnnotation(XmlRootElement.class).name());
    else if(Testi.class.getAnnotation(XmlType.class)!=null
    		&& !Testi.class.getAnnotation(XmlType.class).name().equals("##default"))
    	schema.getSchemaNode().put("name", Testi.class.getAnnotation(XmlType.class).name());
    else
    	schema.getSchemaNode().put("name", Testi.class.getSimpleName());
    String schemaJson = schema.toString();
	System.out.println(schemaJson);
}
 
开发者ID:sumeetchhetri,项目名称:test-html-generator-plugin,代码行数:18,代码来源:Testi.java


示例5: getObjectMapper

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
@Bean(name="defaultObjectMapper")
public ObjectMapper getObjectMapper() {
    if(defaultObjectMapper==null) {
        ObjectMapper mapper = new ObjectMapper();
        AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
        AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
        AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);
        mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
        mapper.getDeserializationConfig().set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.getSerializationConfig().setAnnotationIntrospector(pair);
        mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
        mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
        mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
        this.defaultObjectMapper = mapper;
    }
    return defaultObjectMapper;
}
 
开发者ID:parekhparth,项目名称:SimpleJavaWS,代码行数:18,代码来源:ServiceConfiguration.java


示例6: createObjectMapper

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
private ObjectMapper createObjectMapper() {
  ObjectMapper mapper = new ObjectMapper();
  mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
  mapper.setSerializationInclusion(Inclusion.NON_NULL);
  mapper.configure(Feature.CLOSE_CLOSEABLE, false);
  return mapper;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:8,代码来源:FileSystemTimelineWriter.java


示例7: createRESTClientProxy

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
@Override
protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) {
    URI i = null;
    try {
        i = new URI(apiUrl);
    } catch (URISyntaxException ex) {
        throw new RuntimeException(ex);
    }
    ResteasyClientBuilder builder = new ResteasyClientBuilder();
    builder.connectionCheckoutTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS);
    builder.socketTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS);
    builder.httpEngine(new URLConnectionEngine());
    
    ResteasyProviderFactory.getInstance().register(builder);

    ResteasyClient client = builder.build();
    client.register(new ClientRequestFilter() {
        @Override
        public void filter(ClientRequestContext requestContext) throws IOException {
            requestContext.getHeaders().add("User-Agent", getImplementationName() + "=" + getVersion());
        }
    });
    ObjectMapper mapper = new ObjectMapper();
    JacksonJaxbJsonProvider jaxbProvider
            = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS);
    mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());

    mapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    builder.register(jaxbProvider);
    builder.register(proxy);

    ResteasyWebTarget resteasyWebTarget = client.target(i);
    return resteasyWebTarget.proxy(proxy);
}
 
开发者ID:gopaycommunity,项目名称:gopay-java-api,代码行数:35,代码来源:ResteasyGPConnector.java


示例8: CustomJsonProvider

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
public CustomJsonProvider(){

        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true);
        mapper.configure(org.codehaus.jackson.map.SerializationConfig.Feature.WRAP_ROOT_VALUE, true);
        _mapperConfig.setMapper(mapper);
        _mapperConfig.getConfiguredMapper().setAnnotationIntrospector(new JaxbAnnotationIntrospector());
       
    }
 
开发者ID:ik4tekniker,项目名称:FISTAR-Health-Questionnaire-SE,代码行数:10,代码来源:CustomJsonProvider.java


示例9: CustomJsonProviderList

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
public CustomJsonProviderList(){

        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true);
        mapper.configure(org.codehaus.jackson.map.SerializationConfig.Feature.WRAP_ROOT_VALUE, false);
        _mapperConfig.setMapper(mapper);
        _mapperConfig.getConfiguredMapper().setAnnotationIntrospector(new JaxbAnnotationIntrospector());
       
    }
 
开发者ID:ik4tekniker,项目名称:FISTAR-Health-Questionnaire-SE,代码行数:10,代码来源:CustomJsonProviderList.java


示例10: CustomJsonProviderList

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
public CustomJsonProviderList(){

 	ObjectMapper mapper = new ObjectMapper();
     mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true);
     // Can not deserialize instance of ArrayList out of String
     mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY,true);

     //Remove extra root value for class that include only a list
     mapper.configure(org.codehaus.jackson.map.SerializationConfig.Feature.WRAP_ROOT_VALUE, false);
     _mapperConfig.setMapper(mapper);
     _mapperConfig.getConfiguredMapper().setAnnotationIntrospector(new JaxbAnnotationIntrospector());
    
     
 }
 
开发者ID:ik4tekniker,项目名称:FISTAR-Health-Questionnaire-SE,代码行数:15,代码来源:CustomJsonProviderList.java


示例11: JsonModelDeserializer

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
public JsonModelDeserializer(Class<T> deserializedObjectType) {
	super();
	this.deserializedObjectType = deserializedObjectType;
	objectMapper = new ObjectMapper();
	AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
	// make serializer use JAXB annotations (only)
	objectMapper.setDeserializationConfig(objectMapper.getDeserializationConfig().withAnnotationIntrospector(introspector));
	objectTypeXmlTagName = deserializedObjectType.getAnnotation(XmlRootElement.class).name();

}
 
开发者ID:ina-foss,项目名称:amalia-model,代码行数:11,代码来源:JsonModelDeserializer.java


示例12: updateGenerator

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
/**
 * Update the generator with a default codec and pretty printer
 *
 * @param jsonFactory   Factory to set as codec
 * @param jsonGenerator Generator to configure
 */
private static void updateGenerator(JsonFactory jsonFactory, JsonGenerator jsonGenerator) {
    ObjectMapper mapper = new ObjectMapper(jsonFactory);

    //Update the annotation interceptor to also include jaxb annotations as a second choice
    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector() {

        /**
         * BUG FIX:
         * By contract, if findSerializationInclusion didn't encounter any annotations that should change the
         * inclusion value, it should return the default value it has received; but actually returns null, which
         * overrides the NON_NULL option we set.
         * The doc states issue JACKSON-256 which was supposed to be fixed in 1.5.0. *twilight zone theme song*
         */

        @Override
        public JsonSerialize.Inclusion findSerializationInclusion(Annotated a, JsonSerialize.Inclusion defValue) {
            JsonSerialize.Inclusion inclusion = super.findSerializationInclusion(a, defValue);
            if (inclusion == null) {
                return defValue;
            }
            return inclusion;
        }
    };
    AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);
    mapper.getSerializationConfig().setAnnotationIntrospector(pair);
    mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);

    jsonGenerator.setCodec(mapper);
    jsonGenerator.useDefaultPrettyPrinter();
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:38,代码来源:JacksonFactory.java


示例13: updateParser

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
/**
 * Update the parser with a default codec
 *
 * @param jsonFactory Factory to set as codec
 * @param jsonParser  Parser to configure
 */
private static void updateParser(JsonFactory jsonFactory, JsonParser jsonParser) {
    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
    AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);

    ObjectMapper mapper = new ObjectMapper(jsonFactory);
    mapper.getSerializationConfig().setAnnotationIntrospector(pair);
    mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
    mapper.getDeserializationConfig().disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
    jsonParser.setCodec(mapper);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:18,代码来源:JacksonFactory.java


示例14: JsonProvider

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
public JsonProvider() {
    ObjectMapper mapper = getMapper();
    //Update the annotation interceptor to also include jaxb annotations as a second choice
    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
    AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);

    mapper.getSerializationConfig().setAnnotationIntrospector(pair);
    mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);

    mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
    //Ignore missing properties
    mapper.getDeserializationConfig().disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:15,代码来源:JsonProvider.java


示例15: createObjectMapper

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
private ObjectMapper createObjectMapper() {
  ObjectMapper mapper = new ObjectMapper();
  mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
  mapper.setSerializationInclusion(Inclusion.NON_NULL);
  mapper.configure(Feature.CLOSE_CLOSEABLE, false);
  mapper.configure(Feature.FLUSH_AFTER_WRITE_VALUE, false);
  return mapper;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:9,代码来源:FileSystemTimelineWriter.java


示例16: createObjectMapper

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
static ObjectMapper createObjectMapper() {
  ObjectMapper mapper = new ObjectMapper();
  mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
  mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
  mapper.configure(SerializationConfig.Feature.CLOSE_CLOSEABLE, false);
  return mapper;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:8,代码来源:PluginStoreTestUtils.java


示例17: JacksonJaxbContextResolver

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
public JacksonJaxbContextResolver() {
    this.objectMapper = new ObjectMapper();
    final AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    final AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
    final AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);

    this.objectMapper.getDeserializationConfig().setAnnotationIntrospector(pair);
    this.objectMapper.getSerializationConfig().setAnnotationIntrospector(pair);
}
 
开发者ID:a-jullien,项目名称:cirrus,代码行数:10,代码来源:JacksonJaxbContextResolver.java


示例18: ObjectMapperFactoryBean

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
public ObjectMapperFactoryBean() {
	this.objectMapper = new ObjectMapper();
	this.objectMapper.setSerializationInclusion(Inclusion.NON_NULL);
	this.objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);

	AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
	AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
	AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);

	this.objectMapper.setAnnotationIntrospector(pair);
}
 
开发者ID:doanduyhai,项目名称:Cassandra-rate-limiting-demo,代码行数:12,代码来源:ObjectMapperFactoryBean.java


示例19: locateMapper

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
@Override
public ObjectMapper locateMapper(Class<?> type, MediaType mediaType) {
  ObjectMapper mapper = super.locateMapper(type, mediaType);
  AnnotationIntrospector introspector = new AnnotationIntrospector.Pair(
      new JaxbAnnotationIntrospector(),
      new JacksonAnnotationIntrospector()
  );
  mapper.setAnnotationIntrospector(introspector);
  //mapper.setSerializationInclusion(Inclusion.NON_NULL);
  return mapper;
}
 
开发者ID:apache,项目名称:incubator-slider,代码行数:12,代码来源:SliderJacksonJaxbJsonProvider.java


示例20: createJsonMapper

import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; //导入依赖的package包/类
/**
 * Creates json mapper.
 *
 * @return json mapper
 */
public static ObjectMapper createJsonMapper() {
    final AnnotationIntrospector jaxb = new JaxbAnnotationIntrospector();
    final AnnotationIntrospector jackson = new JacksonAnnotationIntrospector();

    final AnnotationIntrospector pair = new AnnotationIntrospector.Pair(jackson, jaxb);

    final ObjectMapper mapper = new ObjectMapper();
    mapper.getDeserializationConfig().withAnnotationIntrospector(pair);
    mapper.getSerializationConfig().withAnnotationIntrospector(pair);
    return mapper;
}
 
开发者ID:GluuFederation,项目名称:oxCore,代码行数:17,代码来源:Util.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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