XMLStreamWriter writer = createStreamWriter(buffer);
marshaller.get().marshal(obj, writer);
writer.flush();
writer.close();
} catch (JAXBException e) {
throw new HectorSerializationException("Object to serialize " + obj
+ " does not seem compatible with the configured JaxbContext;"
+ " note this Serializer works only with JAXBable objects.", e);
} catch (XMLStreamException e) {
throw new HectorSerializationException(
"Exception occurred writing XML stream.", e);
}
return ByteBuffer.wrap(buffer.toByteArray());
}