de.tsl2.nano.replication.serializer.SerializeJAXB Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tsl2.nano.replication Show documentation
Show all versions of tsl2.nano.replication Show documentation
Provides Database/XML Replication through JPA
package de.tsl2.nano.replication.serializer;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import javax.xml.bind.JAXB;
public class SerializeJAXB implements Serializer {
public static final String KEY = "JAXB";
@Override
public String getKey() {
return KEY;
}
@Override
public String getExtension() {
return "jaxb.xml";
}
@Override
public ByteArrayOutputStream serialize(Object obj) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
JAXB.marshal(obj, out);
return out;
}
@Override
public T deserialize(InputStream stream, Class type) {
return JAXB.unmarshal(stream, type);
}
}