private byte[] marshall(final ActorMapping model) throws XmlMarshallException { try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { final JAXBContext contextObj = JAXBContext.newInstance(model.getClass()); final Marshaller m = contextObj.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(model, baos); return baos.toByteArray(); } catch (JAXBException | IOException e) { throw new XmlMarshallException("Failed to serialize the ActorMapping", e); } }
private byte[] marshall(final ActorMapping model) throws XmlMarshallException { try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { final JAXBContext contextObj = JAXBContext.newInstance(model.getClass()); final Marshaller m = contextObj.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(model, baos); return baos.toByteArray(); } catch (JAXBException | IOException e) { throw new XmlMarshallException("Failed to serialize the ActorMapping", e); } }
private ActorMapping unmarshall(final byte[] model) throws XmlMarshallException { if (model == null) { return null; } try (ByteArrayInputStream bais = new ByteArrayInputStream(model)) { final JAXBContext contextObj = JAXBContext.newInstance(ActorMapping.class); final Unmarshaller um = contextObj.createUnmarshaller(); final StreamSource ss = new StreamSource(bais); final JAXBElement<ActorMapping> jaxbElement = um.unmarshal(ss, ActorMapping.class); return jaxbElement.getValue(); } catch (JAXBException | IOException e) { throw new XmlMarshallException("Failed to deserialize the ActorMapping", e); } }
private ActorMapping unmarshall(final byte[] model) throws XmlMarshallException { if (model == null) { return null; } try (ByteArrayInputStream bais = new ByteArrayInputStream(model)) { final JAXBContext contextObj = JAXBContext.newInstance(ActorMapping.class); final Unmarshaller um = contextObj.createUnmarshaller(); final StreamSource ss = new StreamSource(bais); final JAXBElement<ActorMapping> jaxbElement = um.unmarshal(ss, ActorMapping.class); return jaxbElement.getValue(); } catch (JAXBException | IOException e) { throw new XmlMarshallException("Failed to deserialize the ActorMapping", e); } }