All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ssf4j.jackson.JacksonSerialization Maven / Gradle / Ivy

There is a newer version: 0.4
Show newest version
package org.ssf4j.jackson;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.locks.ReentrantLock;

import org.ssf4j.Locked;
import org.ssf4j.Serialization;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * Serialization facade that uses Jackson's JSON mapper.
 * 

* Jackson cannot serialize everything, but comes pretty close. * @author robin * */ public class JacksonSerialization implements Serialization, Locked { protected ObjectMapper mapper; public JacksonSerialization() {} public JacksonSerialization(ObjectMapper mapper) { this.mapper = mapper; } /** * {@inheritDoc} */ @Override public JacksonSerializer newSerializer(OutputStream out, Class type) throws IOException { return new JacksonSerializer(this, out, mapper); } /** * {@inheritDoc} */ @Override public JacksonDeserializer newDeserializer(InputStream in, Class type) throws IOException { return new JacksonDeserializer(this, in, mapper, type); } @Override public boolean isThreadSafe() { return false; } /** * The lock for this serialization */ protected ReentrantLock lock = new ReentrantLock(); @Override public ReentrantLock getLock() { return lock; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy