/** * Adds the providers */ protected void addProviders() { resourceConfig.register(new JacksonProvider(objectMapper, null)); }
/** * @param object */ public ByteBuf serialize(Object object, MediaType mediaType) { ByteBuf byteBuf = Unpooled.buffer(); OutputStream stream = new ByteBufOutputStream(byteBuf); try { writeTo(object, object.getClass(), object.getClass(), null, mediaType, new MultivaluedHashMap<String, Object>(), stream); } catch (IOException e) { throw new MinnalException(e); } return byteBuf; }
/** * @param object */ public <T> T deserializeCollection(ByteBuf byteBuf, Class<T> type, Class<T> genericType, MediaType mediaType) { InputStream stream = new ByteBufInputStream(byteBuf); try { return (T) readFrom((Class<Object>) genericType, (Class<Object>) type, null, mediaType, new MultivaluedHashMap<String, String>(), stream); } catch (IOException e) { throw new MinnalException(e); } }
/** * @param mapper * @param annotationsToUse */ public JacksonProvider(ObjectMapper mapper, Annotations[] annotationsToUse) { super(mapper, annotationsToUse); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.NONE); mapper.setVisibility(PropertyAccessor.GETTER, Visibility.PROTECTED_AND_PUBLIC); mapper.setVisibility(PropertyAccessor.SETTER, Visibility.PROTECTED_AND_PUBLIC); mapper.configure(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS, true); mapper.setPropertyNamingStrategy(getPropertyNamingStrategy()); }
/** * @param object */ public <T> T deserialize(ByteBuf byteBuf, Class<T> type, MediaType mediaType) { InputStream stream = new ByteBufInputStream(byteBuf); try { return (T) readFrom((Class<Object>) type, type, null, mediaType, new MultivaluedHashMap<String, String>(), stream); } catch (IOException e) { throw new MinnalException(e); } }