Skip to content

Commit

Permalink
Update to the serialization module - only construct object mapper once.
Browse files Browse the repository at this point in the history
  • Loading branch information
abradle committed Jun 23, 2016
1 parent 54261d4 commit 6b06715
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@
*/
public class MessagePackSerialization implements MmtfStructureSerializationInterface {

ObjectMapper objectMapper;
public MessagePackSerialization() {
objectMapper = new ObjectMapper(new MessagePackFactory());
objectMapper.setSerializationInclusion(Include.NON_NULL);
}

@Override
public MmtfStructure deserialize(InputStream inputStream){
MmtfStructure mmtfBean = null;
try {
mmtfBean = new ObjectMapper(new MessagePackFactory()).readValue(inputStream, MmtfStructure.class);
mmtfBean = objectMapper.readValue(inputStream, MmtfStructure.class);
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -31,7 +37,6 @@ public MmtfStructure deserialize(InputStream inputStream){
@Override
public void serialize(MmtfStructure mmtfStructure, OutputStream outputStream) {
ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
objectMapper.setSerializationInclusion(Include.NON_NULL);
try {
objectMapper.writeValue(outputStream, mmtfStructure);
} catch (IOException e) {
Expand Down

0 comments on commit 6b06715

Please sign in to comment.