class JsonTranscoder implements CacheTranscoder {

    @Override
    public CachedObject encode(final Object o) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        try {
            mapper.writeValue(baos, new Holder(o));
            return new CachedObjectImpl(JSON_SERIALIZED, baos.toByteArray());
        } catch (IOException e) {
            LOGGER.warn(String.format("Error serializing object %s", o), e);
            throw new RuntimeException(e);
        } finally {
            try {
                baos.close();
            } catch (IOException e) {
                LOGGER.warn("Error while closing stream", e);
            }
        }
    }

    public  JsonTranscoder(final ObjectMapper mapper);

}