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


Java JaxbAnnotationIntrospector类代码示例

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


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


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