Search in sources :

Example 86 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project jersey by jersey.

the class FilteringJacksonJaxbJsonProvider method _configForWriting.

@Override
protected JsonEndpointConfig _configForWriting(final ObjectMapper mapper, final Annotation[] annotations, final Class<?> defaultView) {
    final AnnotationIntrospector customIntrospector = mapper.getSerializationConfig().getAnnotationIntrospector();
    // Set the custom (user) introspector to be the primary one.
    final ObjectMapper filteringMapper = mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(customIntrospector, new JacksonAnnotationIntrospector() {

        @Override
        public Object findFilterId(final Annotated a) {
            final Object filterId = super.findFilterId(a);
            if (filterId != null) {
                return filterId;
            }
            if (a instanceof AnnotatedMethod) {
                final Method method = ((AnnotatedMethod) a).getAnnotated();
                // Interested only in getters - trying to obtain "field" name from them.
                if (ReflectionHelper.isGetter(method)) {
                    return ReflectionHelper.getPropertyName(method);
                }
            }
            if (a instanceof AnnotatedField || a instanceof AnnotatedClass) {
                return a.getName();
            }
            return null;
        }
    }));
    return super._configForWriting(filteringMapper, annotations, defaultView);
}
Also used : JacksonAnnotationIntrospector(com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector) Annotated(com.fasterxml.jackson.databind.introspect.Annotated) AnnotatedMethod(com.fasterxml.jackson.databind.introspect.AnnotatedMethod) AnnotatedClass(com.fasterxml.jackson.databind.introspect.AnnotatedClass) JacksonAnnotationIntrospector(com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector) AnnotationIntrospector(com.fasterxml.jackson.databind.AnnotationIntrospector) AnnotatedMethod(com.fasterxml.jackson.databind.introspect.AnnotatedMethod) Method(java.lang.reflect.Method) AnnotatedField(com.fasterxml.jackson.databind.introspect.AnnotatedField) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 87 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project hadoop by apache.

the class YarnJacksonJaxbJsonProvider method locateMapper.

@Override
public ObjectMapper locateMapper(Class<?> type, MediaType mediaType) {
    ObjectMapper mapper = super.locateMapper(type, mediaType);
    configObjectMapper(mapper);
    return mapper;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 88 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project storm by apache.

the class TridentSocketSpout method open.

@Override
public void open(Map conf, TopologyContext context) {
    this.queue = new LinkedBlockingDeque<>();
    this.objectMapper = new ObjectMapper();
    this.batches = new HashMap<>();
    try {
        socket = new Socket(host, port);
        in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    } catch (IOException e) {
        throw new RuntimeException("Error opening socket: host " + host + " port " + port);
    }
    readerThread = new Thread(new SocketReaderRunnable());
    readerThread.start();
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Socket(java.net.Socket)

Example 89 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project storm by apache.

the class RedisKeyValueStateProvider method getStateConfig.

StateConfig getStateConfig(Map stormConf) throws Exception {
    StateConfig stateConfig = null;
    String providerConfig = null;
    ObjectMapper mapper = new ObjectMapper();
    mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
    if (stormConf.containsKey(org.apache.storm.Config.TOPOLOGY_STATE_PROVIDER_CONFIG)) {
        providerConfig = (String) stormConf.get(org.apache.storm.Config.TOPOLOGY_STATE_PROVIDER_CONFIG);
        stateConfig = mapper.readValue(providerConfig, StateConfig.class);
    } else {
        stateConfig = new StateConfig();
    }
    return stateConfig;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 90 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project hadoop by apache.

the class StatePool method read.

private void read(DataInput in) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    // define a module
    SimpleModule module = new SimpleModule("State Serializer", new Version(0, 1, 1, "FINAL", "", ""));
    // add the state deserializer
    module.addDeserializer(StatePair.class, new StateDeserializer());
    // register the module with the object-mapper
    mapper.registerModule(module);
    JsonParser parser = mapper.getFactory().createParser((DataInputStream) in);
    StatePool statePool = mapper.readValue(parser, StatePool.class);
    this.setStates(statePool.getStates());
    parser.close();
}
Also used : Version(com.fasterxml.jackson.core.Version) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) JsonParser(com.fasterxml.jackson.core.JsonParser)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6071 Test (org.junit.Test)2235 IOException (java.io.IOException)1016 JsonNode (com.fasterxml.jackson.databind.JsonNode)930 HashMap (java.util.HashMap)444 Map (java.util.Map)429 ArrayList (java.util.ArrayList)416 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)388 File (java.io.File)319 List (java.util.List)268 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)254 Before (org.junit.Before)246 Test (org.junit.jupiter.api.Test)238 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)202 InputStream (java.io.InputStream)185 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)156 Matchers.containsString (org.hamcrest.Matchers.containsString)136 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)127 TypeReference (com.fasterxml.jackson.core.type.TypeReference)123 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)121