public void writeTo(Object o, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> map, OutputStream stream)
throws IOException, WebApplicationException
{
String encoding = getCharsetAsString(mediaType);
xstream.marshal(o, new CompactWriter(new OutputStreamWriter(stream, encoding)));
}