org.codehaus.jackson.map.ser.std.SerializerBase Java Examples
The following examples show how to use
org.codehaus.jackson.map.ser.std.SerializerBase.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonStreamCodec.java From Bats with Apache License 2.0 | 6 votes |
public JsonStreamCodec(Map<Class<?>, Class<? extends StringCodec<?>>> codecs) { JacksonObjectMapperProvider jomp = new JacksonObjectMapperProvider(); if (codecs != null) { for (Map.Entry<Class<?>, Class<? extends StringCodec<?>>> entry : codecs.entrySet()) { try { @SuppressWarnings("unchecked") final StringCodec<Object> codec = (StringCodec<Object>) entry.getValue().newInstance(); jomp.addSerializer(new SerializerBase(entry.getKey()) { @Override public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeString(codec.toString(value)); } }); } catch (Exception ex) { logger.error("Caught exception when instantiating codec for class {}", entry.getKey().getName(), ex); } } } mapper = jomp.getContext(null); }
Example #2
Source File: JsonStreamCodec.java From attic-apex-core with Apache License 2.0 | 6 votes |
public JsonStreamCodec(Map<Class<?>, Class<? extends StringCodec<?>>> codecs) { JacksonObjectMapperProvider jomp = new JacksonObjectMapperProvider(); if (codecs != null) { for (Map.Entry<Class<?>, Class<? extends StringCodec<?>>> entry: codecs.entrySet()) { try { @SuppressWarnings("unchecked") final StringCodec<Object> codec = (StringCodec<Object>)entry.getValue().newInstance(); jomp.addSerializer(new SerializerBase(entry.getKey()) { @Override public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeString(codec.toString(value)); } }); } catch (Exception ex) { logger.error("Caught exception when instantiating codec for class {}", entry.getKey().getName(), ex); } } } mapper = jomp.getContext(null); }
Example #3
Source File: StramWebServices.java From Bats with Apache License 2.0 | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) private void init() { //clear content type httpResponse.setContentType(null); if (!initialized) { Map<Class<?>, Class<? extends StringCodec<?>>> codecs = dagManager.getApplicationAttributes().get(DAGContext.STRING_CODECS); StringCodecs.loadConverters(codecs); if (codecs != null) { SimpleModule sm = new SimpleModule("DTSerializationModule", new Version(1, 0, 0, null)); for (Map.Entry<Class<?>, Class<? extends StringCodec<?>>> entry : codecs.entrySet()) { try { final StringCodec<Object> codec = (StringCodec<Object>)entry.getValue().newInstance(); sm.addSerializer(new SerializerBase(entry.getKey()) { @Override public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeString(codec.toString(value)); } }); } catch (Exception ex) { LOG.error("Caught exception when instantiating codec for class {}", entry.getKey().getName(), ex); } } objectMapper.registerModule(sm); } initialized = true; } }
Example #4
Source File: StramWebServices.java From attic-apex-core with Apache License 2.0 | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) private void init() { //clear content type httpResponse.setContentType(null); if (!initialized) { Map<Class<?>, Class<? extends StringCodec<?>>> codecs = dagManager.getApplicationAttributes().get(DAGContext.STRING_CODECS); StringCodecs.loadConverters(codecs); if (codecs != null) { SimpleModule sm = new SimpleModule("DTSerializationModule", new Version(1, 0, 0, null)); for (Map.Entry<Class<?>, Class<? extends StringCodec<?>>> entry : codecs.entrySet()) { try { final StringCodec<Object> codec = (StringCodec<Object>)entry.getValue().newInstance(); sm.addSerializer(new SerializerBase(entry.getKey()) { @Override public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeString(codec.toString(value)); } }); } catch (Exception ex) { LOG.error("Caught exception when instantiating codec for class {}", entry.getKey().getName(), ex); } } objectMapper.registerModule(sm); } initialized = true; } }