Hello everyone , in the project i am working on, i need to add cdata to end
result xml, since DropWizard uses jersey and it uses JAXB i was reading
some articles about how to read , i successfully added the CDATA part by
using a custom XmlAdapter but then end result was still being escaped , i
was looking for a way to do that and i found this code but i don't know how
to configure that on Dropwizard
writer = new BufferedWriter(new FileWriter(selectedFile));
context = JAXBContext.newInstance(Book.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.setProperty("com.sun.xml.internal.bind.characterEscapeHandler",
new CharacterEscapeHandler() {
@Override
public void escape(char[] ch, int
start, int length,
boolean isAttVal,
Writer writer)
throws IOException {
writer.write(ch, start, length);
}
});
also i've tried add a custom JAXBContext like is explained here:
https://automationrhapsody.com/rest-performance-problems-with-dropwizard-and-jersey-jaxb-provider/
and in the run method of my application i have this code
final Client client = new JerseyClientBuilder(environment)
.using(configuration.getJerseyClientConfiguration())
.withProvider(CustomJAXBContextConfiguration.class)
.using(environment) .build(getName());
client.property(CharacterEscapeHandler.class.getName(),new
CDataCharacterEscapeHandler()) ;
environment.jersey().property(CharacterEscapeHandler.class.getName(),new
CDataCharacterEscapeHandler()) ;
environment.jersey().register(client);
environment.jersey().register(CustomJAXBContextConfiguration.class);
but it doesn't work either,
is there a way to add a property to the marshaller jersey in Dropwizard is
using ? or how i can achieve that
thank you to all of you
--
You received this message because you are subscribed to the Google Groups
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.